source

Galera 클러스터 노드가 wsrep_notify_cmd 및 wsrep_sst_method를 트리거하지 않음

itover 2022. 12. 21. 22:30
반응형

Galera 클러스터 노드가 wsrep_notify_cmd 및 wsrep_sst_method를 트리거하지 않음

셋업을 했습니다.Galera cluster3개의 노드를 사용하여docker containers. 데이터 동기화 시,donor다른 노드에 대한 노드(기준)wsrep_notify_cmd트리거 또는wsrep_sst_method동기 노드에서의 트리거는 해당 노드의 대응하는 Redis 큐에도 데이터를 입력해야 합니다.문제는 이 2개의 트리거가 클러스터를 시작할 때만 호출된다는 것입니다.하나의 노드가 클러스터에 가입했을 때 이들 2개의 트리거가 호출되었음을 나타내는 로그가 있습니다.그러나 스키마를 변경하거나 한 노드에서 CUD 액션을 수행하려고 하면 트리거가 다른 노드에서 실행되지 않았습니다.설정을 잘못했는지, 또는 이러한 트리거가 동작하고 있지 않은지 알 수 없습니다.

클러스터를 작동시키기 위해 사용하는 파일은 다음과 같습니다.

  • docker-param.yml

    version: '3'
    services:
      node1:
          build: ./galera/
          image: galera_mariadb:latest
          container_name: "galera_cluster_node1"
          hostname: node1
          ports:
            - 13306:3306
          networks:
            - galera_cluster
          volumes:
            - ./galera/conf.d/galera.cnf:/etc/mysql/conf.d/galera.cnf
            - /var/data/galera/mysql/node1:/var/lib/mysql/
            # ./galera/scripts contains the bash script which is executed by wsrep_notify_cmd trigger
            - ./galera/scripts/:/etc/mysql/scripts/
          environment:
            - MYSQL_ROOT_PASSWORD=123
            - REPLICATION_PASSWORD=123
            - MYSQL_DATABASE=test_db
            - MYSQL_USER=maria
            - MYSQL_PASSWORD=123
            - GALERA=On
            - NODE_NAME=node1
            - CLUSTER_NAME=maria_cluster
            - CLUSTER_ADDRESS=gcomm://
          command: --wsrep-new-cluster
    
      node2:
          image: galera_mariadb:latest
          container_name: "galera_cluster_node2"
          hostname: node2
          links:
            - node1
          ports:
            - 23306:3306
          networks:
            - galera_cluster
          volumes:
            - ./galera/conf.d/galera.cnf:/etc/mysql/conf.d/galera.cnf
            - /var/data/galera/mysql/node2:/var/lib/mysql/
            - ./galera/scripts/:/etc/mysql/scripts/
          environment:
            - REPLICATION_PASSWORD=123
            - GALERA=On
            - NODE_NAME=node2
            - CLUSTER_NAME=maria_cluster
            - CLUSTER_ADDRESS=gcomm://node1
    
      node3:
          image: galera_mariadb:latest
          container_name: "galera_cluster_node3"
          hostname: node3
          links:
            - node1
          ports:
            - 33306:3306
          networks:
            - galera_cluster
          volumes:
            - ./galera/conf.d/galera.cnf:/etc/mysql/conf.d/galera.cnf
            - /var/data/galera/mysql/node3:/var/lib/mysql/
            - ./galera/scripts/:/etc/mysql/scripts/
          environment:
            - REPLICATION_PASSWORD=123
            - GALERA=On
            - NODE_NAME=node3
            - CLUSTER_NAME=maria_cluster
            - CLUSTER_ADDRESS=gcomm://node1
    
    networks:
      galera_cluster:
          driver: bridge
    
  • 3개의 갤러라 클러스터 노드를 구축하는 데 사용되는 Docker 파일

    # Galera Cluster Dockerfile
    FROM hauptmedia/mariadb:10.1
    RUN apt-get update \
        && apt-get -y install \
            vim \
            python \
            redis-tools
    
    # remove the default galera.cnf in the original image
    RUN rm -rf /etc/mysql/conf.d/galera.cnf
    # add the custom galera.cnf
    COPY ./conf.d/galera.cnf /etc/mysql/conf.d/galera.cnf
    # grant access and execution right
    RUN chmod 755 /etc/mysql/conf.d/galera.cnf
    
  • galera.cnf 파일

    [galera]
    wsrep_on=ON
    
    # wsrep only supports binlog_format='ROW' and storage-engine=innodb
    binlog_format=row
    default_storage_engine=InnoDB
    
    # to avoid issues with 'bulk mode inserts' using autoinc
    innodb_autoinc_lock_mode=2
    
    bind-address=0.0.0.0
    
    # relax flushing logs when running in galera mode
    innodb_flush_log_at_trx_commit=0
    sync_binlog=0
    
    # Query Cache is supported since version 10.0.14 with wsrep
    query_cache_size=8000000
    query_cache_type=1
    
    wsrep_provider=/usr/lib/galera/libgalera_smm.so
    # use the built-in method to manage State Snapshot Transfers
    # we can customize this script to perform a specific logic
    wsrep_sst_method=xtrabackup-v2
    # This bash is volumed from the host which is used to populate synchronized data to the Redis queue
    wsrep_notify_cmd=/etc/mysql/scripts/wsrep_notify.sh
    
    # force transaction level to be read commited
    #transaction-isolation = READ-COMMITTED
    
  • wsrep_displays.

    #!/bin/sh -eu
    
    wsrep_log()
    {
        # echo everything to stderr so that it gets into common error log
        # deliberately made to look different from the rest of the log
        local readonly tst="$(date +%Y%m%d\ %H:%M:%S.%N | cut -b -21)"
        echo "WSREP_SST: $* ($tst)" >&2
    }
    
    wsrep_log_info()
    {
        wsrep_log "[INFO] $*"
    }
    
    STATUS=""
    CLUSTER_UUID=""
    PRIMARY=""
    MEMBERS=""
    INDEX=""
    
    while [ $# -gt 0 ]
    do
       case $1 in
          --status)
             STATUS=$2
             shift
             ;;
          --uuid)
             CLUSTER_UUID=$2
             shift
             ;;
          --primary)
             PRIMARY=$2
             shift
             ;;
          --index)
             INDEX=$2
             shift
             ;;
          --members)
             MEMBERS=$2
             shift
             ;;
             esac
             shift
       done
    
    wsrep_log_info "--status $STATUS --uuid $CLUSTER_UUID --primary $PRIMARY --members $MEMBERS --index $INDEX"
    
  • 다음은 3개 노드의 로그 파일입니다.

node1:

https://drive.google.com/file/d/0B2q2F62RQxVjbkRaQlFrV2NyYnc/view?usp=sharing

node2:

https://drive.google.com/file/d/0B2q2F62RQxVjX3hYZHBpQ2FRV0U/view?usp=sharing

node3:

https://drive.google.com/file/d/0B2q2F62RQxVjelZHQTN3ZDRNZ0k/view?usp=sharing

나는 이 문제에 대해 구글을 검색해 보았지만 운이 없었다.Galera Cluster 셋업에 경험이 있는 사람이라면 문제 해결에 도움이 되었으면 합니다.아니면 다른 방법으로 요구사항을 해결할 수 있는 방법이 있는지 알려주세요.정말 감사해요.

wsrep_module_module

클러스터 멤버쉽 또는 노드 상태가 변경될 때마다 노드가 실행하는 명령을 정의합니다.

따라서 스크립트는 다음 목록에 설명된 상태를 다른 상태로 변경하면 노드에서 시작됩니다.

생각할 수 있는 상태는 다음과 같습니다.

정의되지 않음 노드가 방금 시작되었으며 기본 구성 요소에 연결되어 있지 않습니다.

Joiner 노드가 프라이머리 컴포넌트에 접속되어 상태 스냅샷을 수신하고 있습니다.

기증자 노드가 기본 구성 요소에 연결되어 상태 스냅샷을 보내고 있습니다.

가입 완료 노드의 상태가 완료되어 클러스터를 따라잡고 있습니다.

동기 노드가 클러스터와 동기화되었습니다.

오류(사용 가능한 경우)노드가 에러 상태에 있다.

노드가 시작되고 상태가 변경될 때 이를 알리는 스크립트가 표시됩니다.갤라 클러스터 노드 간에 데이터가 동기화되는 시점만 알리지 않습니다.

언급URL : https://stackoverflow.com/questions/46611987/galera-cluster-nodes-do-not-trigger-wsrep-notify-cmd-and-wsrep-sst-method

반응형