【问题标题】:pgbouncer: user,password per poolpgbouncer:用户,每个池的密码
【发布时间】:2019-07-25 01:08:36
【问题描述】:

我正在尝试设置一个 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/test_user@172.17.0.1:33204 login attempt: db=db1 user=test_user tls=no
2019-03-03 16:04:02.719 1 LOG S-0x2026fd0: db1/test_user@10.1.0.118: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] 部分中指定的用户和密码。

【问题讨论】:

    标签: postgresql connection-pooling pool pgbouncer


    【解决方案1】:

    auth_file 用于通过 pgBouncer 对用户进行身份验证,而不是提供与数据库一起使用的不同密码。 pgBouncer 将使用从客户端收到的密码登录 PostgreSQL。

    我不知道你想用这种方式解决什么问题,但也许你可以在 pgBouncer 和 PostgreSQL 之间使用trust 身份验证,而将身份验证的负担完全交给 pgBouncer。

    在 pgBouncer 中无法“更改身份”。

    【讨论】:

    • 谢谢劳伦兹。将尝试“信任”出来。最初的问题是我们有 pgbouncer 在 AWS NLB 后面运行,它不会将源 IP 传递给 pgbouncer。因此,所有请求都使用 NLB IP 而不是“源”应用程序的 IP 出现在日志中,这使得故障排除变得困难。为了更容易识别来源,我尝试了以下操作:Application --(AppUser/AppPwd)--> pgbouncer --(PgbUser/PgbPwd)--> postgresdb
    • 我明白了。是的,trust 可能会让这成为可能。
    猜你喜欢
    • 2018-01-21
    • 1970-01-01
    • 2020-07-14
    • 2021-05-14
    • 2022-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多