加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

PostgreSQL连接池pgbouncer的使用

发布时间:2020-12-13 18:16:29 所属栏目:百科 来源:网络整理
导读:今天在虚拟机上整理了下pgbouncer的安装使用过程,记录如下。 说明:pgbouncer是一款轻量级针对postgresql的数据库连接工具,可以对客户端的连接做限制,防止恶意连接,另外也可以减少数据库的实际连接数,从而减少数据库的开销。 环境: VMWARE 8 CentOS 5.

今天在虚拟机上整理了下pgbouncer的安装使用过程,记录如下。

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

环境:

VMWARE 8

CentOS 5.7

PG 9.1.2

pgbouncer 1.5.2

libevent-2.0.19

一.安装

1.下载pgbouncer的安装包

http://pgfoundry.org/frs/?group_id=1000258&release_id=1952,本次下载的安装包是pgbouncer-1.5.2.tar.gz

2.下载libevent包

http://monkey.org/~provos/libevent/,见pgbouncer源码包中的Readme

这玩意也是个好东西,在很多地方用到

3.安装libevent

$ cd libevent-2.0.19-stable

$ ./configure --prefix=/home/postgres/libevent

$ make

$ make install

4.安装pgbouncer

$ cd pgbouncer-1.5.2

$ ./configure --prefix=/home/postgres/pgbouncer/ --with-libevent=/home/postgres/libevent/

查看pgbouncer是否安装成功,可以通过查看config.log中最后的返回值exit来确认,0是成功1是失败.

二.配置

1.配置pgbouncer的cfg文件

[postgres@localhost config]$ pwd

/home/postgres/pgbouncer/config

[postgres@localhost config]$ more pgbouncer.ini

[databases]

f_game = host=127.0.0.1 port=1233 dbname=test_db user=test password=test

[pgbouncer]

listen_port = 1999

listen_addr = 127.0.0.1

auth_type = md5

auth_file = /home/postgres/pgbouncer/user.txt

logfile = /home/post

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读