docs: add new 2.1 English docs and revise Chinese docs (#196)
* docs: add new 2.1 English docs and revise Chinese docs Signed-off-by: en-jin19 <jinenwei@pingcap.com> * accept comments Signed-off-by: en-jin19 <jinenwei@pingcap.com> * revise translation Signed-off-by: en-jin19 <jinenwei@pingcap.com> * revise translataion and add images Signed-off-by: en-jin19 <jinenwei@pingcap.com> * relocate images Signed-off-by: en-jin19 <jinenwei@pingcap.com>
This commit is contained in:
parent
28706ac5cd
commit
88ee3cf907
Binary file not shown.
|
After Width: | Height: | Size: 154 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 321 KiB |
|
|
@ -2,4 +2,578 @@
|
|||
title: Simulate JVM Application Faults
|
||||
---
|
||||
|
||||
## TODO
|
||||
Chaosd simulates the faults of JVM application through [Byteman](https://github.com/chaos-mesh/byteman). The supported fault types are as follows:
|
||||
|
||||
- Throw custom exceptions
|
||||
- Trigger garbage collection
|
||||
- Increase method latency
|
||||
- Modify return values of a method
|
||||
- Trigger faults by setting Byteman configuration files
|
||||
- Increase JVM pressure
|
||||
|
||||
This document describes how to use Chaosd to create the above fault types of JVM experiments.
|
||||
|
||||
## Create experiments using command-line mode
|
||||
|
||||
This section introduces how to create the experiments of JVM application faults using command-line mode.
|
||||
|
||||
Before creating the experiment, you can run the following command line to see the types of JVM application faults supported by Chaosd:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm -h
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
JVM attack related commands
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm [command]
|
||||
|
||||
Available Commands:
|
||||
exception throw specified exception for specified method
|
||||
gc trigger GC for JVM
|
||||
latency inject latency to specified method
|
||||
return return specified value for specified method
|
||||
rule-file inject fault with configured byteman rule file
|
||||
stress inject stress to JVM
|
||||
|
||||
Flags:
|
||||
-h, --help help for jvm
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--uid string the experiment ID
|
||||
|
||||
Use "chaosd attack jvm [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
### Throw custom exceptions using command-line mode
|
||||
|
||||
#### Commands for throwing custom exceptions
|
||||
|
||||
To see the usage and configuration items of the command that throws custom exceptions, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm exception --help
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
throw specified exception for specified method
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm exception [options] [flags]
|
||||
|
||||
Flags:
|
||||
-c, --class string Java class name
|
||||
--exception string the exception which needs to throw for action 'exception'
|
||||
-h, --help help for exception
|
||||
-m, --method string the method name in Java class
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for throwing custom exceptions
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `class` | `c` | The name of the Java class | string type, required|
|
||||
| `exception` | None | The thrown custom exception | string type, required |
|
||||
| method | m | The name of the method | string type, required to be configured |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| uid | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for throwing custom exceptions
|
||||
|
||||
```bash
|
||||
chaosd attack jvm exception -c Main -m sayhello --exception 'java.io.IOException("BOOM")' --pid 30045
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 02:39:39.106 +00:00] [INFO] [jvm.go:208] ["byteman rule"] [rule="\nRULE Main-sayhello-exception-q6nd0\nCLASS Main\nMETHOD sayhello\nAT ENTRY\nIF true\nDO \n\tthrow new java.io.IOException(\"BOOM\");\nENDRULE\n"] [file=/tmp/rule.btm296930759]
|
||||
Attack jvm successfully, uid: 26a45ae2-d395-46f5-a126-2b2c6c85ae9d
|
||||
```
|
||||
|
||||
### Trigger garbage collection using command-line mode
|
||||
|
||||
#### Commands for triggering garbage collection
|
||||
|
||||
To see the usage and configuration items of the command that triggers garbage collection, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm gc --help
|
||||
```
|
||||
|
||||
```bash
|
||||
trigger GC for JVM
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm gc [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for gc
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for triggering garbage collection
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for triggering garbage collection
|
||||
|
||||
```bash
|
||||
chaosd attack jvm gc --pid 89345
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 02:49:47.850 +00:00] [INFO] [jvm.go:208] ["byteman rule"] [rule="\nRULE --gc-u0mlf\nGC\nENDRULE\n"] [file=/tmp/rule.btm012481052]
|
||||
Attack jvm successfully, uid: f360e70a-5359-49b6-8526-d7e0a3c6f696
|
||||
```
|
||||
|
||||
Triggering garbage collection is a one-time operation, and the experiment does not require recovery.
|
||||
|
||||
### Increase method latency using command-line mode
|
||||
|
||||
#### Commands for increasing method latency
|
||||
|
||||
To see the usage and configuration items of the command that increases method latency, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm latency --help
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
inject latency to specified method
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm latency [options] [flags]
|
||||
|
||||
Flags:
|
||||
-c, --class string Java class name
|
||||
-h, --help help for latency
|
||||
--latency int the latency duration, unit ms
|
||||
-m, --method string the method name in Java class
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for increasing method latency
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `class` | `c` | The name of the Java class | string type, required |
|
||||
| `latency` | None | The duration of increasing method latency | int type, required. The unit is milisecond. |
|
||||
| `method` | `m` | The name of the method | string type, required |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for increasing method latency
|
||||
|
||||
```bash
|
||||
chaosd attack jvm latency --class Main --method sayhello --latency 5000 --pid 100840
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 03:08:50.716 +00:00] [INFO] [jvm.go:208] ["byteman rule"] [rule="\nRULE Main-sayhello-latency-hlib2\nCLASS Main\nMETHOD sayhello\nAT ENTRY\nIF true\nDO \n\tThread.sleep(5000);\nENDRULE\n"] [file=/tmp/rule.btm359997255]
|
||||
[2021/08/05 03:08:51.155 +00:00] [INFO] [jvm.go:94] ["submit rules"] [output="install rule Main-sayhello-latency-hlib2\n\n"]
|
||||
Attack jvm successfully, uid: bbe00c57-ac9d-4113-bf0c-2a6f184be261
|
||||
```
|
||||
|
||||
### Modify return values of a method using command-line mode
|
||||
|
||||
#### Commands for modifying return values of a method
|
||||
|
||||
To see the usage and configuration items of the command that modifies return values of a method, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm return --help
|
||||
```
|
||||
|
||||
```bash
|
||||
return specified value for specified method
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm return [options] [flags]
|
||||
|
||||
Flags:
|
||||
-c, --class string Java class name
|
||||
-h, --help help for return
|
||||
-m, --method string the method name in Java class
|
||||
--value string the return value for action 'return'. Only supports number and string types.
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for modifying return values of a method
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| class | c | The name of the Java class | string type, required to be configured |
|
||||
| method | m | The name of the method | string type, required to be configured |
|
||||
| value | None | Specifies the return value of the method | string type, required to be configured. Currently, the item can be numeric and string types. If the item (return value) is string, double quotes are required, like "chaos". |
|
||||
| pid | None | The Java process ID where the fault is needed to be injected | int type, required to be configured |
|
||||
| port | None | The port number attached to the Java process agent. The faults is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| uid | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for simulating the scenario of modifying return values of a method
|
||||
|
||||
```bash
|
||||
chaosd attack jvm return --class Main --method getnum --value 999 --pid 112694
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 03:35:10.603 +00:00] [INFO] [jvm.go:208] ["byteman rule"] [rule="\nRULE Main-getnum-return-i6gb7\nCLASS Main\nMETHOD getnum\nAT ENTRY\nIF true\nDO \n\treturn 999;\nENDRULE\n"] [file=/tmp/rule.btm051982059]
|
||||
[2021/08/05 03:35:10.820 +00:00] [INFO] [jvm.go:94] ["submit rules"] [output="install rule Main-getnum-return-i6gb7\n\n"]
|
||||
Attack jvm successfully, uid: e2f204f6-4bed-4d92-aade-2b4a47b02e5d
|
||||
```
|
||||
|
||||
### Trigger faults by setting Byteman configuration files using command-line mode
|
||||
|
||||
You can set the fault rules in the Byteman rule configuration file, and then inject the faults by specifying the path of the configuration file using Chaosd. Regarding the Byteman rule configuration, refer to [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language).
|
||||
|
||||
#### Commands for triggering faults by setting Byteman configuration files
|
||||
|
||||
To see the usage and configuration items of the command that triggers faults by setting Byteman configuration files, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm rule-file --help
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
inject fault with configured byteman rule file
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm rule-file [options] [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for rule-file
|
||||
-p, --path string the path of configured byteman rule file
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd, the value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for triggering faults by setting Byteman configuration files
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `path` | None | Specifies the path of the Byteman configuration file | string type, required |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for triggering faults by setting Byteman configuration files
|
||||
|
||||
First, based on the specific Java program and referring to [the Byteman rule language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language), write a rule configuration file. For example:
|
||||
|
||||
```txt
|
||||
RULE modify return value
|
||||
CLASS Main
|
||||
METHOD getnum
|
||||
AT ENTRY
|
||||
IF true
|
||||
DO
|
||||
return 9999
|
||||
ENDRULE
|
||||
```
|
||||
|
||||
Then, save the configuration file to the `return.btm` file. After that, run the following command to inject faults.
|
||||
|
||||
```bash
|
||||
chaosd attack jvm rule-file -p ./return.btm --pid 112694
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 03:45:40.757 +00:00] [INFO] [jvm.go:152] ["rule file data:RULE modify return value\nCLASS Main\nMETHOD getnum\nAT ENTRY\nIF true\nDO\n return 9999\nENDRULE\n"]
|
||||
[2021/08/05 03:45:41.011 +00:00] [INFO] [jvm.go:94] ["submit rules"] [output="install rule modify return value\n\n"]
|
||||
Attack jvm successfully, uid: 5ca2e06d-a7c6-421d-bb67-0c9908bac17a
|
||||
```
|
||||
|
||||
### Increase JVM stress using command-line mode
|
||||
|
||||
#### Commands for increasing JVM stress
|
||||
|
||||
To see the usage and configuration items of the command that increases JVM stress, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm stress --help
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
inject stress to JVM
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm stress [options] [flags]
|
||||
|
||||
Flags:
|
||||
--cpu-count int the CPU core number
|
||||
-h, --help help for stress
|
||||
--mem-type int the memory type to be allocated. The value can be 'stack' or 'heap'.
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for increasing JVM stress
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `cpu-count` | None | The number of CPU cores used for increasing JVM stress | int type. You can only configure one of `cpu-count` and `mem-type`. |
|
||||
| `mem-type` | None | The type of OOM | string type. Currently, both 'stack' and 'heap' OOM types are supported. You can only configure one of `cpu-count` and `mem-type`. |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for increasing JVM stress
|
||||
|
||||
```bash
|
||||
chaosd attack jvm stress --cpu-count 2 --pid 123546
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 03:59:51.256 +00:00] [INFO] [jvm.go:208] ["byteman rule"] [rule="\nRULE --stress-jfeiu\nSTRESS CPU\nCPUCOUNT 2\nENDRULE\n"] [file=/tmp/rule.btm773062009]
|
||||
[2021/08/05 03:59:51.613 +00:00] [INFO] [jvm.go:94] ["submit rules"] [output="install rule --stress-jfeiu\n\n"]
|
||||
Attack jvm successfully, uid: b9b997b5-0a0d-4f1f-9081-d52a32318b84
|
||||
```
|
||||
|
||||
## Create experiments using service mode
|
||||
|
||||
You can follow the instructions below to create experiments using service mode.
|
||||
|
||||
1. Execute Chaosd in service mode:
|
||||
|
||||
```bash
|
||||
chaosd server --port 31767
|
||||
```
|
||||
|
||||
2. Send HTTP POST request to the `/api/attack/{uid}` path of Chaosd service.
|
||||
|
||||
For the `fault-configuration` in `bash curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{fault-configuration}'`, you need to configure it according to the fault types. For the corresponding parameters, refer to the parameters and examples of each fault type in the following sections.
|
||||
|
||||
:::note
|
||||
|
||||
- When running an experiment, remember to save the UID information of the experiment.
|
||||
- When you want to end the experiment corresponding to the UID, you need to send an HTTP DELETE request to the `/api/attack/{uid}` path of Chaosd service.
|
||||
|
||||
:::
|
||||
|
||||
### Throw custom exceptions using service mode
|
||||
|
||||
#### Parameters for throwing custom exceptions
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "exception" |
|
||||
| `class` | The name of the Java class | string type, required |
|
||||
| `exception` | The thrown custom exception | string type, required |
|
||||
| `method` | The name of the method | string type, required |
|
||||
| `pid` | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | The port number attached to the Java process agent. The faults is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for throwing custom exceptions using service mode
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"exception","class":"Main","method":"sayhello","exception":"java.io.IOException(\"BOOM\")","pid":1828622}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"c3c519bf-819a-4a7b-97fb-e3d0814481fa"}
|
||||
```
|
||||
|
||||
### Trigger garbage collection using service mode
|
||||
|
||||
#### Parameters for triggering garbage collection
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "gc" |
|
||||
| `pid` | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for triggering garbage collection using service mode
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"gc","pid":1828622}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"c3c519bf-819a-4a7b-97fb-e3d0814481fa"}
|
||||
```
|
||||
|
||||
Triggering garbage collection is a one-time operation. The experiment does not require recovery.
|
||||
|
||||
### Increase method latency using service mode
|
||||
|
||||
#### Parameters for increasing method latency
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "latency" |
|
||||
| `class` | The name of the Java class | string type, required |
|
||||
| `latency` | The duration of increasing method latency | int type, required. The unit is milisecond. |
|
||||
| `method` | The name of the method | string type, required |
|
||||
| `pid` | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | The Java process ID where the fault is needed to be injected | int type, required |
|
||||
| `uid` | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for increasing method latency using service mode
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"latency","class":"Main","method":"sayhello","latency":5000,"pid":1828622}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### Modify return values of a method using service mode
|
||||
|
||||
#### Parameters for modifying return values of a method
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "return" |
|
||||
| `class` | The name of the Java class | string type, required |
|
||||
| `method` | The name of the method | string type, required |
|
||||
| `value` | Specifies the return value of the method | string type, required. Currently, the item can be numeric and string types. If the item (return value) is string, double quotes are required, like "chaos". |
|
||||
| `pid` | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for modifying return values of a method using service mode
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"return","class":"Main","method":"getnum","value":"999","pid":1828622}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### Trigger faults by setting Byteman configuration files using service mode
|
||||
|
||||
You can set the fault rules according to the Byteman rule configuration. Regarding to the Byteman rule configuration, refer to [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language).
|
||||
|
||||
#### Parameters for triggering faults by setting Byteman configuration files
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "rule-data" |
|
||||
| `rule-data` | Specifies the Byteman configuration data | string type, required |
|
||||
| `pid` | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for triggering faults by setting Byteman configuration files using service mode
|
||||
|
||||
First, based on the specific Java program and referring to [the Byteman rule language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language), write a rule configuration file. For example:
|
||||
|
||||
```txt
|
||||
RULE modify return value
|
||||
CLASS Main
|
||||
METHOD getnum
|
||||
AT ENTRY
|
||||
IF true
|
||||
DO
|
||||
return 9999
|
||||
ENDRULE
|
||||
```
|
||||
|
||||
Then, convert the line breaks in the configuration file to the newline character "\n", and use the converted text as the value of "rule-data". Run the following command:
|
||||
|
||||
```bash
|
||||
curl -X POST 127.0.0.1:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"rule-data","pid":30045,"rule-data":"\nRULE modify return value\nCLASS Main\nMETHOD getnum\nAT ENTRY\nIF true\nDO return 9999\nENDRULE\n"}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### Increase JVM stress using service mode
|
||||
|
||||
#### Parameters for increasing JVM stress
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "stress" |
|
||||
| `cpu-count` | The number of CPU cores used for increasing CPU stress | int type. You can only configure one of `cpu-count` and `mem-type`. |
|
||||
| `mem-type` | The type of OOM | string type. Currently, both 'stack' and 'heap' OOM types are supported. You can only configure one of `cpu-count` and `mem-type`. |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for increasing JVM stress using service mode
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"stress","cpu-count":1,"pid":1828622}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
|
@ -1,5 +1,152 @@
|
|||
---
|
||||
title: Simulate Faults on Physical Machine
|
||||
title: Simulate Faults on Physical Machines
|
||||
---
|
||||
|
||||
## TODO
|
||||
This document describes how to create PhysicalMachineChaos (physical machine chaos) experiments in Chaos Mesh to simulate the faults of network, disk, pressure, JVM, time, and others in physical or virtual machines.
|
||||
|
||||
## Introduction to PhysicalMachineChaos
|
||||
|
||||
You can use PhysicalMachineChaos to simulate the faults of network, disk, pressure, JVM, time, and others in physical or virtual machines.
|
||||
|
||||
## Deploy Chaosd server
|
||||
|
||||
Before creating PhysicalMachineChaos experiments using Chaos Mesh, you need to deploy Chaosd in service mode to all physical or virtual machines that are going to be injected with faults. For the deployment method of Chaosd, refer to [Download and deploy Chaosd](chaosd-overview.md#download-and-deploy).
|
||||
|
||||
After the deployment is complete, run the following command to start Chaosd in service mode:
|
||||
|
||||
```bash
|
||||
chaosd server --port 31767
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
When using Chaos Mesh v2.1.0, you need to deploy Chaosd [v1.1.0](https://github.com/chaos-mesh/chaosd/releases/tag/v1.1.0).
|
||||
|
||||
:::
|
||||
|
||||
## Create experiments using Chaos Dashboard
|
||||
|
||||
1. Open Chaos Dashboard, and click **NEW EXPERIMENT** on the page to create a new experiment:
|
||||
|
||||

|
||||
|
||||
2. Click **PHYSIC** in **Experiment Type** and choose a specific type of the experiment, such as **NETWORK ATTACK**. Then, choose a specific behavior and fill out the corresponding configurations:
|
||||
|
||||

|
||||
|
||||
3. Fill out the experiment information to specify the range and the planned duration of the experiment:
|
||||
|
||||

|
||||
|
||||
4. Submit the experiment.
|
||||
|
||||
## Create experiments using an YAML file
|
||||
|
||||
1. Write the experimental configurations to the "physicalmachine.yaml" file. For example:
|
||||
|
||||
```yaml
|
||||
apiVersion: chaos-mesh.org/v1alpha1
|
||||
kind: PhysicalMachineChaos
|
||||
metadata:
|
||||
name: physical-network-delay
|
||||
namespace: chaos-testing
|
||||
spec:
|
||||
action: network-delay
|
||||
address:
|
||||
- 172.16.112.130:31767
|
||||
network-delay:
|
||||
device: ens33
|
||||
ip-address: 140.82.112.3
|
||||
latency: 1000ms
|
||||
duration: '10m'
|
||||
```
|
||||
|
||||
The experimental configurations above send HTTP requests to Chaosd service in the specified physical machines or virtual machines to trigger network latency experiments.
|
||||
|
||||
2. Create the experiment using `kubectl`. The command is as follows:
|
||||
|
||||
```bash
|
||||
kubectl apply -f physicalmachine.yaml
|
||||
```
|
||||
|
||||
### Configuration description
|
||||
|
||||
| Configuration item | Type | Description | Default value | Required | Example |
|
||||
| :-- | :-- | :-- | :-- | :-- | :-- |
|
||||
| action | string | Defines the actions of physical machines faults, optional values are as follows: "stress-cpu", "stress-mem", "disk-read-payload", "disk-write-payload", "disk-fill", "network-corrupt", "network-duplicate", "network-loss", "network-delay", "network-partition", "network-dns", "process", "jvm-exception", "jvm-gc", "jvm-latency", "jvm-return", "jvm-stress", "jvm-rule-data", "clock" | None | Yes | "stress-cpu" |
|
||||
| address | string array | Selects the address of Chaosd service to inject faults | [] | Yes | ["192.168.0.10:31767"] |
|
||||
| duration | string | Specifies the duration of experiments | None | Yes | 30s |
|
||||
|
||||
Each fault action has its own specific configurations. The following section introduces various fault types and their corresponding configuration methods.
|
||||
|
||||
#### CPU stress
|
||||
|
||||
To simulate a CPU stress scenario, you need to set the action to "stress-cpu". For the corresponding configurations, refer to Parameters of simulating CPU stress.
|
||||
|
||||
#### Memory stress
|
||||
|
||||
To simulate a memory stress scenario, you need to set the action to "stress-mem". For the corresponding configurations, refer to Parameters of simulating memory stress.
|
||||
|
||||
#### Disk read load
|
||||
|
||||
To simulate a disk read load scenario, you need to set the action to "disk-read-payload". For the corresponding configurations, refer to Parameters of simulating disk read load.
|
||||
|
||||
#### Disk write load
|
||||
|
||||
To simulate a disk write load scenario, you need to set the action to "disk-write-payload". For the corresponding configurations, refer to Parameters of simulating disk write load.
|
||||
|
||||
#### Disk fill
|
||||
|
||||
To simulate a disk fill scenario, you need to set the action to "disk-fill". For the corresponding configurations, refer to Parameters of simulating disk fill.
|
||||
|
||||
#### Network corruption
|
||||
|
||||
To simulate a network corruption scenario, you need to set the action to "network-corrupt". For the corresponding configurations, refer to Parameters of simulating network corruption.
|
||||
|
||||
#### Network latency
|
||||
|
||||
To simulate a network latency scenario, you need to set the action to "network-delay". For the corresponding configurations, refer to Parameters of simulating network latency.
|
||||
|
||||
#### Network duplication
|
||||
|
||||
To simulate a network duplication scenario, you need to set the action to "network-duplicate". For the corresponding configurations, refer to Parameters of simulating network duplication.
|
||||
|
||||
#### Network loss
|
||||
|
||||
To simulate a network loss scenario, you need to set the action to "network-loss". For the corresponding configurations, refer to Parameters of simulating network loss.
|
||||
|
||||
#### Network partition
|
||||
|
||||
To simulate a network partition scenario, you need to set the action to "network-partition". For the corresponding configurations, refer to Parameters of simulating network partition.
|
||||
|
||||
#### DNS fault
|
||||
|
||||
To simulate a DNS fault scenario, you need to set the action to "network-dns". For the corresponding configurations, refer to Parameters of simulating DNS fault.
|
||||
|
||||
#### Process fault
|
||||
|
||||
To simulate a process fault scenario, you need to set the action to "process". For the corresponding configurations, refer to Parameters of simulating process fault.
|
||||
|
||||
#### Throw custom exceptions for JVM applications
|
||||
|
||||
To simulate a scenario that JVM applications throw custom exceptions, you need to set the action to "jvm-exception". For the corresponding configurations, refer to Parameters for throwing custom exceptions.
|
||||
|
||||
#### Increase method latency for JVM applications
|
||||
|
||||
To simulate a scenario that JVM applications increase method latency, you need to set the action to "jvm-latency". For the corresponding configurations, refer to Parameters for increasing method latency.
|
||||
|
||||
#### Modify return values of methods for JVM applications
|
||||
|
||||
To simulate a scenario that JVM applications modify return values of methods, you need to set the action to "jvm-return". For the corresponding configurations, refer to Parameters for modifying return values of a method.
|
||||
|
||||
#### Trigger garbage collection for JVM applications
|
||||
|
||||
To simulate a scenario that JVM applications trigger garbage collection, you need to set the action to "jvm-gc". For the corresponding configurations, refer to Parameters for triggering garbage collection.
|
||||
|
||||
#### Trigger faults using Byteman configuration files for JVM applications
|
||||
|
||||
To simulate a scenario that JVM applications trigger faults using Byteman configuration files, you need to set the action to "jvm-rule-data". For the corresponding configurations, refer to Parameters for triggering faults by setting Byteman configuration files.
|
||||
|
||||
#### Time offset
|
||||
|
||||
To simulate a time offset scenario, you need to set the action to "clock". For the corresponding configurations, refer to Parameters of simulating time offset.
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
---
|
||||
title: Simulate time chaos
|
||||
title: Simulate Time Faults
|
||||
summary: This document describes how to use Chaosd to simulate a time offset scenario.
|
||||
---
|
||||
|
||||
This document describes how to use Chaosd to simulate a time offset scenario. You can create experiments either in command-line mode or service mode.
|
||||
|
||||
## Create experiments using commands
|
||||
## Create experiments using command-line mode
|
||||
|
||||
This section describes how to create time chaos experiments using commands.
|
||||
This section describes how to create time fault experiments using commands.
|
||||
|
||||
Before creating an experiment, you can run the following command to check the options of time chaos:
|
||||
Before creating an experiment, you can run the following command to check the options of time faults:
|
||||
|
||||
```
|
||||
chaosd attack clock -h
|
||||
|
|
@ -68,7 +68,7 @@ Then execute get_time and try to attack it. The following is an example:
|
|||
chaosd attack clock -p $PID -t 11s
|
||||
```
|
||||
|
||||
### Configurations of simulating time chaos
|
||||
### Configurations of simulating time faults
|
||||
|
||||
| Parameter | Type | Note | Default value | Required | Example |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ Fill file /home/andrew/chaosd/bin/example623832242 successfully, uid: 097b4214-8
|
|||
| process-num | 指定使用多少个并发运行的 [dd](https://man7.org/linux/man-pages/man1/dd.1.html) 进程执行程序。 | uint8 类型,默认值为 1,范围为 1-255 |
|
||||
| size | 指定读取多少数据。size 为 多个 dd 读数据的总量。 | string 类型,默认为"",必须要设置。合法形式为一个整数加一个单位。例如:1M、512kB。支持的单位有 c=1、w=2、b=512、kB=1000、K=1024、MB=1000\*1000,M=1024\*1024、GB=1000\*1000\*1000、G=1024\*1024\*1024 BYTE 等。 |
|
||||
|
||||
#### 模拟磁盘读负载示例
|
||||
#### 使用服务模式模拟磁盘读负载示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"read-payload","path":"/dev/zero", "payload-process-num":7,"size":"1000G"}'
|
||||
|
|
@ -239,7 +239,7 @@ curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/j
|
|||
|
||||
读负载为一次性操作,实验不需要恢复。
|
||||
|
||||
### 服务模式模拟磁盘写负载
|
||||
### 使用服务模式模拟磁盘写负载
|
||||
|
||||
本模块介绍使用服务模式创建磁盘写负载实验时所涉及到的相关配置说明与实验创建示例。
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/j
|
|||
| process-num | 指定使用多少个并发运行的 [dd](https://man7.org/linux/man-pages/man1/dd.1.html) 进程执行程序。 | uint8 类型。默认值为 1,范围为 1-255 |
|
||||
| size | 指定写入多少数据,size 为 多个 dd 写数据的总量。 | string 类型,默认为"",合法形式为一个整数加一个单位。例如:1M、512kB。支持的单位有 c=1、w=2、b=512、kB=1000、K=1024、MB=1000\*1000,M=1024\*1024、GB=1000\*1000\*1000、G=1024\*1024\*1024 BYTE 等。size 不能为 "" 。 |
|
||||
|
||||
#### 模拟磁盘写负载示例
|
||||
#### 使用服务模式模拟磁盘写负载示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"write-payload","path":"/tmp/test", "payload-process-num":7,"size":"1000G"}'
|
||||
|
|
@ -279,7 +279,7 @@ curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/j
|
|||
| percent | 指定填充多少百分比磁盘。 | string 类型,默认为 "",可以填入 uint 类型的正整数,size 和 percent 不能同时为 "" |
|
||||
| size | 指定写入多少数据。 | string 类型,默认为"",合法形式为一个整数加一个单位。例如:1M、512kB。支持的单位有 c=1、w=2、b=512、kB=1000、K=1024、MB=1000\*1000,M=1024\*1024、GB=1000\*1000\*1000、G=1024\*1024\*1024 BYTE 等。size 和 percent 不能同时为 ""。 |
|
||||
|
||||
#### 模拟磁盘填充示例
|
||||
#### 使用服务模式模拟磁盘填充示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"fill","path":"/tmp/test", "fill-by-fallocate":true,"percent":"50"}'
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ Attack stress mem successfully, uid: c2bff2f5-3aac-4ace-b7a6-322946ae6f13
|
|||
```
|
||||
2. 向 chaosd 服务的路径 /api/attack/stress 发送 HTTP POTST 请求。 `bash curl -X POST 172.16.112.130:31767/api/attack/stress -H "Content-Type:application/json" -d '{fault-configuration}' ` 其中 `fault-configuration` 需要按照故障类型进行配置,对应的配置参数请参考下文中各个类型故障的相关参数说明和命令示例。 在运行实验时,请注意保存实验的 uid 信息,当要结束 uid 对应的实验时,需要向 chaosd 服务的路径 /api/attack/{uid} 发送 HTTP DELETE 请求。
|
||||
|
||||
### 服务模式模拟 CPU 压力场景
|
||||
### 服务模式下模拟 CPU 压力场景
|
||||
|
||||
#### 模拟 CPU 压力相关参数说明
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ Attack stress mem successfully, uid: c2bff2f5-3aac-4ace-b7a6-322946ae6f13
|
|||
| workers | 指定用于生成 CPU 压力的 worker 数量 | int 类型,默认值为 1 |
|
||||
| options | stress-ng 的其他参数设置,一般情况下不需要配置 | string 类型,默认值为 "" |
|
||||
|
||||
#### 服务模式模拟 CPU 压力示例
|
||||
#### 服务模式下模拟 CPU 压力示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/stress -H "Content-Type:application/json" -d '{"load":10, "action":"cpu","workers":1}'
|
||||
|
|
@ -168,7 +168,7 @@ curl -X POST 172.16.112.130:31767/api/attack/stress -H "Content-Type:application
|
|||
{"status":200,"message":"attack successfully","uid":"c3c519bf-819a-4a7b-97fb-e3d0814481fa"}
|
||||
```
|
||||
|
||||
### 服务模式模拟内存压力场景
|
||||
### 服务模式下模拟内存压力场景
|
||||
|
||||
#### 模拟内存压力相关参数说明
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ curl -X POST 172.16.112.130:31767/api/attack/stress -H "Content-Type:application
|
|||
| size | 指定每个 vm worker 占用内存的大小 | string 类型,支持使用单位 B,KB/KiB,MB/MiB,GB/GiB,TB/TiB 来设置占用的内存大小。如果不设置,则默认占用所有可用的内存。 |
|
||||
| options | stress-ng 的其他参数设置,一般情况下不需要配置 | string 类型,默认值为 "" |
|
||||
|
||||
#### 服务模式模拟内存压力示例
|
||||
#### 服务模式下模拟内存压力示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/stress -H "Content-Type:application/json" -d '{"size":"100M", "action":"mem"}'
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Chaosd 通过 [Byteman](https://github.com/chaos-mesh/byteman) 模拟 JVM 应用
|
|||
- 设置 Byteman 配置文件触发故障
|
||||
- 增加 JVM 压力
|
||||
|
||||
本文主要介绍如何创建以上故障类型的 JVM 实验。
|
||||
本文主要介绍如何通过 Chaosd 创建以上故障类型的 JVM 实验。
|
||||
|
||||
## 使用命令行模式创建实验
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ Global Flags:
|
|||
Use "chaosd attack jvm [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
### 抛出自定义异常
|
||||
### 使用命令行模式模拟抛出自定义异常
|
||||
|
||||
#### 抛出自定义异常命令
|
||||
|
||||
|
|
@ -90,8 +90,8 @@ Global Flags:
|
|||
| exception | 无 | 抛出的自定义异常 | string 类型,必须配置 |
|
||||
| method | m | 方法名称 | string 类型,必须配置 |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,因为 Chaosd 会随机生成一个 |
|
||||
|
||||
#### 抛出自定义异常示例
|
||||
|
||||
|
|
@ -106,11 +106,11 @@ chaosd attack jvm exception -c Main -m sayhello --exception 'java.io.IOException
|
|||
Attack jvm successfully, uid: 26a45ae2-d395-46f5-a126-2b2c6c85ae9d
|
||||
```
|
||||
|
||||
### 触发垃圾回收
|
||||
### 使用命令行模式模拟触发垃圾回收
|
||||
|
||||
#### 触发垃圾回收命令
|
||||
|
||||
运行以下命令查看抛出自定义异常场景支持的配置:
|
||||
运行以下命令查看抛出触发垃圾回收场景支持的配置:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm gc --help
|
||||
|
|
@ -137,7 +137,7 @@ Global Flags:
|
|||
| 配置项 | 配置缩写 | 说明 | 值 |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 触发垃圾回收示例
|
||||
|
|
@ -155,7 +155,7 @@ Attack jvm successfully, uid: f360e70a-5359-49b6-8526-d7e0a3c6f696
|
|||
|
||||
触发垃圾回收为一次性操作,实验不需要恢复。
|
||||
|
||||
### 增加方法延迟
|
||||
### 使用命令行模式模拟增加方法延迟
|
||||
|
||||
#### 增加方法延迟命令
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ Global Flags:
|
|||
| latency | 无 | 增加方法的延迟时间 | int 类型,必须配置,单位为 ms |
|
||||
| method | m | 方法名称 | string 类型,必须配置 |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 增加方法延迟示例
|
||||
|
|
@ -209,7 +209,7 @@ chaosd attack jvm latency --class Main --method sayhello --latency 5000 --pid 10
|
|||
Attack jvm successfully, uid: bbe00c57-ac9d-4113-bf0c-2a6f184be261
|
||||
```
|
||||
|
||||
### 修改方法返回值
|
||||
### 使用命令行模式模拟修改方法返回值
|
||||
|
||||
#### 修改方法返回值命令
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ Global Flags:
|
|||
| method | m | 方法名称 | string 类型,必须配置 |
|
||||
| value | 无 | 指定方法的返回值 | string 类型,必须配置。目前支持数字和字符串类型的返回值,如果为字符串,则需要使用双引号,例如:"chaos"。 |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 修改方法返回值示例
|
||||
|
|
@ -261,9 +261,9 @@ chaosd attack jvm return --class Main --method getnum --value 999 --pid 112694
|
|||
Attack jvm successfully, uid: e2f204f6-4bed-4d92-aade-2b4a47b02e5d
|
||||
```
|
||||
|
||||
### 设置 Byteman 配置文件触发故障
|
||||
### 命令行模式下设置 Byteman 配置文件触发故障
|
||||
|
||||
通过 Byteman 规则配置文件来设置故障规则,然后使用 Chaosd 指定该文件路径来注入故障。关于 Byteman 的规则配置,请参考 [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language)。
|
||||
你可以先在 Byteman 规则配置文件中设置故障规则,然后再通过使用 Chaosd 指定该文件路径的方式注入故障。关于 Byteman 的规则配置,请参考 [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language)。
|
||||
|
||||
#### 设置 Byteman 配置文件触发故障命令
|
||||
|
||||
|
|
@ -296,7 +296,7 @@ Global Flags:
|
|||
| :-- | :-- | :-- | :-- |
|
||||
| path | 无 | 指定 Byteman 配置文件的路径 | string 类型,必须配置 |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 设置 Byteman 配置文件触发故障示例
|
||||
|
|
@ -314,7 +314,7 @@ DO
|
|||
ENDRULE
|
||||
```
|
||||
|
||||
将该文件保存到文件 `return.btm`,然后运行以下命令注入故障:
|
||||
其次,将该配置文件保存到文件 `return.btm` 后,运行以下命令注入故障:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm rule-file -p ./return.btm --pid 112694
|
||||
|
|
@ -328,7 +328,7 @@ chaosd attack jvm rule-file -p ./return.btm --pid 112694
|
|||
Attack jvm successfully, uid: 5ca2e06d-a7c6-421d-bb67-0c9908bac17a
|
||||
```
|
||||
|
||||
### 增加 JVM 压力
|
||||
### 使用命令行模式模拟增加 JVM 压力
|
||||
|
||||
#### 增加 JVM 压力命令
|
||||
|
||||
|
|
@ -361,9 +361,9 @@ Global Flags:
|
|||
| 配置项 | 配置缩写 | 说明 | 值 |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| cpu-count | 无 | 增加 CPU 压力所使用的 CPU 核的数量 | int 类型,`cpu-count` 和 `mem-type` 只能配置一个 |
|
||||
| mem-type | 无 | OOM 的类型 | string 类型,目前支持 'stack' 和 'heap' 两种 OOM 类型。cpu-count 和 mem-type 只能配置一个 |
|
||||
| mem-type | 无 | OOM 的类型 | string 类型,目前支持 'stack' 和 'heap' 两种 OOM 类型。`cpu-count` 和 `mem-type` 只能配置一个。 |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 增加 JVM 压力示例
|
||||
|
|
@ -390,9 +390,16 @@ Attack jvm successfully, uid: b9b997b5-0a0d-4f1f-9081-d52a32318b84
|
|||
chaosd server --port 31767
|
||||
```
|
||||
|
||||
2. 向 chaosd 服务的路径 /api/attack/jvm 发送 HTTP POTST 请求。其中,`bash curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{fault-configuration}'` 的 `fault-configuration` 需要按照故障类型进行配置,其对应的配置参数请参考下文中各个类型故障的相关参数说明和命令示例。在运行实验时,请注意保存实验的 UID 信息,当要结束 UID 对应的实验时,需要向 Chaosd 服务的路径 /api/attack/{uid} 发送 HTTP DELETE 请求。
|
||||
2. 向 chaosd 服务的路径 /api/attack/jvm 发送 HTTP POTST 请求。其中,`bash curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{fault-configuration}'` 的 `fault-configuration` 需要按照故障类型进行配置,其对应的配置参数请参考下文中各个类型故障的相关参数说明和命令示例。
|
||||
|
||||
### 服务模式抛出自定义异常
|
||||
::: note 注意
|
||||
|
||||
- 在运行实验时,请注意保存实验的 UID 信息。
|
||||
- 当要结束 UID 对应的实验时,需要向 Chaosd 服务的路径 /api/attack/{uid} 发送 HTTP DELETE 请求。
|
||||
|
||||
:::
|
||||
|
||||
### 使用服务模式模拟抛出自定义异常
|
||||
|
||||
#### 抛出自定义异常相关参数说明
|
||||
|
||||
|
|
@ -403,10 +410,10 @@ Attack jvm successfully, uid: b9b997b5-0a0d-4f1f-9081-d52a32318b84
|
|||
| exception | 抛出的自定义异常 | string 类型,必须配置 |
|
||||
| method | 方法名称 | string 类型,必须配置 |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务模式抛出自定义异常示例
|
||||
#### 使用服务模式模拟抛出自定义异常示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"exception","class":"Main","method":"sayhello","exception":"java.io.IOException(\"BOOM\")","pid":1828622}'
|
||||
|
|
@ -418,7 +425,7 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
{"status":200,"message":"attack successfully","uid":"c3c519bf-819a-4a7b-97fb-e3d0814481fa"}
|
||||
```
|
||||
|
||||
### 服务模式触发垃圾回收
|
||||
### 使用服务模式模拟触发垃圾回收
|
||||
|
||||
#### 触发垃圾回收相关参数说明
|
||||
|
||||
|
|
@ -426,10 +433,10 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
| :-- | :-- | :-- |
|
||||
| action | 实验的行为 | 设置为 "gc" |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务模式触发垃圾回收示例
|
||||
#### 使用服务模式模拟触发垃圾回收示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"gc","pid":1828622}'
|
||||
|
|
@ -443,7 +450,7 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
|
||||
触发垃圾回收为一次性操作,实验不需要恢复。
|
||||
|
||||
### 服务模式增加方法延迟
|
||||
### 使用服务模式模拟增加方法延迟
|
||||
|
||||
#### 增加方法延迟相关参数说明
|
||||
|
||||
|
|
@ -454,10 +461,10 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
| latency | 增加方法的延迟时间 | int 类型,必须配置,单位为 ms |
|
||||
| method | 方法名称 | string 类型,必须配置 |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务增加方法延迟示例
|
||||
#### 使用服务模式模拟增加方法延迟示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"latency","class":"Main","method":"sayhello","latency":5000,"pid":1828622}'
|
||||
|
|
@ -469,7 +476,7 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### 服务模式修改方法返回值
|
||||
### 使用服务模式模拟修改方法返回值
|
||||
|
||||
#### 修改方法返回值相关参数说明
|
||||
|
||||
|
|
@ -480,10 +487,10 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
| method | 方法名称 | string 类型,必须配置 |
|
||||
| value | 指定方法的返回值 | string 类型,必须配置。目前支持数字和字符串类型的返回值,如果为字符串,则需要使用双引号,例如:"chaos"。 |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务模式修改方法返回值示例
|
||||
#### 使用服务模式模拟修改方法返回值示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"return","class":"Main","method":"getnum","value":"999","pid":1828622}'
|
||||
|
|
@ -495,21 +502,21 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### 服务模式设置 Byteman 配置触发故障
|
||||
### 服务模式下设置 Byteman 配置文件触发故障
|
||||
|
||||
通过 Byteman 规则配置来设置故障规则。关于 Byteman 的规则配置,请参考 [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language)。
|
||||
|
||||
#### 设置 Byteman 配置触发故障相关参数说明
|
||||
#### 设置 Byteman 配置文件触发故障相关参数说明
|
||||
|
||||
| 参数 | 说明 | 值 |
|
||||
| :-- | :-- | :-- |
|
||||
| action | 实验的行为 | 设置为 "rule-data" |
|
||||
| rule-data | 指定 Byteman 配置数据 | string 类型,必须配置 |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务模式设置 Byteman 配置触发故障示例
|
||||
#### 服务模式下设置 Byteman 配置文件触发故障示例
|
||||
|
||||
首先根据具体的 Java 程序,并参考 [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language) 编写一个规则配置文件,例如:
|
||||
|
||||
|
|
@ -524,7 +531,7 @@ DO
|
|||
ENDRULE
|
||||
```
|
||||
|
||||
将配置中的换行转换为换行符 "\n",将转换后的数据设置为参数 "rule-data" 的值,运行如下命令:
|
||||
其次,通过如下命令把配置中的换行转换为换行符 "\n",并将转换后的数据设置为参数 "rule-data" 的值:
|
||||
|
||||
```bash
|
||||
curl -X POST 127.0.0.1:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"rule-data","pid":30045,"rule-data":"\nRULE modify return value\nCLASS Main\nMETHOD getnum\nAT ENTRY\nIF true\nDO return 9999\nENDRULE\n"}'
|
||||
|
|
@ -536,7 +543,7 @@ curl -X POST 127.0.0.1:31767/api/attack/jvm -H "Content-Type:application/json" -
|
|||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### 服务模式增加 JVM 压力
|
||||
### 使用服务模式模拟增加 JVM 压力
|
||||
|
||||
#### 增加 JVM 压力相关参数说明
|
||||
|
||||
|
|
@ -544,12 +551,12 @@ curl -X POST 127.0.0.1:31767/api/attack/jvm -H "Content-Type:application/json" -
|
|||
| :-- | :-- | :-- |
|
||||
| action | 实验的行为 | 设置为 "stress" |
|
||||
| cpu-count | 增加 CPU 压力所使用的 CPU 核的数量 | int 类型,`cpu-count` 和 `mem-type` 中必须配置一个 |
|
||||
| mem-type | OOM 的类型 | string 类型,目前支持 'stack' 和 'heap' 两种 OOM 类型。cpu-count 和 mem-type 只能配置一个 |
|
||||
| mem-type | OOM 的类型 | string 类型,目前支持 'stack' 和 'heap' 两种 OOM 类型。`cpu-count` 和 `mem-type` 中必须配置一个 |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务模式增加 JVM 压力示例
|
||||
#### 使用服务模式模拟增加 JVM 压力示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"stress","cpu-count":1,"pid":1828622}'
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ Use "chaosd attack network [command] --help" for more information about a comman
|
|||
|
||||
目前 Chaosd 支持模拟网络包错误(corrupt)、延迟(delay)、重复(duplicate)、丢失(loss)四种实验场景。
|
||||
|
||||
### 网络包错误
|
||||
### 使用命令行模式模拟网络包错误
|
||||
|
||||
通过运行网络包错误命令,可以查看模拟网络包错误场景支持的配置。
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ chaosd attack network corrupt -d eth0 -i 172.16.4.4 --percent 50
|
|||
Attack network successfully, uid: 4eab1e62-8d60-45cb-ac85-3c17b8ac4825
|
||||
```
|
||||
|
||||
### 网络包延迟
|
||||
### 使用命令行模式模拟网络包延迟
|
||||
|
||||
通过运行网络包延迟命令,查看模拟网络延迟场景支持的配置。
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ chaosd attack network delay -d eth0 -i 172.16.4.4 -l 10ms
|
|||
Attack network successfully, uid: 4b23a0b5-e193-4b27-90a7-3e04235f32ab
|
||||
```
|
||||
|
||||
### 网络包重复
|
||||
### 使用命令行模式模拟网络包重复
|
||||
|
||||
可以运行网络包重复命令,查看模拟网络包重复场景支持的配置:
|
||||
|
||||
|
|
@ -239,11 +239,11 @@ chaosd attack network duplicate -d eth0 -i 172.16.4.4 --percent 50
|
|||
Attack network successfully, uid: 7bcb74ee-9101-4ae4-82f0-e44c8a7f113c
|
||||
```
|
||||
|
||||
### 网络包丢失
|
||||
### 使用命令行模式模拟网络包丢失
|
||||
|
||||
可以运行网络包丢失命令,查看模拟网络包丢失场景支持的配置:
|
||||
|
||||
#### 网络包丢失命令
|
||||
#### 使用命令行模式模拟网络包丢失命令
|
||||
|
||||
具体命令如下所示:
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ chaosd attack network loss -d eth0 -i 172.16.4.4 --percent 50
|
|||
Attack network successfully, uid: 1e818adf-3942-4de4-949b-c8499f120265
|
||||
```
|
||||
|
||||
### 网络分区
|
||||
### 使用命令行模式模拟网络分区
|
||||
|
||||
可以运行网络分区命令,查看模拟网络分区场景支持的配置。
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ Global Flags:
|
|||
./chaosd attack network partition -i 172.16.4.4 -d eth0 --direction from
|
||||
```
|
||||
|
||||
### DNS 故障
|
||||
### 使用命令行模式模拟 DNS 故障
|
||||
|
||||
可以运行 DNS 故障命令,查看模拟 DNS 故障场景支持的配置。
|
||||
|
||||
|
|
@ -413,7 +413,7 @@ Global Flags:
|
|||
```
|
||||
2. 向 chaosd 服务的路径 /api/attack/network 发送 HTTP POTST 请求。 `bash curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{fault-configuration}' ` 其中 `fault-configuration` 需要按照故障类型进行配置,对应的配置参数请参考下文中各个类型故障的相关参数说明和命令示例。 在运行实验时,请注意保存实验的 uid 信息,当要结束 uid 对应的实验时,需要向 chaosd 服务的路径 /api/attack/{uid} 发送 HTTP DELETE 请求。
|
||||
|
||||
### 服务模式模拟网络包错误
|
||||
### 使用服务模式模拟网络包错误
|
||||
|
||||
在使用服务模拟网络包错误时,请参考如下内容。
|
||||
|
||||
|
|
@ -433,13 +433,13 @@ Global Flags:
|
|||
| source-port | 仅影响到指定目的端口的入口流量,仅当 protocol 为 tcp 或 udp 时配置 | string 类型,使用 "," 分隔指定的端口或者端口范围,如 "80,8001:8010" |
|
||||
| percent | 网络包错误的比例 | string 类型,取值范围为 0 到 100,表示百分比(10 表示 10%),默认值为 1 |
|
||||
|
||||
#### 服务模式模拟网络包错误示例
|
||||
#### 使用服务模式模拟网络包错误示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"corrupt","device":"eth0","ip-address":"172.16.4.4","percent":"50"}'
|
||||
```
|
||||
|
||||
### 服务模式模拟网络包延迟
|
||||
### 使用服务模式模拟网络包延迟
|
||||
|
||||
在使用服务模拟网络包延迟时,请参考如下内容。
|
||||
|
||||
|
|
@ -460,13 +460,13 @@ curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:applicatio
|
|||
| ip-protocol | 只影响指定的 IP 协议 | string 类型,支持协议类型包括:tcp、 udp、icmp、all(表示影响所有网络协议) |
|
||||
| source-port | 仅影响到指定目的端口的入口流量,仅当 protocol 为 tcp 或 udp 时配置 | string 类型,使用 "," 分隔指定的端口或者端口范围,如 "80,8001:8010" |
|
||||
|
||||
#### 服务模式模拟网络包延迟示例
|
||||
#### 使用服务模式模拟网络包延迟示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"delay","device":"eth0","ip-address":"172.16.4.4","latency":"10ms"}'
|
||||
```
|
||||
|
||||
### 服务模式模拟网络包重复
|
||||
### 使用服务模式模拟网络包重复
|
||||
|
||||
在使用服务模拟网络包重复时,请参考如下内容。
|
||||
|
||||
|
|
@ -486,13 +486,13 @@ curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:applicatio
|
|||
| ip-protocol | 只影响指定的 IP 协议 | string 类型,支持协议类型包括:tcp、 udp、icmp、all(表示影响所有网络协议) |
|
||||
| source-port | 仅影响到指定目的端口的入口流量,仅当 protocol 为 tcp 或 udp 时配置 | string 类型,使用 "," 分隔指定的端口或者端口范围,如 "80,8001:8010" |
|
||||
|
||||
#### 服务模式模拟网络包重复示例
|
||||
#### 使用服务模式模拟网络包重复示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"duplicate","ip-protocol":"172.16.4.4","device":"eth0","percent":"50"}'
|
||||
```
|
||||
|
||||
### 服务模式模拟网络包丢失
|
||||
### 使用服务模式模拟网络包丢失
|
||||
|
||||
在使用服务模拟网络包丢失时,请参考如下内容。
|
||||
|
||||
|
|
@ -512,14 +512,14 @@ curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:applicatio
|
|||
| ip-protocol | 只影响指定的 IP 协议 | string 类型,支持协议类型包括:tcp、 udp、icmp、all(表示影响所有网络协议) |
|
||||
| source-port | 仅影响到指定目的端口的入口流量,仅当 protocol 为 tcp 或 udp 时配置 | string 类型,使用 "," 分隔指定的端口或者端口范围,如 "80,8001:8010" |
|
||||
|
||||
#### 服务模式模拟网络包丢失示例
|
||||
#### 使用服务模式模拟网络包丢失示例
|
||||
|
||||
````bash
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"loss","ip-protocol":"172.16.4.4","device":"eth0","percent":"50"}'
|
||||
````
|
||||
|
||||
### 服务模式模拟网络分区
|
||||
### 使用服务模式模拟网络分区
|
||||
|
||||
在使用服务模拟网络分区时,请参考如下内容。
|
||||
|
||||
|
|
@ -543,7 +543,7 @@ curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:applicatio
|
|||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"partition","ip-protocol":"172.16.4.4","device":"eth0","direction":"from"}'
|
||||
```
|
||||
|
||||
### 服务模式模拟 DNS 故障
|
||||
### 使用服务模式模拟 DNS 故障
|
||||
|
||||
在使用服务模拟 DNS 故障时,请参考如下内容。
|
||||
|
||||
|
|
@ -558,7 +558,7 @@ curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:applicatio
|
|||
| dns-ip | 表示将影响的域名映射到该地址。 | string 类型,例如 "123.123.123.123" |
|
||||
| dns-server | 指定 DNS 服务地址。 | string 类型,默认值为 "123.123.123.123" |
|
||||
|
||||
#### 服务模式模拟 DNS 故障示例
|
||||
#### 使用服务模式模拟 DNS 故障示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"dns","dns-ip":"123.123.123.123","dns-domain-name":"chaos-mesh.org"}'
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ chaosd server --port 31767
|
|||
|
||||
## 使用 Dashboard 方式创建实验
|
||||
|
||||
1. 单击实验页面中的**新的实验**按钮创建实验:
|
||||
1. 打开 Chaos Dashboard 面板,单击实验页面中的**新的实验**按钮创建实验:
|
||||
|
||||

|
||||
|
||||
|
|
@ -105,7 +105,7 @@ chaosd server --port 31767
|
|||
|
||||
#### 网络包延迟
|
||||
|
||||
模拟网络包延迟,将 action 设置为 "network-delay",对应的配置可参考[网络包错误相关参数说明](simulate-network-chaos-in-physical-nodes.md#网络包错误相关参数说明)。
|
||||
模拟网络包延迟,将 action 设置为 "network-delay",对应的配置可参考[网络包延迟相关参数说明](simulate-network-chaos-in-physical-nodes.md#网络包延迟相关参数说明)。
|
||||
|
||||
#### 网络包重复
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ chaosd server --port 31767
|
|||
|
||||
#### DNS 故障
|
||||
|
||||
模拟 DNS 故障, 将 action 设置为 "network-dns",对应的配置可参考[DNS 故障相关参数说明](simulate-network-chaos-in-physical-nodes.md#DNS-故障相关参数说明)。
|
||||
模拟 DNS 故障, 将 action 设置为 "network-dns",对应的配置可参考 [DNS 故障相关参数说明](simulate-network-chaos-in-physical-nodes.md#DNS-故障相关参数说明)。
|
||||
|
||||
#### 进程故障
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ chaosd server --port 31767
|
|||
|
||||
模拟 JVM 应用触发垃圾回收,将 action 设置为 "jvm-gc",对应的配置可参考[触发垃圾回收相关参数说明](simulate-jvm-application-chaos-in-physical-nodes.md#触发垃圾回收相关参数说明)。
|
||||
|
||||
#### JVM 应用使用 Byteman 配置触发故障
|
||||
#### JVM 应用使用 Byteman 配置文件触发故障
|
||||
|
||||
JVM 应用使用 Byteman 配置触发故障,将 action 设置为 "jvm-rule-data",对应的配置可参考[设置 Byteman 配置触发故障相关参数说明](simulate-jvm-application-chaos-in-physical-nodes.md#设置-Byteman-配置触发故障相关参数说明)。
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ Use "chaosd attack process [command] --help" for more information about a comman
|
|||
|
||||
目前 Chaosd 支持模拟进程被终止或暂停的故障。
|
||||
|
||||
### 模拟进程被终止
|
||||
### 使用命令行模式模拟进程被终止
|
||||
|
||||
#### 模拟进程被终止命令
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ Attack process python successfully, uid: 10e633ac-0a37-41ba-8b4a-cd5ab92099f9
|
|||
|
||||
:::
|
||||
|
||||
### 模拟进程被暂停
|
||||
### 使用命令行模式模拟进程被暂停
|
||||
|
||||
#### 模拟进程被暂停命令
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ Attack process python successfully, uid: 9cb6b3be-4f5b-4ecb-ae05-51050fcd0010
|
|||
| process | 需要结束进程的名字或者进程的标识符 | string 类型,默认为 "" |
|
||||
| signal | 所提供的进程信号值 | int 类型,默认为 9。 |
|
||||
|
||||
#### 服务模式进程故障示例
|
||||
#### 使用服务模式模拟进程故障示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{"process":"12345","signal":15}'
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ title: 模拟时间故障
|
|||
|
||||
本文主要介绍如何使用 Chaosd 模拟时间偏移的场景。本功能支持通过命令行模式或服务模式创建实验。
|
||||
|
||||
## 通过命令行创建实验
|
||||
## 使用命令行模式创建实验
|
||||
|
||||
本节介绍如何在命令行模式中创建时间故障实验。
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ chaosd attack clock -p $PID -t 11s
|
|||
| time-offset | 指定时间的偏移量。 | string 类型,例如:"-5m" |
|
||||
| clock-ids-slice | 指定时间偏移作用的时钟,详见 [clock_gettime documentation](https://man7.org/linux/man-pages/man2/clock_gettime.2.html) 。 | string 数组类型,默认为 `["CLOCK_REALTIME"]` |
|
||||
|
||||
### 时间故障示例
|
||||
### 使用服务模式模拟时间故障示例
|
||||
|
||||
运行[快速使用](#快速使用)中的测试程序,使用以下命令创建时间故障:
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ Fill file /home/andrew/chaosd/bin/example623832242 successfully, uid: 097b4214-8
|
|||
| process-num | 指定使用多少个并发运行的 [dd](https://man7.org/linux/man-pages/man1/dd.1.html) 进程执行程序。 | uint8 类型,默认值为 1,范围为 1-255 |
|
||||
| size | 指定读取多少数据。size 为 多个 dd 读数据的总量。 | string 类型,默认为"",必须要设置。合法形式为一个整数加一个单位。例如:1M、512kB。支持的单位有 c=1、w=2、b=512、kB=1000、K=1024、MB=1000\*1000,M=1024\*1024、GB=1000\*1000\*1000、G=1024\*1024\*1024 BYTE 等。 |
|
||||
|
||||
#### 模拟磁盘读负载示例
|
||||
#### 使用服务模式模拟磁盘读负载示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"read-payload","path":"/dev/zero", "payload-process-num":7,"size":"1000G"}'
|
||||
|
|
@ -239,7 +239,7 @@ curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/j
|
|||
|
||||
读负载为一次性操作,实验不需要恢复。
|
||||
|
||||
### 服务模式模拟磁盘写负载
|
||||
### 使用服务模式模拟磁盘写负载
|
||||
|
||||
本模块介绍使用服务模式创建磁盘写负载实验时所涉及到的相关配置说明与实验创建示例。
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/j
|
|||
| process-num | 指定使用多少个并发运行的 [dd](https://man7.org/linux/man-pages/man1/dd.1.html) 进程执行程序。 | uint8 类型。默认值为 1,范围为 1-255 |
|
||||
| size | 指定写入多少数据,size 为 多个 dd 写数据的总量。 | string 类型,默认为"",合法形式为一个整数加一个单位。例如:1M、512kB。支持的单位有 c=1、w=2、b=512、kB=1000、K=1024、MB=1000\*1000,M=1024\*1024、GB=1000\*1000\*1000、G=1024\*1024\*1024 BYTE 等。size 不能为 "" 。 |
|
||||
|
||||
#### 模拟磁盘写负载示例
|
||||
#### 使用服务模式模拟磁盘写负载示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"write-payload","path":"/tmp/test", "payload-process-num":7,"size":"1000G"}'
|
||||
|
|
@ -279,7 +279,7 @@ curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/j
|
|||
| percent | 指定填充多少百分比磁盘。 | string 类型,默认为 "",可以填入 uint 类型的正整数,size 和 percent 不能同时为 "" |
|
||||
| size | 指定写入多少数据。 | string 类型,默认为"",合法形式为一个整数加一个单位。例如:1M、512kB。支持的单位有 c=1、w=2、b=512、kB=1000、K=1024、MB=1000\*1000,M=1024\*1024、GB=1000\*1000\*1000、G=1024\*1024\*1024 BYTE 等。size 和 percent 不能同时为 ""。 |
|
||||
|
||||
#### 模拟磁盘填充示例
|
||||
#### 使用服务模式模拟磁盘填充示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"fill","path":"/tmp/test", "fill-by-fallocate":true,"percent":"50"}'
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ Attack stress mem successfully, uid: c2bff2f5-3aac-4ace-b7a6-322946ae6f13
|
|||
```
|
||||
2. 向 chaosd 服务的路径 /api/attack/stress 发送 HTTP POTST 请求。 `bash curl -X POST 172.16.112.130:31767/api/attack/stress -H "Content-Type:application/json" -d '{fault-configuration}' ` 其中 `fault-configuration` 需要按照故障类型进行配置,对应的配置参数请参考下文中各个类型故障的相关参数说明和命令示例。 在运行实验时,请注意保存实验的 uid 信息,当要结束 uid 对应的实验时,需要向 chaosd 服务的路径 /api/attack/{uid} 发送 HTTP DELETE 请求。
|
||||
|
||||
### 服务模式模拟 CPU 压力场景
|
||||
### 服务模式下模拟 CPU 压力场景
|
||||
|
||||
#### 模拟 CPU 压力相关参数说明
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ Attack stress mem successfully, uid: c2bff2f5-3aac-4ace-b7a6-322946ae6f13
|
|||
| workers | 指定用于生成 CPU 压力的 worker 数量 | int 类型,默认值为 1 |
|
||||
| options | stress-ng 的其他参数设置,一般情况下不需要配置 | string 类型,默认值为 "" |
|
||||
|
||||
#### 服务模式模拟 CPU 压力示例
|
||||
#### 服务模式下模拟 CPU 压力示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/stress -H "Content-Type:application/json" -d '{"load":10, "action":"cpu","workers":1}'
|
||||
|
|
@ -168,7 +168,7 @@ curl -X POST 172.16.112.130:31767/api/attack/stress -H "Content-Type:application
|
|||
{"status":200,"message":"attack successfully","uid":"c3c519bf-819a-4a7b-97fb-e3d0814481fa"}
|
||||
```
|
||||
|
||||
### 服务模式模拟内存压力场景
|
||||
### 服务模式下模拟内存压力场景
|
||||
|
||||
#### 模拟内存压力相关参数说明
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ curl -X POST 172.16.112.130:31767/api/attack/stress -H "Content-Type:application
|
|||
| size | 指定每个 vm worker 占用内存的大小 | string 类型,支持使用单位 B,KB/KiB,MB/MiB,GB/GiB,TB/TiB 来设置占用的内存大小。如果不设置,则默认占用所有可用的内存。 |
|
||||
| options | stress-ng 的其他参数设置,一般情况下不需要配置 | string 类型,默认值为 "" |
|
||||
|
||||
#### 服务模式模拟内存压力示例
|
||||
#### 服务模式下模拟内存压力示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/stress -H "Content-Type:application/json" -d '{"size":"100M", "action":"mem"}'
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Chaosd 通过 [Byteman](https://github.com/chaos-mesh/byteman) 模拟 JVM 应用
|
|||
- 设置 Byteman 配置文件触发故障
|
||||
- 增加 JVM 压力
|
||||
|
||||
本文主要介绍如何创建以上故障类型的 JVM 实验。
|
||||
本文主要介绍如何通过 Chaosd 创建以上故障类型的 JVM 实验。
|
||||
|
||||
## 使用命令行模式创建实验
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ Global Flags:
|
|||
Use "chaosd attack jvm [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
### 抛出自定义异常
|
||||
### 使用命令行模式模拟抛出自定义异常
|
||||
|
||||
#### 抛出自定义异常命令
|
||||
|
||||
|
|
@ -90,8 +90,8 @@ Global Flags:
|
|||
| exception | 无 | 抛出的自定义异常 | string 类型,必须配置 |
|
||||
| method | m | 方法名称 | string 类型,必须配置 |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,因为 Chaosd 会随机生成一个 |
|
||||
|
||||
#### 抛出自定义异常示例
|
||||
|
||||
|
|
@ -106,11 +106,11 @@ chaosd attack jvm exception -c Main -m sayhello --exception 'java.io.IOException
|
|||
Attack jvm successfully, uid: 26a45ae2-d395-46f5-a126-2b2c6c85ae9d
|
||||
```
|
||||
|
||||
### 触发垃圾回收
|
||||
### 使用命令行模式模拟触发垃圾回收
|
||||
|
||||
#### 触发垃圾回收命令
|
||||
|
||||
运行以下命令查看抛出自定义异常场景支持的配置:
|
||||
运行以下命令查看抛出触发垃圾回收场景支持的配置:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm gc --help
|
||||
|
|
@ -137,7 +137,7 @@ Global Flags:
|
|||
| 配置项 | 配置缩写 | 说明 | 值 |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 触发垃圾回收示例
|
||||
|
|
@ -155,7 +155,7 @@ Attack jvm successfully, uid: f360e70a-5359-49b6-8526-d7e0a3c6f696
|
|||
|
||||
触发垃圾回收为一次性操作,实验不需要恢复。
|
||||
|
||||
### 增加方法延迟
|
||||
### 使用命令行模式模拟增加方法延迟
|
||||
|
||||
#### 增加方法延迟命令
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ Global Flags:
|
|||
| latency | 无 | 增加方法的延迟时间 | int 类型,必须配置,单位为 ms |
|
||||
| method | m | 方法名称 | string 类型,必须配置 |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 增加方法延迟示例
|
||||
|
|
@ -209,7 +209,7 @@ chaosd attack jvm latency --class Main --method sayhello --latency 5000 --pid 10
|
|||
Attack jvm successfully, uid: bbe00c57-ac9d-4113-bf0c-2a6f184be261
|
||||
```
|
||||
|
||||
### 修改方法返回值
|
||||
### 使用命令行模式模拟修改方法返回值
|
||||
|
||||
#### 修改方法返回值命令
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ Global Flags:
|
|||
| method | m | 方法名称 | string 类型,必须配置 |
|
||||
| value | 无 | 指定方法的返回值 | string 类型,必须配置。目前支持数字和字符串类型的返回值,如果为字符串,则需要使用双引号,例如:"chaos"。 |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 修改方法返回值示例
|
||||
|
|
@ -261,9 +261,9 @@ chaosd attack jvm return --class Main --method getnum --value 999 --pid 112694
|
|||
Attack jvm successfully, uid: e2f204f6-4bed-4d92-aade-2b4a47b02e5d
|
||||
```
|
||||
|
||||
### 设置 Byteman 配置文件触发故障
|
||||
### 命令行模式下设置 Byteman 配置文件触发故障
|
||||
|
||||
通过 Byteman 规则配置文件来设置故障规则,然后使用 Chaosd 指定该文件路径来注入故障。关于 Byteman 的规则配置,请参考 [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language)。
|
||||
你可以先在 Byteman 规则配置文件中设置故障规则,然后再通过使用 Chaosd 指定该文件路径的方式注入故障。关于 Byteman 的规则配置,请参考 [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language)。
|
||||
|
||||
#### 设置 Byteman 配置文件触发故障命令
|
||||
|
||||
|
|
@ -296,7 +296,7 @@ Global Flags:
|
|||
| :-- | :-- | :-- | :-- |
|
||||
| path | 无 | 指定 Byteman 配置文件的路径 | string 类型,必须配置 |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 设置 Byteman 配置文件触发故障示例
|
||||
|
|
@ -314,7 +314,7 @@ DO
|
|||
ENDRULE
|
||||
```
|
||||
|
||||
将该文件保存到文件 `return.btm`,然后运行以下命令注入故障:
|
||||
其次,将该配置文件保存到文件 `return.btm` 后,运行以下命令注入故障:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm rule-file -p ./return.btm --pid 112694
|
||||
|
|
@ -328,7 +328,7 @@ chaosd attack jvm rule-file -p ./return.btm --pid 112694
|
|||
Attack jvm successfully, uid: 5ca2e06d-a7c6-421d-bb67-0c9908bac17a
|
||||
```
|
||||
|
||||
### 增加 JVM 压力
|
||||
### 使用命令行模式模拟增加 JVM 压力
|
||||
|
||||
#### 增加 JVM 压力命令
|
||||
|
||||
|
|
@ -361,9 +361,9 @@ Global Flags:
|
|||
| 配置项 | 配置缩写 | 说明 | 值 |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| cpu-count | 无 | 增加 CPU 压力所使用的 CPU 核的数量 | int 类型,`cpu-count` 和 `mem-type` 只能配置一个 |
|
||||
| mem-type | 无 | OOM 的类型 | string 类型,目前支持 'stack' 和 'heap' 两种 OOM 类型。cpu-count 和 mem-type 只能配置一个 |
|
||||
| mem-type | 无 | OOM 的类型 | string 类型,目前支持 'stack' 和 'heap' 两种 OOM 类型。`cpu-count` 和 `mem-type` 只能配置一个。 |
|
||||
| pid | 无 | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 无 | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 无 | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 增加 JVM 压力示例
|
||||
|
|
@ -390,9 +390,16 @@ Attack jvm successfully, uid: b9b997b5-0a0d-4f1f-9081-d52a32318b84
|
|||
chaosd server --port 31767
|
||||
```
|
||||
|
||||
2. 向 chaosd 服务的路径 /api/attack/jvm 发送 HTTP POTST 请求。其中,`bash curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{fault-configuration}'` 的 `fault-configuration` 需要按照故障类型进行配置,其对应的配置参数请参考下文中各个类型故障的相关参数说明和命令示例。在运行实验时,请注意保存实验的 UID 信息,当要结束 UID 对应的实验时,需要向 Chaosd 服务的路径 /api/attack/{uid} 发送 HTTP DELETE 请求。
|
||||
2. 向 chaosd 服务的路径 /api/attack/jvm 发送 HTTP POTST 请求。其中,`bash curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{fault-configuration}'` 的 `fault-configuration` 需要按照故障类型进行配置,其对应的配置参数请参考下文中各个类型故障的相关参数说明和命令示例。
|
||||
|
||||
### 服务模式抛出自定义异常
|
||||
::: note 注意
|
||||
|
||||
- 在运行实验时,请注意保存实验的 UID 信息。
|
||||
- 当要结束 UID 对应的实验时,需要向 Chaosd 服务的路径 /api/attack/{uid} 发送 HTTP DELETE 请求。
|
||||
|
||||
:::
|
||||
|
||||
### 使用服务模式模拟抛出自定义异常
|
||||
|
||||
#### 抛出自定义异常相关参数说明
|
||||
|
||||
|
|
@ -403,10 +410,10 @@ Attack jvm successfully, uid: b9b997b5-0a0d-4f1f-9081-d52a32318b84
|
|||
| exception | 抛出的自定义异常 | string 类型,必须配置 |
|
||||
| method | 方法名称 | string 类型,必须配置 |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务模式抛出自定义异常示例
|
||||
#### 使用服务模式模拟抛出自定义异常示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"exception","class":"Main","method":"sayhello","exception":"java.io.IOException(\"BOOM\")","pid":1828622}'
|
||||
|
|
@ -418,7 +425,7 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
{"status":200,"message":"attack successfully","uid":"c3c519bf-819a-4a7b-97fb-e3d0814481fa"}
|
||||
```
|
||||
|
||||
### 服务模式触发垃圾回收
|
||||
### 使用服务模式模拟触发垃圾回收
|
||||
|
||||
#### 触发垃圾回收相关参数说明
|
||||
|
||||
|
|
@ -426,10 +433,10 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
| :-- | :-- | :-- |
|
||||
| action | 实验的行为 | 设置为 "gc" |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务模式触发垃圾回收示例
|
||||
#### 使用服务模式模拟触发垃圾回收示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"gc","pid":1828622}'
|
||||
|
|
@ -443,7 +450,7 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
|
||||
触发垃圾回收为一次性操作,实验不需要恢复。
|
||||
|
||||
### 服务模式增加方法延迟
|
||||
### 使用服务模式模拟增加方法延迟
|
||||
|
||||
#### 增加方法延迟相关参数说明
|
||||
|
||||
|
|
@ -454,10 +461,10 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
| latency | 增加方法的延迟时间 | int 类型,必须配置,单位为 ms |
|
||||
| method | 方法名称 | string 类型,必须配置 |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务增加方法延迟示例
|
||||
#### 使用服务模式模拟增加方法延迟示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"latency","class":"Main","method":"sayhello","latency":5000,"pid":1828622}'
|
||||
|
|
@ -469,7 +476,7 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### 服务模式修改方法返回值
|
||||
### 使用服务模式模拟修改方法返回值
|
||||
|
||||
#### 修改方法返回值相关参数说明
|
||||
|
||||
|
|
@ -480,10 +487,10 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
| method | 方法名称 | string 类型,必须配置 |
|
||||
| value | 指定方法的返回值 | string 类型,必须配置。目前支持数字和字符串类型的返回值,如果为字符串,则需要使用双引号,例如:"chaos"。 |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务模式修改方法返回值示例
|
||||
#### 使用服务模式模拟修改方法返回值示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"return","class":"Main","method":"getnum","value":"999","pid":1828622}'
|
||||
|
|
@ -495,21 +502,21 @@ curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/js
|
|||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### 服务模式设置 Byteman 配置触发故障
|
||||
### 服务模式下设置 Byteman 配置文件触发故障
|
||||
|
||||
通过 Byteman 规则配置来设置故障规则。关于 Byteman 的规则配置,请参考 [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language)。
|
||||
|
||||
#### 设置 Byteman 配置触发故障相关参数说明
|
||||
#### 设置 Byteman 配置文件触发故障相关参数说明
|
||||
|
||||
| 参数 | 说明 | 值 |
|
||||
| :-- | :-- | :-- |
|
||||
| action | 实验的行为 | 设置为 "rule-data" |
|
||||
| rule-data | 指定 Byteman 配置数据 | string 类型,必须配置 |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务模式设置 Byteman 配置触发故障示例
|
||||
#### 服务模式下设置 Byteman 配置文件触发故障示例
|
||||
|
||||
首先根据具体的 Java 程序,并参考 [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language) 编写一个规则配置文件,例如:
|
||||
|
||||
|
|
@ -524,7 +531,7 @@ DO
|
|||
ENDRULE
|
||||
```
|
||||
|
||||
将配置中的换行转换为换行符 "\n",将转换后的数据设置为参数 "rule-data" 的值,运行如下命令:
|
||||
其次,通过如下命令把配置中的换行转换为换行符 "\n",并将转换后的数据设置为参数 "rule-data" 的值:
|
||||
|
||||
```bash
|
||||
curl -X POST 127.0.0.1:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"rule-data","pid":30045,"rule-data":"\nRULE modify return value\nCLASS Main\nMETHOD getnum\nAT ENTRY\nIF true\nDO return 9999\nENDRULE\n"}'
|
||||
|
|
@ -536,7 +543,7 @@ curl -X POST 127.0.0.1:31767/api/attack/jvm -H "Content-Type:application/json" -
|
|||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### 服务模式增加 JVM 压力
|
||||
### 使用服务模式模拟增加 JVM 压力
|
||||
|
||||
#### 增加 JVM 压力相关参数说明
|
||||
|
||||
|
|
@ -544,12 +551,12 @@ curl -X POST 127.0.0.1:31767/api/attack/jvm -H "Content-Type:application/json" -
|
|||
| :-- | :-- | :-- |
|
||||
| action | 实验的行为 | 设置为 "stress" |
|
||||
| cpu-count | 增加 CPU 压力所使用的 CPU 核的数量 | int 类型,`cpu-count` 和 `mem-type` 中必须配置一个 |
|
||||
| mem-type | OOM 的类型 | string 类型,目前支持 'stack' 和 'heap' 两种 OOM 类型。cpu-count 和 mem-type 只能配置一个 |
|
||||
| mem-type | OOM 的类型 | string 类型,目前支持 'stack' 和 'heap' 两种 OOM 类型。`cpu-count` 和 `mem-type` 中必须配置一个 |
|
||||
| pid | 需要注入故障的 Java 进程号 | int 类型,必须配置 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 9288 |
|
||||
| port | 附加到 Java 进程 agent 的端口号,通过该端口号将故障注入到 Java 进程 | int 类型,默认为 `9288` |
|
||||
| uid | 实验的编号 | string 类型,可以不配置,Chaosd 会随机生成一个 |
|
||||
|
||||
#### 服务模式增加 JVM 压力示例
|
||||
#### 使用服务模式模拟增加 JVM 压力示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"stress","cpu-count":1,"pid":1828622}'
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ Use "chaosd attack network [command] --help" for more information about a comman
|
|||
|
||||
目前 Chaosd 支持模拟网络包错误(corrupt)、延迟(delay)、重复(duplicate)、丢失(loss)四种实验场景。
|
||||
|
||||
### 网络包错误
|
||||
### 使用命令行模式模拟网络包错误
|
||||
|
||||
通过运行网络包错误命令,可以查看模拟网络包错误场景支持的配置。
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ chaosd attack network corrupt -d eth0 -i 172.16.4.4 --percent 50
|
|||
Attack network successfully, uid: 4eab1e62-8d60-45cb-ac85-3c17b8ac4825
|
||||
```
|
||||
|
||||
### 网络包延迟
|
||||
### 使用命令行模式模拟网络包延迟
|
||||
|
||||
通过运行网络包延迟命令,查看模拟网络延迟场景支持的配置。
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ chaosd attack network delay -d eth0 -i 172.16.4.4 -l 10ms
|
|||
Attack network successfully, uid: 4b23a0b5-e193-4b27-90a7-3e04235f32ab
|
||||
```
|
||||
|
||||
### 网络包重复
|
||||
### 使用命令行模式模拟网络包重复
|
||||
|
||||
可以运行网络包重复命令,查看模拟网络包重复场景支持的配置:
|
||||
|
||||
|
|
@ -239,11 +239,11 @@ chaosd attack network duplicate -d eth0 -i 172.16.4.4 --percent 50
|
|||
Attack network successfully, uid: 7bcb74ee-9101-4ae4-82f0-e44c8a7f113c
|
||||
```
|
||||
|
||||
### 网络包丢失
|
||||
### 使用命令行模式模拟网络包丢失
|
||||
|
||||
可以运行网络包丢失命令,查看模拟网络包丢失场景支持的配置:
|
||||
|
||||
#### 网络包丢失命令
|
||||
#### 使用命令行模式模拟网络包丢失命令
|
||||
|
||||
具体命令如下所示:
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ chaosd attack network loss -d eth0 -i 172.16.4.4 --percent 50
|
|||
Attack network successfully, uid: 1e818adf-3942-4de4-949b-c8499f120265
|
||||
```
|
||||
|
||||
### 网络分区
|
||||
### 使用命令行模式模拟网络分区
|
||||
|
||||
可以运行网络分区命令,查看模拟网络分区场景支持的配置。
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ Global Flags:
|
|||
./chaosd attack network partition -i 172.16.4.4 -d eth0 --direction from
|
||||
```
|
||||
|
||||
### DNS 故障
|
||||
### 使用命令行模式模拟 DNS 故障
|
||||
|
||||
可以运行 DNS 故障命令,查看模拟 DNS 故障场景支持的配置。
|
||||
|
||||
|
|
@ -413,7 +413,7 @@ Global Flags:
|
|||
```
|
||||
2. 向 chaosd 服务的路径 /api/attack/network 发送 HTTP POTST 请求。 `bash curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{fault-configuration}' ` 其中 `fault-configuration` 需要按照故障类型进行配置,对应的配置参数请参考下文中各个类型故障的相关参数说明和命令示例。 在运行实验时,请注意保存实验的 uid 信息,当要结束 uid 对应的实验时,需要向 chaosd 服务的路径 /api/attack/{uid} 发送 HTTP DELETE 请求。
|
||||
|
||||
### 服务模式模拟网络包错误
|
||||
### 使用服务模式模拟网络包错误
|
||||
|
||||
在使用服务模拟网络包错误时,请参考如下内容。
|
||||
|
||||
|
|
@ -433,13 +433,13 @@ Global Flags:
|
|||
| source-port | 仅影响到指定目的端口的入口流量,仅当 protocol 为 tcp 或 udp 时配置 | string 类型,使用 "," 分隔指定的端口或者端口范围,如 "80,8001:8010" |
|
||||
| percent | 网络包错误的比例 | string 类型,取值范围为 0 到 100,表示百分比(10 表示 10%),默认值为 1 |
|
||||
|
||||
#### 服务模式模拟网络包错误示例
|
||||
#### 使用服务模式模拟网络包错误示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"corrupt","device":"eth0","ip-address":"172.16.4.4","percent":"50"}'
|
||||
```
|
||||
|
||||
### 服务模式模拟网络包延迟
|
||||
### 使用服务模式模拟网络包延迟
|
||||
|
||||
在使用服务模拟网络包延迟时,请参考如下内容。
|
||||
|
||||
|
|
@ -460,13 +460,13 @@ curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:applicatio
|
|||
| ip-protocol | 只影响指定的 IP 协议 | string 类型,支持协议类型包括:tcp、 udp、icmp、all(表示影响所有网络协议) |
|
||||
| source-port | 仅影响到指定目的端口的入口流量,仅当 protocol 为 tcp 或 udp 时配置 | string 类型,使用 "," 分隔指定的端口或者端口范围,如 "80,8001:8010" |
|
||||
|
||||
#### 服务模式模拟网络包延迟示例
|
||||
#### 使用服务模式模拟网络包延迟示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"delay","device":"eth0","ip-address":"172.16.4.4","latency":"10ms"}'
|
||||
```
|
||||
|
||||
### 服务模式模拟网络包重复
|
||||
### 使用服务模式模拟网络包重复
|
||||
|
||||
在使用服务模拟网络包重复时,请参考如下内容。
|
||||
|
||||
|
|
@ -486,13 +486,13 @@ curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:applicatio
|
|||
| ip-protocol | 只影响指定的 IP 协议 | string 类型,支持协议类型包括:tcp、 udp、icmp、all(表示影响所有网络协议) |
|
||||
| source-port | 仅影响到指定目的端口的入口流量,仅当 protocol 为 tcp 或 udp 时配置 | string 类型,使用 "," 分隔指定的端口或者端口范围,如 "80,8001:8010" |
|
||||
|
||||
#### 服务模式模拟网络包重复示例
|
||||
#### 使用服务模式模拟网络包重复示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"duplicate","ip-protocol":"172.16.4.4","device":"eth0","percent":"50"}'
|
||||
```
|
||||
|
||||
### 服务模式模拟网络包丢失
|
||||
### 使用服务模式模拟网络包丢失
|
||||
|
||||
在使用服务模拟网络包丢失时,请参考如下内容。
|
||||
|
||||
|
|
@ -512,14 +512,14 @@ curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:applicatio
|
|||
| ip-protocol | 只影响指定的 IP 协议 | string 类型,支持协议类型包括:tcp、 udp、icmp、all(表示影响所有网络协议) |
|
||||
| source-port | 仅影响到指定目的端口的入口流量,仅当 protocol 为 tcp 或 udp 时配置 | string 类型,使用 "," 分隔指定的端口或者端口范围,如 "80,8001:8010" |
|
||||
|
||||
#### 服务模式模拟网络包丢失示例
|
||||
#### 使用服务模式模拟网络包丢失示例
|
||||
|
||||
````bash
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"loss","ip-protocol":"172.16.4.4","device":"eth0","percent":"50"}'
|
||||
````
|
||||
|
||||
### 服务模式模拟网络分区
|
||||
### 使用服务模式模拟网络分区
|
||||
|
||||
在使用服务模拟网络分区时,请参考如下内容。
|
||||
|
||||
|
|
@ -543,7 +543,7 @@ curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:applicatio
|
|||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"partition","ip-protocol":"172.16.4.4","device":"eth0","direction":"from"}'
|
||||
```
|
||||
|
||||
### 服务模式模拟 DNS 故障
|
||||
### 使用服务模式模拟 DNS 故障
|
||||
|
||||
在使用服务模拟 DNS 故障时,请参考如下内容。
|
||||
|
||||
|
|
@ -558,8 +558,8 @@ curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:applicatio
|
|||
| dns-ip | 表示将影响的域名映射到该地址。 | string 类型,例如 "123.123.123.123" |
|
||||
| dns-server | 指定 DNS 服务地址。 | string 类型,默认值为 "123.123.123.123" |
|
||||
|
||||
#### 服务模式模拟 DNS 故障示例
|
||||
#### 使用服务模式模拟 DNS 故障示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/network -H "Content-Type:application/json" -d '{"action":"dns","dns-ip":"123.123.123.123","dns-domain-name":"chaos-mesh.org"}'
|
||||
```
|
||||
```
|
||||
|
|
@ -26,7 +26,7 @@ chaosd server --port 31767
|
|||
|
||||
## 使用 Dashboard 方式创建实验
|
||||
|
||||
1. 单击实验页面中的**新的实验**按钮创建实验:
|
||||
1. 打开 Chaos Dashboard 面板,单击实验页面中的**新的实验**按钮创建实验:
|
||||
|
||||

|
||||
|
||||
|
|
@ -105,7 +105,7 @@ chaosd server --port 31767
|
|||
|
||||
#### 网络包延迟
|
||||
|
||||
模拟网络包延迟,将 action 设置为 "network-delay",对应的配置可参考[网络包错误相关参数说明](simulate-network-chaos-in-physical-nodes.md#网络包错误相关参数说明)。
|
||||
模拟网络包延迟,将 action 设置为 "network-delay",对应的配置可参考[网络包延迟相关参数说明](simulate-network-chaos-in-physical-nodes.md#网络包延迟相关参数说明)。
|
||||
|
||||
#### 网络包重复
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ chaosd server --port 31767
|
|||
|
||||
#### DNS 故障
|
||||
|
||||
模拟 DNS 故障, 将 action 设置为 "network-dns",对应的配置可参考[DNS 故障相关参数说明](simulate-network-chaos-in-physical-nodes.md#DNS-故障相关参数说明)。
|
||||
模拟 DNS 故障, 将 action 设置为 "network-dns",对应的配置可参考 [DNS 故障相关参数说明](simulate-network-chaos-in-physical-nodes.md#DNS-故障相关参数说明)。
|
||||
|
||||
#### 进程故障
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ chaosd server --port 31767
|
|||
|
||||
模拟 JVM 应用触发垃圾回收,将 action 设置为 "jvm-gc",对应的配置可参考[触发垃圾回收相关参数说明](simulate-jvm-application-chaos-in-physical-nodes.md#触发垃圾回收相关参数说明)。
|
||||
|
||||
#### JVM 应用使用 Byteman 配置触发故障
|
||||
#### JVM 应用使用 Byteman 配置文件触发故障
|
||||
|
||||
JVM 应用使用 Byteman 配置触发故障,将 action 设置为 "jvm-rule-data",对应的配置可参考[设置 Byteman 配置触发故障相关参数说明](simulate-jvm-application-chaos-in-physical-nodes.md#设置-Byteman-配置触发故障相关参数说明)。
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ Use "chaosd attack process [command] --help" for more information about a comman
|
|||
|
||||
目前 Chaosd 支持模拟进程被终止或暂停的故障。
|
||||
|
||||
### 模拟进程被终止
|
||||
### 使用命令行模式模拟进程被终止
|
||||
|
||||
#### 模拟进程被终止命令
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ Attack process python successfully, uid: 10e633ac-0a37-41ba-8b4a-cd5ab92099f9
|
|||
|
||||
:::
|
||||
|
||||
### 模拟进程被暂停
|
||||
### 使用命令行模式模拟进程被暂停
|
||||
|
||||
#### 模拟进程被暂停命令
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ Attack process python successfully, uid: 9cb6b3be-4f5b-4ecb-ae05-51050fcd0010
|
|||
| process | 需要结束进程的名字或者进程的标识符 | string 类型,默认为 "" |
|
||||
| signal | 所提供的进程信号值 | int 类型,默认为 9。 |
|
||||
|
||||
#### 服务模式进程故障示例
|
||||
#### 使用服务模式模拟进程故障示例
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{"process":"12345","signal":15}'
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ title: 模拟时间故障
|
|||
|
||||
本文主要介绍如何使用 Chaosd 模拟时间偏移的场景。本功能支持通过命令行模式或服务模式创建实验。
|
||||
|
||||
## 通过命令行创建实验
|
||||
## 使用命令行模式创建实验
|
||||
|
||||
本节介绍如何在命令行模式中创建时间故障实验。
|
||||
|
||||
|
|
@ -79,13 +79,13 @@ chaosd attack clock -p $PID -t 11s
|
|||
|
||||
### 模拟时间故障相关参数说明
|
||||
|
||||
| 参数 | 说明 | 值 |
|
||||
| :-- | :-- | :-- |
|
||||
| 参数 | 说明 | 值 |
|
||||
| :---------- | :----------------------------------------------------------------- | :-------------------------------------------------------------------------- |
|
||||
| pid | 进程的标识符。 | int 类型 |
|
||||
| time-offset | 指定时间的偏移量。 | string 类型,例如:"-5m" |
|
||||
| clock-ids-slice | 指定时间偏移作用的时钟,详见 [clock_gettime documentation](https://man7.org/linux/man-pages/man2/clock_gettime.2.html) 。 | string 数组类型,默认为 `["CLOCK_REALTIME"]` |
|
||||
|
||||
### 时间故障示例
|
||||
### 使用服务模式模拟时间故障示例
|
||||
|
||||
运行[快速使用](#快速使用)中的测试程序,使用以下命令创建时间故障:
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 154 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 321 KiB |
|
|
@ -2,4 +2,578 @@
|
|||
title: Simulate JVM Application Faults
|
||||
---
|
||||
|
||||
## TODO
|
||||
Chaosd simulates the faults of JVM application through [Byteman](https://github.com/chaos-mesh/byteman). The supported fault types are as follows:
|
||||
|
||||
- Throw custom exceptions
|
||||
- Trigger garbage collection
|
||||
- Increase method latency
|
||||
- Modify return values of a method
|
||||
- Trigger faults by setting Byteman configuration files
|
||||
- Increase JVM pressure
|
||||
|
||||
This document describes how to use Chaosd to create the above fault types of JVM experiments.
|
||||
|
||||
## Create experiments using command-line mode
|
||||
|
||||
This section introduces how to create the experiments of JVM application faults using command-line mode.
|
||||
|
||||
Before creating the experiment, you can run the following command line to see the types of JVM application faults supported by Chaosd:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm -h
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
JVM attack related commands
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm [command]
|
||||
|
||||
Available Commands:
|
||||
exception throw specified exception for specified method
|
||||
gc trigger GC for JVM
|
||||
latency inject latency to specified method
|
||||
return return specified value for specified method
|
||||
rule-file inject fault with configured byteman rule file
|
||||
stress inject stress to JVM
|
||||
|
||||
Flags:
|
||||
-h, --help help for jvm
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--uid string the experiment ID
|
||||
|
||||
Use "chaosd attack jvm [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
### Throw custom exceptions using command-line mode
|
||||
|
||||
#### Commands for throwing custom exceptions
|
||||
|
||||
To see the usage and configuration items of the command that throws custom exceptions, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm exception --help
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
throw specified exception for specified method
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm exception [options] [flags]
|
||||
|
||||
Flags:
|
||||
-c, --class string Java class name
|
||||
--exception string the exception which needs to throw for action 'exception'
|
||||
-h, --help help for exception
|
||||
-m, --method string the method name in Java class
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for throwing custom exceptions
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `class` | `c` | The name of the Java class | string type, required|
|
||||
| `exception` | None | The thrown custom exception | string type, required |
|
||||
| method | m | The name of the method | string type, required to be configured |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| uid | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for throwing custom exceptions
|
||||
|
||||
```bash
|
||||
chaosd attack jvm exception -c Main -m sayhello --exception 'java.io.IOException("BOOM")' --pid 30045
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 02:39:39.106 +00:00] [INFO] [jvm.go:208] ["byteman rule"] [rule="\nRULE Main-sayhello-exception-q6nd0\nCLASS Main\nMETHOD sayhello\nAT ENTRY\nIF true\nDO \n\tthrow new java.io.IOException(\"BOOM\");\nENDRULE\n"] [file=/tmp/rule.btm296930759]
|
||||
Attack jvm successfully, uid: 26a45ae2-d395-46f5-a126-2b2c6c85ae9d
|
||||
```
|
||||
|
||||
### Trigger garbage collection using command-line mode
|
||||
|
||||
#### Commands for triggering garbage collection
|
||||
|
||||
To see the usage and configuration items of the command that triggers garbage collection, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm gc --help
|
||||
```
|
||||
|
||||
```bash
|
||||
trigger GC for JVM
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm gc [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for gc
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for triggering garbage collection
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for triggering garbage collection
|
||||
|
||||
```bash
|
||||
chaosd attack jvm gc --pid 89345
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 02:49:47.850 +00:00] [INFO] [jvm.go:208] ["byteman rule"] [rule="\nRULE --gc-u0mlf\nGC\nENDRULE\n"] [file=/tmp/rule.btm012481052]
|
||||
Attack jvm successfully, uid: f360e70a-5359-49b6-8526-d7e0a3c6f696
|
||||
```
|
||||
|
||||
Triggering garbage collection is a one-time operation, and the experiment does not require recovery.
|
||||
|
||||
### Increase method latency using command-line mode
|
||||
|
||||
#### Commands for increasing method latency
|
||||
|
||||
To see the usage and configuration items of the command that increases method latency, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm latency --help
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
inject latency to specified method
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm latency [options] [flags]
|
||||
|
||||
Flags:
|
||||
-c, --class string Java class name
|
||||
-h, --help help for latency
|
||||
--latency int the latency duration, unit ms
|
||||
-m, --method string the method name in Java class
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for increasing method latency
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `class` | `c` | The name of the Java class | string type, required |
|
||||
| `latency` | None | The duration of increasing method latency | int type, required. The unit is milisecond. |
|
||||
| `method` | `m` | The name of the method | string type, required |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for increasing method latency
|
||||
|
||||
```bash
|
||||
chaosd attack jvm latency --class Main --method sayhello --latency 5000 --pid 100840
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 03:08:50.716 +00:00] [INFO] [jvm.go:208] ["byteman rule"] [rule="\nRULE Main-sayhello-latency-hlib2\nCLASS Main\nMETHOD sayhello\nAT ENTRY\nIF true\nDO \n\tThread.sleep(5000);\nENDRULE\n"] [file=/tmp/rule.btm359997255]
|
||||
[2021/08/05 03:08:51.155 +00:00] [INFO] [jvm.go:94] ["submit rules"] [output="install rule Main-sayhello-latency-hlib2\n\n"]
|
||||
Attack jvm successfully, uid: bbe00c57-ac9d-4113-bf0c-2a6f184be261
|
||||
```
|
||||
|
||||
### Modify return values of a method using command-line mode
|
||||
|
||||
#### Commands for modifying return values of a method
|
||||
|
||||
To see the usage and configuration items of the command that modifies return values of a method, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm return --help
|
||||
```
|
||||
|
||||
```bash
|
||||
return specified value for specified method
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm return [options] [flags]
|
||||
|
||||
Flags:
|
||||
-c, --class string Java class name
|
||||
-h, --help help for return
|
||||
-m, --method string the method name in Java class
|
||||
--value string the return value for action 'return'. Only supports number and string types.
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for modifying return values of a method
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| class | c | The name of the Java class | string type, required to be configured |
|
||||
| method | m | The name of the method | string type, required to be configured |
|
||||
| value | None | Specifies the return value of the method | string type, required to be configured. Currently, the item can be numeric and string types. If the item (return value) is string, double quotes are required, like "chaos". |
|
||||
| pid | None | The Java process ID where the fault is needed to be injected | int type, required to be configured |
|
||||
| port | None | The port number attached to the Java process agent. The faults is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| uid | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for simulating the scenario of modifying return values of a method
|
||||
|
||||
```bash
|
||||
chaosd attack jvm return --class Main --method getnum --value 999 --pid 112694
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 03:35:10.603 +00:00] [INFO] [jvm.go:208] ["byteman rule"] [rule="\nRULE Main-getnum-return-i6gb7\nCLASS Main\nMETHOD getnum\nAT ENTRY\nIF true\nDO \n\treturn 999;\nENDRULE\n"] [file=/tmp/rule.btm051982059]
|
||||
[2021/08/05 03:35:10.820 +00:00] [INFO] [jvm.go:94] ["submit rules"] [output="install rule Main-getnum-return-i6gb7\n\n"]
|
||||
Attack jvm successfully, uid: e2f204f6-4bed-4d92-aade-2b4a47b02e5d
|
||||
```
|
||||
|
||||
### Trigger faults by setting Byteman configuration files using command-line mode
|
||||
|
||||
You can set the fault rules in the Byteman rule configuration file, and then inject the faults by specifying the path of the configuration file using Chaosd. Regarding the Byteman rule configuration, refer to [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language).
|
||||
|
||||
#### Commands for triggering faults by setting Byteman configuration files
|
||||
|
||||
To see the usage and configuration items of the command that triggers faults by setting Byteman configuration files, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm rule-file --help
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
inject fault with configured byteman rule file
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm rule-file [options] [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for rule-file
|
||||
-p, --path string the path of configured byteman rule file
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd, the value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for triggering faults by setting Byteman configuration files
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `path` | None | Specifies the path of the Byteman configuration file | string type, required |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for triggering faults by setting Byteman configuration files
|
||||
|
||||
First, based on the specific Java program and referring to [the Byteman rule language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language), write a rule configuration file. For example:
|
||||
|
||||
```txt
|
||||
RULE modify return value
|
||||
CLASS Main
|
||||
METHOD getnum
|
||||
AT ENTRY
|
||||
IF true
|
||||
DO
|
||||
return 9999
|
||||
ENDRULE
|
||||
```
|
||||
|
||||
Then, save the configuration file to the `return.btm` file. After that, run the following command to inject faults.
|
||||
|
||||
```bash
|
||||
chaosd attack jvm rule-file -p ./return.btm --pid 112694
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 03:45:40.757 +00:00] [INFO] [jvm.go:152] ["rule file data:RULE modify return value\nCLASS Main\nMETHOD getnum\nAT ENTRY\nIF true\nDO\n return 9999\nENDRULE\n"]
|
||||
[2021/08/05 03:45:41.011 +00:00] [INFO] [jvm.go:94] ["submit rules"] [output="install rule modify return value\n\n"]
|
||||
Attack jvm successfully, uid: 5ca2e06d-a7c6-421d-bb67-0c9908bac17a
|
||||
```
|
||||
|
||||
### Increase JVM stress using command-line mode
|
||||
|
||||
#### Commands for increasing JVM stress
|
||||
|
||||
To see the usage and configuration items of the command that increases JVM stress, run the following command:
|
||||
|
||||
```bash
|
||||
chaosd attack jvm stress --help
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
inject stress to JVM
|
||||
|
||||
Usage:
|
||||
chaosd attack jvm stress [options] [flags]
|
||||
|
||||
Flags:
|
||||
--cpu-count int the CPU core number
|
||||
-h, --help help for stress
|
||||
--mem-type int the memory type to be allocated. The value can be 'stack' or 'heap'.
|
||||
|
||||
Global Flags:
|
||||
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
|
||||
--pid int the pid of Java process which needs to attach
|
||||
--port int the port of agent server (default 9288)
|
||||
--uid string the experiment ID
|
||||
```
|
||||
|
||||
#### Configuration description for increasing JVM stress
|
||||
|
||||
| Configuration item | Abbreviation | Description | Value |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `cpu-count` | None | The number of CPU cores used for increasing JVM stress | int type. You can only configure one of `cpu-count` and `mem-type`. |
|
||||
| `mem-type` | None | The type of OOM | string type. Currently, both 'stack' and 'heap' OOM types are supported. You can only configure one of `cpu-count` and `mem-type`. |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for increasing JVM stress
|
||||
|
||||
```bash
|
||||
chaosd attack jvm stress --cpu-count 2 --pid 123546
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
[2021/08/05 03:59:51.256 +00:00] [INFO] [jvm.go:208] ["byteman rule"] [rule="\nRULE --stress-jfeiu\nSTRESS CPU\nCPUCOUNT 2\nENDRULE\n"] [file=/tmp/rule.btm773062009]
|
||||
[2021/08/05 03:59:51.613 +00:00] [INFO] [jvm.go:94] ["submit rules"] [output="install rule --stress-jfeiu\n\n"]
|
||||
Attack jvm successfully, uid: b9b997b5-0a0d-4f1f-9081-d52a32318b84
|
||||
```
|
||||
|
||||
## Create experiments using service mode
|
||||
|
||||
You can follow the instructions below to create experiments using service mode.
|
||||
|
||||
1. Execute Chaosd in service mode:
|
||||
|
||||
```bash
|
||||
chaosd server --port 31767
|
||||
```
|
||||
|
||||
2. Send HTTP POST request to the `/api/attack/{uid}` path of Chaosd service.
|
||||
|
||||
For the `fault-configuration` in `bash curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{fault-configuration}'`, you need to configure it according to the fault types. For the corresponding parameters, refer to the parameters and examples of each fault type in the following sections.
|
||||
|
||||
:::note
|
||||
|
||||
- When running an experiment, remember to save the UID information of the experiment.
|
||||
- When you want to end the experiment corresponding to the UID, you need to send an HTTP DELETE request to the `/api/attack/{uid}` path of Chaosd service.
|
||||
|
||||
:::
|
||||
|
||||
### Throw custom exceptions using service mode
|
||||
|
||||
#### Parameters for throwing custom exceptions
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "exception" |
|
||||
| `class` | The name of the Java class | string type, required |
|
||||
| `exception` | The thrown custom exception | string type, required |
|
||||
| `method` | The name of the method | string type, required |
|
||||
| `pid` | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | The port number attached to the Java process agent. The faults is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for throwing custom exceptions using service mode
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"exception","class":"Main","method":"sayhello","exception":"java.io.IOException(\"BOOM\")","pid":1828622}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"c3c519bf-819a-4a7b-97fb-e3d0814481fa"}
|
||||
```
|
||||
|
||||
### Trigger garbage collection using service mode
|
||||
|
||||
#### Parameters for triggering garbage collection
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "gc" |
|
||||
| `pid` | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for triggering garbage collection using service mode
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"gc","pid":1828622}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"c3c519bf-819a-4a7b-97fb-e3d0814481fa"}
|
||||
```
|
||||
|
||||
Triggering garbage collection is a one-time operation. The experiment does not require recovery.
|
||||
|
||||
### Increase method latency using service mode
|
||||
|
||||
#### Parameters for increasing method latency
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "latency" |
|
||||
| `class` | The name of the Java class | string type, required |
|
||||
| `latency` | The duration of increasing method latency | int type, required. The unit is milisecond. |
|
||||
| `method` | The name of the method | string type, required |
|
||||
| `pid` | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | The Java process ID where the fault is needed to be injected | int type, required |
|
||||
| `uid` | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for increasing method latency using service mode
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"latency","class":"Main","method":"sayhello","latency":5000,"pid":1828622}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### Modify return values of a method using service mode
|
||||
|
||||
#### Parameters for modifying return values of a method
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "return" |
|
||||
| `class` | The name of the Java class | string type, required |
|
||||
| `method` | The name of the method | string type, required |
|
||||
| `value` | Specifies the return value of the method | string type, required. Currently, the item can be numeric and string types. If the item (return value) is string, double quotes are required, like "chaos". |
|
||||
| `pid` | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for modifying return values of a method using service mode
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"return","class":"Main","method":"getnum","value":"999","pid":1828622}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### Trigger faults by setting Byteman configuration files using service mode
|
||||
|
||||
You can set the fault rules according to the Byteman rule configuration. Regarding to the Byteman rule configuration, refer to [byteman-rule-language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language).
|
||||
|
||||
#### Parameters for triggering faults by setting Byteman configuration files
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "rule-data" |
|
||||
| `rule-data` | Specifies the Byteman configuration data | string type, required |
|
||||
| `pid` | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for triggering faults by setting Byteman configuration files using service mode
|
||||
|
||||
First, based on the specific Java program and referring to [the Byteman rule language](https://downloads.jboss.org/byteman/4.0.16/byteman-programmers-guide.html#the-byteman-rule-language), write a rule configuration file. For example:
|
||||
|
||||
```txt
|
||||
RULE modify return value
|
||||
CLASS Main
|
||||
METHOD getnum
|
||||
AT ENTRY
|
||||
IF true
|
||||
DO
|
||||
return 9999
|
||||
ENDRULE
|
||||
```
|
||||
|
||||
Then, convert the line breaks in the configuration file to the newline character "\n", and use the converted text as the value of "rule-data". Run the following command:
|
||||
|
||||
```bash
|
||||
curl -X POST 127.0.0.1:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"rule-data","pid":30045,"rule-data":"\nRULE modify return value\nCLASS Main\nMETHOD getnum\nAT ENTRY\nIF true\nDO return 9999\nENDRULE\n"}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
||||
### Increase JVM stress using service mode
|
||||
|
||||
#### Parameters for increasing JVM stress
|
||||
|
||||
| Parameter | Description | Value |
|
||||
| :-- | :-- | :-- |
|
||||
| `action` | The action of the experiment | Set to "stress" |
|
||||
| `cpu-count` | The number of CPU cores used for increasing CPU stress | int type. You can only configure one of `cpu-count` and `mem-type`. |
|
||||
| `mem-type` | The type of OOM | string type. Currently, both 'stack' and 'heap' OOM types are supported. You can only configure one of `cpu-count` and `mem-type`. |
|
||||
| `pid` | None | The Java process ID where the fault is to be injected | int type, required |
|
||||
| `port` | None | The port number attached to the Java process agent. The fault is injected into the Java process through this port number. | int type. The default value is `9288`. |
|
||||
| `uid` | None | The experiment ID | string type. This item is not required to be configured, because Chaosd randomly creates one. |
|
||||
|
||||
#### Example for increasing JVM stress using service mode
|
||||
|
||||
```bash
|
||||
curl -X POST 172.16.112.130:31767/api/attack/jvm -H "Content-Type:application/json" -d '{"action":"stress","cpu-count":1,"pid":1828622}'
|
||||
```
|
||||
|
||||
The result is as follows:
|
||||
|
||||
```bash
|
||||
{"status":200,"message":"attack successfully","uid":"a551206c-960d-4ac5-9056-518e512d4d0d"}
|
||||
```
|
||||
|
|
@ -1,5 +1,152 @@
|
|||
---
|
||||
title: Simulate Faults on Physical Machine
|
||||
title: Simulate Faults on Physical Machines
|
||||
---
|
||||
|
||||
## TODO
|
||||
This document describes how to create PhysicalMachineChaos (physical machine chaos) experiments in Chaos Mesh to simulate the faults of network, disk, pressure, JVM, time, and others in physical or virtual machines.
|
||||
|
||||
## Introduction to PhysicalMachineChaos
|
||||
|
||||
You can use PhysicalMachineChaos to simulate the faults of network, disk, pressure, JVM, time, and others in physical or virtual machines.
|
||||
|
||||
## Deploy Chaosd server
|
||||
|
||||
Before creating PhysicalMachineChaos experiments using Chaos Mesh, you need to deploy Chaosd in service mode to all physical or virtual machines that are going to be injected with faults. For the deployment method of Chaosd, refer to [Download and deploy Chaosd](chaosd-overview.md#download-and-deploy).
|
||||
|
||||
After the deployment is complete, run the following command to start Chaosd in service mode:
|
||||
|
||||
```bash
|
||||
chaosd server --port 31767
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
When using Chaos Mesh v2.1.0, you need to deploy Chaosd [v1.1.0](https://github.com/chaos-mesh/chaosd/releases/tag/v1.1.0).
|
||||
|
||||
:::
|
||||
|
||||
## Create experiments using Chaos Dashboard
|
||||
|
||||
1. Open Chaos Dashboard, and click **NEW EXPERIMENT** on the page to create a new experiment:
|
||||
|
||||

|
||||
|
||||
2. Click **PHYSIC** in **Experiment Type** and choose a specific type of the experiment, such as **NETWORK ATTACK**. Then, choose a specific behavior and fill out the corresponding configurations:
|
||||
|
||||

|
||||
|
||||
3. Fill out the experiment information to specify the range and the planned duration of the experiment:
|
||||
|
||||

|
||||
|
||||
4. Submit the experiment.
|
||||
|
||||
## Create experiments using an YAML file
|
||||
|
||||
1. Write the experimental configurations to the "physicalmachine.yaml" file. For example:
|
||||
|
||||
```yaml
|
||||
apiVersion: chaos-mesh.org/v1alpha1
|
||||
kind: PhysicalMachineChaos
|
||||
metadata:
|
||||
name: physical-network-delay
|
||||
namespace: chaos-testing
|
||||
spec:
|
||||
action: network-delay
|
||||
address:
|
||||
- 172.16.112.130:31767
|
||||
network-delay:
|
||||
device: ens33
|
||||
ip-address: 140.82.112.3
|
||||
latency: 1000ms
|
||||
duration: '10m'
|
||||
```
|
||||
|
||||
The experimental configurations above send HTTP requests to Chaosd service in the specified physical machines or virtual machines to trigger network latency experiments.
|
||||
|
||||
2. Create the experiment using `kubectl`. The command is as follows:
|
||||
|
||||
```bash
|
||||
kubectl apply -f physicalmachine.yaml
|
||||
```
|
||||
|
||||
### Configuration description
|
||||
|
||||
| Configuration item | Type | Description | Default value | Required | Example |
|
||||
| :-- | :-- | :-- | :-- | :-- | :-- |
|
||||
| action | string | Defines the actions of physical machines faults, optional values are as follows: "stress-cpu", "stress-mem", "disk-read-payload", "disk-write-payload", "disk-fill", "network-corrupt", "network-duplicate", "network-loss", "network-delay", "network-partition", "network-dns", "process", "jvm-exception", "jvm-gc", "jvm-latency", "jvm-return", "jvm-stress", "jvm-rule-data", "clock" | None | Yes | "stress-cpu" |
|
||||
| address | string array | Selects the address of Chaosd service to inject faults | [] | Yes | ["192.168.0.10:31767"] |
|
||||
| duration | string | Specifies the duration of experiments | None | Yes | 30s |
|
||||
|
||||
Each fault action has its own specific configurations. The following section introduces various fault types and their corresponding configuration methods.
|
||||
|
||||
#### CPU stress
|
||||
|
||||
To simulate a CPU stress scenario, you need to set the action to "stress-cpu". For the corresponding configurations, refer to Parameters of simulating CPU stress.
|
||||
|
||||
#### Memory stress
|
||||
|
||||
To simulate a memory stress scenario, you need to set the action to "stress-mem". For the corresponding configurations, refer to Parameters of simulating memory stress.
|
||||
|
||||
#### Disk read load
|
||||
|
||||
To simulate a disk read load scenario, you need to set the action to "disk-read-payload". For the corresponding configurations, refer to Parameters of simulating disk read load.
|
||||
|
||||
#### Disk write load
|
||||
|
||||
To simulate a disk write load scenario, you need to set the action to "disk-write-payload". For the corresponding configurations, refer to Parameters of simulating disk write load.
|
||||
|
||||
#### Disk fill
|
||||
|
||||
To simulate a disk fill scenario, you need to set the action to "disk-fill". For the corresponding configurations, refer to Parameters of simulating disk fill.
|
||||
|
||||
#### Network corruption
|
||||
|
||||
To simulate a network corruption scenario, you need to set the action to "network-corrupt". For the corresponding configurations, refer to Parameters of simulating network corruption.
|
||||
|
||||
#### Network latency
|
||||
|
||||
To simulate a network latency scenario, you need to set the action to "network-delay". For the corresponding configurations, refer to Parameters of simulating network latency.
|
||||
|
||||
#### Network duplication
|
||||
|
||||
To simulate a network duplication scenario, you need to set the action to "network-duplicate". For the corresponding configurations, refer to Parameters of simulating network duplication.
|
||||
|
||||
#### Network loss
|
||||
|
||||
To simulate a network loss scenario, you need to set the action to "network-loss". For the corresponding configurations, refer to Parameters of simulating network loss.
|
||||
|
||||
#### Network partition
|
||||
|
||||
To simulate a network partition scenario, you need to set the action to "network-partition". For the corresponding configurations, refer to Parameters of simulating network partition.
|
||||
|
||||
#### DNS fault
|
||||
|
||||
To simulate a DNS fault scenario, you need to set the action to "network-dns". For the corresponding configurations, refer to Parameters of simulating DNS fault.
|
||||
|
||||
#### Process fault
|
||||
|
||||
To simulate a process fault scenario, you need to set the action to "process". For the corresponding configurations, refer to Parameters of simulating process fault.
|
||||
|
||||
#### Throw custom exceptions for JVM applications
|
||||
|
||||
To simulate a scenario that JVM applications throw custom exceptions, you need to set the action to "jvm-exception". For the corresponding configurations, refer to Parameters for throwing custom exceptions.
|
||||
|
||||
#### Increase method latency for JVM applications
|
||||
|
||||
To simulate a scenario that JVM applications increase method latency, you need to set the action to "jvm-latency". For the corresponding configurations, refer to Parameters for increasing method latency.
|
||||
|
||||
#### Modify return values of methods for JVM applications
|
||||
|
||||
To simulate a scenario that JVM applications modify return values of methods, you need to set the action to "jvm-return". For the corresponding configurations, refer to Parameters for modifying return values of a method.
|
||||
|
||||
#### Trigger garbage collection for JVM applications
|
||||
|
||||
To simulate a scenario that JVM applications trigger garbage collection, you need to set the action to "jvm-gc". For the corresponding configurations, refer to Parameters for triggering garbage collection.
|
||||
|
||||
#### Trigger faults using Byteman configuration files for JVM applications
|
||||
|
||||
To simulate a scenario that JVM applications trigger faults using Byteman configuration files, you need to set the action to "jvm-rule-data". For the corresponding configurations, refer to Parameters for triggering faults by setting Byteman configuration files.
|
||||
|
||||
#### Time offset
|
||||
|
||||
To simulate a time offset scenario, you need to set the action to "clock". For the corresponding configurations, refer to Parameters of simulating time offset.
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
---
|
||||
title: Simulate time chaos
|
||||
title: Simulate Time Faults
|
||||
summary: This document describes how to use Chaosd to simulate a time offset scenario.
|
||||
---
|
||||
|
||||
This document describes how to use Chaosd to simulate a time offset scenario. You can create experiments either in command-line mode or service mode.
|
||||
|
||||
## Create experiments using commands
|
||||
## Create experiments using command-line mode
|
||||
|
||||
This section describes how to create time chaos experiments using commands.
|
||||
This section describes how to create time fault experiments using commands.
|
||||
|
||||
Before creating an experiment, you can run the following command to check the options of time chaos:
|
||||
Before creating an experiment, you can run the following command to check the options of time faults:
|
||||
|
||||
```
|
||||
chaosd attack clock -h
|
||||
|
|
@ -68,7 +68,7 @@ Then execute get_time and try to attack it. The following is an example:
|
|||
chaosd attack clock -p $PID -t 11s
|
||||
```
|
||||
|
||||
### Configurations of simulating time chaos
|
||||
### Configurations of simulating time faults
|
||||
|
||||
| Parameter | Type | Note | Default value | Required | Example |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
|
|
|
|||
Loading…
Reference in New Issue