当前位置:网站首页>Mysql 45 study notes (twenty-four) MYSQL master-slave consistency
Mysql 45 study notes (twenty-four) MYSQL master-slave consistency
2022-07-31 03:18:00 【Kong Tom】
One. The basic principle of MySQL master and backup
Active-standby switching process:

- The client's read and write directly access node A, and node B is the standby database of A. It just synchronizes the updates of A and executes it locally, so that the data of nodes B and A are kept the same
- Switch to state 2, the client read and write access to node B, and node A is the standby database of B
Set Node B (standby database) to readonly mode
- Some operational query statements will be placed in the backup database to check,Set read-only to prevent misuse;
- Prevent switching logic from bugs.Double writing occurs during the switching process, resulting in inconsistency between active and standby;
- readonly state, to determine the role of the node
Set standby to read-only, and follow The main library is kept up to date:
Because the readonly setting is invalid for super users, it is used for A thread that synchronizes updates has super permission.
Second, the UPDATE statement executes the steps of synchronizing to node B on node A:

- After the main library receives the follow-up request from the client, it executes the update logic of the internal transaction and writes the binlog at the same time
- A long connection is maintained between the standby database B and the primary database A.There is a special thread inside the main database A to serve the long connection of the standby database B
Three. The complete process of transaction log synchronization:
- Use the change master command on the standby database B to set the IP of the primary database A.Port, username, password and where to start requesting binlog, this location contains filename and log offset
- Execute the start slave command on the standby database B. At this time, the standby database will start two threads, namely io_thread and sql_thread in the figure.Among them, io_thread is responsible for establishing a connection with the main library
- After verifying the user name and password, the main database A starts to read the binlog from the local according to the location passed by the standby database B, and sends it to B
- After the standby database B gets the binlog, it writes it to the local file, which is called the relay log
- sql_thread reads the secondary school log, parses the commands in the log, and executes them.
边栏推荐
- 【C语言】预处理操作
- 【CocosCreator 3.5】CocosCreator get network status
- endian mode
- 递归查询单表-单表树结构-(自用)
- Why SocialFi achievement Web3 decentralized social in the future
- CloudCompare & PCL calculate the degree of overlap between two point clouds
- How to develop a high-quality test case?
- [Godot][GDScript] 二维洞穴地图随机生成
- Moxa NPort 设备缺陷可能使关键基础设施遭受破坏性攻击
- 什么是系统?
猜你喜欢

【C语言】表达式求值的一般方法

识Flutter 基本组件之showTimePicker 方法

With 7 years of experience, how can functional test engineers improve their abilities step by step?

SQL injection Less54 (limited number of SQL injection + union injection)

SQL injection Less46 (injection after order by + rand() Boolean blind injection)

【C语言】三子棋(经典解法+一览图)

【编译原理】递归下降语法分析设计原理与实现

Crypto Firms Offer Offer To Theft Hackers: Keep A Little, Give The Rest

MultipartFile file upload

LeetCode简单题之两个数组间的距离值
随机推荐
想从手工测试转岗自动化测试,需要学习哪些技能?
Multilingual settings of php website (IP address distinguishes domestic and foreign)
6. Display comments and replies
SIP协议标准和实现机制
刚出道“一战成名”,安全、舒适一个不落
What is distributed and clustered?What is the difference?
Modbus on AT32 MCUs
Point Cloud DBSCAN Clustering (MATLAB, not built-in function)
Is interprofessional examination difficult?Low success rate of "going ashore"?Please accept this practical guide!
endian mode
Addition and Subtraction of Scores in LeetCode Medium Questions
LeetCode每日一练 —— 138. 复制带随机指针的链表
SonarQube的BUG定义
Redis实现分布式锁
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
【编译原理】词法分析程序设计原理与实现
LeetCode简单题之找到和最大的长度为 K 的子序列
Chapter 9 SVM实践
11. Redis implements follow, unfollow, and follow and follower lists
SIP Protocol Standard and Implementation Mechanism