mysql master slave

來源:互聯網
上載者:User

標籤:master   type   記錄   color   資料   class   不重複   span   mic   

mysql主從複製配置

配置原理(slave資料庫通過二進位記錄檔對資料庫進行AUDQ)


一、需求:

  1.  版本一致

  2. 系統啟動mysql

二、 master的配置: 修改二進位日誌,和server-id

log-bin=logbin(可跟絕對路徑,注意許可權)

server-id=11(可以為和slave不重複的任一數字,一般是IP的末位)

三、 slave的配置: 唯一必須更改的是servier-id

log-bin=logbin(不是必須啟用或更改的)

server-id=12(必須啟用的,但不能和master或其他slave相同)

master-host=192.168.1.12

master-user=repli

master-password=newpassword

master-port=3306

replicate-do-db=dbname

四、 master上建立授權帳號給slave

grant replication slave on *.* to 'repli'@'%' identified by 'newpassword';

五、 查看master的狀態,並記錄log-bin檔案名稱及position值


六、 擷取master中的log-bin配置slave,並啟動slave

change master to master_host='192.168.1.12',master_user='repli',master_password='newpassword',master_log_file='logbin.000018',master_log_pos=155;

start slave;


七、 查看slave狀態, 主要是兩個參數 Slave_IO_Running、 Slave_SQL_Running均為yes為正常,即可在master建立資料庫驗證

show slave status \G;

             Slave_IO_Running: Yes

            Slave_SQL_Running: Yes






mysql master slave

聯繫我們

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