混沌实验工具ChaosBlade的使用
ChaosBlade 是阿里巴巴开源的一款遵循混沌工程原理和混沌实验模型的实验注入工具,帮助企业提升分布式系统的容错能力,并且在企业上云或往云原生系统迁移过程中业务连续性保障。
地址:https://github.com/chaosblade-io/chaosblade
文档:https://chaosblade-io.gitbook.io/chaosblade-help-zh-cn/blade
安装
从以下路劲获取最新版本
https://github.com/chaosblade-io/chaosblade/releases/
解压即用
tar -zxvf chaosblade-0.6.0-linux-amd64.tar.gz
解压后进入chaosblade-0.6.0目录
[cli@node1 chaosblade-0.6.0]$ ls bin blade chaosblade.dat lib logs
故障演练
cpu满载
./blade create cpu fullload
返回信息
[cli@node1 chaosblade-0.6.0]$ ./blade create cpu fullload {"code":200,"success":true,"result":"04387569ffd9e877"}
top查看cpu使用情况
故障恢复
./blade destroy 04387569ffd9e877
返回信息
[cli@node1 chaosblade-0.6.0]$ ./blade destroy 04387569ffd9e877 {"code":200,"success":true,"result":{"Target":"cpu","Scope":"","ActionName":"fullload","ActionFlags":{}}}
查看cpu使用情况,已经恢复正常
磁盘满
填充20个G的文件
./blade create disk fill --size 20480
返回信息
{"code":200,"success":true,"result":"13bfcd49ce80b5a5"}
查看磁盘
恢复故障
./blade destroy 13bfcd49ce80b5a5
磁盘io高
./blade create disk burn --write --read --size 10 --timeout 300
禁止端口访问
blade create network drop --local-port 80 --remote-port 80
网络丢包
网络掉包50% blade create network loss --interface eth0 --percent 50 --local-port 6483 --remote-port 6483
网络延时
对网卡eth0,延时3秒 blade create network delay --interface eth0 --time 3000 --local-port 6483 --remote-port 6483
查看创建的故障记录
./blade status --type create
查看销毁的故障记录
./blade status --type destroy
各种故障演练参考官方文档
但行好事,莫问前程