欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

postgreSQL pgBouncer安装配置

程序员文章站 2024-02-18 22:05:58
...

postgreSQL pgBouncer安装配置 下载地址:http://pgfoundry.org/frs/?group_id=1000258release_id=1981 1.安装步骤: $ ./configure --prefix=/usr/local --with-libevent=libevent-prefix $ make $ make install 如果没有libevent,那么http://monkey.org/~

postgreSQL pgBouncer安装配置

下载地址:http://pgfoundry.org/frs/?group_id=1000258&release_id=1981

1.安装步骤:

$ ./configure --prefix=/usr/local --with-libevent=libevent-prefix

$ make

$ make install

如果没有libevent,那么http://monkey.org/~provos/libevent/下载

Libevent安装:

$ ./configure && make

$ make verify

# make install 注意安装时用root用户

tail -1f config.log

configure: exit 0 0说明安装成功,1为失败

2.创建配置文件:

Mkdir –p $PGDATA/pgbouncer

postgres@readerlogdb-> more config.ini

[databases]

testdb = host=127.0.0.1 port=1931 dbname=testdb user=testuser password=testuser

[pgbouncer]

listen_port = 1688

listen_addr = 127.0.0.1

auth_type = md5

auth_file = /opt/pgdata/pg_root/pgbouncer/user.txt

logfile = /opt/pgdata/pg_root/pgbouncer/pgbouncer.log

pidfile = /opt/pgdata/pg_root/pgbouncer/pgbouncer.pid

pool_mode = Transaction

admin_users = pgbouncer_admin

stats_users = pgbouncer_guest

3.添加用户信息

more user.txt

"testuser" "testuser"

"pgbouncer_admin" "pgbouncer_admin"

4.启动pgbouncer

pgbouncer -d /opt/pgdata/pg_root/pgbouncer/config.ini

5.测试连接

psql -h 127.0.0.1 -p 1688 -d testdb -U testuser #testuser用户连接testdb

psql -h 127.0.0.1 -p 1688 -d pgbouncer -U pgbouncer_admin #以pgbouncer管理用户进入本身的数据库pgbouncer

6.查看相关信息

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 []

RESUME []

KILL

SUSPEND

SHUTDOWN

Show config; #查看相关配置

Show stats;

Show lists;#查看连接相关信息,如,数据库个数,空闲连接数等等

Show pools;#查看池中连接信息

Show databases;#查看相关数据库

Show clients; #查看连接数

如果修改了配置文件,那么需要reload重新加载

pgbouncer=# reload;

RELOAD

连接方式有三种,之前介绍过,种类不再详述,以上 一些参数的介绍,在源安装包里doc目录下有详细说明和举例。