Galera cluster
을 3 노드로 설정했습니다. 동기화 노드에서
wsrep_notify_cmd
트리거 또는
wsrep_sst_method
트리거를 기반으로 데이터가
donor
노드에서 다른 노드로 동기화 될 때 해당 노드의 해당 Redis 큐에 데이터를 채워야한다는 요구 사항이 있습니다. 이 두 트리거는 클러스터를 시작할 때만 호출됩니다. 하나의 노드가 클러스터에 결합 될 때이 두 트리거가 호출되었다는 로그가 있습니다. 그러나 한 노드에서 스키마를 수정하거나 CUD 작업을 시도하면 트리거가 다른 노드에서 시작되지 않았습니다. 구성을 잘못 수행했는지 또는 이러한 트리거 작동 방식이 아닌지 잘 모릅니다. 다음은
Galera 클러스터 노드가 wsrep_notify_cmd 및 wsrep_sst_method를 트리거하지 않음
내가 작업 클러스터를 만들기 위해 사용하는 파일입니다Dockerfile 3 갈레 클러스터 노드를 구축하는 데 사용
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
고정 표시기 - compose.yml
# 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 파일
https://drive.google.com/file/d/0B2q2F62RQxVjbkRaQlFrV2NyYnc/view?usp=sharing
#!/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"
691,363,210
[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
3 개 노드
노드 1의 로그 파일입니다개
노드 2 :
https://drive.google.com/file/d/0B2q2F62RQxVjX3hYZHBpQ2FRV0U/view?usp=sharing
노드 3 : 나는이 문제에 대해 인터넷 검색되었지만 운이 없었다
https://drive.google.com/file/d/0B2q2F62RQxVjelZHQTN3ZDRNZ0k/view?usp=sharing
. Galera 클러스터 설치 경험이있는 사람이라면 누구든지이 문제를 해결할 수 있기를 바랍니다. 아니면 요구 사항을 해결하기위한 또 다른 접근법이 필요합니다. 덕분에 많은
이 경우 어떤 노드에서 데이터가 동기화되는지 확인하기 위해 어떤 상태 변수를 사용해야합니까? https://mariadb.com/kb/en/library/galera-cluster-status-variables/#wsrep_local_commits가 올바른지 궁금합니다. – tilonthuduc
또한 데이터가 Redis에 채워지는 테이블에 대해 Insert/Update/Delete 트리거를 생성 할 트리거에 대해서 생각해 봅니다. 이것은 좋은 접근 방법이며, 성능 문제가 있는지 알아야합니까? – tilonthuduc