下载地址:http://pgpool.net/mediawiki/index.php/Downloads
环境:
两台redhat linux 6.5 两台机器上均安装好pg(本机postgresql9.4.4)
ip:data1 192.168.11.66 (主) pgpool安装在此机器上
data2 192.168.11.68 (备)
1、源码安装
[root@localhost ~]# tar xvf pgpool-II-3.3.3.tar.gz
[root@localhost ~]#mkdir /opt/pgpool
[root@localhost ~]#chown -R postgres:postgres /opt/*
[postgres@localhost~]$ cd /opt/pgpool-II-3.3.3
[postgres@localhost pgpool-II-3.3.3]$./configure --prefix=/opt/pgpool
[postgres@localhost pgpool-II-3.3.3]$make
[postgres@localhost pgpool-II-3.3.3]$make install2、安装pgpool_regclass 和pgpool-recovery
[postgres@localhost pgpool-II-3.3.3]$ cd /pgpool-II-3.3.3/sql/pgpool_regclass
[postgres@localhost pgpool_regclass]$make && make install
[postgres@localhost pgpool_regclass]$psql -f pgpool-regclass.sql template1
[postgres@localhost pgpool_regclass]$cd /pgpool-II-3.3.3/sql/pgpool-recovery
[postgres@localhost pgpool-recovery] $make && make install
[postgres@localhost pgpool-recovery]$psql -f pgpool-recovery.sql template1
3、建立inert_lock表
[postgres@localhost pgpool-recovery]$cd /pgpool-II-3.3.3/sql/
[postgres@localhost sql]$psql -f insert_lock.sql template14、配置即使用
查看配置文件
[postgres@localhost pgpool-II-3.3.3]$ cd /opt/pgpool/etc/
[postgres@localhost etc]$ ll
total 180
-rw-r--r--. 1 postgres postgres 858 Dec 19 13:28 pcp.conf.sample
-rw-r--r--. 1 postgres postgres 30979 Dec 19 13:28 pgpool.conf.sample
-rw-r--r--. 1 postgres postgres 30669 Dec 19 13:28 pgpool.conf.sample-master-slave
-rw-r--r--. 1 postgres postgres 30651 Dec 19 13:28 pgpool.conf.sample-replication
-rw-r--r--. 1 postgres postgres 30690 Dec 19 13:28 pgpool.conf.sample-stream
-rw-r--r--. 1 postgres postgres 3200 Dec 19 13:28 pool_hba.conf.sample
-rw-rw-r--. 1 postgres postgres 43 Dec 19 13:53 pool_passwd
[postgres@localhost etc]$ cp pgpool.conf.sample pgpool.conf
[postgres@localhost etc]$ cp pcp.conf.sample pcp.conf
[postgres@localhost etc]$ pool_hba.conf.sample pool_hba.conf
pg_pool默认只接受端口的本地连接。如果想从其他主机接受连接,请设置listen_address='*' ,相对应在pgpool.conf中配置修改如下:
listen_address='*'
port =9999
因为不是安装在默认的“/usr/local/”目录下的,所以要指定目录的配置项,
pid_file_name ='/opt/pgpool/run/pgpool.pid'
创建相对应目录的命令
[postgres@localhost etc]$mkdir /opt/pgpool/run
配置后端数据库,pgpool.conf
# - Backend Connection Settings - 这一部分用来配置后台连接的数据库
backend_hostname0 = '192.168.11.66'
backend_port0 = 5432
backend_weight0 = 1
backend_data_directory0 = '/opt/pgsql/data'
backend_flag0 = 'ALLOW_TO_FAILOVER'
backend_hostname1 = '192.168.11.68'
backend_port1 = 5432
backend_weight1 = 1
backend_data_directory1 = '/opt/pgsql/data'
backend_flag1 = 'ALLOW_TO_FAILOVER'
一般使用hba的方式进行登录认证。所以要在pgpool.conf中打开如下选项:
enable_pool_nba=on
通常会把访问pgpool的用户名和密码的MD5值记录在/opt/pgpool/etc/pool_passwd中
[postgres@localhost etc]$pg_md5 -m -p -u postgres pool_passwd
passwd:
这样就生成了pool_passwd文件,使用cat查看文件内容:
postgres:md5279d84d3239474da07235e5a6555c73b
启动pgpool
[postgres@localhost etc]$pgpool
如果想让pgpool在前台运行,可以加“-n”参数
[postgres@localhost etc]$pgpool -n
如果想让日志打印到一个文件。使用一下命令
[postgres@localhost etc]$pgpool -n> /tmp/pgpool.log 2>&1 &
如果想打印调度信息,加上参数“-d”
[postgres@localhost etc]$pgpool -n -d > /tmp/pgpool.log 2>&1 &
停止pgpool
[postgres@localhost etc]$pgpool stop
也可以加上参数
[postgres@localhost etc]$pgpool -m fast stop5、复制和负载均衡的示例
在pgpool.conf中配置以下内容:
replication_mode = true
load_balance_mode = truebackend_hostname0 = '192.168.11.66'
backend_port0 = 5432
backend_weight0 = 1
backend_data_directory0 = '/opt/pgsql/data'
backend_flag0 = 'ALLOW_TO_FAILOVER'
backend_hostname1 = '192.168.11.68'
backend_port1 = 5432
backend_weight1 = 1
backend_data_directory1 = '/opt/pgsql/data'
backend_flag1 = 'ALLOW_TO_FAILOVER'启动pgpool
pgpool -f /opt/pgpool/etc/pgpool.conf在data1上连接pgpool的端口9999,然后创建一张表。并插入数据
[postgres@localhost etc]$ psql -h 192.168.11.66 -d postgres -p 9999 -U postgres
psql (9.4.4)
Type "help" for help.postgres=# \d
List of relations
Schema | Name | Type | Owner
----------------+------+------+--------
oracle_catalog | dual | view | postgres
(1 row)postgres=# create table aaa (a int);
CREATE TABLE
highgo=# \d
List of relations
Schema | Name | Type | Owner
----------------+------+-------+--------
oracle_catalog | dual | view | postgres
public | aaa | table | postgres
(2 rows)postgres=# insert into aaa values (1);
INSERT 0 1
postgres=# insert into aaa values (2);
INSERT 0 1
postgres=# insert into aaa values (3);
INSERT 0 1
postgres=# select * from aaa ;
a
---
1
2
3
(3 rows)
在data2上可以看到,表和数据都弄好了,而且数据完全一样
[postgres@localhost data]$ psql
Password:
psql (9.4.4)
Type "help" for help.postgres=# \d
List of relations
Schema | Name | Type | Owner
----------------+------+-------+--------
oracle_catalog | dual | view | postgres
public | aaa | table | postgres
(2 rows)postgres=# select * from aaa ;
a
---
1
2
3
(3 rows)

pgpool-ii的安装与使用相关推荐

  1. [转载] PGPool介绍和安装经验

    PGPool介绍和安装经验 Pgpool的介绍 一.介绍 是一个工作在PostgreSQL多服务器和PostgreSQL数据库客户端之间的中间件. 二.概念图 三.功能 连接池:pgpool -Ⅱ保存 ...

  2. Quartus II软件安装过程中的can't find Quartus II subscription Editon device file(.qdz)

    上一篇文章说道,安装玩Quartus软件之后,还需要安装器件库就是一个.qdz文件.我想很多初学者跟我一样,不知道去哪下载,下载那个文件.在折腾了几个小时之后,我终于 弄好了,下面我把解决的办法写下来 ...

  3. t110ii装系统_DELL T110 II如何安装server2003操作系统

    DELL POWER Edge T110II本身要求是安装SERVER2008的,DELL销售明确说是不能安装server2003的,因为没有server2003的驱动. 这就是为什么DELL T11 ...

  4. quartus ii 的安装和破解注意事项

    用的是黑金动力社区的,cyclone4 的开发板,按照视频教程一步步做,但是在设置保存路径时,保存在自己习惯的一个路径下,结果破解时,出错,后来删除,重装,路径只是盘符变动,后面破解就没有问题了.

  5. 2020-01-03 KK日记,第一次进行postgresql 11.5+pgpool 安装

    一.安装规划 安装单实例 配置主从 安装pgpool -ii 二.单实例安装 2.1 操作系统 os: centos 7.6 cpu: 4 core memory:32g disk: 60g 192. ...

  6. 安装部署postgresql-15 高可用(pgpool)

    安装部署postgresql-15 高可用(pgpool) 文章目录 前言 部署环境: 下载地址: 安装pg15 安装pgpool 配置pgpass文件 创建pgpool_node_id Pgpool ...

  7. Quartus II 13.1的下载和安装

    文章目录 一.Quartus II的下载 二.Quartus II的安装 三.Quartus II的注册 参考 一.Quartus II的下载 百度网盘下载链接: https://pan.baidu. ...

  8. Quartus II 13.1的安装与注册

    目录 一.Quartus II的下载 二.Quartus II的安装 三.Quartus II的注册 四.Quartus II配置驱动 五.与 Modelsim 连接 参考文献 一.Quartus I ...

  9. Quartus II与Modelsim软件安装教程

    Quartus II与Modelsim软件安装教程 一.Quartus II软件安装 1.Quartus II安装 2.器件安装 3.Quartus 破解 4.USB Blaster 驱动安装 二.M ...

  10. Quartus II 安装教程—FPGA入门教程

    Quartus II 工具安装一般分为两个部分,首先是开发工具本身的安装,其次就是器件库的安装,我们可以根据我们的需要选择相应的器件库来安装,这里我们使用Cyclone IV的FPGA,即安装Cycl ...

最新文章

  1. PyTorch官方教程大更新:增加标签索引,更加新手友好
  2. 程序员的疯狂:打工与创业的残酷区别
  3. matplotlib 笔记:设置x轴 y轴文字
  4. docker迁移与备份
  5. Android 文件下载的三种基本方式
  6. 小学生计算机辅助教学系统--练习加,减,乘,除法
  7. dxf转nc代码软件_Window绝赞的6款软件,效率加班党必备,快到惊人!
  8. DynamicsCompressorNode
  9. vue限制点击次数_vue点击切换颜色限制个数(用了mui框架)
  10. 洛谷P1600 天天爱跑步
  11. Spring Cloud入门+深入(十二)-Gateway网关(一)
  12. 日历查询---在线阴阳历转换器
  13. 违反GPL协议赔偿50万,国内首例!
  14. 公差基本偏差代号_基本偏差代号怎么确定
  15. Cesium之粒子---简单粒子特效
  16. RK3368 Edp屏调试,利用EDID做兼容
  17. Apple 设备尺寸
  18. FET335X核心板 序---用飞凌AM335X开始工作了
  19. html游戏能在手机上玩吗,怎么在电脑上玩手机游戏? 每日一答
  20. 【软件测试】智能电视应用测试要求1

热门文章

  1. Latex中如何使用中文?
  2. Hystrix学习(2)雪崩效应
  3. 网络安全专栏——修改电脑密码修改虚拟机密码(图文)
  4. GIT 修改用户名和密码
  5. 苹果用计算机知道密码,苹果电脑钥匙串登录密码忘了怎么办
  6. JAVA高级工程师笔试面试题
  7. 云浮农村生活污水处理设备——水生态环境保护“十四五”规划
  8. 7-1 树的同构 【已改正】
  9. 如何搭建自己的博客网站(手把手教你搭建免费个人博客网站)
  10. 【EF框架】EF框架的开发方法