Mysql 5.7主從

來源:互聯網
上載者:User

標籤:mysql5.7

安裝忽略,參考我前面的部落格。從庫複製主庫,複製主要資料庫後,需要修改 server-id  和 /data/mysql/auto.cnf   中的UUID, 修改pid檔案名稱字


修改my.cnf

master: 只發送binlog-do-db=autoopsslave: 只接受replicate-do-db=autoops






主庫設定:

設定檔開啟  log-bin=mysql-bin               從庫一般開啟

                  

mysql> show variables like 'log_bin%';+---------------------------------+-------+| Variable_name                   | Value |+---------------------------------+-------+| log_bin                              | ON    |mysql> grant replication  slave  on *.*  to 'rep'@'192.168.10.%'  identified  by '123456';mysql> flush privileges;


主庫:

mysqldump  -uroot -p    -B  autoops   --events   --master-data=2   --single-transaction   > rep.sql


查看req.sql     記錄  MASTER_LOG_FILE  和 MASTER_LOG_POS


22    -- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000009', MASTER_LOG_POS=1564447;




注意:innodb用       –single-transaction,       myisam需要用 –lock-all-tables。




scp rep.sql   [email protected]:/root




從庫:

mysql     -uroot -p123456    <   /opt/rep.sql



CHANGE MASTER TOMASTER_HOST='192.168.10.29',MASTER_PORT=3306,MASTER_USER='rep',MASTER_PASSWORD='123456',MASTER_LOG_FILE='mysql-bin.000009',MASTER_LOG_POS=1486295;



/data/master.info               //產生的檔案



mysql> start slave;

mysql> show slave status\G;

      Slave_IO_Running: Yes

      Slave_SQL_Running: Yes



relay-bin.index

/data/3307/relay-bin.000001

/data/3307/relay-bin.000002

relay-log.info                    /中繼日誌

427

mysql-bin.000005

591


Mysql 5.7主從

聯繫我們

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