====== PgBouncer ======
PGBouncer是一个轻量级的针对PostgreSQL的数据库连接池工具,搭配使用可提高[[postgresql|PostgreSQL]]的性能
===== 安装 =====
sudo apt-get install pgbouncer
===== 配置 =====
配置:
编辑''/etc/pgbouncer/pgbouncer.ini'',在''[databases]''一节中添加想要连接的数据库
[databases]
bardb = host=localhost dbname=bazdb
在''[pgbouncer]''一节中配置监听的IP地址和端口;改''auth_type''为''md5''方式避免添加明文密码,添加数据库用户
[pgbouncer]
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt
admin_users = postgres
添加密码文件:
密码格式为
"username" "md5"+md5(username+password)
cat /etc/pgbouncer/userlist.txt
"postgres" "md55c741542912dfff76641f377ffff1283"
重启pgbouncer:
sudo service pgbouncer restart
如配置成功,使用以下命令能够连接到数据库''bardb''
psql -U postgres -p 6432 bardb