Postgre SQL   发布时间:2022-05-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了PostgreSQL数据库开源连接池pgbouncer的使用大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

首先,先介绍一个POSTGResql的资源网站:http://pgfoundry.org/ 这里面有非常多和POSTGREsql相关的资源。

pgbouncer是一个非常小型的连接池,最经典的用法是在PLproxy环境中。

这里介绍一下在liNUX平台下的安装和使用,安装时需要libevent,gcc,make等常用工具。

下载:

源码 http://pgfoundry.org/frs/download.php/2608/pgbouncer-1.3.2.tgz

文档 http://developer.skype.com/SkypeGarage/DbProjects/PgBouncer

libevent源码 http://monkey.org/~provos/libevent/ 下一个稳定版

安装:

1. 安装liBEVENT

解包

cd libevent-1.4.13-stable

less README 查看一下帮助文档

./configure && make

@H_813_0@make install

2.安装PGBOUNCER

解包

cd pgbouncer-1.3.2

less README

./configure –prefix=/opt/pgbouncer –with-libevent=/usr/local/

@H_813_0@make

@H_813_0@make install

3.修改环境变量

su – POSTGRes

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

4.编写配置文件与用户密码文件

su – POSTGRes

@H_813_0@mkdir -p ~/pgconfig

cd ~/pgconfig

vi users.txt

“gamehall” “*************”

vi config.ini

[databases]

gamehall = host=192.168.*.* dbname=**** port=****

[pgbouncer]

pool_mode = transaction

Listen_port = 9601

Listen_addr = *

auth_type = md5

auth_file = /home/POSTGRes/pgconfig/users.txt

logfile = /dev/null

pIDfile = /home/POSTGRes/pgconfig/pgbouncer.pID

@H_813_0@max_clIEnt_conn = 1500

default_pool_size = 200

reserve_pool_timeout = 0

reserve_pool_size = 30

server_reset_query = disCARD ALL;

admin_users = pgbouncer_admin

stats_users = pgbouncer_guest

ignore_startup_parameters = extra_float_digits

5.启动pgbouncer

su – POSTGRes

/opt/pgbouncer/bin/pgbouncer -d /home/POSTGRes/pgconfig/config.ini

6.测试

psql -h 127.0.0.1 -p 9601 -U gamehall -d **** -W

正常

PGBOUNCER配置介绍:

非常详细的介绍在DOC里面有,这里简单介绍一下连接池模式

Session pooling::

@H_813_0@most polite method. When clIEnt connects,a server connection

will be assigned to it for the whole duration it stays connected.

When clIEnt disconnects,the server connection will be put BACk

into pool.

transaction pooling::

Server connection is assigned to clIEnt only during a transaction.

When !PgBouncer notices that transaction is over,the server

will be put BACk into pool. This is a Hack as it breaks application

expectations of BACkend connection. You can use it only when

application cooperates with such usage by not using features

that can break. See the table below for breaking features.

Statement pooling::

@H_813_0@most aggressive method. This is transaction pooling with a twist -

@H_813_0@multi-statement transactions are disallowed. This is meant to enforce

“autocommit” mode on clIEnt,mostly targeted for PL/Proxy.

大佬总结

以上是大佬教程为你收集整理的PostgreSQL数据库开源连接池pgbouncer的使用全部内容,希望文章能够帮你解决PostgreSQL数据库开源连接池pgbouncer的使用所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:gcc首先