2013-04-16 69 views
1

我試圖讓pgbouncer在獨立的postgresql服務器上工作,但是當我嘗試使用pgbouncer端口連接到數據庫時,出現超時錯誤。pgbouncer無法連接到本地postgresql數據庫(超時)

PostgreSQL的:9.1.8

pgBouncer:1.4.2

操作系統:Ubuntu的LTS 12.04.2(GNU/Linux的3.8.4-x86_64的-linode31 x86_64的)

這裏是我的conf文件:

[databases] 
postgres = host=127.0.0.1 port=5432 dbname=postgres 
mydb = host=127.0.0.1 port=5432 dbname=mydb 

[pgbouncer] 
logfile = /home/username/pg_log/pgbouncer.log 
pidfile = /tmp/pgbouncer.pid 
listen_addr = xxx.xxx.xxx.xxx 
listen_port = 6432 
unix_socket_dir = /var/run/postgresql 
auth_type = md5 
auth_file = /etc/pgbouncer/userlist.txt 
admin_users = postgres 
stats_users = stats, root 
user = postgres 
pool_mode = session 
server_reset_query = DISCARD ALL 
max_client_conn = 1000 
default_pool_size = 20 
log_connections = 1 
log_disconnections = 1 
log_pooler_errors = 1 

我試着來測試像這樣的連接:

psql -p 6432 -U postgres mydb 

這裏是我的日誌文件:

28396 LOG listening on xxx.xxx.xxx.xxx:6432 
28396 LOG listening on unix:/var/run/postgresql/.s.PGSQL.6432 
28396 LOG process up: pgbouncer 1.4.2, libevent 2.0.16-stable (epoll), adns: evdns2 
28864 LOG C-0x23f7890: mydb/[email protected]:6432 login attempt: db=mydb user=postgres 
28864 LOG C-0x23f7890: mydb/[email protected]:6432 closing because: client unexpected eof (age=0) 
28864 LOG C-0x23f7890: mydb/[email protected]:6432 login attempt: db=mydb user=postgres 
28864 LOG S-0x2415240: mydb/[email protected]:5432 new connection to server 
28864 LOG S-0x2415240: mydb/[email protected]:5432 closing because: connect failed (age=0) 
28864 LOG S-0x2415240: mydb/[email protected]:5432 new connection to server 
28864 LOG S-0x2415240: mydb/[email protected]:5432 closing because: connect failed (age=0) 
28864 LOG S-0x2415240: mydb/[email protected]:5432 new connection to server 
28864 LOG S-0x2415240: mydb/[email protected]:5432 closing because: connect failed (age=0) 
28864 LOG S-0x2415240: mydb/[email protected]:5432 new connection to server 
28864 LOG S-0x2415240: mydb/[email protected]:5432 closing because: connect failed (age=0) 
28864 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us 
28864 LOG C-0x23f7890: mydb/[email protected]:6432 closing because: client_login_timeout (server down) (age=60) 
28864 WARNING C-0x23f7890: mydb/[email protected]:6432 Pooler Error: client_login_timeout (server down) 
28864 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us 
28864 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us 

有沒有別的東西,我需要改變,以使pgbouncer工作?

+0

防火牆單向阻止數據包? –

+0

嗯,看起來很奇怪。我在本地和外部測試連接: tcp 0 0 xxx.xxx.xxx.xxx.64x :6432 0.0.0.0:* LISTEN 27040/pgbouncer –

回答

1

變化

listen_addresses = 'private_ip' 

listen_addresses = '*' 

在postgresql.conf文件。

+1

不應該'listen_addresses ='localhost''工作? –

0

看起來你正在嘗試使用Unix套接字進行連接。根據您的Postgres安裝,套接字可能已經在/ tmp中創建,而不是在/ var/run/postgres中創建。我遇到了這個問題,它一直是discussed here

嘗試改變pgbouncer.ini配置到這一點:

unix_socket_dir = /tmp 

你也可以嘗試只通過添加-h如下連接到本地主機:

psql -p 6432 -h localhost -U postgres mydb 

希望這有助於!

+0

錯誤發生在我的postgresql.conf文件中。我的listen_adresses被設置爲不接受本地傳入。將其更改爲listen_addresses ='*',現在它可以工作! –

+1

太棒了!感謝您的更新。 – marcj

相關問題