当前位置:网站首页>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高可用系统的可用性,是依赖主备延迟的
延迟时间越小,在主库故障服务恢复时间越短可用性越高
边栏推荐
- 8、统一处理异常(控制器通知@ControllerAdvice全局配置类、@ExceptionHandler统一处理异常)
- LeetCode 每日一题 2022/7/25-2022/7/31
- Number 16, top posts
- SQL注入 Less46(order by后的注入+rand()布尔盲注)
- The simulation application of common mode inductance is here, full of dry goods for everyone
- Word/Excel fixed table size, when filling in the content, the table does not change with the cell content
- CMOS和TTL的区别?
- Draw Your Cards
- Mycat's master-slave relationship, vertical sub-database, horizontal sub-table, and detailed configuration of mycat fragmented table query (mysql5.7 series)
- Why is String immutable?
猜你喜欢
【Bank Series Phase 1】People's Bank of China
【银行系列第一期】中国人民银行
CefSharp入门-winform
12 磁盘相关命令
CMOS和TTL的区别?
跨专业考研难度大?“上岸”成功率低?这份实用攻略请收下!
Intel's software and hardware optimization empowers Neusoft to accelerate the arrival of the era of smart medical care
YOLOV5 study notes (2) - environment installation + operation + training
汉源高科8路HDMI综合多业务高清视频光端机8路HDMI视频+8路双向音频+8路485数据+8路E1+32路电话+4路千兆物理隔离网络
Word/Excel fixed table size, when filling in the content, the table does not change with the cell content
随机推荐
医疗影像领域AI软件开发流程
The modification is not properly placed in the sandbox, causing Apple compatibility issues
全流程调度——MySQL与Sqoop
Difference between CMOS and TTL?
Face detection based on opencv
There is a problem with the multiplayer-hlap package and the solution cannot be upgraded
f.grid_sample
print task sorting js od huawei
7. List of private messages
拒绝加班,程序员开发的效率工具集
The use of font compression artifact font-spider
【C语言】求两个整数m和n的最大公因数和最小公倍数之和一般方法,经典解法
LeetCode 1161 最大层内元素和[BFS 二叉树] HERODING的LeetCode之路
Unity3D Button mouse hover enter and mouse hover exit button events
如何搭建私有yum源
The Sad History of Image Processing Technology
Word/Excel fixed table size, when filling in the content, the table does not change with the cell content
品牌广告投放平台的中台化应用与实践
Uninstallation of mysql5.7.37 under CentOS7 [perfect solution]
Huawei od dice js