无法从Rest API获取其他节点上的Consul代理服务注册,但在UI上显示 [英] Consul Agent Service Registrations on other nodes are not fetchable from Rest API but is showing on UI

查看:94
本文介绍了无法从Rest API获取其他节点上的Consul代理服务注册,但在UI上显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个由3个服务器组成的领事集群,并通过Rest Api在其中任何一个上注册代理服务.

We have a consul cluster of 3 servers and registering agent services on any of them via Rest Api.

在UI中,也可以在其他服务器上看到服务器的注册.例如在服务器B的UI上可以看到服务器A上的注册(可通过http://serverb:8500/访问).

In UI, registrations of a server are visible on other servers as well. For e.g. registration on server A is visible on server B's UI (accessible by http://serverb:8500/).

但是,当通过Rest Api击中服务器B时,它仅显示自己的注册,而不显示服务器A的注册.

However when hitting server B via Rest Api, it only shows its own registrations and do not show server A registration.

服务器启动为服务器A consul -server -ui bootstrap-expect = 1 -node = ServerA -data-dir = D:\ data -bind = 11.223.15.78 -client = 0.0.0.0 -retry-join = 11.223.15.79 -retry-join = 11.223.15.80

Server are started as Server A consul -server -ui bootstrap-expect=1 -node=ServerA -data-dir=D:\data -bind=11.223.15.78 -client=0.0.0.0 -retry-join=11.223.15.79 -retry-join=11.223.15.80


服务器B
consul -server -ui bootstrap-expect = 1 -node = ServerB -data-dir = D:\ data -bind = 11.223.15.79 -client = 0.0.0.0 -retry-join = 11.223.15.78 -retry-join= 11.223.15.80


Server B
consul -server -ui bootstrap-expect=1 -node=ServerB -data-dir=D:\data -bind=11.223.15.79 -client=0.0.0.0 -retry-join=11.223.15.78 -retry-join=11.223.15.80


服务器C
consul -server -ui bootstrap-expect = 1 -node = ServerC -data-dir = D:\ data -bind = 11.223.15.80 -client = 0.0.0.0 -retry-join = 11.223.15.78 -retry-join= 11.223.15.79


Server C
consul -server -ui bootstrap-expect=1 -node=ServerC -data-dir=D:\data -bind=11.223.15.80 -client=0.0.0.0 -retry-join=11.223.15.78 -retry-join=11.223.15.79

这是问题还是我做错了什么?

Is this an issue or am I doing something wrong?

推荐答案

服务的可见性取决于您所使用的API端点以及在何处注册服务.Consul打算将服务注册到与部署的服务在同一主机上运行的Consul客户端代理.在数据中心向每个代理注册的服务被汇总以形成服务目录(https://www.consul.io/docs/architecture/anti-entropy#catalog ).

The visibility of services will depend on which API endpoint you're using, and where you're registering your services. Consul intends for services to be registered against a Consul client agent which is running on the same host as the deployed service. The services registered with each agent in the data center are aggregated to form the service catalog (https://www.consul.io/docs/architecture/anti-entropy#catalog).

/catalog/services 端点返回跨数据中心向每个代理注册的服务的汇总列表. /agent/services 端点将仅返回针对您正在与之通信的特定本地代理注册的服务.

The /catalog/services endpoint returns an aggregated list of services registered with each agent across the data center. The /agent/services endpoint will only return services registered against the specific local agent with which you are communicating.

如果希望客户端能够在任何服务器上注册服务,则需要使用 /catalog/register 端点.您可以选择使用咨询外部服务监控器之类的工具来独立于服务进行运行状况检查领事服务器.参见 https://www.hashicorp.com/blog/consul-and-external-服务以获取更多信息.

If you want clients to be able to register services across any server, you'll want to register them using the /catalog/register endpoint. You can optionally use a tool like Consul External Services Monitor to provide health checking for services, independently from the Consul servers. See https://www.hashicorp.com/blog/consul-and-external-services for more information.

这篇关于无法从Rest API获取其他节点上的Consul代理服务注册,但在UI上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆