pgbouncer是连接池。其实plproxy,pgpool什么的,都有这功能。pgbouncer与之相比,最大的好处是简单,小型。
如果不需要负载均衡什么的功能,用pgbouncer就足够了。
PgBouncer的特点
a.内存消耗低(默认为2k/连接),因为Bouncer不需要每次都接受完整的数据包
b.可以把不同的数据库连接到一个机器上,而对客户端保持透明
c.支持在线的重新配置而无须重启
环境:
centos 7.2
pg9.6.1
pgbouncer 1.7.2
libevent 2.0.21
1、安装过程
安装pgbouncer之前需要先安装libevent
安装libevent
[postgres@root opt] m k d i r / h o m e / p o s t g r e s / l i b e v e n t [ p o s t g r e s @ r o o t o p t ] mkdir /home/postgres/libevent [postgres@root opt] mkdir/home/postgres/libevent[postgres@rootopt] tar -zxvf libevent-2.0.21-stable.tar.gz
[postgres@root opt]$ cd libevent-2.0.21-stable
[postgres@root libevent-2.0.21-stable] . / c o n f i g u r e — p r e f i x = / h o m e / p o s
pgbouncer连接池的应用
![](https://img-home.csdnimg.cn/images/20240711042549.png)