PgBouncer
Allikas: Kuutõrvaja
Sisukord
Sissejuhatus
PgBouncer https://developer.skype.com/SkypeGarage/DbProjects/PgBouncer ...
Tarkvara paigaldamine
Tarkvara paigaldamiseks Debian Squeeze keskkonnas sobib öelda
# apt-get install pgbouncer
Paigaldatakse muu seas sellised failid
/usr/sbin/pgbouncer /etc/default/pgbouncer /etc/pgbouncer/pgbouncer.ini /etc/pgbouncer/userlist.txt /etc/init.d/pgbouncer
Tarkvara seadistamine ja käivitamine
Tarvara tööd kontrollivad seadistusfailid
- /etc/pgbouncer/pgbouncer.ini, mille sisu võiks olla nt
# egrep -v "^$|^;" /etc/pgbouncer/pgbouncer.ini [databases] test = host=127.0.0.1 dbname=test [pgbouncer] logfile = /var/log/postgresql/pgbouncer.log pidfile = /var/run/postgresql/pgbouncer.pid listen_addr = * listen_port = 6432 unix_socket_dir = /var/run/postgresql auth_type = trust auth_file = /etc/pgbouncer/userlist.txt admin_users = postgres stats_users = postgres pool_mode = session server_reset_query = server_check_query = select 1 server_check_delay = 10 max_client_conn = 100 default_pool_size = 20 log_connections = 1 log_disconnections = 1 log_pooler_errors = 1
- /etc/pgbouncer/userlist.txt sisaldab nt
"postgres" "parool"
Käivitamiseks peab olema failis /etc/default/pgbouncer rida
START=1
ja tuleb öelda
# /etc/init.d/pgbouncer start
PgBouceri kasutamine
PgBouceri kasutamiseks tuleb ühenduda PgBounceri porti, nt 192.168.10.205:6432 ja kasutada seda nagu tavalist andmebaasi.
PgBounceri haldamine
PgBounceri haldamiseks sobib kasutada andmebaasi pgbouncer, nt
$ psql -h 127.0.0.1 -p 6432 -U postgres pgbouncer -c 'show databases;' name | host | port | database | force_user | pool_size | reserve_pool -----------+-----------+------+-----------+------------+-----------+-------------- pgbouncer | | 6432 | pgbouncer | pgbouncer | 2 | 0 test | 127.0.0.1 | 5432 | test | | 20 | 0
(2 rows)