toxiproxy 安裝試用

備註:
   其實是一個代理工具,可是又不是簡單的進行代理(tcp,能夠配置策略,toxics 實現延遲,模擬故障,
   對於這個你們可能瞭解的就是netflix 公司的chaos monkey,實際的使用你們能夠參考相關文章,本次只是
   對於toxiproxy 的簡單安裝試用,同時這個工具能夠放到你們持續集成工具集中。
 
1. 安裝(爲了簡單同時安裝了server 以及cli)
// 下載地址
wget https://github.com/Shopify/toxiproxy/releases/download/v2.1.2/toxiproxy-server-linux-amd64 
wget https://github.com/Shopify/toxiproxy/releases/download/v2.1.2/toxiproxy-cli-linux-amd64 

// 配置安裝(實際上就是更名稱,拷貝文件)
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.net
toxiproxy-php-client
toxiproxy-node-client
toxiproxy-java
5. 參考文檔
https://github.com/Shopify/toxiproxy
相關文章
相關標籤/搜索