54 CHEN

Pgpool安装

下载地址:http://pgfoundry.org/projects/pgpool/ 文件为:pgpool-II-2.0.1.tar,tar xvfj pgpool-II-2.0.1.tar 在pgpool-II-2.0.1目录下,执行./configure –prefix=/home/y/share/pgsql —-with-pgsql=/home/y/share/pgsql, 要求with-pgsql目录必须为pgsql安装目录。 之后执行gmake,sudo gmake install; pgpool需要用PCP命令来连接数据库检索数据,其用户名、密码是在pcp.conf文件中保存的。密码是经过md5加密的,需要用户手工输入。 cp /home/y/share/pgsql/etc/pcp.conf.sample /home/y/share/pgsql/etc/pcp.conf md5加密码可以用/home/y/share/pgsql/bin/pg_md5直接生成 :例/home/y/share/pgsql/bin/pg_md5 postgres 结果为e8a48653851e28c69d0506508fb27fc5 将用户名,密码记入到pcp.conf文件中。 pcp默认端口为pcp_port = 9898。可以在pgpool.conf文件内修改 cp /home/y/share/pgsql/etc/pgpool.conf.sample /home/y/share/pgsql/etc/pgpool.conf,默认连接端口为port = 9999, 默认只允许本地连接,listen_addresses = ‘localhost’, 如果需要所有ip可连接,可改为listen_addresses = ‘*'。 cp /home/y/share/pgsql/etc/pool_hba.conf.sample /home/y/share/pgsql/etc/pool_hba.conf,

添加远端连接 host all all 0.0.0.0/0 trust.

添加pgsql节点
backend_hostname0 = ‘phx6.sds.cnb.yahoo.com’
backend_port0 = 5432
backend_weight0 = 1
backend_hostname1 = ‘phx7.sds.cnb.yahoo.com’
backend_port1 = 5432
backend_weight1 = 1

如果需要开启多级拷贝功能需要设置replication_mode = true
如果需要开启负载均衡功能需要设置load_balance_mode = true

启动pgpool
pgpool -n -d > /tmp/pgpool.log 2>&1 &
关闭pgpool
pgpool stop

原创文章如转载,请注明:转载自五四陈科学院[http://www.54chen.com]

Posted by 54chen linux

« TA 们放肆摇晃的青春尾巴—龙城八月,有淫气。 pgsql如何控制来自其他电脑的连接? »