Linux 平台安装pgbouncer说明文档

1.安装libevent


下载网址:http://libevent.org/

libevent 1.4.14b-stable

# ./configure

# make

# make install


vi /etc/profile


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


2.安装pgbouncer


1)安装配置pgbouncer


下载网址:http://pgfoundry.org/projects/pgbouncer/

pgbouncer-1.5.4.tar.gz

# ./configure

# make

# make install


复制配置文件

[postgres@gclient pgbouncer-1.5.4]$ pwd

/home/soft/pgbouncer-1.5.4

[postgres@gclient pgbouncer-1.5.4]$ cp etc/pgbouncer.ini /etc/


修改配置文件

[databases]

# 建立数据库连接字符串pgconn

pgconn=host=127.0.0.1 port=5432 user=postgres dbname=postgres

[pgbouncer]

# 监听IP和端口

listen_addr = 192.168.2.9

listen_port = 6432

#日志文件

logfile = /var/log/pgbouncer/pgbouncer.log

#进程文件

pidfile = /var/run/pgbouncer/pgbouncer.pid

#认证类型

auth_type = trust

#认证文件

auth_file = /etc/pgbouncer/userlist.txt

#认证文件

auth_file = /etc/pgbouncer/userlist.txt

#管理用户

admin_users = postgres

#池模式

pool_mode = Transaction


2)建立目录并授权


根据配置文件项目建立目录

auth_file = /etc/pgbouncer/userlist.txt

logfile = /var/log/pgbouncer/pgbouncer.log

pidfile = /var/run/pgbouncer/pgbouncer.pid


mkdir /etc/pgbouncer/

vi /etc/pgbouncer/userlist.txt

# username      password

"postgres"      "postgres"


mkdir /var/log/pgbouncer

chown -R postgres /var/log/pgbouncer

mkdir /var/run/pgbouncer

chown -R postgres /var/run/pgbouncer


3)启动进程

#su - postgres

$ pgbouncer -d /etc/pgbouncer.ini

2013-12-04 10:55:08.059 15844 LOG File descriptor limit: 1024 (H:1024), max_client_conn: 100, max fds possible: 130

[postgres@gclient ~]$


3.连接测试

#su - postgres

### pgconn 配置文件中连接字符名称

$ psql -p 6432 pgconn

psql (9.3.1)

Type "help" for help.


pgconn=# \d

       List of relations

Schema | Name | Type  |  Owner  

--------+------+-------+----------

public | t1   | table | postgres

(1 row)


pgconn=# \q

$


[postgres@gclient ~]$ psql -p 6432 pgbouncer

psql (9.3.1, server 1.5.4/bouncer)

Type "help" for help.


pgbouncer=#


登录管理pgbouncer


$ psql -p 6432 pgbouncer

psql (9.3.1, server 1.5.4/bouncer)

Type "help" for help.


pgbouncer=# show help;

NOTICE:  Console usage

DETAIL:  

       SHOW HELP|CONFIG|DATABASES|POOLS|CLIENTS|SERVERS|VERSION

       SHOW STATS|FDS|SOCKETS|ACTIVE_SOCKETS|LISTS|MEM

       SHOW DNS_HOSTS|DNS_ZONES

       SET key = arg

       RELOAD

       PAUSE [<db>]

       RESUME [<db>]

       KILL <db>

       SUSPEND

       SHUTDOWN

SHOW

pgbouncer=#



本文转自 pgmia 51CTO博客,原文链接:http://blog.51cto.com/heyiyi/1335817

上一篇:sed 如何转换大小写字母


下一篇:启动Tomcat服务器报错