当前位置:网站首页>Mysql 45讲学习笔记(二十五)MYSQL保证高可用
Mysql 45讲学习笔记(二十五)MYSQL保证高可用
2022-07-31 02:50:00 【孔汤姆】
一.最终一致性
- 只要主库执行更新生成的所有binlog都会被传送到备库并被正确的执行
- 备库能达到主库一致的状态
二.主备延迟
1.同步延迟
- 主库A执行完成一个事务,写入binlog,这时我们把这个时刻记为T1;
- 传给备库B,我们把备库B接收完这个binlog的时刻记为T2;
- 备库B执行完成这个事务,我们把这个时刻记为T3
主备延迟:同一个事务,在备库执行完成的时间和主库执行完成的时间之差----T3-T1
2.show salve status命令
备库执行show slave status命令,返回结果显示seconds_behind_master,表示当前备库延迟了多少秒
3.seconds_behind_master计算方法
- 每个事务的binlog里面都有一个时间字段,用于记录主库上写入的时间;
- 备库取出当前正在执行的事务的时间字段的值,计算它与当前系统时间的差值
三.导致主备延迟的来源
备库机器性能比主库差可能导致主备延迟
备库上做统计分析与查询消耗了大量的CPU资源 解决方案:
- 一主多从:多连接从库分担读的压力
- binlog输出到外部系统,比如Hadoop系统,让外部系统提供统计类查询的能力
3.大事务
四.可靠性优先策略

- 判断备库B现在的second_behind_master,如果小于5s就继续,否则重试
- 把主库A改成只读状态,把readonly设置为true
- 判断备库B的second_behind_master的值,直到值变为0(保持可靠性---需要足够小,因为此时不可用)
- 把备库B改为可读写状态,也就是readonly设置为false;
- 将业务请求切换为备库B
五.可用性优先策略
- 将步骤4 把备库B改为可读写状态,也就是readonly设置为false;
- 步骤5 将业务请求切换为备库B
- 直接执行不等数据同步一致
缺点:
数据不一致
在满足数据可靠性的前提下,MYAQL高可用系统的可用性,是依赖主备延迟的
延迟时间越小,在主库故障服务恢复时间越短可用性越高
边栏推荐
- AI中的数学思想
- Installation of mysql5.7.37 under CentOS7 [perfect solution]
- Modbus on AT32 MCUs
- Moxa NPort device flaw could expose critical infrastructure to devastating attack
- 知识蒸馏7:知识蒸馏代码详解
- 16. Registration Center-consul
- 冒泡排序、选择排序、直接插入排序、二分法查找
- Discussion on Service Commitment of Class Objects under Multithreading
- MPPT solar charge controller data collection - through the gateway acquisition capacity battery SOC battery voltage, wi-fi
- What is a distributed lock?Three ways of implementing distributed lock
猜你喜欢

mycat的主从关系 垂直分库 水平分表 以及mycat分片联表查询的配置详解(mysql5.7系列)

The use of font compression artifact font-spider
![LeetCode 1161 The largest element in the layer and the LeetCode road of [BFS binary tree] HERODING](/img/56/fcc8ee6f592abf0a374fc950a3362f.png)
LeetCode 1161 The largest element in the layer and the LeetCode road of [BFS binary tree] HERODING

221. Largest Square

工程(五)——小目标检测tph-yolov5

图解lower_bound&upper_bound

Detailed explanation of STP election (step + case)

The Sad History of Image Processing Technology

1. Non-type template parameters 2. Specialization of templates 3. Explanation of inheritance

String为什么不可变?
随机推荐
MPPT太阳能充放电控制器数据采集-通过网关采集电池电压容量电量SOC,wifi传输
CMOS和TTL的区别?
Multilingual settings of php website (IP address distinguishes domestic and foreign)
The Sad History of Image Processing Technology
图像处理技术的心酸史
The simulation application of common mode inductance is here, full of dry goods for everyone
19. Support Vector Machines - Intuitive Understanding of Optimization Objectives and Large Spacing
Calculate S=a+aa+…+aa…a
Basic learning about Redis related content
Mathematics to solve the problem - circular linked list
AI在医疗影像设备全流程应用
Thesis framework of the opening report
Moxa NPort device flaw could expose critical infrastructure to devastating attack
分布式与集群是什么 ? 区别是什么?
【Android】Room —— SQLite的替代品
Difference between CMOS and TTL?
Intranet Infiltration - Privilege Escalation
221. Largest Square
Coldfusion file read holes (CVE - 2010-2861)
数学解决——环形链表问题