DESCRIPTION

pgbouncer is a PostgreSQL connection pooler. Any target application can be connected to pgbouncer as if it were a PostgreSQL server, and pgbouncer will create a connection to the actual server, or it will reuse one of its existing connections.

The aim of pgbouncer is to lower the performance impact of opening new connections to PostgreSQL.

In order not to compromise transaction semantics for connection pooling, pgbouncer supports several types of pooling when rotating connections:

Session pooling

Most polite method. When client connects, a server connection will be assigned to it for the whole duration the client stays connected. When the client disconnects, the server connection will be put back into the pool. This is the default method.

Transaction pooling

A server connection is assigned to client only during a transaction. When PgBouncer notices that transaction is over, the server connection will be put back into the pool.

Statement pooling

Most aggressive method. The server connection will be put back into pool immediately after a query completes. Multi-statement transactions are disallowed in this mode as they would break.

The administration interface of pgbouncer consists of some new SHOW commands available when connected to a special virtual database pgbouncer.

QUICK-START

Basic setup and usage as following.

  1. Create a pgbouncer.ini file. Details in pgbouncer(5). Simple example:

    [databases]
    template1 = host=127.0.0.1 port=5432 dbname=template1
    [pgbouncer]
    listen_port = 6543
    listen_addr = 127.0.0.1
    auth_type = md5
    auth_file = users.txt
    logfile = pgbouncer.log
    pidfile = pgbouncer.pid
    admin_users = someuser
  2. Create a users.txt file:

    "someuser" "same_password_as_in_server"
  3. Launch pgbouncer:

    $ pgbouncer -d pgbouncer.ini
  4. Have your application (or the psql client) connect to pgbouncer instead of directly to PostgreSQL server.

    $ psql -p 6543 -U someuser template1
  5. Manage pgbouncer by connecting to the special administration database pgbouncer and issuing show help; to begin:

    $ psql -p 6543 -U someuser pgbouncer
    pgbouncer=# show help;
    NOTICE: Console usage
    DETAIL:
    SHOW [HELP|CONFIG|DATABASES|FDS|POOLS|CLIENTS|SERVERS|SOCKETS|LISTS|VERSION]
    SET key = arg
    RELOAD
    PAUSE
    SUSPEND
    RESUME
    SHUTDOWN
  6. If you made changes to the pgbouncer.ini file, you can reload it with:

pgbouncer配置的更多相关文章

  1. 使用PgBouncer连接池

    1.pgbouncer 的介绍 pgbouncer是一个针对PostgreSQL数据库的轻量级连接池,任何目标应用都可以把 pgbouncer 当作一个 PostgreSQL/Greenplum 服务 ...

  2. PostgreSQL Replication之第八章 与pgbouncer一起工作(1)

    当您在使用大规模的设施工作,可能有时候,您必须处理许多并发打开的连接.没有人会使用十台服务器来为两个并发用户提供服务--在许多情况下,这根本没有意义.大量的设施通常会处理成百上千的并发连接.引入连接池 ...

  3. [原]OpenStreetMap数据瓦片服务性能篇

    上文说到如何利用node-mapnik架设OpenStreetMap瓦片服务,解决了有没有的问题.然而这个服务还是比较孱弱,主要表现在以下几个方面: 1. Node.js只能使用CPU的一个核,不能有 ...

  4. linux ---pgbouncer的安装和配置

    pgbouncer是一款轻量级针对postgresql的数据库连接工具,可以对客户端的连接做限制,防止恶意连接,另外也可以减少数据库的实际连接数,从而减少数据库的开销. 环境: centos 6.5 ...

  5. pgbouncer的安装和配置

    tar -zxvf libevent-2.0.21-stable.tar.gzcd libevent-2.0.21-stable/mkdir /home/pg10/libevent./configur ...

  6. pgbouncer介绍

    一.Pgbouncer 的介绍 Pgbouncer是一个针对PostgreSQL数据库的轻量级连接池,任何目标应用都可以把 pgbouncer 当作一个 PostgreSQL 服务器来连接,然后pgb ...

  7. pgbouncer+pg(fdw)+pg(datanode)分表方案

    pgbouncer+pg(fdw)+pg(datanode)分表方案 (环境RHEL6.5,PG9.4.5,pgbouncer1.5.4,libevent2.0.22) 方案架构图如下: pgboun ...

  8. [原创]PostgreSQL Plus Advince Server在 HA环境中一对多的Stream Replication配置(一)

    内容较多,开篇作为说明和目录. 实验环境规划:服务器:IBM x3500 m3三台其中两台用作HA,另外一台安装VMware ESXi安装两个虚机做Stream Replication.NAS存储IP ...

  9. postgresql9.5 run 文件linux安装后配置成开机服务

    网上出现的比较多安装方法要么是源码安装,要么是yum安装,我发觉都要配置很多属性,比较麻烦,所以现在我在centos7长用 run文件来安装 http://get.enterprisedb.com/p ...

随机推荐

  1. UIlabel设置不同的颜色

    NSString *string = @"注册过程中出现问题,致电400-650-5167联系会养车工作人员";    NSRange range = [string rangeO ...

  2. ubuntu16.04操作练习&问题解决

    1. 安装更新时提示/boot空间不足: boot文件夹里存放的是系统引导文件和内核的一些东西,旧内核的东西需要手动删除,释放空间.所以: step1:查看 dpkg --get-selections ...

  3. linux下IPTABLES配置详解

    如果你的IPTABLES基础知识还不了解,建议先去看看. 开始配置 我们来配置一个filter表的防火墙. (1)查看本机关于IPTABLES的设置情况 [root@tp ~]# iptables - ...

  4. 5分钟学习maven(根据英文文档整理)

    英文原地址:http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html 一.前提 需要懂得如何在计算机上安装软件 ...

  5. 自定义UIPageControl

    iphone的UIPageControl控件可以显示用户huan'dong滑动到的页码.但是里面的小点的颜色时默认的白色.如果背景也是白色的hu话,你就悲剧了.于是乎上网找了一些资料,找到了改变UIP ...

  6. C语言数据类型在IA32中的大小

    这个主要是一些常识问题,以及在使用AT&T语法汇编时会使用的编码后缀: C声明 Intel数据类型 汇编后缀 大小(byte) char 字节  b  1 short 字  w  2 int ...

  7. Java Serializable

    实现Serializable的class表明object可以被保存. 被保存的时候实际是存储class里的instance variable,这样在deserialization的时候可以恢复obje ...

  8. HDU4055 - number string(DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4055 思路:dp[i][j]表示处理前i个字符以j结尾可能的序列数. 当a[i]=='I'时,dp[i ...

  9. Win7 登入提示临时漫游档案

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

  10. oracle第一招之神马都是浮云

    oracle: 一款关系型(二维表)数据库,可以用来存储海量数据.在大数据量并发检索的情况下,性能要高于其他的同类数据库产品.一般运行环境是Linux和Unix操作系统上! 目前最流行的商业数据库,主 ...