資料庫 基於GTID主從複製
阿新 • • 發佈:2020-12-20
根據前章主從複製進行拓展內容,無需主從複製,但需要開啟資料庫
檢視主從資料庫的GTID狀態
1 show variables like "gtid_mode"
關閉狀態
開啟enforce_gtid_consistency set global enforce_gtid_consistency=on; 開啟GTID set global gtid_mode=1 set global gtid_mode=2 set global gtid_mode=3
開啟狀態
主資料庫
授權從資料庫獲取資料
grant replication slave on *.* to 'repl'@'200.200.2.11' identified by '123456'';
從資料庫
前邊有做主從
停止從資料庫
stop slave
清空所有配置 reset slave all
未做主從
使用登陸的賬號連線主資料庫
change master to master_user="repl",master_password="123456",master_host="200.200.2.20",master_auto_position=1;
永久開啟GTID
vim /etc/my.conf 在檔案[mysqld]下加u gtid_mode=ON enforce_gtid_consistency=ON