我正在尝试使用包含用户和密码的池定义来设置连接到数据库的pgbouncer池。
随后每个客户端应用程序应使用不同的用户和密码进行连接这个想法是一个池由多个客户端用户共享。
那可能吗?
这是我的设置:pgbouncer.ini
[databases]
testpool = host=testpool.mycompany.com dbname=db1 port=544 user=company_dbo password=company123 max_db_connections=20
[pgbouncer]
auth_type = plain
auth_file = /etc/pgbouncer/users.txt
users.txt
"test_user" "test123"
当我尝试连接时,我得到以下错误
$ export PGPASSWORD='test123';psql -h localhost -U test_user -d db1 -p 5442
psql: ERROR: password authentication failed for user "test_user"
日志说
2019-03-03 16:04:02.668 1 LOG C-0x2022000: db1/[email protected]:33204 login attempt: db=db1 user=test_user tls=no
2019-03-03 16:04:02.719 1 LOG S-0x2026fd0: db1/[email protected]:5442 new connection to server (from 172.17.0.2:58920)
2019-03-03 16:04:02.762 1 WARNING server login failed: FATAL password authentication failed for user "test_user"
似乎pgbouncer尝试使用客户端用户和密码登录数据库,而不是使用[databases]
部分中指定的用户和密码。
auth_file
用于使用pgBouncer对用户进行身份验证,而不是提供与数据库一起使用的不同密码。 pgBouncer将使用从客户端收到的密码登录PostgreSQL。
我不知道你试图以这种方式解决什么问题,但也许你可以在pgBouncer和PostgreSQL之间使用trust
身份验证,并完全用pgBouncer来承担身份验证的负担。
在pgBouncer中无法“改变身份”。