您好,登錄后才能下訂單哦!
1、修改MySQL配置:
主庫配置
server-id = 3
binlog-do-db=xmcp_gxfc #the db need to sync
binlog-ignore-db = mysql #不需要同步的數(shù)據(jù)庫
binlog-ignore-db = redmine #不需要同步的數(shù)據(jù)庫
log_slave_updates = 1
binlog_format=mixed
relay_log = /usr/local/mysql/relay_log/mysql-relay-bin
read_only = 1
2創(chuàng)建賬號
grant replication slave on . to 'slave2'@'%' identified by 'FjAfj6#xajot#K%V';
grant replication slave on . to 'slave3'@'%' identified by 'FjAfj6#xajot#K%V';
mysql>flush privileges;
mysql> show master status;
記錄下 File為mysql-bin.000001
記錄下 position為 154
3、修改從庫MySQL配置:
從庫配置:
server-id = 5
log-bin = mysql-bin
replicate-do-db=xmcp_gxfc
binlog_format=mixed
relay_log=/usr/local/mysql/relay_log/mysql-relay-bin
read_only = 1
4、執(zhí)行同步命令
mysql>change master to master_host='10.2.2.2',master_user='slave2',master_password='FjAfj6#xajot#K%V',master_log_file='mysql-bin.000001',master_log_pos=154;
mysql>start slave;
5、檢查從數(shù)據(jù)庫狀態(tài):
mysql> show slave status\G;
注:Slave_IO_Running及Slave_SQL_Running進程必須正常運行,即YES狀態(tài),否則說明同步失敗??捎眠@兩項判斷從服務器是否掛掉
mysql > SET GLOBAL server_id=2;
6、Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.
原因分析:
mysql 5.6的復制引入了uuid的概念,各個復制結構中的server_uuid得保證不一樣,但是查看到直接copy data文件夾后server_uuid是相同的,show variables like '%server_uuid%';
解決方法:
找到data文件夾下的auto.cnf文件,修改里面的uuid值,保證各個db的uuid不一樣,重啟db即可
場景二:創(chuàng)建主從關系時copy了同樣的my.cnf文件,報錯
Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids;
原因分析:
和server_uuid類似,servier_id也得保證不一樣
解決方法:
找到my.cnf配置文件中的server_id,修改從庫的server_id保證和復制結構中的其他db不一樣,重啟db即可
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。