[mysqld]
# Replication Setting
server-id=1
log-bin=mysql-bin
binlog-do-db=adj
CREATE USER 'repluser'@'10.0.0.52' IDENTIFIED BY 'YOUR_PASSWORD';
GRANT REPLICATION SLAVE ON *.* TO 'repluser'@'10.0.0.52';
FLUSH PRIVILEGES;
[mysqld]
# Replication Setting
server-id=2
replicate-do-db=adj
relay_log = relay-bin.log
CHANGE MASTER TO MASTER_HOST='10.0.0.51', MASTER_PORT=3306, MASTER_USER='repluser',MASTER_PASSWORD='YOUR_PASSWORD';
緊接著執行以下 SQL 指令以啟動複寫機制運作:
START SLAVE;
SHOW SLAVE STATUS \G;
*** MySQL 同步指令 ***
# mysql -u repluser -p'123456' -e"CHANGE MASTER TO MASTER_HOST='10.0.0.51', MASTER_PORT=3306, MASTER_USER='repluser',MASTER_PASSWORD='YOUR_PASSWORD';"
*** 看 MySQL Slave 狀態 ***
# mysql -u repluser -p'123456' -e"show slave status \G;"
*** 啟動關閉同步 ***
# mysql -u repluser -p'123456' -e"STOP SLAVE;"
# mysql -u repluser -p'123456' -e"START SLAVE;"
*** 刪除 Slave 同步設定 ***
# mysql -u repluser -p'123456' -e"reset slave all;"
歡迎光臨 ADJ網路實驗室 (http://dz.adj.idv.tw/) | Powered by Discuz! 6.0.0 |