nginx+consul+consul-template
下载consul-template
https://releases.hashicorp.com/consul-template/0.20.0/
https://releases.hashicorp.com/consul-template/0.20.0/consul-template_0.20.0_windows_amd64.zip
开始监听
consul-template -consul-addr 127.0.0.1:8500 -template "./consulconf/1.tpl:./consulconf/1.conf:nginx -s reload |
nginx配置
stream
stream { |
http
upstream aa{ |
删除consul服务
curl --request PUT http://127.0.0.1:8500/v1/agent/service/deregister/webB |
添加服务
curl --request PUT --data @siteA.json http://localhost:8500/v1/agent/service/register |
{ |
注意事项
consul 以服务方式启动 才会持久化数据
consul agent -server -ui -bootstrap-expect=1 -data-dir=./consul -node=agent-one -advertise=127.0.0.1 -bind=0.0.0.0 -client=0.0.0.0 |
-server:服务器模式
-ui:能webui展示
-bootstrap-expect:server为1时即选择server集群leader
-data-dir:consul状态存储文件地址
-node:指定结点名
advertise:本地ip地址
-client:指定可访问这个服务结点的ip
注意 Cluster Addr集群地址是我们上面advertise指定的ip地址
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment