PostgreSQL服务端监听设置及客户端连接方法


背景介绍:

  PostgreSQL服务端运行在RedHat Linux上,IP为:192.168.230.128

  客户端安装在Windows XP上, IP为:192.168.230.1

配置方法:

1.  修改服务端/opt/postgresql/data/postgresql.conf文件,将

  1. #listen_address='localhost'改成  
  2.   
  3. listen_address='*'  

2. 修改/opt/postgresql/data/gp_hba.conf文件

在其中增加客户端的ip,如下,注意最后一行:

  1. # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD  
  2.   
  3. # "local" is for Unix domain socket connections only  
  4. local   all         all                               trust  
  5. # IPv4 local connections:  
  6. host    all         all         127.0.0.1/32          trust  
  7. # IPv6 local connections:  
  8. host    all         all         ::1/128               trust  
  9.   
  10. #kevin add  
  11. # IPv4 local connections:  
  12. host    all         all         192.168.230.1/32          trust  

3.重启PG服务

  1. [postgres@localhost data]$ pg_ctl restart  
  2. waiting for server to shut down....LOG:  received smart shutdown request  
  3. LOG:  autovacuum launcher shutting down  
  4. LOG:  shutting down  
  5. LOG:  database system is shut down  
  6.  done  
  7. server stopped  
  8. server starting  
  9. [postgres@localhost data]$ LOG:  database system was shut down at 2011-07-09 14:54:29 CST  
  10. LOG:  autovacuum launcher started  
  11. LOG:  database system is ready to accept connections  
  12.   
  13. [postgres@localhost data]$  

4. 使用客户端连接,配置如下:

5.点击“确定”进行连接,成功后,如下:

相关内容