_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › pgbouncer

Contents

1 覯 覲
2
3 覦覯 ろ
4 DB 覦 企
5 config
6 れ md5
7 users.txt
8
9 192.168.56.1 ろ


PgBouncer is a lightweight connection pooler for PostgreSQL.

1 覯 覲 #

  • 192.168.56.101 --> pgbouncer1.6
  • 192.168.56.102 --> postgresql9.4, pg_hba.conf 殊 192.168.56.102

2 #

rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
yum update
yum install pgbouncer

3 覦覯 ろ #

firewall-cmd --permanent --add-port=6543/tcp
firewall-cmd --reload

4 DB 覦 企 #

192.168.56.102覯
psql -x -c "CREATE DATABASE sample WITH ENCODING='UTF8' CONNECTION LIMIT=-1;" 
psql -x -d sample -c "create table test(id int)" 
psql -x -d sample -c "insert into test(id) values(1)"
psql -x -d sample -c "select * from test" 

5 config #

vi /etc/pgbouncer/config.ini

[databases]
db1 = host=192.168.56.102 port=5432 dbname=sample user=postgres password=9999

[pgbouncer]
pool_mode = session
listen_port = 6543
listen_addr = *
auth_type = md5
auth_file = /etc/pgbouncer/users.txt
logfile = pgbouncer.log
pidfile = pgbouncer.pid
admin_users = postgres

6 れ md5 #

sql
select 'md5' || md5 ('9999' || 'postgres');

shell script
user=postgres; passwd=9999; echo -n md5; echo $passwd$user | md5sum

7 users.txt #

vi /etc/pgbouncer/users.txt

"postgres" "md59b9579bc6327c1a529d21c8a011e552d"

8 #

su - postgres
pgbouncer -d /etc/pgbouncer/config.ini -R

9 192.168.56.1 ろ #

psql -h 192.168.56.101 -p 6543 -d db1 -U postgres
pgbouncer_test.png
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

磯ゴ 覯 讌 覈詩 譬 讌螳 . (襴ろ)