国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

mysql 面試(八) 整理之mysql 復(fù)制

2019-11-08 20:58:39
字體:
供稿:網(wǎng)友

7.1 請簡述復(fù)制的原理和流程

 MySQL的復(fù)制原理:Master上面事務(wù)提交時會將該事務(wù)的binlog event寫入binlogfile,然后master將binlogevent傳到slave上面,slave應(yīng)用該binlog event實現(xiàn)邏輯復(fù)制。

Mysql 的復(fù)制流程:

 MySQL的復(fù)制是基于如下3個線程的交互(多線程復(fù)制里面應(yīng)該是4類線程):

a. Master上面的binlogdump線程,該線程負責將master的binlogevent傳到slave;

b. Slave上面的IO線程,該線程負責接收Master傳過來的binlog,并寫入relay log;

c. Slave上面的SQL線程,該線程負責讀取relay log并執(zhí)行;

d. 如果是多線程復(fù)制,無論是5.6庫級別的假多線程還是MariaDB或者5.7的真正的多線程復(fù)制,SQL線程只做coordinator,只負責把relay log中的binlog讀出來然后交給worker線程,woker線程負責具體binlog event的執(zhí)行;

 

7.2 如何確保復(fù)制的一致性

 

7.2     Seconds_Behind_Master值的含義

Doc里邊是這樣說的:

This field isan indication of how “l(fā)ate” the slave is:? When the slave is actively PRocessing updates,this field shows the difference between the current timestamp on the slave andthe original timestamp logged on the master for the most event currently beingprocessed on the slave.? When no event is currently being processed onthe slave, this value is 0.

意思是說

1)當slave正在處理更新,該字段表示當前slave的時間戳與最近在slave上執(zhí)行的事件(master上記錄的,也就是slave上relay-log中的事件)的時間戳的差值。2)當slave沒有事件處理(relay-log),顯示的值為0。

 

7.3     口述復(fù)制的搭建步驟?

1> .主庫授權(quán):grant replication slave on *.* to 'xx'@'xxx' identified by 'xx';  

2>.配置N的my.cnf:  

  修改server_id  

3>mysqldump -uxx -pxx -AER --single-transaction --master-data > mas.sql  

4>.slave導(dǎo)入mas.sql,如果沒有master-data,則需要手動change master  

5>.開啟start slave;  

6>.檢查同步狀態(tài)show slave status; 

7.4如何校驗復(fù)制的一致性
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 阿坝| 扬中市| 宿迁市| 天长市| 海口市| 台前县| 泰顺县| 星座| 泰州市| 巴林右旗| 赣州市| 湘潭市| 漾濞| 巴塘县| 桂东县| 临澧县| 开化县| 张家川| 延川县| 蒙城县| 和硕县| 沂南县| 紫阳县| 巨野县| 化州市| 博白县| 涞水县| 新巴尔虎左旗| 于都县| 黄浦区| 通榆县| 平阳县| 东乡| 翁源县| 宝丰县| 拜城县| 常熟市| 抚州市| 社旗县| 开远市| 永宁县|