【MySQL 複製】20G以下的mysql資料庫從庫快速搭建

來源:互聯網
上載者:User

因為20G以下,所以資料容量比較小,用mysqldump全庫匯出對業務影響不大,所以採用這種模式進行從庫的搭建:


PS: master-data=1 ,record the Master_Log_File and Read_Master_Log_Pos: 

 


1 backup the backup sql log
/usr/local/mysql/bin/mysqldump -uroot -p  -S /usr/local/mysql/mysql.sock  --default-character-set=utf8 --extended-insert=false --triggers -R --hex-blob --all-databases --master-data=1  --flush-logs  >/tmp/create-master2-20140416.sql


2 scp the sql log to the slave from master
scp create-master2-20140409.sql 10.xx.3.x2:/tmp/




3 create the replication account in master db servers.
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'xx@xx';


4 import the sql to slave 
/usr/local/mysql/bin/mysql -uroot -p -S /usr/local/mysql/mysql.sock  --default-character-set=utf8 < /tmp/


5 reset the replication slave status
 find the master binlog position of slave  from backup sql log file.

 change master to master_user='repl', master_password='Plcc0805@replicationm2', master_host='10.xx.3.x1',master_port=3306, master_log_file='mysql-bin.008713',master_log_pos=120;


6 啟動slave

start slave;

show slave status\G


聯繫我們

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