当前位置:网站首页>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高可用系统的可用性,是依赖主备延迟的
延迟时间越小,在主库故障服务恢复时间越短可用性越高
边栏推荐
- The simulation application of common mode inductance is here, full of dry goods for everyone
- 19.支持向量机-优化目标和大间距直观理解
- String为什么不可变?
- 工程(五)——小目标检测tph-yolov5
- 软件积累 -- 截图软件ScreenToGif
- Layer 2 broadcast storm (cause + judgment + solution)
- General introduction to the Unity interface
- 【Bank Series Phase 1】People's Bank of China
- 拒绝加班,程序员开发的效率工具集
- 字体压缩神器font-spider的使用
猜你喜欢
The whole process scheduling, MySQL and Sqoop
JS function this context runtime syntax parentheses array IIFE timer delay self.backup context call apply
How to do a startup CTO?
php 网站的多语言设置(IP地址区分国内国外)
Installation, start and stop of redis7 under Linux
英特尔软硬优化,赋能东软加速智慧医疗时代到来
LeetCode 1161 The largest element in the layer and the LeetCode road of [BFS binary tree] HERODING
JS 函数 this上下文 运行时点语法 圆括号 数组 IIFE 定时器 延时器 self.备份上下文 call apply
Mycat's master-slave relationship, vertical sub-database, horizontal sub-table, and detailed configuration of mycat fragmented table query (mysql5.7 series)
YOLOV5 study notes (2) - environment installation + operation + training
随机推荐
7、私信列表
Face detection based on opencv
16. Registration Center-consul
【C语言基础】解决C语言error: expected ‘;‘, ‘,‘ or ‘)‘ before ‘&‘ token
The simulation application of common mode inductance is here, full of dry goods for everyone
15、网站统计数据
品牌广告投放平台的中台化应用与实践
共模电感的仿真应用来了,满满的干货送给大家
Refuse to work overtime, a productivity tool set developed by programmers
Thesis framework of the opening report
AI software development process in medical imaging field
全流程调度——MySQL与Sqoop
Project (5) - Small target detection tph-yolov5
Huawei od dice js
2022牛客多校联赛第四场 题解
冒泡排序、选择排序、直接插入排序、二分法查找
Linux下redis7的安装,启动与停止
分布式与集群是什么 ? 区别是什么?
StringJoiner in detail
SQL注入 Less47(报错注入) 和Less49(时间盲注)