我试图在PgBouncer服务器上用pgbench测试PostgreSQL连接。但是我在closing because: server DNS lookup failed上收到了错误消息,在pgbench上得到了以下消息:
pgbench -c 10 -t 10 -C -f C:\Users\Administrator\Downloads\query.sql -U postgres -p 6432 -n tags
Password:
pgbench: error: connection to server at "localhost" (::1), port 6432 failed: FATAL: client_login_timeout (server down)在PgBouncer日志中可以观察到这一点:
LOG C-01715ff0: tags/postgres@[::1]:52768 login attempt: db=tags user=postgres tls=no
WARNING DNS lookup failed: localhost: result=11001
LOG S-0174d218: tags/postgres@(bad-af):0 closing because: server DNS lookup failed (age=0s)我在Windows 2019上运行PostgreSQL14.5
PgBouncer Config:
[databases]
postgres = host=localhost port=5435
tags = dbname=postgres host=localhost port=5435 user=postgres password=Admin@!23 auth_user=postgres
[pgbouncer]
logfile = C:\Program Files (x86)\PgBouncer\log\pgbouncer.log
pidfile = C:\Program Files (x86)\PgBouncer\log\pgbouncer.pid
listen_addr = *
listen_port = 6432
auth_type = md5
auth_file = C:\Program Files (x86)\PgBouncer\etc\userlist.txt
admin_users = postgres
stats_users = postgres
pool_mode = session
max_client_conn = 100
default_pool_size = 20我尝试了在这个post中建议的解决方案,比如在postgresql.conf中设置listen_addresses = '*',但是无法解决这个问题。我还在互联网上搜索解决方案,但没有找到任何解决方案。
我是不是漏掉了什么,或者请提出解决这个问题的办法。提前谢谢。
发布于 2022-11-23 04:58:18
在pgbouncer.ini中设置数据库配置后,我可以连接到Postgres,例如:tags = host=127.0.0.1 port=5435 auth_user=postgres dbname=postgres。
事实证明,问题是localhost没有添加到pg_hba.conf中。
https://stackoverflow.com/questions/74533090
复制相似问题