第二天,如果我使用auth_type = hba,我无法通过pgbouncer克服连接错误。
postgres=# create user monitoring with password 'monitoring';
postgres=# create database monitoring owner monitoring;
postgres=# \du+ monitoring
List of roles
Role name | Attributes | Member of | Description
------------+------------+-----------+-------------
monitoring | | {} |
postgres=# \l+ monitoring
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
------------+------------+----------+-------------+-------------+-------------------+---------+------------+-------------
monitoring | monitoring | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 7861 kB | pg_default |/var/lib/pgsql/10/data/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
host monitoring monitoring 0.0.0.0/0 trust
local monitoring monitoring trust/etc/pgbouncer/pgbouncer.ini
pidfile = /var/run/pgbouncer/pgbouncer.pid
reserve_pool_size = 5
reserve_pool_timeout = 2
listen_port = 6432
listen_addr = *
auth_type = hba
auth_hba_file = /etc/pgbouncer/hba_bouncer.conf
auth_file = /etc/pgbouncer/userlist.txt
logfile = /var/log/pgbouncer/pgbouncer.log
log_connections = 0
log_disconnections = 0
log_pooler_errors = 1
max_client_conn = 5000
server_idle_timeout = 30
pool_mode = transaction
server_reset_query =
admin_users = root
stats_users = root,monitoring
[databases]
* = client_encoding=UTF8 host=localhost port=5432 pool_size=1000在pgbouncer的pg_hba.conf中,我还尝试使用掩码/32,也掩码/8,/16 (我的网段的真实掩码)来指定服务器接口的特定地址。
结果只有一个:登录被拒绝!
/etc/pgbouncer/hba_bouncer.conf
host monitoring monitoring 0.0.0.0/0 trust
host monitoring monitoring 127.0.0.1/32 trust/etc/pgbouncer/userlist.txt
"monitoring" "monitoring"连接尝试:
# psql -U monitoring -p 5432 -h 127.0.0.1
psql (10.1)
Type "help" for help.
monitoring=>
# psql -U monitoring -p 6432 -h 127.0.0.1
psql: ERROR: login rejected发布于 2019-11-08 09:34:06
我们有一个与您的用例类似的用例。我们运行的是1.12.0版本,我们遇到了同样的问题,我们也收到了"ERROR: login rejected“消息。
经过调查后发现,我们对pg_bouncer的pg_hba.conf权限是不正确的。一旦我们给了pgbouncer读权限,它就可以正常工作了。不幸的是,我们打开的更高的日志记录中没有显示这一点,我们碰巧通过自己的测试发现了这个解决方案。
Ps。当我们在连接上使用信任时,我们在pgbouncer配置中保留的密码散列为"“。我不认为我们的配置与您发布的内容有什么不同。
https://stackoverflow.com/questions/57428206
复制相似问题