2016-11-23 144 views
0

我在web服務器上有一個haproxy的體系結構,它是路由到從服務器的,在那裏我通過postgre使用pgbouncer。 HAPoxy配置:HAProxy + pgbouncer服務器意外關閉了連接

global 
    log 127.0.0.1 local1 debug 
    user haproxy 
    group haproxy 

defaults 
    log global 
    retries 3 
    timeout connect 1s 
    timeout server 20m 
    timeout client 20m 

listen pgsql-cluster 
    bind 127.0.0.1:5433 
    mode tcp 
    balance leastconn 
    #option pgsql-check user postgres - 
    default-server inter 1s downinter 1s rise 2 fall 1 
    server pgsql-1 10.5.8.14:6432 check 
    server pgsql-2 10.5.8.21:6432 check 

Pgbouncer配置是默認的。 第一個問題,pgsql-check不起作用。 pgboucer.log:

2016-11-23 12:47:37.805 17068 WARNING C-0x23bb760: (nodb)/(nouser)@10.5.8.13:48898 Pooler Error: No such database: postgres 
2016-11-23 12:47:37.805 17068 LOG C-0x23bb760: (nodb)/(nouser)@10.5.8.13:48898 login failed: db=postgres user=postgres 

但最大的問題是,一段時間後,我已經在我的網站(Yii2)得到了許多錯誤。日誌:

2016-11-22 16:37:42 [10.5.33.135][-][-][error][application] SQLSTATE[08006] [7] server closed the connection unexpectedly 
This probably means the server terminated abnormally 
before or while processing the request. in file /var/www/copy-search/vendor/yiisoft/yii2/db/Connection.php on line 547 

我有這種感覺,haproxy只是打破了會議。

回答

0

要回答第一個問題,請確保名爲postgres的用戶在您的PG Bouncer配置中定義。我目前有HA Proxy設置來分配兩個PG Bouncer進程之間的負載,並有一個postgres用戶和一個postgres數據庫在我的配置和健康檢查工作中定義。至於第二個問題,我目前得到同樣的錯誤。

更新:

我增加了HA代理上的超時,這解決了我的問題。

listen pgsql-cluster 
    bind 127.0.0.1:5433 
    mode tcp 
    balance leastconn 
    timeout client 30h 
    timeout server 30h 
    #option pgsql-check user postgres - 
    default-server inter 1s downinter 1s rise 2 fall 1 
    server pgsql-1 10.5.8.14:6432 check 
    server pgsql-2 10.5.8.21:6432 check 
相關問題