2016-11-23 1 views
0

웹 서버에 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 configs에 정의되어 있는지 확인하십시오. 나는 현재 두 개의 PG Bouncer 프로세스 사이에로드를 분산시키고, configs와 health check가 정의한 postgres 사용자와 postgres 데이터베이스를 가지는 HA 프록시 설정을 가지고있다. 두 번째 문제는 현재 동일한 오류가 발생합니다.

업데이트 :

나는 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 
관련 문제