更新时间:2024-10-23 GMT+08:00
Redis配置示例
结合配置项说明,在配置文件或配置信息添加故障注入相关配置。
- 配置文件示例config_Redis_chaos.yaml
props: version: v1 appId: xxx monitorId: xxxx cloud: xxxx region: xxxxx azs: az1 etcd: address: xxx.xxx.xxx.xxx:xxxx apiVersion: v3 username: xxxx password: xxxx httpsEnable: false Redis: nearest: dc1 asyncRemoteWrite: retryTimes: 4 connectionPool: enable: true asyncRemotePool: persist: true threadCoreSize: 10 taskQueueSize: 5 persistDir: dataDir/ servers: dc1: hosts: xxx.xxx.xxx.xxx:xxxx password: xxxxxx type: normal# cluster, master-slave, normal cloud: xxxx region: xxxxx azs: az1 pool: maxTotal: 100 maxIdle: 8 minIdle: 0 maxWaitMillis: 10000 timeBetweenEvictionRunsMillis: 1000 dc2: hosts: xxx.xxx.xxx.xxx:xxxx, xxx.xxx.xxx.xxx:xxxx password: xxxxxx type: cluster# cluster, master-slave, normal cloud: xxxx region: xxxxx azs: az1 pool: maxTotal: 100 maxIdle: 8 minIdle: 0 maxWaitMillis: 10000 timeBetweenEvictionRunsMillis: 1000 routeAlgorithm: single-read-write# local-read-single-write, single-read-write, double-write active: dc1 chaos: active: true# 全局开关 默认false duration: 20 interval: 100 percentage: 100 delayInjection: active: true percentage: 75 timeMs: 1000 jitterMs: 500 errorInjection: active: true percentage: 20
- 配置信息
func RedisConfiguration() *config.Configuration { return &config.Configuration{ Props: &mas.PropertiesConfiguration{ Version: "v1", AppID: "xxx", MonitorID: "xxxx", Cloud: "xxx", Region: "xxxxx", Azs: "az1", }, EtcdConfig: &etcd.EtcdConfiguration{ Address: "xxx.xxx.xxx.xxx:xxxx", APIVersion: "v3", Username: "xxxx", Password: "xxxx", HTTPSEnable: false, }, RedisConfig: &config.RedisConfiguration{ Nearest: "dc1", AsyncRemoteWrite: &config.AsyncRemoteWrite{ RetryTimes: 4, }, ConnectionPoolConfig: &config.RedisConnectionPoolConfiguration{ Enable: true, }, AsyncRemotePoolConfiguration: &config.AsyncRemotePoolConfiguration{ Persist: true, ThreadCoreSize: 10, TaskQueueSize: 5, PersistDir: "dataDir/", }, Servers: map[string]*config.ServerConfiguration{ "dc1": { Hosts: "xxx.xxx.xxx.xxx:xxxx", Password: "xxxxxx", Type: "normal", Cloud: "xxxx", Region: "xxxx", Azs: "az1", ConnectionPool: &config.ServerConnectionPoolConfiguration{ MaxTotal: 100, MaxIdle: 8, MinIdle: 0, MaxWaitMillis: 10000, TimeBetweenEvictionRunsMillis: 1000, }, }, "dc2": { Hosts: "xxx.xxx.xxx.xxx:xxxx,xxx.xxx.xxx.xxx:xxxx", Password: "xxxxxx", Type: "cluster", Cloud: "xxxx", Region: "xxxx", Azs: "az1", ConnectionPool: &config.ServerConnectionPoolConfiguration{ MaxTotal: 100, MaxIdle: 8, MinIdle: 0, MaxWaitMillis: 10000, TimeBetweenEvictionRunsMillis: 1000, }, }, }, }, RouteAlgorithm: "single-read-write", Active: "dc1", Chaos: &mas.InjectionProperties{ Active: true, Duration: 20, Interval: 100, Percentage: 100, DelayInjection: &mas.DelayInjection{ Active: true, Percentage: 75, TimeMs: 1000, JitterMs: 500, }, ErrorInjection: &mas.ErrorInjection{ Active: true, Percentage: 20, }, }, } }
父主题: 使用指南