programing

haproxy를 mariadb 클러스터의 밴랜서로 사용하지만 쿼리 중에 연결이 끊어졌습니다.

minecode 2022. 10. 1. 14:05
반응형

haproxy를 mariadb 클러스터의 밴랜서로 사용하지만 쿼리 중에 연결이 끊어졌습니다.

haproxy를 mariadb galera 클러스터의 밴랜서로 사용하고 있기 때문에 정상적으로 접속하여 조작할 수 있지만, serval seconds 후에 다시 검색을 하고 싶은데 쿼리 에러 중에 연결이 끊겼습니다.아래 이미지 오류를 참조하십시오.

연결 끊김 img

여기 haproxy.cfg가 있습니다.

 defaults
        log                     global
        mode                    tcp
        option                  tcplog
        option                  dontlognull
        option http-server-close
        option                  redispatch
        retries                 3
        timeout http-request    10s
        timeout queue           1m
        timeout connect         10s
        timeout client          50000ms
        timeout server          50000ms
        timeout http-keep-alive 10s
        timeout check           10s
        maxconn                 3000

haproxy.cfg의 mariadb 클러스터 잔액

listen mariadb_cluster_writes 0.0.0.0:50613    
    ## A failover pool for writes to ensure writes only hit one node at a time.
        mode tcp
        #option httpchk
        option tcpka
        option mysql-check user haproxy
        server node65 172.27.12.65:3306 check weight 2
        server node64 172.27.12.64:3306 check weight 1
        server node67 172.27.12.67:3306 check weight 1

    listen mariadb_cluster_reads 0.0.0.0:50614
    ## A load-balanced pool for reads to utilize all nodes for reads.
        mode tcp
        balance leastconn
        #option httpchk
        option tcpka
        option mysql-check user haproxy
        server node65 172.27.12.65:3306 check weight 1
        server node64 172.27.12.64:3306 check weight 1
        server node67 172.27.12.67:3306 check weight 1

누구 짐작 가는 사람?

이유를 찾은 것 같아Haproxy 자체에는 서버와 클라이언트의 타임아웃이 있습니다.서버 타임아웃과 클라이언트의 타임아웃은 mysql 타임아웃과 같은8시간으로 설정합니다.이제 다음과 같습니다.

defaults
        log                     global
        mode                    tcp
        option                  tcplog
        option                  dontlognull
        option http-server-close
        option                  redispatch
        retries                 3
        timeout http-request    10s
        timeout queue           1m
        timeout connect         10s
        timeout client          480m
        timeout server          480m
        timeout http-keep-alive 10s
        timeout check           10s
        maxconn                 3000

희망은 다른 사람들을 도울 수 있다.

그러나 mariadb 클러스터를 사용하고 있습니다.마스터와 머터 아키텍처입니다.모든 노드를 삽입할 수 있기 때문에 haproxy.cfg를 변경했습니다.현재는 다음과 같습니다.

# Global settings
global
    log         127.0.0.1 local2
    maxconn     4000
    daemon

defaults
    log                     global
    mode                    tcp
    #option                  tcplog

    option                  dontlognull
    option                  tcp-smart-accept
    option                  tcp-smart-connect
    option                  redispatch
    retries                 3
    timeout connect         5s
    timeout client          480m
    timeout server          480m

listen admin_stats 
        bind 0.0.0.0:50613
        mode http                       
        maxconn 10
        stats refresh 30s              
        stats uri /stats               
        stats realm XingCloud\ Haproxy  
        stats auth admin:admin          


listen galera_back
        bind :50614
        balance leastconn
        server node65 172.27.12.65:3306 check weight 1
        server node64 172.27.12.64:3306 check weight 1
        server node67 172.27.12.67:3306 check weight 1

언급URL : https://stackoverflow.com/questions/37407021/i-use-haproxy-as-banlancer-for-mariadb-cluster-but-got-lost-connection-during-qu

반응형