zoukankan      html  css  js  c++  java
  • pgbouncer配置

    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:

  • 相关阅读:
    使用ajax和window.history.pushState无刷新改变页面内容和地址栏URL
    URL中“#” “?” &“”号的作用
    JavaScript中事件捕获(Event capturing)-------------->由外向内,事件冒泡(Event bubblin)---------->由内向外
    单页面应用程序案例
    【344】Jupyter relevant problems
    【343】MathJax、LaTex、Mathml 数学公式
    【342】Linear Regression by Python
    【341】Numpy 相关应用
    【340】GIS related knowledge
    java中通过反射获取方法并且调用(getMethod和invoke深入)实践
  • 原文地址:https://www.cnblogs.com/xiaotengyi/p/4067304.html
Copyright © 2011-2022 走看看