追加從mysql

來源:互聯網
上載者:User

標籤:ase   許可權   nsa   show   結果   主從   star   ant   flush   

追加從mysql:

情境:在已主從mysql的基礎上再追加1個從mysql

註:
該方式在備份時會鎖表,建議在晚上沒業務用的時候執行

在主mysql上建立有同步許可權的帳號

mysql –u root –p’xxxxxx’

grant replication slave on . to ‘ming‘@‘10.0.0.3‘ identified by ‘xxxxxx‘;
flush privileges;
exit

/usr/bin/mysqldump -u root -p‘xxxxxx‘ --routines --single_transaction --master-data=2 --databases bugs > /backup1/bugs.sql

註:
--routines:匯出預存程序和函數
--single_transaction:匯出開始時設定事務隔離狀態,並使用一致性快照開始事務,然後unlock tables;而lock-tables是鎖住一張表不能寫操作,直到dump完畢。
--master-data:預設等於1,將dump起始(change master to)binlog點和pos值寫到結果中,等於2是將change master to寫到結果中並注釋

在從mysql上進行匯入:

mysql -u root -p’xxxxxx’

create database bugs default character set utf8;
exit

mysql -u root -p’xxxx’ bugs > /space/bugs.sqlcat /space/bugs.sql | head –n 30 (查看master_log_file和master_log_pos資訊)mysql -u root -p’xxxxxx’

change master to master_host=‘10.0.0.2‘,master_user=‘ming‘,master_password=‘xxxx‘,master_log_file=’log.000241’,master_log_pos=419123624;
start slave;
show slave status \G;
如果有1062報錯類的可在/etc/my.cnf裡進行忽略(slave-skip-errors=1062),當然不報錯是最好的,看到Slave_IO_Running和Slave_SQL_Running都為Yes說明已在正常同步
exit

追加從mysql

聯繫我們

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