背景
云数据库 MySQL 实例可以配置多个只读实例组(Read Only Group,简称 RO 组),RO 组可承担主实例的只读请求,提高 MySQL 整体的读性能。云顾问 - 混沌演练提供模拟 MySQL 只读实例组不可用故障场景,该场景可验证以下场景:
1. 跨可用区部署的 RO 组,当发生单 AZ 故障后,另外可用区的 RO 组能否对外提供正常服务。
2. RO 组实例故障后对业务影响(主节点能否承受读压力)。
说明:
该故障动作会进行用户安全组数量以及 MySQL 实例是否配置有只读实例的环境检测,若您的实例不满足该条件,故障注入将会失败。为 MySQL 实例创建只读实例可参见云数据库 MySQL 文档 创建只读实例。
故障描述
该故障动作会将用户指定注入范围内的 RO 组实例封禁,使其对外不可用,故障相关 RO 组中实例的存量连接会被中断。
演练实施
步骤一:演练准备
一台 云数据库 MySQL 实例,并且该实例已经配置了只读实例。
一台 云服务器 CVM 实例,用于测试数据库连接。(用户可选择其他连接方式验证测试)
步骤二:演练编排
1. 登录 云顾问 > 混沌演练控制台,进入演练管理页面,单击新建演练。
![](https://qcloudimg.tencent-cloud.cn/image/document/04ba3398e8e03964f3ed93ed27776254.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/04ba3398e8e03964f3ed93ed27776254.png)
2. 进入经验模板选择界面,点击跳过,创建空白演练。
![](https://qcloudimg.tencent-cloud.cn/image/document/7bdea55e5ed13d0d2c0344f8251af2c9.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/7bdea55e5ed13d0d2c0344f8251af2c9.png)
3. 填写演练基本信息。
![](https://qcloudimg.tencent-cloud.cn/image/document/efa41ac6bb3e92ed133b425c7f4743c6.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/efa41ac6bb3e92ed133b425c7f4743c6.png)
4. 填写演练动作组信息,选择资源类型为云资源,资源对象为 MySQL,并点击添加实例。
![](https://qcloudimg.tencent-cloud.cn/image/document/197ff847f0c6a80470906fbef3b223a4.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/197ff847f0c6a80470906fbef3b223a4.png)
演示 MySQL 实例概览:
![](https://qcloudimg.tencent-cloud.cn/image/document/d3ca95cb175fade4f6a3c34172c6eec3.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/d3ca95cb175fade4f6a3c34172c6eec3.png)
5. 点击立即添加添加故障动作,选择只读实例组不可用故障动作,并单击下一步。
![](https://qcloudimg.tencent-cloud.cn/image/document/fd61e48871563a8f61533808724782f9.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/fd61e48871563a8f61533808724782f9.png)
6. 填写故障动作参数。
![](https://qcloudimg.tencent-cloud.cn/image/document/614bbf5cfab1aa113857796246a2886f.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/614bbf5cfab1aa113857796246a2886f.png)
这里故障注入范围选择主可用区 RO 组,因此故障将会注入到所选中的 MySQL 实例的位于主实例可用区下的 RO 组实例中。
说明:
持续 kill 连接时长(s):当前动作会帮您创建持续 kill 连接任务,用来 kill 存量长连接,此参数用来指定持续 kill 任务时长,如果您的 MySQL 连接数较大,可以增大此参数,确保能在持续时间内kill完所有连接,默认时间为60s。
故障注入范围:选择注入故障的可用区。
主可用区:主实例所在可用区的 RO 组
非主可用区:其他非主实例所在的可用区的 RO 组。
全部可用区:所有可用区的 RO 组。
指定可用区:指定可用区的 RO 组。
7. 单击下一步,进入全局配置,全局配置请参见 快速入门。确认无误后,单击提交,创建演练。
![](https://qcloudimg.tencent-cloud.cn/image/document/26b4b754e1d6f5e1406db20a9c69505f.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/26b4b754e1d6f5e1406db20a9c69505f.png)
步骤三:执行演练
故障前:
MySQL RO 组实例在故障前,将会依据之前步骤配置的注入范围,对选定只读实例进行故障注入。使用 CVM 实例登录当前 RO 实例,建立一个客户端连接。
![](https://qcloudimg.tencent-cloud.cn/image/document/003d72cc3f24f78efd8edb31a9b6f830.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/003d72cc3f24f78efd8edb31a9b6f830.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/04e01e0659d115a757ded1047f8f063a.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/04e01e0659d115a757ded1047f8f063a.png)
执行演练:
1. 进入演练详情,在动作卡片处点击执行,开始执行演练动作。![](https://qcloudimg.tencent-cloud.cn/image/document/19b059c30ed61a75c8e7006dceed4f53.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/19b059c30ed61a75c8e7006dceed4f53.png)
故障注入之后,可单击详情,查看执行结果信息。![](https://qcloudimg.tencent-cloud.cn/image/document/d0085137415c1cd190797aa24919bdd9.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/d0085137415c1cd190797aa24919bdd9.png)
此时,可观察到存量的连接已断连。![](https://qcloudimg.tencent-cloud.cn/image/document/f03767972e365e4ab944ba97179eaa15.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/f03767972e365e4ab944ba97179eaa15.png)
2. 点击执行恢复动作。
![](https://qcloudimg.tencent-cloud.cn/image/document/72dc24554275e9af1258e8f53ef713c0.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/72dc24554275e9af1258e8f53ef713c0.png)
恢复动作执行成功之后,使用 CVM 重新连接 RO 实例。恢复之后,可重新连接到该 RO 实例,故障已被清除。
![](https://qcloudimg.tencent-cloud.cn/image/document/c20a60df579e77a4fd7f3ef20137a8b6.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/c20a60df579e77a4fd7f3ef20137a8b6.png)