安装postgresql96
yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
yum install postgresql96
yum install postgresql96-server
/usr/pgsql-9.6/bin/postgresql96-setup initdb
1.在postgesql数据库节点输入如下命令,打开配置文件(pg_hba.conf)修改其中配置,在最后新增一行,表示开启远程连接,设置允许连接的IP地址段,全0表示全部允许,md5表示使用md5加密传输,如下图所示。
vim /var/lib/pgsql/9.6/data/pg_hba.conf
2.输入如下命令打开配置文件(postgresql.conf)修改其中配置,在最后新增字段,如下图所示。
vim /var/lib/pgsql/9.6/data/postgresql.conf
3.在postgresql.conf文件中修改postgresql默认的连接数,将其修改为1000
4.输入如下命令启动postgresql数据库,检查其运行状态
systemctl start postgresql-9.6
systemctl status postgresql-9.6
5.输入如下命令切换至postgres用户,然后连接postgres数据库
切换用户:su - postgres
连接命令:psql
6.输入如下命令更改postgres用户默认密码(postgres),完成后退出。
修改命令:alter user postgres with password ‘postgres’;
退出命令:\q
验证:
输入如下命令以postgres用户登录postgresql数据库,输入修改后的密码(postgres)完成登录(注:其中的IP为postgresql节点地址)
psql -h 192.168.9.11-U postgres