MySQL 5.6 的--dump-slave參數的用法

來源:互聯網
上載者:User

MySQL 5.6 的--dump-slave參數的用法

在5.5及以後版本的MySQL裡面,增加了個參數--dump-slave,使用該參數,我們可以在slave節點匯出資料用於建立新的slave,避免對主庫的壓力。

方法如下:
在slave上執行;
1、查看當前同步的狀態
# show slave status\G  主要關注下面的部分:

Master_Log_File: mysql-bin.000095

Read_Master_Log_Pos: 50607116
Relay_Master_Log_File: mysql-bin.000095
Exec_Master_Log_Pos: 50607116

2、然後在slave上匯出資料,如下:
# mysqldump -uroot -proot --single-transaction --dump-slave=2 -A > all.sql

3、查看匯出的檔案

# head -30 all.sql 可以看到類似如下的欄位:

-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000095', MASTER_LOG_POS=50607116;

這樣的話,我們拿著這個匯出資料,恢複到某一台新的slave上,執行:

> CHANGE MASTER TO
MASTER_HOST='master_ip',
MASTER_USER='repluser',
MASTER_PASSWORD='123456',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin.000095',
MASTER_LOG_POS=50607116,
MASTER_CONNECT_RETRY=10;

> start slave; 即可在新的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.