领事座席如何知道自己是集群的领导者? [英] How does a Consul agent know it is the leader of a cluster?

查看:96
本文介绍了领事座席如何知道自己是集群的领导者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Consul中,您可以有许多代理作为服务器或客户端。在所有服务器中,一个被选为领导者。从座席的角度来看,怎么知道他是领袖?

In Consul you can have many agents as servers or clients. Amongst all servers one is chosen as the leader. From the agent's point of view, how does it know it is the leader?

推荐答案

领事领袖是通过以下方式实现的: Consul服务器法定人数中的筏协议。只有配置为服务器的Consul实例才能参与Raft Protocol通信。 领事代理(守护程序)可以作为客户端服务器

The Consul leader is elected via an implementation of the Raft Protocol from amongst the Quorum of Consul Servers. Only Consul instances that are configured as Servers participate in the Raft Protocol communication. The Consul Agent (the daemon) can be started as either a Client or a Server. Only a Server can be the leader of a Datacenter.

Raft协议是由斯坦福大学的Diego Ongaro和John Ousterhout创建的,以应对诸如格式为 Paxos 。 Raft通过使用随机计时器选举一位领导者。 Ongaro和Ousterhout的论文中详细介绍了该算法。

The Raft Protocol was created by Diego Ongaro and John Ousterhout from Stanford University in response to the complexity of existing consensus protocols such as Paxos. Raft elects a leader via the use of randomized timers. The algorithm is detailed in Ongaro and Ousterhout's paper.

配置为客户端的Consul实例通过八卦协议,它基于 Serf 。农奴沟通最终是一致的。 Serf群集没有中央服务器,每个节点被视为相等。参与Gossip / Serf协议的所有节点(客户端和服务器)都将消息传播到它们的邻居,后者依次将消息传播到他们的邻居,直到消息传播到整个群集。有点像僵尸启示录的感染路径。这样做是为了极大地减少群集中的通信开销,因为它可以扩展到成千上万个节点。

Consul instances that are configured as Clients communicate with the cluster via the Gossip Protocol which is based on Serf. Serf communication is eventually consistent. The Serf cluster has no central server, each node is considered equal. All nodes (Clients and Servers) in participating the Gossip/Serf Protocol spread messages to their neighbors, which in turn spread messages to their neighbors until the message has propagated to the entire cluster. Sort of like the infection path of a zombie apocalypse. This is done to greatly reduce communication overhead in the cluster as it scales to potentially tens of thousands of nodes.

Consul客户端可以将消息转发到任何Consul Server,然后由Consul Server转发给领导者的信息。 Consul客户无需关心哪个Consul Server是领导者。仅服务器需要维护。

Consul Clients can forward messages to any Consul Server which will then forward the message to the Leader. Consul Clients do not need to care which Consul Server is the Leader. Only the Servers need to care.

在任何平台上运行的 Consul HTTP API Consul Server将在 $ ANY_CONSUL_SERVER / v1 / status / leader 中告诉您哪个服务器是领导者。但是,这与领事代理人如何进行领导人选举无关。

The Consul HTTP API running on any Consul Server will tell you which Server is the leader at $ANY_CONSUL_SERVER/v1/status/leader. However, this has nothing to do with how Consul Agents do leader election.

这篇关于领事座席如何知道自己是集群的领导者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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