溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Mysql的鏈條式復(fù)制的優(yōu)缺點(diǎn)是什么

發(fā)布時(shí)間:2021-09-15 07:30:16 來源:億速云 閱讀:241 作者:chen 欄目:數(shù)據(jù)庫(kù)

這篇文章主要介紹“Mysql的鏈條式復(fù)制的優(yōu)缺點(diǎn)是什么”,在日常操作中,相信很多人在Mysql的鏈條式復(fù)制的優(yōu)缺點(diǎn)是什么問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”Mysql的鏈條式復(fù)制的優(yōu)缺點(diǎn)是什么”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!

這么做的目的是為了減輕 mysql  C 從mysql A 同步數(shù)據(jù)的時(shí)候,造成mysql A的壓力.

缺點(diǎn)就是  mysql B出點(diǎn)問題的話,mysql C 也就停止同步了~  
造成從數(shù)據(jù)庫(kù)同步失敗常見原因有
1.        網(wǎng)絡(luò)的延遲    我們不是跨機(jī)房的mysql分離,mysql A 出現(xiàn)瓶頸的時(shí)候,也會(huì)造成 mysql B同步失敗,日志顯示網(wǎng)絡(luò)的延遲造成的
2   mysql A 異常情況下,也會(huì)出現(xiàn)同步失敗,這樣的情況,重新change file值和pos值就可以了~
但是出現(xiàn)的概率都很小~
下面是配置的過程~~~~~
其實(shí)這個(gè)不難的~ 主要就是b上的一個(gè)參數(shù)~
MYSQL鏈?zhǔn)綇?fù)制:A=>B=>C
A:    192.168.2.155主
B:    192.168.2.156從/主
C:    192.168.2.160從

雙擊代碼全選
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27A主機(jī):              vi /etc/my.cnf              log-bin=mysql-bin              server-id=1              binlog-do-db=tongbu              (注:如不指定此參數(shù),binlog記錄所有庫(kù)的操作,添加用戶binlog也會(huì)改變,也會(huì)復(fù)制到從服務(wù)器)              service mysqld restart              mysql -uroot -p123456              create database tongbu;use tongbu;create table tbl1(id int);insert into tbl1 values(1);select * from tbl1;              grant replication slave on *.* to tongbu156@192.168.2.156 identified by '123456';              flush tables with read lock;(可以同時(shí)鎖定多個(gè)庫(kù),鎖定時(shí)不可以建表等操作,退出后所有庫(kù)自動(dòng)解鎖)              show master status; (記下日志文件及position)              exit;              mysqldump -uroot -p123456 tongbu > /tongbu.sql (把此文件拷貝到B主機(jī)/下)
雙擊代碼全選
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43B主機(jī):              vi /etc/my.cnf              log-bin=mysql-bin              server-id=2             binlog-do-db=tongbu              (注:如不指定此參數(shù),binlog記錄所有庫(kù)的操作,添加用戶binlog也會(huì)改變,也會(huì)復(fù)制到從服務(wù)器)              log-slave-updates(產(chǎn)生自己的日志文件,建議在此位置添加該行)              service mysqld restart              mysql -uroot -p123456              create database tongbu;              use tongbu;              source /tongbu.sql                                   開啟從服務(wù)器角色              change master to master_host='192.168.2.155',master_user='tongbu156',master_password='123456',master_log_file='mysql-bin.000007',master_log_pos=107              start slave;                                   grant replication slave on *.* to tongbu160@192.168.2.160 identified by '123456';              flush tables with read lock;              show master status; (記下日志文件及position)              exit;              mysqldump -uroot -p123456 tongbu > /tongbu.sql (把此文件拷貝到C主機(jī)/下)
雙擊代碼全選
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25C主機(jī):              vi /etc/my.cnf              log-bin=mysql-bin              server-id=3              service mysqld restart              mysql -uroot -p123456              create database tongbu;              use tongbu;              source /tongbu.sql                                   開啟從服務(wù)器角色              Change master to master_host='192.168.2.156',master_user='tongbu160',master_password='123456',master_log_file='mysql-bin.000009',master_log_pos=222              start slave;

注:
show slave status;查看從服務(wù)器狀態(tài)
show processlist;查看日志處理狀態(tài)

到此,關(guān)于“Mysql的鏈條式復(fù)制的優(yōu)缺點(diǎn)是什么”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI