MySQL開啓GTID主從同步

主庫配置mysql

[mysqld]
log_bin = /path/mysql/master/data/log_bin
gtid_mode = ON
enforce-gtid-consistency = true
log_slave_updates = 1

basedir = /usr/local/Cellar/mysql/5.7.17
datadir = /path/mysql/master/data
port = 3306
server_id = 13306
socket = mysql.sock

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

從庫配置sql

[mysqld]
log_bin = /path/mysql/slave/data/log_bin
relay_log = /path/mysql/slave/data/relay_log
relay-log-index = /path/mysql/slave/data/relay-log-index
relay-log-info-file = /path/mysql/slave/data/relay-relay-log.info
replicate-do-db = test
log_slave_updates = 1
gtid_mode = ON
enforce-gtid-consistency = true

datadir = /Users/Aim/mysql/slave/data
port = 3307
server_id = 13307
socket = mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

查看是否成功開啓GTID同步,Command顯示Binlog Dump GTID表示成功開啓GTID同步。架構

mysql> SHOW PROCESSLIST \G
*************************** 1. row ***************************
     Id: 3
   User: root
   Host: localhost:62976
     db: NULL
Command: Binlog Dump GTID
   Time: 267
  State: Master has sent all binlog to slave; waiting for more updates
   Info: NULL
*************************** 2. row ***************************
     Id: 6
   User: root
   Host: localhost:63016
     db: NULL
Command: Query
   Time: 0
  State: starting
   Info: SHOW PROCESSLIST
2 rows in set (0.00 sec)

更多架構、PHP、GO相關踩坑實踐技巧請關注個人公衆號:PHP架構師socket

相關文章
相關標籤/搜索