psql与pgbouncer的连接超时

时间:2018-11-07 16:27:13

标签: postgresql pgbouncer

我在repmgr群集中的端口5432上运行3台PostgreSQL v 9.6服务器-1个主服务器和2个备用服务器。 我也有一个运行pgbouncer 1.8.1并在端口6432上监听的pgbouncer服务器。

我们将使用pgbouncer使应用程序透明地连接到主数据库-在发生故障转移的情况下,pgbouncer.database.ini文件将自动更新为指向新的主数据库,然后pgbouncer将重新启动。 / p>

我的问题是我无法从PostgreSQL服务器执行psql命令以能够执行pgbouncer控制台命令(如果我的术语不太正确,我深表歉意)-我一直在超时:

以PostgreSQL主服务器上的postgres用户身份:

-bash-4.1$ psql -h <pgbouncer servername> -p 6432 -U pgbouncer -d pgbouncer
psql: could not connect to server: Connection timed out
        Is the server running on host "<pgbouncer servername>" (xxx.xxx.xxx.xxx) and accepting
        TCP/IP connections on port 6432?

我与我们的防火墙人员核对了,他说这些服务器位于同一VLAN中,因此它们之间没有防火墙,并且它们应该能够相互自由通信。

我安装了pgbouncer,然后配置了以下文件:

/etc/pgbouncer/pgbouncer.ini:

[databases]
%include /etc/pgbouncer/pgbouncer.database.ini
[pgbouncer]
logfile = /var/log/pgbouncer/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
listen_addr = *
listen_port = 6432
client_tls_sslmode = require
client_tls_key_file = /home/pgbouncer/server.key
client_tls_cert_file = /home/pgbouncer/server.crt
client_tls_ca_file = /home/pgbouncer/server_ca.crt
server_tls_sslmode = require
auth_type = md5
auth_file = /etc/pgbouncer/pgb_userlist.txt
admin_users = postgres, pgbouncer
stats_users = stats, postgres, pgbouncer
pool_mode = session
server_reset_query = DISCARD ALL
max_client_conn = 100
default_pool_size = 20
reserve_pool_size = 5
reserve_pool_timeout = 3

/etc/pgbouncer/pgbouncer.database.ini:

[databases]
postgres = host=<primary servername> dbname=postgres
test_db = host=<primary servername> dbname=test_db auth_user=user_test

/etc/pgbouncer/pgb_userlist.txt:

"user_test" "md5..."
"postgres" "md5..."

然后我使用以下命令启动pgbouncer:

pgbouncer -d /etc/pgbouncer/pgbouncer.ini

日志文件显示:

2018-11-07 10:24:23.808 23193 LOG File descriptor limit: 1024 (H:4096), max_client_conn: 100, max fds possible: 430
2018-11-07 10:24:23.811 23195 LOG listening on 0.0.0.0:6432
2018-11-07 10:24:23.811 23195 LOG listening on ::/6432
2018-11-07 10:24:23.811 23195 LOG listening on unix:/tmp/.s.PGSQL.6432
2018-11-07 10:24:23.811 23195 LOG process up: pgbouncer 1.8.1, libevent 2.0.21-stable (epoll), adns: c-ares 1.10.0, tls: OpenSSL 1.0.1e-fips 11 Feb 2013

如果我尝试从pgbouncer服务器发出psql命令,则会出现以下错误:

[pgbouncer@<pgbouncer servername> ~]$ psql -p 6432 pgbouncer
-bash: psql: command not found

配置服务器时是否错过了某些东西? 我根据同事的建议配置了服务器,该同事以这种方式设置了服务器,而且他没有任何问题。但是他不能帮助我让我的工作。

0 个答案:

没有答案