Ubuntu服务器中PgBouncer的安装

发表时间:2013-04-12 8:06 | 分类:PostgreSQL | 浏览:2,804 次

这几天章郎虫学着安装了PgBouncer,把安装的过程和大家分享下。PgBouncer是PostgreSQL的一个服务器端连接池插件,可以有效的降低服务器端的数据库连接数。
一、安装准备

下载pgbouncer最新发布的源代码并解压

http://pgfoundry.org/frs/?group_id=1000258

安装依赖包libevent
aptitude install libevent-dev

二、安装

编译源代码
进入源代码目录:
./configure --prefix=/usr/local --with-libevent=libevent-prefix
make
make install

三、配置

建立配置目录
mkdir /etc/pgbouncer
编辑配置文件
cp /usr/local/share/doc/pgbouncer/pgbouncer.ini /etc/pgbouncer/
这个文件里的配置项的具体含义可以参考pgbouncer的文档,例如端口、代理模式等。配置的端口注意不要是已经被其它程序所使用过的。

四、生成用pgbouncer连接的用户列表

在数据库服务器上运行,生成的文件userlist.txt放至配置目录下。
forummon=# \o userlist.txt
forummon=# select '"'||rolname||'" "'||rolpassword||'"' from pg_authid;
forummon=# \o
forummon=# \q

修改配置文件权限
chown -R postgres.postgres /etc/pgbouncer

建立log目录
mkdir /var/log/pgbouncer
chown postgres.postgres /var/log/pgbouncer

建立pid目录
mkdir /var/run/pgbouncer
chown postgres.postgres /var/run/pgbouncer

五、启动

pgbouncer -d /etc/pgbouncer/pgbouncer.ini
启动完后查看log是否启动成功。

本文标签:,

本文链接:https://www.sijitao.net/1309.html

欢迎您在本博客中留下评论,如需转载原创文章请注明出处,谢谢!

一键脚本 博客历程 留言联系 文章归档 网站地图 谷歌地图
Copyright © 2010-2024 章郎虫博客 All Rights Reserved.