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