Linux部署postgresql并开启远程访问( 二 )

3.1、修改postgresql.conf# vi /opt/app/postgresql/data/postgresql.conf

Linux部署postgresql并开启远程访问

文章插图
 
注: 取消 listen_addresses 的注释 , 将参数值改为“*”
3.2、修改pg_hba.conf# vi /opt/app/postgresql/data/pg_hba.conf
Linux部署postgresql并开启远程访问

文章插图
 
注: 找到host all all 127.0.0.1/32 trust这行 , 然后在下面添加一行:host all all 0.0.0.0/0 trust即可
3.2、重启服务# bin/pg_ctl -D /opt/app/postgresql/data -l /opt/app/postgresql/logs/logfile restart
# service postgresql restart三、配置防火墙4.1、开启5432端口# firewall-cmd --zone=public --add-port=5432/tcp --permanent # 开放5432端口# firewall-cmd --zone=public --remove-port=5432/tcp --permanent #关闭5432端口#配置立即生效
# firewall-cmd --reload #重启防火墙
# service firewalld restart #查看已开放的端口
# firewall-cmd --list-ports


推荐阅读