按服务的重要性来分类,越是重要的服务就需要通过跨机、跨机房或跨地域来保障服务容灾性,当然这种容灾成本也会相应的升高,因为相当于一批硬件资源解决的是容灾保障而非带来收益,但这仍然是有必要的,当硬件出现异常情况时可以通过保险逃生通道来保证业务稳定性与连续性。 而云是提供类似的保障方案,相应的硬件设备会均摊到需要类似服务的用户上,相当于买保险的价格来保障我们的服务。 近年也有很多类似的事件,如锂电池失火导致机房不可用、空调异常导致机房高温服务异常等问题,本章以腾讯云为例来演示如果通过同地域跨可用区来保障业务高可用。
环境情况
以下为搭建环境相应的配置与架构图

架构图

购买资源
购买云服务器,云服务器控制台。

购买负载均衡clb,负载均衡控制台

注意可用区为五区与八区。

购买数据库,云数据库MySQL控制台

注意可用区为五区与八区。

放通两个子网安全组。

云数据库MySQL配置
设置库。

负载均衡配置
将两个可用区的云服务器加入负载均衡中。

云服务器配置
登录任意一台购买云服务器,通过安装wordpress来模拟机器故障,wordpress依然能访问场景。
1 | sudo yum install -y yum-utils |
安装docker
1 | sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y |
修改docker源
1 | vi /etc/docker/daemon.json |
添加内容如下
1 | { |
重启容器
1 | sudo systemctl daemon-reload |
配置容器
1 | docker run --name vurt-wordpress \ |
访问负载均衡IP会到以下界面。

容灾演练
负载均衡CLB
调整权重为0,来模拟服务故障。

数据库
切换主备
