searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

故障模拟工具-ChaosBlade使用介绍

2023-07-02 08:56:54
570
0

ChaosBlade是一款常用的故障模拟工具,支持内存,CPU,硬盘,网络,容器,进程等故障模拟,本文重点介绍软件的基础使用。

软件安装部署

步骤1:获取软件

https://github.com/chaosblade-io/chaosblade/releases

 

步骤2:将chaosblade软件上传到对应的安装目录下,执行tar命令解压chaosblade软件

[root~]tar -xzvf chaosblade-1.3.0-linux-amd64.tar.gz 
[root~]cd chaosblade-1.3.0/

ChaosBlade软件使用

  1. 模拟CPU:

(1)让CPU负载到90%:

命令格式:./blade create cpu load --cpu-percent XX

示例:

[chaosblade-1.3.0]$ sudo ./blade create cpu load --cpu-percent 90
{"code":200,"success":true,"result":"3286ba7ef4cf6c89"}

(2)让CPU满负载

[chaosblade-1.3.0]$ sudo ./blade create cpu fullload
{"code":200,"success":true,"result":"bfccb763c8185eec"}

 

  1. 模拟内存使用:

(1)模拟内存占用80%

命令格式:./blade c mem load --mode ram --mem-percent  XX

示例:

./blade c mem load --mode ram --mem-percent 80

(2)内存占用速度为100M/s逐步占用,最终预留500M内存

示例:

./blade c mem load --mode ram --reserve 500 --rate 100

 

3.模拟网络故障

 (1)注入网络时延,单位为ms

./blade create network delay --interface eth2 --time 300

(2)注入网络丢包80%

./blade create network loss --percent 80 --interface eth2

 

4.模拟磁盘异常

(1)模拟目录使用容量80%

./blade create disk fill --path /mnt/file --percent 80 --retain-handle

 

5. 清除故障:

步骤1:找到要清除的故障UID,可以通过log日志中查询到:

[~~~chaosblade-1.3.0]$ cat  logs/chaosblade.log 
time="2023-06-30 16:54:46.347682944 CST" level=info msg="mode: create, target: mem, action: load, flags [mode=ram mem-percent=90 uid=61a9c02cc7bf9b11]"
time="2023-06-30 16:56:19.77386401 CST" level=info msg="destroy by 61a9c02cc7bf9b11 uid, force-remove: false, target: "
time="2023-06-30 16:56:19.848990862 CST" level=info msg="mode: destroy, target: mem, action: load, flags [mode=ram mem-percent=90 uid=61a9c02cc7bf9b11]"
time="2023-06-30 16:56:45.221775502 CST" level=info msg="mode: create, target: mem, action: load, flags [mode=ram mem-percent=90 uid=083b0c612c8b961f]"
time="2023-06-30 16:57:50.983287204 CST" level=info msg="mode: create, target: cpu, action: fullload, flags [cpu-percent=90 uid=bfccb763c8185eec]"
time="2023-06-30 17:00:40.364139358 CST" level=info msg="mode: create, target: mem, action: load, flags [mode=ram mem-percent=90 uid=6d8351e404c1043c]"

步骤2:执行命令:./blade destroy uid

示例:[chaosblade-1.3.0]$ sudo ./blade destroy 6d8351e404c1043c
{"code":200,"success":true,"result":{"target":"mem","action":"load","flags":{"mem-percent":"90","mode":"ram"}}}

0条评论
0 / 1000
w****n
8文章数
1粉丝数
w****n
8 文章 | 1 粉丝
原创

故障模拟工具-ChaosBlade使用介绍

2023-07-02 08:56:54
570
0

ChaosBlade是一款常用的故障模拟工具,支持内存,CPU,硬盘,网络,容器,进程等故障模拟,本文重点介绍软件的基础使用。

软件安装部署

步骤1:获取软件

https://github.com/chaosblade-io/chaosblade/releases

 

步骤2:将chaosblade软件上传到对应的安装目录下,执行tar命令解压chaosblade软件

[root~]tar -xzvf chaosblade-1.3.0-linux-amd64.tar.gz 
[root~]cd chaosblade-1.3.0/

ChaosBlade软件使用

  1. 模拟CPU:

(1)让CPU负载到90%:

命令格式:./blade create cpu load --cpu-percent XX

示例:

[chaosblade-1.3.0]$ sudo ./blade create cpu load --cpu-percent 90
{"code":200,"success":true,"result":"3286ba7ef4cf6c89"}

(2)让CPU满负载

[chaosblade-1.3.0]$ sudo ./blade create cpu fullload
{"code":200,"success":true,"result":"bfccb763c8185eec"}

 

  1. 模拟内存使用:

(1)模拟内存占用80%

命令格式:./blade c mem load --mode ram --mem-percent  XX

示例:

./blade c mem load --mode ram --mem-percent 80

(2)内存占用速度为100M/s逐步占用,最终预留500M内存

示例:

./blade c mem load --mode ram --reserve 500 --rate 100

 

3.模拟网络故障

 (1)注入网络时延,单位为ms

./blade create network delay --interface eth2 --time 300

(2)注入网络丢包80%

./blade create network loss --percent 80 --interface eth2

 

4.模拟磁盘异常

(1)模拟目录使用容量80%

./blade create disk fill --path /mnt/file --percent 80 --retain-handle

 

5. 清除故障:

步骤1:找到要清除的故障UID,可以通过log日志中查询到:

[~~~chaosblade-1.3.0]$ cat  logs/chaosblade.log 
time="2023-06-30 16:54:46.347682944 CST" level=info msg="mode: create, target: mem, action: load, flags [mode=ram mem-percent=90 uid=61a9c02cc7bf9b11]"
time="2023-06-30 16:56:19.77386401 CST" level=info msg="destroy by 61a9c02cc7bf9b11 uid, force-remove: false, target: "
time="2023-06-30 16:56:19.848990862 CST" level=info msg="mode: destroy, target: mem, action: load, flags [mode=ram mem-percent=90 uid=61a9c02cc7bf9b11]"
time="2023-06-30 16:56:45.221775502 CST" level=info msg="mode: create, target: mem, action: load, flags [mode=ram mem-percent=90 uid=083b0c612c8b961f]"
time="2023-06-30 16:57:50.983287204 CST" level=info msg="mode: create, target: cpu, action: fullload, flags [cpu-percent=90 uid=bfccb763c8185eec]"
time="2023-06-30 17:00:40.364139358 CST" level=info msg="mode: create, target: mem, action: load, flags [mode=ram mem-percent=90 uid=6d8351e404c1043c]"

步骤2:执行命令:./blade destroy uid

示例:[chaosblade-1.3.0]$ sudo ./blade destroy 6d8351e404c1043c
{"code":200,"success":true,"result":{"target":"mem","action":"load","flags":{"mem-percent":"90","mode":"ram"}}}

文章来自个人专栏
存储底座
8 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0