consul 健康检查官方文档:https://www.consul.io/docs/discovery/checks
注册服务:
curl -X PUT -d '{"id": "Linux-1","name": "Linux","address": "10.0.0.5","port": 9100,"tags": ["Nginx"],"checks": [{"http": "http://10.0.0.5:9100/metrics", "interval": "5s"}]}' http://10.0.0.6:8500/v1/agent/service/register
查询注册信息:
curl http://10.0.0.6:8500/v1/catalog/service/Linux
撤销注册:
curl -X PUT http://10.0.0.6:8500/v1/agent/service/deregister/Linux-1
在注册服务后,发现 consul 健康检查失败,报错 401 Unauthorized
。该服务开启了 basic auth
,需要认证才能访问.
发现它带有 header:Authorization: Basic cHJvbTpwYXgxMjM0NTY=
,可以看到是 base64 后的结果。所以将 账号:密码
经过 base64 编码后,放到验证的请求头中.
即可成功注册到 consul 。注册命令如下
您暂时无权查看此隐藏内容!