模拟压力场景
本文主要介绍如何使用 Chaosd 模拟压力场景。该功能通过使用 stress-ng 在主机上生成 CPU 或者内存压力,支持通过命令行模式或服务模式创建压力实验。
使用命令行模式创建压力实验
本节介绍如何在命令行模式中创建压力实验。
在创建压力实验前,可运行以下命令查看 Chaosd 支持的压力实验类型:
chaosd attack stress --help
输出如下所示:
Stress attack related commands
Usage:
chaosd attack stress [command]
Available Commands:
cpu continuously stress CPU out
mem continuously stress virtual memory out
Flags:
-h, --help help for stress
Global Flags:
--log-level string the log level of chaosd, the value can be 'debug', 'info', 'warn' and 'error'
Use "chaosd attack stress [command] --help" for more information about a command.
目前 Chaosd 支持创建 CPU 压力实验和内存压力实验。
模拟 CPU 压力场景
模拟 CPU 压力命令
运行以下命令可查看模拟 CPU 压力场景支持的配置:
chaosd attack stress cpu --help
输出如下所示:
continuously stress CPU out
Usage:
chaosd attack stress cpu [options] [flags]
Flags:
-h, --help help for cpu
-l, --load int Load specifies P percent loading per CPU worker. 0 is effectively a sleep (no load) and 100 is full loading. (default 10)
-o, --options strings extend stress-ng options.
-w, --workers int Workers specifies N workers to apply the stressor. (default 1)
Global Flags:
--log-level string the log level of chaosd, the value can be 'debug', 'info', 'warn' and 'error'