consul支持http、tcp、script、ttl类型的健康检查

1、cd到/etc/consul.d目录下

2、使用gedit编辑web.json 命令:sudo wget web.json

3、添加服务及健康检查

{
    "service":{
        "name":"xf1",
        "tags":[
            "ser1",
            "server1"
        ],
        "address":"192.168.132.133",
        "port":9000,
        "check":{
            "id":"api",
            "name":"xf1 check 9000",
            "http":"http://192.168.132.133:9000",
            "interval":"5s",
            "timeout":"1s"
        }
    }
}

4、如果consul已经运行执行 consul reload 重新加载配置文件;

如果consul 没有运行,则执行以下命令:

consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul -node=node1 -ui -rejoin -config-dir=/etc/consul.d/ -client 0.0.0.0
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐