標籤:mysql 5.7
準備環境:
os version:CentOS release 6.5 (Final)
伺服器資訊:
Master1:192.168.1.29
Master2:192.168.1.37
Slave:192.168.1.86
1,修改my.cnf
Slave中的my.cnf加入以下參數
啟用enhanced multi-threaded slave (多線程複製)
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=8
master_info_repository=TABL
relay_log_info_repository=TABLE
relay_log_recovery=ON
可以通過以下監控並行複製
mysql> show tables like ‘replication%‘;
+---------------------------------------------+
| Tables_in_performance_schema (replication%) |
+---------------------------------------------+
| replication_applier_configuration |
| replication_applier_status |
| replication_applier_status_by_coordinator |
| replication_applier_status_by_worker |
| replication_connection_configuration |
| replication_connection_status |
| replication_group_member_stats |
| replication_group_members |
+----------------------------------
2,授權,在master1上和master2上授權,允許slave複製
3,change master
change master tomaster_host="192.168.1.29",master_port=3306,master_user="root",master_password="[email protected]"FOR CHANNEL "master1";
change master tomaster_host="192.168.1.37",master_port=3306,master_user="root",master_password="[email protected]"FOR CHANNEL "master2";
4,啟動slave
start slave for channel "master1";
start slave for channel "master2";
MySQL 5.7才可稱為真正的並行複製,這其中最為主要的原因就是slave伺服器的回放與主機是一致的即master伺服器上是怎麼並存執行的slave上就怎樣進行並行回放。不再有庫的並行複製限制,對於二進位日誌格式也無特殊的要求(基於庫的並行複製也沒有要求)。
從MySQL官方來看,其並行複製的原本計劃是支援表級的並行複製和行級的並行複製,行級的並行複製通過解析ROW格式的二進位日誌的方式來完成,WL#4648。但是最終出現給小夥伴的確是在開發計劃中稱為:MTS: Prepared transactions slave parallel applier,可見:WL#6314。該並行複製的思想最早是由MariaDB的Kristain提出,並已在MariaDB 10中出現,相信很多選擇MariaDB的小夥伴最為看重的功能之一就是並行複製。
本文出自 “我是一隻小小鳥” 部落格,請務必保留此出處http://2242558.blog.51cto.com/2232558/1709694
Mysql 5.7多源複製及並行複製功能