当前位置:网站首页>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.
边栏推荐
- [Dynamic programming] Maximum sum of consecutive subarrays
- Is interprofessional examination difficult?Low success rate of "going ashore"?Please accept this practical guide!
- 【CocosCreator 3.5】CocosCreator get network status
- 识Flutter 基本组件之showTimePicker 方法
- SQL injection Less54 (limited number of SQL injection + union injection)
- endian mode
- 浅识Flutter 基本组件之CheckBox组件
- els 方块向右移动边界判断、向下加速
- Recursive query single table - single table tree structure - (self-use)
- LeetCode simple problem to find the subsequence of length K with the largest sum
猜你喜欢
Detailed explanation of TCP (2)
TCP和UDP详解
Mysql 45讲学习笔记(二十五)MYSQL保证高可用
Problems that need to be solved in distributed system architecture
10 Permission introduction
Chapter 9 SVM实践
浅识Flutter 基本组件之CheckBox组件
What skills do I need to learn to move from manual testing to automated testing?
[C language] Preprocessing operation
TCP详解(二)
随机推荐
选好冒烟测试用例,为进入QA的制品包把好第一道关
IIR滤波器和FIR滤波器
[C language] Preprocessing operation
WebSocket Session为null
TCP详解(二)
VS QT——ui不显示新添加成员(控件)||代码无提示
Day32 LeetCode
Ambiguous method call.both
分布式锁以及实现方式三种
Ambiguous method call.both
Compile Hudi
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
刚出道“一战成名”,安全、舒适一个不落
Detailed explanation of TCP (1)
[Android] Room - Alternative to SQLite
[C language foundation] Solve C language error: expected ';', ',' or ')' before '&' token
CloudCompare&PCL 计算两个点云之间的重叠度
SQL injection Less47 (error injection) and Less49 (time blind injection)
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
Chapter 9 SVM Practice