歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Linux 平台安裝PgBouncer說明文檔

Linux 平台安裝PgBouncer說明文檔

日期:2017/3/1 9:49:38   编辑:Linux編程

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=#

Copyright © Linux教程網 All Rights Reserved