1. 花了一上午时间将pgbouncer的参数通读了一遍,对他有个大致的了解:
    1.配置分为连接池和pgbouncer两个部分[database]\[pgbouncer  ]。
    2.一条记录对应创建一个连接池,连接池的大小可以在这条配置中设置,如果不设置,则使用pgbouncer部分中配置的默认值20,当然也可以修改。
    3.验证模式使用md5,则需要配置user.txt文件,即密码文件;如果使用hba,则需要指定对应的pg_hba.conf文件(即可以使用PostgreSQL的验证模式)。
    4.admin_user是允许哪些用户可以在控制台连接pgbouncer这个管理数据库,并进行修改。
    5.database配置连接池中,又分为配置user/passwordauth_user,这里还有点迷糊,后面实验了再来说,下面是解释:
  1. user, password
  2. If user= is set, all connections to the destination database will be done with the specified user, meaning that there will be only one pool for this database.
  3.  
  4. Otherwise PgBouncer tries to log into the destination database with client username, meaning that there will be one pool per user.
  5.  
  6. auth_user
  7. If auth_user is set, any user not specified in auth_file will be queried from pg_shadow in the database using auth_user. Auth_users password will be taken from auth_file.
  8.  
  9. Direct access to pg_shadow requires admin rights. Its preferable to use non-admin user that calls SECURITY DEFINER function instead.
  1. 6.超时时间中server_lifetimeserver_idle_timeout表示不是很明白,超时后第一个直接close掉,第二个直接drop掉,是何意思?
  1. server_lifetime
  2. The pooler will try to close server connections that have been connected longer than this. Setting it to means the connection is to be used only once, then closed. [seconds]
  3.  
  4. Default: 3600.0
  5.  
  6. server_idle_timeout
  7. If a server connection has been idle more than this many seconds it will be dropped. If then timeout is disabled. [seconds]
  8.  
  9. Default: 600.0

  1. 进入正题,安装过程中遇到了一个比较蛋疼的问题,openssl安装了,但是configure时提示没有找到。查了一些资料都是胡扯,最后发现是少了对应的库:
  1. checking for OpenSSL... configure: error: not found
  2.  
  3. 原因:

    The OpenSSL library is usually already installed, but you have to install the header files. Depending on your Linux distribution, you'll need these packages:

  • Red Hat, Fedora, CentOS - openssl-devel
  • Debian, Ubuntu - libssl-dev
  • Arch - openssl
  1. yum install openssl-devel -y
  1. 下面是具体安装步骤了,官网的:
  1. $ ./configure --prefix=/usr/local --with-libevent=libevent-prefix
  2. $ make
  3. $ make install

配置文件:

  1. -bash-4.1$ cat pgbouncer.ini
  2. [databases]
  3. mydb = host=127.0.0.1 port= dbname=mydb user=postgres password=postgres
  4. postgres = host=127.0.0.1 port= dbname=postgres user=postgres password=postgres
  5.  
  6. [pgbouncer]
  7. listen_port =
  8. listen_addr = *
  9. auth_type = md5
  10. auth_file = /var/lib/pgsql/pgbouncer/config/user.txt
  11. logfile = /var/lib/pgsql/pgbouncer/config/pgbouncer.log
  12. pidfile = /var/lib/pgsql/pgbouncer/config/pgbouncer.pid
  13. admin_users = postgres
  14. pool_mode = session

由于配置的是md5,因此这里要用user.txt文件:

  1. -bash-4.1$ cat user.txt
  2. "postgres" "postgres"

启动:

  1. $pgbouncer -d pgbouncer.ini

-bash-4.1$ ps -ef|grep pgbouncer
  postgres 29377 1 0 16:19 ? 00:00:00 pgbouncer -d pgbouncer.ini
  postgres 31574 29031 0 16:28 pts/0 00:00:00 grep pgbouncer

使用:

  1. -bash-4.1$ psql -p
  2. psql: could not connect to server: No such file or directory
  3. Is the server running locally and accepting
  4. connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
  5. -bash-4.1$ psql -p -h localhost
  6. Password:
  7. psql (9.5.)
  8. Type "help" for help.
  9.  
  10. postgres=#
  11. postgres=# \d
  12. No relations found.
  13. postgres=# \l
  14. List of databases
  15. Name | Owner | Encoding | Collate | Ctype | Access privileges
  16. -----------+----------+----------+-------------+-------------+-----------------------
  17. postgres | postgres | UTF8 | en_US.UTF- | en_US.UTF- |
  18. template0 | postgres | UTF8 | en_US.UTF- | en_US.UTF- | =c/postgres +
  19. | | | | | postgres=CTc/postgres
  20. template1 | postgres | UTF8 | en_US.UTF- | en_US.UTF- | =c/postgres +
  21. | | | | | postgres=CTc/postgres
  22. ( rows)

进入后台,查看连接和重载参数:

  1. -bash-4.1$ psql -p -h localhost pgbouncer
  2. Password:
  3. psql (9.5., server 1.7./bouncer)
  4. Type "help" for help.
  5.  
  6. pgbouncer=#
  7. pgbouncer=# show help;
  8. NOTICE: Console usage
  9. DETAIL:
  10. SHOW HELP|CONFIG|DATABASES|POOLS|CLIENTS|SERVERS|VERSION
  11. SHOW STATS|FDS|SOCKETS|ACTIVE_SOCKETS|LISTS|MEM
  12. SHOW DNS_HOSTS|DNS_ZONES
  13. SET key = arg
  14. RELOAD
  15. PAUSE [<db>]
  16. RESUME [<db>]
  17. DISABLE <db>
  18. ENABLE <db>
  19. KILL <db>
  20. SUSPEND
  21. SHUTDOWN
  22. SHOW
  23. pgbouncer=# reload;
  24. RELOAD
  25. pgbouncer=# show clients;
  26. type | user | database | state | addr | port | local_addr | local_port | connect_time | request_time | ptr | link | remote_pid | tls
  27. ------+----------+-----------+--------+------+-------+------------+------------+---------------------+---------------------+----------+------+------------+-----
  28. C | postgres | pgbouncer | active | :: | | :: | | -- :: | -- :: | 0xebe780 | | |
  29. ( row)
  30.  
  31. pgbouncer=# show fds;
  32. fd | task | user | database | addr | port | cancel | link | client_encoding | std_strings | datestyle | timezone | password
  33. ----+--------+----------+----------+-----------+------+---------------+------+-----------------+-------------+-----------+----------+----------
  34. | pooler | | | 0.0.0.0 | | | | | | | |
  35. | pooler | | | :: | | | | | | | |
  36. | pooler | | | unix | | | | | | | |
  37. | server | postgres | postgres | 127.0.0.1 | | | | UTF8 | on | ISO, MDY | PRC |
  38. ( rows)
  1. 其他说明:
    在[database]中,可以指定其他服务器的数据库,而且如果数据库名字重复,会以后一条的数据库生效:
  1. [databases]
  2. kdb = host=127.0.0.1 port=5433 dbname=mydb user=postgres password=postgres
  3. postgres = host=127.0.0.1 port=5433 dbname=postgres user=postgres password=postgres
  4. ;;postgres = host=10.9.5.20 port=5433 dbname=postgres user=postgres password=postgres
  1.  

编译安装pgbouncer-checking for OpenSSL... configure: error: not found的更多相关文章

  1. linux下编译安装php5.6出现 configure: error: Cannot find MySQL header files under /usr/local/mysql.

    #yum install gcc gcc-c++ libxml2 libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-dev ...

  2. 解决编译apache出现的问题:configure: error: APR not found . Please read the documentation - ____哊.時^随记 - 51CTO技术博客

    解决编译apache出现的问题:configure: error: APR not found . Please read the documentation - ____哊.時^随记 - 51CTO ...

  3. checking for tgetent()... configure: error: NOT FOUND!

    今天centos出现了下面的异常: checking for tgetent()... configure: error: NOT FOUND! You need to install a termi ...

  4. centos7编译安装pgbouncer

    1.下载pgbouncer程序包和libevent依赖包 wget https://github.com/libevent/libevent/releases/download/release-2.1 ...

  5. CentOS 6.2 二进制安装apache2.4.3出现configure: error: APR-util not found. Please read the documentation的解决方

    CentOS 6.2 二进制安装apache2.4.3出现configure: error: APR-util not found. Please read the documentation的解决方 ...

  6. 解决编译apache出现的问题:configure: error: APR not found . Please read the documentation

    今日编译apache时出错: #./configure --prefix……检查编辑环境时出现: checking for APR... no configure: error: APR not fo ...

  7. 解决编译Apache出现的问题:configure: error: APR not found

    今日编译apache时出错: #./configure --prefix……检查编辑环境时出现: checking for APR... noconfigure: error: APR not fou ...

  8. Linux下编译安装源码包软件 configure ,make, make install, make test/check, make clean

    http://www.360doc7.net/wxarticlenew/541275971.html 一.什么是源码包软件? 顾名思义,源码包就是源代码的可见的软件包,基于Linux和BSD系统的软件 ...

  9. Linux下编译安装源码包软件 configure ,make, make install, make test/check, make clean 假目标

    http://www.360doc7.net/wxarticlenew/541275971.html 一.程序的组成部分 Linux下程序大都是由以下几部分组成: 二进制文件:也就是可以运行的程序文件 ...

随机推荐

  1. opencv2 学习第8天 提取分离前景和背景

    http://blog.csdn.net/zhouzhouzf/article/details/9281327 GrabCut 代码来自于http://www.cnblogs.com/tornadom ...

  2. spring项目gitignore

    target/ ### STS ### .apt_generated .classpath .factorypath .project .settings .springBeans ### Intel ...

  3. saltstack实现自动化扩容

    案例:当nginx的并发达到3000,并持续了一段时间时,通过自动化创建一台虚拟机,部署应用最后添加到集群提供服务: zabbix监控(nginx并发量)------->action------ ...

  4. Linux读书笔记1/2章

    linux的内核设计: 第一章 1.1Linux历史: 历经时间的考验,今天Unix已经发展成一个支持抢占式多任务.多线程.虚拟内存.换页.动态链接.TCP/Ip网络的现代化操作系统. 1.2追寻Li ...

  5. 强大的jQuery选择器 平时用的太少了 下次要先来看看

  6. filebeat 乱码

    查看 文件的类型 [root@elk-node-1 rsyslog] # file 192.168.1.16.log 192.168.1.16.log: Non-ISO extended-ASCII ...

  7. centos redis 3.2.11 安装与配置

    centos 7 下载解压 wget http://download.redis.io/releases/redis-3.2.11.tar.gz tar xzf redis-3.2.11.tar.gz ...

  8. ASP.NET.Identity 加密算法

    public static string HashPassword(string password) { if (password == null) { throw new ArgumentNullE ...

  9. Ubuntu 安装 networkx

    参考:ubuntu 下NetworkX的安装和使用 Dependences pip setuptools Commands 1.install networkx sudo pip install ne ...

  10. Linux计划任务,自动删除n天前的旧文件

    Linux计划任务,自动删除n天前的旧文件 linux是一个很能自动产生文件的系统,日志.邮件.备份等.虽然现在硬盘廉价,我们可以有很多硬盘空间供这些文件浪费,但需求总是多方面的嘛-我就觉得让系统定时 ...