一、部署环境
配置名称 | 配置详情 |
---|---|
系统配置 | CentOS Linux release 7.7.1908 (Core) |
数据库版本 | postgresql10-10.20 |
操作用户角色 | root |
二、下载安装
postgres依赖包
下载地址:https://yum.postgresql.org/10/redhat/rhel-7-x86_64/repoview/postgresqldbserver10.group.html
postgresql10-10.20-1PGDG.rhel7.x86_64.rpm
postgresql10-libs-10.20-1PGDG.rhel7.x86_64.rpm
postgresql10-server-10.20-1PGDG.rhel7.x86_64.rpm
下载上面四个依赖包至本地。
libicu依赖包
下载地址:https://centos.pkgs.org/7/centos-x86_64/libicu-50.2-4.el7_7.x86_64.rpm.html
libicu-50.2-4.el7_7.x86_64.rpm
rpm安装
rpm -ivh libicu-50.2-4.el7_7.x86_64.rpm
rpm -ivh postgresql10-libs-10.16-1PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql10-10.16-1PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql10-server-10.16-1PGDG.rhel7.x86_64.rpm
三、配置
1)初始化
初始化数据库
/usr/pgsql-10/bin/postgresql-10-setup initdb
设置自启动
systemctl enable postgresql-10.service #设置数据库的开机启动
systemctl start postgresql-10 #启动数据库
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
2)添加账户
切换用户
su - postgres
进入psql
psql
添加用户
ALTER USER postgres WITH PASSWORD 'postgres';
退出
\q
3) 设置配置文件
设置外部连接密码访问
vi /var/lib/pgsql/10/data/pg_hba.conf
内容如下:
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
host all all 0.0.0.0/0 md5 #修改成这样
修改监听端口
vi /var/lib/pgsql/10/data/postgresql.conf
找到 listen_addresses值给为*
重启服务
systemctl restart postgresql-10
网友评论