安装pgbouncer

yum install libevent -y
yum install libevent-devel -y
wget http://www.pgbouncer.org/downloads/files/1.11.0/pgbouncer-1.11.0.tar.gz
tar -xvf pgbouncer-1.11.0.tar.gz
./configure --prefix=/usr/local --with-libevent=libevent-prefix
make
make install

node1:编辑pgbouncer.ini配置文件

cat /etc/pgbouncer/pgbouncer.ini
[databases]
postgres = host=127.0.0.1 port=5432 dbname=postgres [pgbouncer]
logfile = /var/log/pgbouncer/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
listen_addr = 192.168.216.130
listen_port = 6432
unix_socket_dir = /var/run/postgresql
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt
admin_users = postgres
ignore_startup_parameters = extra_float_digits,geqo pool_mode = session
server_reset_query = DISCARD ALL
max_client_conn = 10000
default_pool_size = 10
reserve_pool_size = 1
reserve_pool_timeout = 1
max_db_connections = 1000
pkt_buf = 8192 # Documentation https://pgbouncer.github.io/config.html

配置postgres管理账户和密码

cat /etc/pgbouncer/userlist.txt
"postgres" "postgres-pass"

node2:编辑pgbouncer.ini配置文件

cat /etc/pgbouncer/pgbouncer.ini
[databases]
postgres = host=127.0.0.1 port=5432 dbname=postgres [pgbouncer]
logfile = /var/log/pgbouncer/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
listen_addr = 192.168.216.132
listen_port = 6432
unix_socket_dir = /var/run/postgresql
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt
admin_users = postgres
ignore_startup_parameters = extra_float_digits,geqo pool_mode = session
server_reset_query = DISCARD ALL
max_client_conn = 10000
default_pool_size = 10
reserve_pool_size = 1
reserve_pool_timeout = 1
max_db_connections = 1000
pkt_buf = 8192 # Documentation https://pgbouncer.github.io/config.html

配置postgres管理账户和密码

cat /etc/pgbouncer/userlist.txt
"postgres" "postgres-pass"

node3:编辑pgbouncer.ini配置文件

cat /etc/pgbouncer/pgbouncer.ini
[databases]
postgres = host=127.0.0.1 port=5432 dbname=postgres [pgbouncer]
logfile = /var/log/pgbouncer/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
listen_addr = 192.168.216.134
listen_port = 6432
unix_socket_dir = /var/run/postgresql
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt
admin_users = postgres
ignore_startup_parameters = extra_float_digits,geqo pool_mode = session
server_reset_query = DISCARD ALL
max_client_conn = 10000
default_pool_size = 10
reserve_pool_size = 1
reserve_pool_timeout = 1
max_db_connections = 1000
pkt_buf = 8192 # Documentation https://pgbouncer.github.io/config.html

配置postgres管理账户和密码

cat /etc/pgbouncer/userlist.txt
"postgres" "postgres-pass"

创建/etc/systemd/system/pgbouncer.service文件,通过systemctl管理pgbouncer服务

cat /etc/systemd/system/pgbouncer.service
[Unit]
Description=pgBouncer connection pooling for PostgreSQL
After=syslog.target network.target [Service]
Type=forking User=postgres
Group=postgres PermissionsStartOnly=true
ExecStartPre=-/bin/mkdir -p /var/run/pgbouncer /var/log/pgbouncer
ExecStartPre=/bin/chown -R postgres:postgres /var/run/pgbouncer /var/log/pgbouncer
ExecStart=/usr/bin/pgbouncer -d /etc/pgbouncer/pgbouncer.ini
ExecReload=/bin/kill -SIGHUP $MAINPID
PIDFile=/var/run/pgbouncer/pgbouncer.pid LimitNOFILE=100000 [Install]
WantedBy=multi-user.target

  

最新文章

  1. Daily Scrum 10.24
  2. sublime3+quick智能提示
  3. [noip2005提高]过河 dp
  4. ASP.NET MVC 学习1、新增Controller,了解MVC运行机制
  5. IDEA 编译错误:java: try-with-resources is not supported in -source 1.6 (use -source 7 or higher to enable try-with-resources)
  6. FreeMarker 自己定义指令(三)
  7. [Regionals 2012 :: Asia - Tokyo ]
  8. cocos2d-x过程动作CCProgressTo示例学习笔记
  9. ZooKeeper原理及配置
  10. Entity Framework Tools install to VS 2015
  11. 公众号第三方平台开发-aes解密失败
  12. CentOs环境下给PHP7.0安装fileinfo扩展
  13. 数据分组分析—-groupby
  14. 潭州课堂25班:Ph201805201 并发(协程) 第十五课 (课堂笔记)
  15. 系统编码、文件编码与python系统编码
  16. java json-lib配置
  17. 理解C#的Lock语法意义
  18. 【JavaScript算法】---希尔排序
  19. Python3 图像识别(二)
  20. Julia - 字符串判断函数

热门文章

  1. Spring boot + mybatis + oracle代码生成器
  2. JDK8从永生代到元数据区
  3. SQL Server 索引的最佳实践
  4. 深度学习-深度强化学习(DRL)-Policy Gradient与PPO笔记
  5. Docker容器挂载文件(转载)
  6. 原!!Spring redis的Scan的坑,慎用!
  7. 1.ASP.NET Core 中向 Razor Pages 应用添加模型
  8. 十二.作业难点(有IT大牛路过的可以帮我解答我的疑问?万分感谢)--转行的苦逼人
  9. Ubuntu中使用sanp一键安装安装Notepad ++
  10. 必须修改getdate()格式,判断是否处于两个日期之间