用户工具

站点工具


linux:pgbouncer

PgBouncer

PGBouncer是一个轻量级的针对PostgreSQL的数据库连接池工具,搭配使用可提高PostgreSQL的性能

安装

sudo apt-get install pgbouncer

配置

配置:

编辑/etc/pgbouncer/pgbouncer.ini,在[databases]一节中添加想要连接的数据库

[databases]
bardb = host=localhost dbname=bazdb

[pgbouncer]一节中配置监听的IP地址和端口;改auth_typemd5方式避免添加明文密码,添加数据库用户

[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
linux/pgbouncer.txt · 最后更改: 2023/12/03 10:24 由 127.0.0.1