programing

haproxy를 통한 Galera 연결 문제

mailnote 2023. 8. 24. 22:24
반응형

haproxy를 통한 Galera 연결 문제

K8 클러스터에서는 Galera 클러스터에 연결하기 위해 haproxy 앱을 사용합니다.

haproxy.cnf 파일은 다음과 같습니다.

global
    maxconn 2048
    external-check
    stats socket /var/run/haproxy.sock mode 600 expose-fd listeners level user
    user haproxy
    group haproxy

defaults
    log global
    mode tcp
    retries 10
    timeout client 30000
    timeout connect 100500
    timeout server 30000

frontend mysql-router-service
    bind *:6446
    mode tcp
    option tcplog
    default_backend galera_cluster_backend

# MySQL Cluster BE configuration
backend galera_cluster_backend
    mode tcp
    option tcpka
    option mysql-check user haproxy
    balance source
    server pitipana-opsdb1 192.168.144.82:3306  check weight 1
    server pitipana-opsdb2 192.168.144.83:3306  check weight 1
    server pitipana-opsdb3 192.168.144.84:3306  check weight 1

haproxy 이미지를 생성하기 위한 도커 파일

FROM haproxy:2.3
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg

Galera 노드에서, 나는 지속적으로 경고를 받습니다./var/log/mysql/error.log

2021-12-20 21:16:47 5942 [Warning] Aborted connection 5942 to db: 'ourdb' user: 'ouruser' host: '192.168.1.2' (Got an error reading communication packets)
2021-12-20 21:16:47 5943 [Warning] Aborted connection 5943 to db: 'ourdb' user: 'ouruser' host: '192.168.1.2' (Got an error reading communication packets)
2021-12-20 21:16:47 5944 [Warning] Aborted connection 5944 to db: 'ourdb' user: 'ouruser' host: '192.168.1.2' (Got an error reading communication packets)

나는 증가했습니다.max_packet_size64MB 및max_connections천까지

내가 가져갈 때tcpdumpGalera 노드에서:

Frame 16: 106 bytes on wire (848 bits), 106 bytes captured (848 bits)
Linux cooked capture
Internet Protocol Version 4, Src: 192.168.1.2, Dst: 192.168.10.3
Transmission Control Protocol, Src Port: 62495, Dst Port: 3306, Seq: 1, Ack: 1, Len: 50
    Source Port: 62495
    Destination Port: 3306
    [Stream index: 2]
    [TCP Segment Len: 50]
    Sequence number: 1    (relative sequence number)
    [Next sequence number: 51    (relative sequence number)]
    Acknowledgment number: 1    (relative ack number)
    0101 .... = Header Length: 20 bytes (5)
    Flags: 0x018 (PSH, ACK)
        000. .... .... = Reserved: Not set
        ...0 .... .... = Nonce: Not set
        .... 0... .... = Congestion Window Reduced (CWR): Not set
        .... .0.. .... = ECN-Echo: Not set
        .... ..0. .... = Urgent: Not set
        .... ...1 .... = Acknowledgment: Set
        .... .... 1... = Push: Set
        .... .... .0.. = Reset: Not set
        .... .... ..0. = Syn: Not set
        .... .... ...0 = Fin: Not set
        [TCP Flags: ·······AP···]
    Window size value: 507
    [Calculated window size: 64896]
    [Window size scaling factor: 128]
    Checksum: 0x3cec [unverified]
    [Checksum Status: Unverified]
    Urgent pointer: 0
    [SEQ/ACK analysis]
    [Timestamps]
    TCP payload (50 bytes)
    [PDU Size: 45]
    [PDU Size: 5]
MySQL Protocol
    Packet Length: 41
    Packet Number: 1
    Request Command SLEEP
        Command: SLEEP (0)
        Payload: 820000008000012100000000000000000000000000000000...
            [Expert Info (Warning/Protocol): Unknown/invalid command code]
                [Unknown/invalid command code]
                [Severity level: Warning]
                [Group: Protocol]
MySQL Protocol
    Packet Length: 1
    Packet Number: 0
    Request Command Quit
        Command: Quit (1)

여기서192.168.1.2K8 작업자 노드이며192.168.10.3갤러라 노드입니다.

K8에서 응용프로그램을 연결하면 응용프로그램에 액세스할 수 있지만 편집을 시도하면 작업이 중단됩니다.

이것을 고칠 수 있는 제안이 있습니까?

언급URL : https://stackoverflow.com/questions/70424956/galera-connection-issues-over-haproxy

반응형