pgpool安装使用
下载地址:http://pgpool.net/mediawiki/index.php/Downloads
环境:
两台redhat linux 6.5 两台机器上均安装好pg(本机postgresql9.4.4)
ip:
data1 192.168.1.10 (主) pgpool安装在此机器上
data2 192.168.1.11 (备)
1、源码安装
[root@localhost ~]# tar xvf pgpool-II-3.3.3.tar.gz
[root@localhost ~]# mkdir /opt/pgpool
[root@localhost ~]# chown -R postgres:postgres /opt/*
[root@localhost ~]# su - postgres
[postgres@localhost~]$ cd /tmp/pgpool-II-3.3.3
[postgres@localhost pgpool-II-3.3.3]$ ./configure --prefix=/opt/pgpool
[postgres@localhost pgpool-II-3.3.3]# configure: error: libpq is not installed or libpq is old
缺少软件包,挂载镜像,配置yum源
[postgres@localhost pgpool-II-3.3.3]# yum install postgresql* -y
[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 /tmp/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 /tmp/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 /tmp/pgpool-II-3.3.3/sql/
[postgres@localhost sql]$ psql -f insert_lock.sql template1
4、配置即使用
查看配置文件
[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
切换到root用户下z
[root@localhost etc]chown postgres:postgres -R /opt/
[root@localhost etc]su - postgres
[postgres@localhost ]cd /opt/pgpool/etc/
[postgres@localhost etc]$ cp pgpool.conf.sample pgpool.conf
[postgres@localhost etc]$ cp pcp.conf.sample pcp.conf
[postgres@localhost etc]$ cp 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.1.10'
backend_port0 = 5432
backend_weight0 = 1
backend_data_directory0 = '/opt/pgsql-9.4.4/data'
backend_flag0 = 'ALLOW_TO_FAILOVER'
backend_hostname1 = '192.168.1.11'
backend_port1 = 5432
backend_weight1 = 1
backend_data_directory1 = '/opt/pgsql-9.4.4/data'
backend_flag1 = 'ALLOW_TO_FAILOVER'
一般使用hba的方式进行登录认证。所以要在pgpool.conf中打开如下选项:
enable_pool_nba=on
通常会把访问pgpool的用户名和密码的MD5值记录在/opt/pgpool/etc/pool_passwd中
修改.bash_profile文件, PATH=/opt/pgsql-9.4.4/bin:$PATH:/opt/pgpool/bin
[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、复制和负载均衡的示例
192.168.1.10 为安装pgpool的服务器
192.168.1.11 为后端数据节点在pgpool.conf中配置以下内容:
replication_mode = true
load_balance_mode = true backend_hostname0 = '192.168.1.10'
backend_port0 = 5432
backend_weight0 = 1
backend_data_directory0 = '/opt/pgsql-9.4.4/data'
backend_flag0 = 'ALLOW_TO_FAILOVER'
backend_hostname1 = '192.168.1.11'
backend_port1 = 5432
backend_weight1 = 1
backend_data_directory1 = '/opt/pgsql-9.4.4/data'
backend_flag1 = 'ALLOW_TO_FAILOVER'启动pgpool
pgpool -n -d > /tmp/pgpool.log 2>&1 &
在data1上连接pgpool的端口9999,然后创建一张表。并插入数据
[postgres@localhost etc]$ psql -h 192.168.1.10 -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安装使用相关推荐
- 2020-01-03 KK日记,第一次进行postgresql 11.5+pgpool 安装
一.安装规划 安装单实例 配置主从 安装pgpool -ii 二.单实例安装 2.1 操作系统 os: centos 7.6 cpu: 4 core memory:32g disk: 60g 192. ...
- Pgpool安装部署(亲测可用)
Pgpool安装部署指导 1. 环境准备 1.1软件 CentOS 7.6 PGPool 3.5 PostgreSQL11.2 1.2节点 node1 172.16.8.7(主库) ...
- 安装部署postgresql-15 高可用(pgpool)
安装部署postgresql-15 高可用(pgpool) 文章目录 前言 部署环境: 下载地址: 安装pg15 安装pgpool 配置pgpass文件 创建pgpool_node_id Pgpool ...
- pgpool-ii的安装与使用
下载地址:http://pgpool.net/mediawiki/index.php/Downloads 环境: 两台redhat linux 6.5 两台机器上均安装好pg(本机postgresql ...
- 基于Pgpool搭建PostgreSQL11的集群
基于Pgpool-II4.1.0搭建PostgreSQL11集群 Pgpool介绍 pgpool相关介绍不在该文章中,需要者可以参考我的另一篇文章.传送门:pgpool介绍 环境准备 本次使用三台Ce ...
- Pgpool-II安装部署
Pgpool-II部署 There are six different running modes in Pgpool-II: streaming replication mode, logical ...
- pgpool 之四 2 pgpool + 2 postgresql 的 stream replication 模式
os: ubuntu 16.04 db: postgresql 9.6.8 pgpool: pgpool-II-3.7.7 pgpool 简介 准确的名字是Pgpool-II,这里简称为pgpool. ...
- pg高性能服务器,Pgpool-II 负载均衡对PG的性能影响
Pgpool-II相当于中间件,Pgpool-II与PG是解耦合的,基于这样的机制,Pgpool-II可以搭建在已经存在的任意版本的PG主从结构上,主从结构的实现与Pgpool-II无关,可以通过sl ...
- pgpool-II 高可用搭建
pgpool-II主备流复制的架设 1.环境 OS: CentOS release 6.4 (Final) DB: postgresql 9.3.6 pgpool服务器: pgpool 172.16. ...
最新文章
- 深度学习如何提高训练集准确率_吴恩达深度学习笔记(61)-训练调参中的准确率和召回率...
- Eclipse中JVM内存设置
- hdu 1317 XYZZY【Bellheman_ford 判断正环小应用】
- stream去重_使用Java Stream API中DistinctBy删除重复数据
- 扎心!全国6.5亿网民月收入不足5000元
- (三)slatstack配置管理
- DBN原理及实践-TensorFlow
- 第五章 线性回归 学习笔记上
- php课程设计学生信息管理系统,学生成绩管理系统/学生信息管理系统
- 【毕设教程】ESP8266 WiFi 模块介绍和使用
- 智遥工作流连接SAP,查询超时解决方法
- python arp协议分析_通过python对本局域网进行ARP扫描获取MAC
- 【图解】本地IIS局域网内无法访问的问题
- R与指数分布(1) 概率密度函数
- 无人驾驶感知篇之融合(一)
- Python基于Django城市PM2.5空气质量数据可视化分析
- merger oracle,merger oracle 函数
- LeetCode——1737. 满足三条件之一需改变的最少字符数(Change Minimum Characters to Satisfy One of Three...)——分析及代码(Java)
- php开源商城 yii,Yii2开源电商系统 fecshop
- 短信平台软件,支持CMPP, SGIP,ISAG/ISMP协议模块
热门文章
- 物联网学习笔记(摘录)
- msyql [note] mysqld (mysqld 5.6.40) starting as process xxxx...
- 计算机配置方案2018,写给设计师的电脑配置攻略之PS篇 2018-08-15
- java 海报二: 如何生成圆形头像
- 如何设置电脑定时自动关机
- am335x linux 调试uart
- Docker使用docker compose创建 轻量级私人云端相册 实时管理个人相片 控制相册访问权限 Lychee 部署搭建
- 如何在pc上安装安卓应用程序
- 【微信小程序系列】微信小程序连接后端数据库(SSM)案例
- 各大数据竞赛 Top 解决方案汇总