关键词
安装
wget https://chaosblade.oss-cn-hangzhou.aliyuncs.com/agent/github/1.3.0/chaosblade-1.3.0-linux-amd64.tar.gz
tar xf chaosblade-1.3.0-linux-amd64.tar.gz
version: 1.3 .0
env:
build-time: Wed Aug 4 12 :52:28 UTC 2021
帮助
./blade -h
./blade create -h
./blade create cpu fullload -d
-d, --debug 设置工具为 DEBUG 模式,主要用于调试使用
-h, --help 查看 blade 命令帮助文档
Demo演示
创建混沌实验命令,每个实验对应一个 uid,后续的查询、销毁实验都要用到此 uid,如果遗忘了 uid,可以通过
./blade status --type create
./blade status --type create --status Success
命令进行查询
./blade create cpu fullload --cpu-count 1
{ "code" :200,"success" :true,"result" : "6fa04946baf42920" }
./blade destroy 6fa04946baf42920
{ "code" :200,"success" :true,"result" : "command: cpu fullload --cpu-count 2 --debug false --help false" }
压测CPU
./blade create cpu load --help
./blade create cpu load
./blade create cpu load --cpu-percent 60
./blade create cpu load --cpu-percent 60 --cpu-count 1
上述创建的测试都是在后台运行的,需要取消某个测试,参考上面的'Demo演示'
压测Memory
./blade create mem load --help
./blade create mem load --mode ram --mem-percent 50
./blade create mem load --mode cache --mem-percent 50
./blade create mem load --mode ram --reserve 500 --rate 100
ram 模式采用代码申请内存实现 cache 模式采用 dd、mount 命令实现,挂载 tmpfs 并且进行文件填充
问:误操作内存打满,机器搞死,动不了,怎么搞?
答:重启机器
压测磁盘IO
yum install sysstat iotop -y
iostat -x -t 2
iostat -dxm 1
iotop
./blade create disk burn --help
./blade create disk burn --read --path /home
./blade create disk burn --write --path /home
./blade create disk burn --read --write
压测磁盘填充
./blade create disk fill --help
./blade create disk fill --path /data --size 10000
./blade create disk fill --path /data --percent 70 --retain-handle
./blade create disk fill --path /data --reserve 4096
网卡延迟模拟
./blade create network delay --help
yum install iproute -y
./blade create network delay --time 3000 --offset 1000 --interface eth0 --local-port 8080,8081
./blade create network delay --time 5000 --interface eth0 --exclude-port 22,8000 -8080
篡改DNS域名解析
此实验会修改本地的 hosts,篡改域名地址映射。
网络丢包场景主要验证域名解析异常的情况下,系统的自我容错能力。
./blade create network dns --domain www.baidu.com --ip 10.0 .0.0
网络丢包
blade create network loss --percent 70 --interface eth0 --local-port 8080,8081
blade create network loss --percent 100 --interface eth0 --timeout 20
参考资料
https://github.com/chaosblade-io/chaosblade
https://chaosblade.oss-cn-hangzhou.aliyuncs.com/agent/github/1.3.0/chaosblade-1.3.0-linux-amd64.tar.gz
https://chaosblade-io.gitbook.io/chaosblade-help-zh-cn/blade-version