consul 動態負載均衡


下載 nginx-upsync-module

wget https://github.com/weibocom/nginx-upsync-module/archive/v2.1.0.tar.gz
 
重新編譯nginx --add-module=/root/sortware/nginx-upsync-module-2.1.0

下載consul ungzip解壓 cp consul /usr/bin

運行 consul agent  -server  -bootstrap-expect 1 -data-dir /tmp/consul -node=ali      -bind=內網地址    -ui   -client=0.0.0.0

 

upstream swoole_server {
  server nginx.xuedong.vip:9501;

  upsync 127.0.0.1:8500/v1/kv/upstreams/swoole_test upsync_timeout=6m upsync_interval=500ms upsync_type=consul strong_dependency=off;
  upsync_dump_path /root/servers_test.conf;
  include /root/servers_test.conf;
}

nginx -s reload

添加upstream  curl -X PUT -d '{"weight":1,"max_fails":2,"fail_timeout":10}' http://127.0.0.1:8500/v1/kv/upstreams/swoole_test/127.0.0.1:9502

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM