CentOS 6.6 中 mysql_5.6 主從資料庫配置

來源:互聯網
上載者:User

標籤:啟用   查看   worker   資料集   soc   centos   所有權   crc   主從複製   

【mysql5.6 主從複製】1、配置主從節點的服務組態檔1.1、配置master節點
[mysqld]binlog-format=rowlog-bin=master-binlog-slave-updates=truegtid-mode=onenforce-gtid-consistency=truemaster-info-repository=TABLErelay-log-info-repository=TABLEsync-master-info=1slave-parallel-workers=1binlog-checksum=CRC32       ##迴圈冗餘校正法32位master-verify-checksum=1slave-sql-verify-checksum=1binlog-rows-query-log_events=1server-id=1report-port=3306port=3306datadir=/mydata/datasocket=/var/lib/mysql/mysql.sock   ##此項可以不改report-host=master.node1    ##報告主機一般是自己的主機名稱

  

1.2、配置slave節點
[mysqld]binlog-format=rowlog-slave-updates=truegtid-mode=onenforce-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=/var/lib/mysql/mysql.sock ##此項可以不改report-host=slave.node2

 

2、在主節點上建立複製使用者
mysql> GRANT REPLICATION SLAVE ON *.* TO [email protected]192.168.1.110 IDENTIFIED BY ‘密碼‘;

 

說明:192.168.1.110是從節點伺服器,如果想一次性授權更多的節點,可以自行根據需要修改。

 

3、為從伺服器節點提供初始資料集

鎖定主表,備份主節點上的資料,將其還原至從節點,如果沒有啟用GTID,在備份時需要在master上使用show master status命令查看二進位記錄檔名稱及事件位置,以便後面啟動slave節點時使用。

4、啟動從節點的複製線程

如果啟用了GTID功能,則使用如下命令:

mysql> CHANGE MASTER TO MASTER_HOST=‘master.magedu.com‘, MASTER_USER=‘repluser‘, MASTER_PASSWORD=‘密碼‘, MASTER_AUTO_POSITION=1;沒啟用GTID,需要使用如下命令:slave> CHANGE MASTER TO MASTER_HOST=‘192.168.1.102‘,-> MASTER_USER=‘repluser‘,-> MASTER_PASSWORD=‘密碼‘,-> MASTER_LOG_FILE=‘master-bin.000003‘,-> MASTER_LOG_POS=1174

 

5、啟動root使用者的所有許可權(主要用於允許前端的amoeba代理能以root訪問主從資料庫) 分別在主、從資料庫裡執行如下命令:
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘密碼‘ WITH GRANT OPTION;

 

CentOS 6.6 中 mysql_5.6 主從資料庫配置

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.