這是本文件的舊版!
Replication 主要是由Master Server 將寫入的事件(新增,刪除及修改) 記錄在Master Binary Log中,Slave 由(I/O threads) 再讀取Master Binary Log 相關SQL語句 ,送到Slave Relay Log(中繼日誌檔)暫時存放,再由Slave (SQL threads)讀取 Relay Log 來重新執行 SQL相關語句。
基本上以下所列的都是 非同步(asynchronous,異步) replication
*Slave 版本要比Master新 (因為 當新版本Slave 在讀取 舊版本Master binlog時,除了新的特性或與語法外,還能相容於舊版本相關格式或過時的語法)
假定以下LAB環境狀況:
vim /etc/my.cnf
~略~ server-id=1 log-bin=mysql-bin(二進制日誌) ~略
要給Slave一個帳號可以存取Master
GRANT RELOAD, SUPER, REPLICATION SLAVE ON *.* TO 'backup171'@'192.168.0.171' IDENTIFIED BY 'qwedcxza'
備份 Master 伺服器的資料庫。
mysqldump --all-databases --lock-all-tables >master.sql
mysql -uroot < master.sql
server-id = 2 #不要與Master值一樣就好了 relay-log=mysql-relay-bin #中繼日誌 log-slave-updates=1 #指定更新紀錄到slave binlog read-only=1 #只允許來自從服務器線程或具有SUPER權限的用戶的更新。可以確保從服務器不接受來自客戶的更新 master-port=3306 #指定要與Master 連接的阜口 replicate-do-db=zabbix2 #指定要與Master 哪個資料庫複寫 master-user=backup171 #Slave連接Master的帳號 master-password=qwedcxza #Slave連接Master的密碼 master-connect-retry=60 #複製從I/O線程 狀態下,與Master無法連接或連接錯誤,指定多少秒後再重新連接Master
除了寫在/etc/my.cnf以外,也可以使用Mysql Command方式 方法二
change master to master_host='192.168.0.170', ->master_user='backup171', ->master_password='qwedcxza', ->master_log_file='mysql-bin.000008', ->master_log_pos=176146;
11.高性能Mysql主從架構的複製原理及配置 http://www.360doc.com/content/13/0409/18/891660_277200925.shtml 12.清理 ZABBIX 的歷史數據 http://www.bitbi.biz/%E6%B8%85%E7%90%86-zabbix-%E7%9A%84%E5%8E%86%E5%8F%B2%E6%95%B0%E6%8D%AE-5582/#more-5582 13.MySQL中的複製 http://dev.mysql.com/doc/refman/5.1/zh/replication.html 14.mysql Replication 原理分析 http://zhaolinjnu.blog.sohu.com/103459345.html 15.Galera Cluster for MySQL Multi-master Replication http://blog.wu-boy.com/2013/03/galera-cluster-for-mysql-multi-master-replication/ 16.mysql-mmm http://mysql-mmm.org/mmm1:installation 17.MySQL半同步Semi-sync原理介紹 http://www.orczhou.com/index.php/2011/07/why-and-how-mysql-5-5-semi-sync-replication/ 18. maatkit—-mysql管理工具 http://diyoki.blog.51cto.com/2158750/1156627