Master-Slave Replication 1- Master 上編輯 Mysql 設定檔 sudo nano /etc/mysql/mysql .conf.d /mysqld.cnf server-id=1 log-bin=mysql-bin log-slave-updates=true skip_slave_start=1 gtid-mode=ON enforce_gtid_consistency=ON 2- 創建一個用來做主從架構的使用者 CREATE USER 'andylee' @ '%' IDENTIFIED WITH mysql_native_password BY 'zrQ1A4fQ^WZL8pkX!!' ; GRANT ALL PRIVILEGES ON *.* TO 'andylee' @ '%' WITH GRANT OPTION ; FLUSH PRIVILEGES ; 3- 重啟 Mysql systemctl restart mysql 4- Slave 上編輯 Mysql 設定檔 sudo nano /etc/mysql/mysql .conf.d /mysqld.cnf server-id=2 relay_log=mysql-relay-bin read_only=1 log-bin=mysql-bin log_slave_updates=1 gtid-mode=ON enforce_gtid_consistency=ON require_secure_transport=ON 5- 重啟 Mysql systemctl restart mysql 6- Slave 的 Mysql 下,執行 CHANGE MASTER TO MASTER_HOST = '192.168.1.238' , MASTER_USER = 'andylee' , MASTER_PASSWORD = 'zrQ1A4fQ^WZL8pkX!!' , MASTER_PORT =3306, MASTER_AUTO_POSITION = 1; 7- 查看 Master 和 Slave 的狀態 SHOW MAS...
留言