MySQL-5.6 基於GTID及多線程的複製

來源:互聯網
上載者:User

標籤:伺服器安全   二進位   多線程   監控   資訊   


MySQL 5.6引入的GTID(Global Transaction IDs)使得其複製功能的配置、監控及管理變得更加易於實現,且更加健壯。


要在MySQL 5.6中使用複製功能,其服務配置段[mysqld]中致少應該定義如下選項:


binlog-format:二進位日誌的格式,有row、statement和mixed幾種類型;

log-slave-updates、gtid-mode、enforce-gtid-consistency、report-port和report-host:用於啟動GTID及滿足附屬的其它需求;

master-info-repository和relay-log-info-repository:啟用此兩項,可用於實現在崩潰時保證二進位及從伺服器安全的功能;

sync-master-info:啟用之可確保無資訊丟失;

slave-paralles-workers:設定從伺服器的SQL線程數;0表示關閉多線程複製功能;

binlog-checksum、master-verify-checksum和slave-sql-verify-checksum:啟用複製有關的所有校正功能;

binlog-rows-query-log-events:啟用之可用於在二進位日誌記錄事件相關的資訊,可降低故障排除的複雜度;

log-bin:啟用二進位日誌,這是保證複製功能的基本前提;

server-id:同一個複寫拓撲中的所有伺服器的id號必須惟一;


簡單主從模式配置步驟:


1、配置主從節點的服務組態檔1.1、配置master節點:[mysqld]binlog-format=ROWlog-bin=master-binlog-slave-updates=truegtid-mode=on enforce-gtid-consistency=truemaster-info-repository=TABLErelay-log-info-repository=TABLEsync-master-info=1slave-parallel-workers=2binlog-checksum=CRC32master-verify-checksum=1slave-sql-verify-checksum=1binlog-rows-query-log_events=1server-id=1report-port=3306port=3306datadir=/mydata/datasocket=/tmp/mysql.sockreport-host=master.magedu.com1.2、配置slave節點:[mysqld]binlog-format=ROWlog-slave-updates=truegtid-mode=on enforce-gtid-consistency=truemaster-info-repository=TABLErelay-log-info-repository=TABLEsync-master-info=1slave-parallel-workers=2binlog-checksum=CRC32master-verify-checksum=1slave-sql-verify-checksum=1binlog-rows-query-log_events=1server-id=11report-port=3306port=3306log-bin=mysql-bin.logdatadir=/mydata/datasocket=/tmp/mysql.sockreport-host=slave.magedu.com2、建立複製使用者mysql> GRANT REPLICATION SLAVE ON *.* TO [email protected] IDENTIFIED BY ‘replpass‘;說明:172.16.100.7是從節點伺服器;如果想一次性授權更多的節點,可以自行根據需要修改;3、為備節點提供初始資料集鎖定主表,備份主節點上的資料,將其還原至從節點;如果沒有啟用GTID,在備份時需要在master上使用show master status命令查看二進位記錄檔名稱及事件位置,以便後面啟動slave節點時使用。4、啟動從節點的複製線程如果啟用了GTID功能,則使用如下命令:mysql> CHANGE MASTER TO MASTER_HOST=‘master.magedu.com‘, MASTER_USER=‘repluser‘, MASTER_PASSWORD=‘replpass‘, MASTER_AUTO_POSITION=1;沒啟用GTID,需要使用如下命令:slave> CHANGE MASTER TO MASTER_HOST=‘172.16.100.6‘,-> MASTER_USER=‘repluser‘,-> MASTER_PASSWORD=‘replpass‘,-> MASTER_LOG_FILE=‘master-bin.000003‘,-> MASTER_LOG_POS=1174;



MySQL-5.6 基於GTID及多線程的複製

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.