consul内部服务和外部服务的区别以及注册、注销方式

本文主要解释什么是内部服务、外部服务,以及consul对内部服务和外部服务的不同的处理。

一、内部服务

Internal services run on the same node (machine) as a Consul agent. The local Consul agent is responsible for running any health checks registered for the service and updating the catalog accordingly.

内部服务运行在和consul agent 相同的节点(机器)上。

注册方式: 配置文件方式或者/agent/service/register的方式。

本地的consul agent 负责运行针对这些本地服务的健康检查以及把服务信息同步到集群的catalog。

二、外部服务

External services run on nodes where the Consul agent cannot be run. They must be registered directly with the catalog because, by definition, they don't have a local Consul agent to register with.

外部服务运行在没有consul agent 运行的节点(机器)上,只能通过catalog的方式来注册。

Because Consul monitoring requires that a Consul agent be running on the monitored service, health checks are not performed on external services. To enable health monitoring for external services, use Consul External Service Monitor.

因为consul monitoring要求consul agent 运行在被监视的服务所在的节点上,所以不会对外部服务执行健康检查。

如需要外部服务的健康监测功能,需要使用External Service Monitor(简称ESM)

三、关于服务注册方式

使用/agent/service/register注册的服务,在该节点转载地址使用/agent/services可以看到该服务,在其他节点使用/agent/services则看不到。

但是,在任何节点都可以使用/catalog/services 看到该服务,在任何节点使用/health/service/web?passing=false 都可以看到服务,dig域名也正确,说明同步完成;

使用/catalog/register/注册服务,在任何节点都可以看到,dig 域名也正确,说明同步成功;

使用
/agent/service/deregister/只能注销在该节点上通过/agent/service/register注册的服务;

问题:节点A注册了服务SA,然后节点A挂了,在其他节点上如何注销服务SA?

答案:使用/catalog/deregister这个api, 例如:

# curl --request PUT -d '{ "Datacenter": "huanan", "Node": "172.21.81.147", "ServiceID": "web" }' http://127.0.0.1:8500/v1/catalog/deregister

以上就是consul内部服务、外部服务以及他们在注册方式上的一些差别,希望对大家有用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值