12

pgbouncer バージョン 1.7.2

psql (9.5.6)

PgBouncer で auth_hba_file (/var/lib/pgsql/9.5/data/pg_hba.conf) を使用してみます。

pgbouncer.ini の設定

postgres = host=localhost port=5432 dbname=postgres user=postgres
test = host=localhost port=5432 dbname=test user=test
[pgbouncer]
logfile = /var/log/pgbouncer/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
listen_addr = *
listen_port = 6432
auth_type = hba
auth_hba_file = /var/lib/pgsql/9.5/data/pg_hba.conf
admin_users = postgres
stats_users = stats, postgres
pool_mode = session
server_reset_query = DISCARD ALL
max_client_conn = 100
default_pool_size = 20

猫pg_hba.conf | grep -v "#" | grep -v "^$"

local   all             all                              trust
host    all             all             127.0.0.1/32     trust
host    all             all             ::1/128          trust
host    test            test            10.255.4.0/24    md5

psql -h 10.233.4.16 -p 5432 -U テスト

Password for user test:
psql (9.5.6)
Type "help" for help.

test=> \q

psql -h 10.233.4.16 -p 6432 -U テスト

psql: ERROR:  No such user: test

テール -fn10 /var/log/pgbouncer/pgbouncer.log

LOG C-0x78f7e0: (nodb)/(nouser)@10.255.4.245:8963 closing because: No such user: test (age=0)
WARNING C-0x78f7e0: (nodb)/(nouser)@10.255.4.245:8963 Pooler Error: No such user: test
LOG C-0x78f7e0: (nodb)/(nouser)@10.255.4.245:8963 login failed: db=test user=test

しかし、pg_hba.confを使用して(PgBouncerを使用して)postgresqlに接続できません

誰か助けてくれませんか?auth_hba_file の使用例を教えてください。ありがとう

構成を変更しました:

[root@dev-metrics2 pgbouncer]# 猫 pgbouncer.ini | grep -v ";" | | grep -v "^$" | grep -v "#"

[databases]
postgres = host=localhost port=5432 dbname=postgres user=postgres
test = host=localhost port=5432 dbname=test auth_user=test
[pgbouncer]
logfile = /var/log/pgbouncer/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
listen_addr = *
listen_port = 6432
auth_query = SELECT usename, passwd FROM pg_shadow WHERE usename=$1
admin_users = postgres
stats_users = stats, postgres
pool_mode = session
server_reset_query = DISCARD ALL
max_client_conn = 100
default_pool_size = 20

ユーザーとDBをドロップして作成

[local]:5432 postgres@postgres # DROP DATABASE test;
DROP DATABASE
[local]:5432 postgres@postgres # DROP USER test ;
DROP ROLE
[local]:5432 postgres@postgres # CREATE USER test with password 'test';
CREATE ROLE
[local]:5432 postgres@postgres # CREATE DATABASE test with owner test;
CREATE DATABASE

PGPASSWORD=test psql -h 10.233.4.16 -p 6432 -U テスト

Password for user test:
psql: ERROR:  Auth failed

テール -fn1 /var/log/pgbouncer/pgbouncer.log

LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us
LOG C-0x17b57a0: test/test@10.255.4.245:3069 login attempt: db=test user=test tls=no
LOG C-0x17b57a0: test/test@10.255.4.245:3069 closing because: client unexpected eof (age=0)
LOG C-0x17b57a0: test/test@10.255.4.245:3070 login attempt: db=test user=test tls=no
LOG C-0x17b57a0: test/test@10.255.4.245:3070 closing because: Auth failed (age=0)
WARNING C-0x17b57a0: test/test@10.255.4.245:3070 Pooler Error: Auth failed

作業構成:

猫 pgbouncer.ini | grep -v ";" | | grep -v "^$" | grep -v "#"

[databases]
*= port=5432 auth_user=postgres
[pgbouncer]
logfile = /var/log/pgbouncer/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
listen_addr = *
listen_port = 6432
auth_query = SELECT usename, passwd FROM pg_shadow WHERE usename=$1
admin_users = postgres
stats_users = stats, postgres
pool_mode = session
server_reset_query = DISCARD ALL
max_client_conn = 100
default_pool_size = 20
4

1 に答える 1