use*_*984 6 .net networking firewall npgsql pgbouncer
我正在开发与 postgresql (npgsql) 连接的 .net 应用程序。由于大量空闲连接(npgsql 无法终止它),我不得不安装 pgbouncer。我编写了一个配置文件并设置了一个 auth_user_file。
pgbouncer配置:
[databases]
dbr = host=HOST_DNS_NAME port=16252 dbname=app_database user=PGB_USER password=PGB_PASSWORD
[pgbouncer]
listen_port = 16252
listen_addr = *
auth_type = md5
auth_file = /URL_TO_AUTH_FILE/users.txt
logfile = pgbouncer.log
pidfile = pgbouncer.pid
admin_users = root
stats_users = root
default_pool_size = 50
max_client_conn = 100
log_connections = 1
log_disconnections = 1
log_pooler_errrors = 1
unix_socket_dir = /tmp
Run Code Online (Sandbox Code Playgroud)
我允许在 16252 端口上进行通信 (iptables)
-A INPUT -m state --state NEW,ESTABLISHED -m tcp -p tcp --dport 16252 -j ACCEPT
netstat -na | grep 16252
tcp 0 0 0.0.0.0:16252 0.0.0.0:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 2726363 /tmp/.s.PGSQL.16252
Run Code Online (Sandbox Code Playgroud)
当我通过 SSH 直接连接到服务器并且我想通过本地 pgbouncer 连接时
psql -h HOST_DNS_NAME -p 16252 -U PGB_USER dbr
Run Code Online (Sandbox Code Playgroud)
一切安好。但是当我想通过 pgbouncer 从另一个位置远程连接时,psql 客户端会向我抛出以下消息:
psql: could not connect to server: Connection refuses <0x0000274D/10061>
Is the server running on host HOST_DNS_NAME and accepting TCP/IP connections on port 16252
Run Code Online (Sandbox Code Playgroud)
如果我仅将端口更改为标准 5432(直接 postgresql),则一切正常。
你有什么主意吗?
| 归档时间: |
|
| 查看次数: |
1909 次 |
| 最近记录: |