PostgreSQL PGPOOL-II 环境准备

1 背景知识

本文主要介绍如何在 PostgreSQL 数据库准备 PGPOOL-II 环境,通常 UNIX 类操作系统都可以运行 Pgppol-II,不支持windows 平台。

2 操作系统防火墙配置

2.1 开放 PGPOOL-II 相关的端口

firewall-cmd --permanent --zone=public --add-port=9999/tcp --add-port=9898/tcp --add-port=9000/tcp
firewall-cmd --permanent --zone=public --add-port=9694/udp
firewall-cmd --reload
Warning

这里是测试环境直接关闭。

端口 说明
9999 pgpool-II 监听端口,用于数据库连接。
9898 pgpool-II PCP监听端口,用于 pgpool-II 管理端口。
9000 pgpool-II watchdog监听端口,用于看门狗的相互监控。
9694 pgpool-II 心跳监听端口,用于心跳检测的端口。

2.2 开放 PostgreSQL 服务器相关端口

firewall-cmd --permanent --zone=public --add-service=postgresql
firewall-cmd --reload

2.3 安装 PGPOOL 依赖包

Warning

对于源码安装的postgresql 服务器。postgresql-lib postgresql-devel lib 包就不需要安装了。
1、make
2、gcc
3、tar
4、gzip
5、postgresql-libs
6、postgresql-devel
7、flex
8、bison

dnf install make gcc tar gzip flex bison libmemcached libmemcached-libs memcached docbook-dtds  docbook-style-xsl libxslt  -y

如果要开启缓存查询请安装 libmemcached-devel

dnf --enablerepo=powertools install libmemcached-devel -y

更多请参考 libmemcached 章节。

2.4 SSH 互信配置

PGPOOL-II 需要配置 SSH 互信

3 数据库环境准备

3.1 准备 PGPOOL-II 数据库用户

su - postgres 
#postgres>
psql -U postgres -d testdb
--testdb#
CREATE ROLE pgpool WITH PASSWORD 'pgpool' LOGIN;
GRANT pg_monitor TO pgpool;

3.2 配置 PostgreSQL 密码文件

su - postgres
vi ~/.pgpass
*:5432:*:repl:repl
*:5432:*:postgres:postgres
*:5432:*:pgpool:pgpool
chmod 600  ~/.pgpass
scp ~/.pgpass node1:~
scp ~/.pgpass node2:~
scp ~/.pgpass node3:~