toxiproxy 安装试用
备注:
实际上是一个代理工具,但是又不是简单的进行代理(tcp,可以配置策略,toxics 实现延迟,模拟故障,对于这个大家可能了解的就是netflix 公司的chaos monkey,实际的使用大家可以参考相关文章,本次只是对于toxiproxy 的简单安装试用,同时这个工具可以放到大家持续集成工具集中。
1. 安装(为了简单同时安装了server 以及cli)
// 下载
// 配置安装(实际上就是改名称,拷贝文件)
mv toxiproxy-cli-linux-amd64 toxiproxy-cli
mv toxiproxy-server-linux-amd64 toxiproxy-server
chmod +x *
cp * /usr/bin/
2. 试用(为了测试安装了redis )
// redis 环境准备
yum install -y redis
systemctl restart redis
// 启动toxiproxy (后台进程)
nohup toxiproxy-server -host "0.0.0.0" &
// 代理 redis
toxiproxy-cli create myredis -l 0.0.0.0:26379 -u 127.0.0.1:6379
// 配置toxic(让redis 处理延迟1秒)
toxiproxy-cli toxic add myredis -t latency -a latency=1000
// 连接测试
redis-cli -h XXXXXX -p 26379
测试效果
3. 帮助命令(比较简单)
a. server
toxiproxy-server --help
Usage of toxiproxy-server:
-config string
JSON file containing proxies to create on startup
-host string
Host for toxiproxy's API to listen on (default "localhost")
-port string
Port for toxiproxy's API to listen on (default "8474")
-seed int
Seed for randomizing toxics with (default 1511142454198638055)
b. cli
list, l, li, ls list all proxies
usage: 'toxiproxy-cli list'
inspect, i, ins inspect a single proxy
usage: 'toxiproxy-cli inspect <proxyName>'
create, c, new create a new proxy
usage: 'toxiproxy-cli create <proxyName> --listen <addr> --upstream <addr>'
toggle, tog toggle enabled status on a proxy
usage: 'toxiproxy-cli toggle <proxyName>'
delete, d delete a proxy
usage: 'toxiproxy-cli delete <proxyName>'
toxic, t add, remove or update a toxic
usage: see 'toxiproxy-cli toxic'
4. client sdk (因为提供了rest api sdk 比较好使用,同时官方也提供了好多)
toxiproxy-ruby
toxiproxy-go
toxiproxy-python
toxiproxy-php-client
toxiproxy-node-client
toxiproxy-java