【发布时间】:2016-10-28 07:38:55
【问题描述】:
我有三台机器,例如:
[consul@cjportal]$ consul members
Node Address Status Type Build Protocol DC
portal1 192.168.11.155:8301 alive client 0.7.0 2 dc1
portal0 192.168.14.100:8301 alive client 0.7.0 2 dc1
portal2 192.168.11.182:8301 alive server 0.7.0 2 dc1
并且所有 3 台机器都有相同的 consul 配置文件,例如:
{
"service":{
"name":"portal_confgen",
"tags":[
"portal"
],
"address": "127.0.0.1",
"port": 8823,
"check":{
"name":"ping",
"script":"ping -c1 192.168.11.155",
"interval":"10s"
}
}
}
所有3台机器都运行consul,只有服务器portal2运行consul-template,使用命令:
consul-template -config=/home/consul/consul-template/config/hosts.hcl -consul=localhost:8500
我的领事模板配置文件,hosts.hcl:
template {
source = "/home/consul/consul-template/hosts.ctmpl"
destination = "/home/consul/conf/conf.d/test.conf"
}
但是当我在consul存储中更改k/v时,只有localhost portal2正确写入目标文件,远程机器portal0和portal1不起作用。我错过了什么???
【问题讨论】:
-
我必须在每台机器上运行 consul-template 吗???