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;
}

reload -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

猜你喜欢

转载自www.cnblogs.com/zhangxuedonga/p/11834276.html
今日推荐