免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3130 | 回复: 0

PGPool-II installation testing [复制链接]

论坛徽章:
0
发表于 2011-12-22 08:53 |显示全部楼层
PGpool-II 3.0.4 被蹂躏了2个星期后,终于能用了,但从多方测试结果来看效果不同,下面进行3.1的安装测试,也算是给自己留个备忘。

多说无益,进入正题,pgpool介绍请看这里,你也可以根据其提供的安装说明进行安装。(目前只有英文版和日文版,不过很快就会有中文版了,因为笔者已经先拿到了中文版 O(∩_∩)O~ )

具体用哪个版本还要随各位看管的喜好,我做测试的所以就用个最新版了。

您可以从这里获得相关软件,放到安装主机上,当然 前提是你的PG已经装好了
PG的路径:/data/pgsql/   (我已经编译安装了PG 9.0.4在这个目录下)

pgpool-II 的安装
解压源码包
tar zxvf pgpool-II-3.1.0-alpha3.tar.gz

进入编译并安装
cd pgpool-II-3.1.0-alpha3/
./configure --prefix=/data/pgpool/ --with-pgsql=/data/pgsql/ --enable-sequence-lock
make 
make install 
--如果你不是 root,建议使用sudo make install,确认 pgpool的安装目录的owner是你当前用户。

安装pgpool_regclass & pgpool_walrecrunning
若您在使用 PostgreSQL 8.0 或之后的版本,强烈推荐在需要访问的 PostgreSQL 中安装 pgpool_regclass 函数,因为它被 pgpool-II 内部使用。如果不这样做,在不同的 schema 中处理相同的表名会出现问题(临时表不会出问题)。
cd pgpool-II-x.x.x/sql/pgpool-regclass make make install psql -f pgpool-regclass.sql template1

在 PostgreSQL 9.0 或更高的版本中使用了流复制,你需要在所有的通过 pgpool-II 访问的 PostgreSQL 中安装 pgpool_walrecrunning 函数。

cd pgpool-II-x.x.x/sql/pgpool-walrecrunning make make install psql -f pgpool-walrecrunning.sql template1

--应在在每台通过 pgpool-II 访问的数据库中执行 pgpool-regclass.sql or pgpool-walrecrunning.sql。你不需要在你执行“psql -f pgpool-regclass.sql/pgpool-walrecrunning.sql template1”后建立的数据库中这么做,因为这个模板数据库将被克隆成新建的数据库。

建立 insert_lock 表
若您在复制模式中使用了 insert_lock ,强烈推荐建立 pgpool_catalog.insert_lock 表,用于互斥。到现在为止,insert_lock 还能够工作。但是,在这种情况下,pgpool-II 需要锁定插入的目标表。这种行为和 pgpool-II 2.2 和 2.3 系列类似。表锁与 VACUUM 冲突,所以 INSERT 操作可能因而等待很长时间。

cd pgpool-II-x.x.x/sql psql -f insert_lock.sql template1

应在在每台通过 pgpool-II 访问的数据库中执行 insert_lock.sql。你不需要在你执行“psql -f insert_lock.sql template1”后建立的数据库中这么做,因为这个模板数据库将被克隆成新建的数据库。

安装过程至此完成。如果你是使用 Solaris 或者 FreeBSD,你需要在以上的描述中用 “gmake” 代替 “make”,因为这些操作系统需要 GNU make。 

配置 pgpool-II
详情请看这里
配置 pcp.conf   
cd /data/pgpool/etc mkdri sample mv *.sample* sample cp sample/pcp.conf.sample pcp.conf
格式: username:[password encrypted in md5]
pg_md5 -p password: <your password>

或者 ./pg_md5

配置 pgpool.conf

cp sample/pgpool.conf.sample-stream pgpool.conf

 针对每种不同的模式,提供了附加的示例 pgpool.conf。

模式 示例文件
复制模式 pgpool.conf.sample-replication
主/备模式(Slony-I) pgpool.conf.sample-master-slave
主/备模式(流复制) pgpool.conf.sample-stream


为客户端认证设置 pool_hba.conf (HBA)
cat pool_hba.conf  
local   all         all             md5
host    all         all         127.0.0.1/32          md5
host    all         all         10.0.0.0/8              md5

启动/关闭 pgpool-II

pgpool -n  > /tmp/pgpool.log 2>&1 &
or
pgpool -c -f /data/pgpool/etc/pgpool.conf -F /data/pgpool/etc/pcp.conf -a /data/pgpool/etc/pool_hba.conf 
or
pgpool -c -f /data/pgpool/etc/pgpool.conf -F /data/pgpool/etc/pcp.conf -a /data/pgpool/etc/pool_hba.conf -n >/data/pgpool/log/pgpool-`date +%F%H%M%S`.log 2>&1 &

pgpool [ -m ] stop 

重新加载配置信息

pgpool-II 能够不需要重启而重新加载配置文件。
pgpool [-c][-f config_file][-a hba_file][-F pcp_config_file] reload



如果一个节点fail,首次链接可以能回失败返回,log也会有如下记录。
2011-08-24 01:30:27 LOG:   pid 17426: postmaster on DB node 1 was shutdown by administrative command
2011-08-24 01:30:27 LOG:   pid 17426: degenerate_backend_set: 1 fail over request from pid 17426
2011-08-24 01:30:27 LOG:   pid 17417: starting degeneration. shutdown host 10.0.2.23(2011)
2011-08-24 01:30:27 LOG:   pid 17417: Restart all children
2011-08-24 01:30:27 LOG:   pid 17417: find_primary_node_repeatedly: waiting for finding a primary node
2011-08-24 01:30:27 LOG:   pid 17417: find_primary_node: primary node id is 0
2011-08-24 01:30:27 LOG:   pid 17417: failover: set new primary node: 0
2011-08-24 01:30:27 LOG:   pid 17417: failover: set new master node: 0
2011-08-24 01:30:27 LOG:   pid 17417: failover done. shutdown host 10.0.2.23(2011)
2011-08-24 01:31:17 LOG:   pid 19253: connection received: host=bogon port=17086

持续更新...

Q&A
  1. 连接时 有下面提示:
  2. psql -p 9999
  3. psql: could not connect to server: No such file or directory
  4.         Is the server running locally and accepting
  5.         connections on Unix domain socket "/tmp/.s.PGSQL.9999"?
    请先确认conf文件里制定的socket dir,psql里面有这样那个的帮助:
    -h, --host=HOSTNAME database server host or socket directory (default: "local socket")

  6. psql -p 9999 -h /data/pgpool
    psql: ERROR:  "MD5" authentication with pgpool failed for user "postgres"
    请用pg_md5 --md5auth -p 生成 ~/etc/pool_passwd 文件内容
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP