当前位置:网站首页>Mysql 45 study notes (twenty-five) MYSQL guarantees high availability
Mysql 45 study notes (twenty-five) MYSQL guarantees high availability
2022-07-31 03:18:00 【Kong Tom】
One. Eventual consistency
- As long as main library performs an updateall binlogs generated will be sent to standby and executed correctly
- The standby database can reach the same state as the main database
2. Primary and secondary delay
1. Synchronization delay
- Main library A executes a transaction and writes it to binlog. At this time, we record this moment as T1;
- Pass it to the standby database B, we record the moment when the standby database B receives the binlog as T2;
- Standby B executes this transaction, and we record this moment as T3
Main-standby delay: The difference between the time when the same transaction is completed in the standby database and the time when the main database is completed----T3-T1
2.show salve status command
The standby database executes the show slave status command, and the returned result shows seconds_behind_master, indicating how many seconds the current standby database is delayed
3.seconds_behind_master calculation method
- The binlog of each transaction contains a aTime field for records the time of writing on the master library;
- Standby libraryRemove the current executing transactionThe value of the time field, calculates its difference from the current system time
Three. The source of the main and standby delays
The machine performance of the standby database is worse than that of the main database, which may lead to the delay of the active and standby databases
Statistical analysis and query on the standby database consumes a lot of CPU resources
- One master and multiple slaves: multiple connections and slave libraries share the pressure of reading
- binlog is output to external systems, such as Hadoop systems, so that external systems can provide statistical query capabilities
3. Big business
Four. Reliability priority strategy
- Determine the current second_behind_master of standby database B, if it is less than 5s, continue, otherwise try again
- Change the main library A to read-only state and set readonly to true
- Determine the value of second_behind_master of standby database B until the value becomes 0 (Maintain reliability---need to be small enough, because it is unavailable at this time strong>)
- Change the standby database B to readable and writable state, that is, set readonly to false;
- Switch the business request to the standby database B
V. Availability priority strategy
- Change the standby database B to readable and writable state in step 4, that is, set readonly to false;
- Step 5 Switch the business request to the standby database B
- Directly execute unequal data synchronization and consistency
Disadvantages:
Inconsistent data
On the premise of data reliability, the availability of the MYAQL high-availability system depends on the delay of the active and standby systems
The smaller the delay time, the shorter the recovery time of the faulty service in the main database, the higher the availability
边栏推荐
- Recursive query single table - single table tree structure - (self-use)
- CorelDRAW2022 streamlined Asia Pacific new features in detail
- VS QT——ui不显示新添加成员(控件)||代码无提示
- Why SocialFi achievement Web3 decentralized social in the future
- Analysis summary - self-use
- Office automation case: how to automatically generate period data?
- YOLOV5 study notes (2) - environment installation + operation + training
- 【C语言】求两个整数m和n的最大公因数和最小公倍数之和一般方法,经典解法
- SQL injection Less54 (limited number of SQL injection + union injection)
- 编译Hudi
猜你喜欢
6. Display comments and replies
Office automation case: how to automatically generate period data?
【C语言】三子棋(经典解法+一览图)
Detailed explanation of TCP and UDP
[Compilation principle] Lexical analysis program design principle and implementation
浅识Flutter 基本组件之showDatePicker方法
TCP详解(一)
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
MultipartFile文件上传
web容器及IIS --- 中间件渗透方法1
随机推荐
Analysis summary - self-use
C primer plus学习笔记 —— 8、结构体
SQL 面试用题(重点)
【动态规划】连续子数组的最大和
顺序表的实现
一份高质量的测试用例如何养成?
【CocosCreator 3.5】CocosCreator get network status
[Compilation principle] Lexical analysis program design principle and implementation
10 Permission introduction
Redis implements distributed locks
Moxa NPort 设备缺陷可能使关键基础设施遭受破坏性攻击
【HCIP】ISIS
The distance value between two arrays of LeetCode simple questions
Map.Entry理解和应用
Number 16, top posts
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
Addition and Subtraction of Scores in LeetCode Medium Questions
2022牛客多校联赛第四场 题解
想从手工测试转岗自动化测试,需要学习哪些技能?
Detailed explanation of TCP (2)