Consul 简明教程
Consul - Introduction
Consul 是 HashiCorp 旗下的一款工具,用于发现和配置基础架构中各种不同的服务。它基于 Golang 构建。构建 Consul 的核心原因之一是维护分布式系统中存在的服务。Consul 提供的一些重要功能如下。
Consul is a Hashicorp based tool for discovering and configuring a variety of different services in your infrastructure. It is based and built on Golang. One of the core reasons to build Consul was to maintain the services present in the distributed systems. Some of the significant features that Consul provides are as follows.
-
Service Discovery − Using either DNS or HTTP, applications can easily find the services they depend upon.
-
Health Check Status − It can provide any number of health checks. It is used by the service discovery components to route traffic away from unhealthy hosts.
-
Key/Value Store − It can make use of Consul’s hierarchical key/value store for any number of purposes, including dynamic configuration, feature flagging, coordination, leader election, etc.
-
Multi Datacenter Deployment − Consul supports multiple datacenters. It is used for building additional layers of abstraction to grow to multiple regions.
-
Web UI − Consul provides its users a beautiful web interface using which it can be easy to use and manage all of the features in consul.
Service Discovery
服务发现是 Consul 最重要的功能之一。服务发现的定义是使用不同的服务和网络协议来检测服务。服务发现的使用对于分布式系统来说是一个福音。这是当今大规模行业面临的一个主要问题,因为分布式系统在他们的环境中不断发展。
Service discovery is one of the most important feature of Consul. It is defined as the detection of different services and network protocols using which a service is found. The usage of service discovery comes in as a boon for distributed systems. This is one of the main problems, which are faced by today’s large-scale industries with the advancement of distributed systems in their environment.
Comparison with Etcd and Zookeeper
当我们查看此域中的其他服务发现工具时,我们有两个流行的选择。软件行业的一些主要参与者过去一直在使用它。这些工具是 Etcd 和 Zookeeper 。
When we look at other service discovery tools in this domain, we have two popular options. Some major players in the software industry have been using it in the past. These tools are Etcd and Zookeeper.
让我们考虑以下表格来比较每个工具的不同方面。我们还将了解每个工具在内部使用什么。
Let us consider the following table for comparing different aspects of each tool. We will also understand what each one of them uses internally.
Properties |
Consul |
Etcd |
Zoo Keeper |
User Interface |
Available |
||
RPC |
Available |
Available |
|
Health Check |
HTTP API |
HTTP API |
TCP |
Key Value |
3 Consistency modes |
Good Consistency |
Strong Consistency |
Token System |
Available |
||
Language |
Golang |
Golang |
Java |
Consul - Members and Agents
Consul 成员可以定义为使用 Consul 集群进行部署的不同代理和服务器模式的列表。Consul 为我们提供了命令行功能,我们可以使用该功能轻松列出与 Consul 关联的所有代理。
Consul members can be defined as the list of different agents and server modes using which a consul cluster is deployed. Consul provides us with a command line feature using which we can easily list all the agents associated with consul.
Consul 代理是 Consul 的核心流程。代理维护成员资格信息、注册服务、运行检查、响应查询等。任何代理都可以使用这两种模式中的一种运行: Client 或 Server 。可以在使用 Consul 时根据角色确定这两者的使用方式。Consul 代理通过向我们提供以下信息来提供帮助。
Consul agent is the core process of Consul. The agent maintains membership information, registers services, runs checks, responds to queries, etc. Any agent can be run in one of two modes: Client or Server. These two modes can be used according to their role as decided when using consul. The consul agent helps by providing us information, which is listed below.
-
Node name − This is the hostname of the machine.
-
Datacenter − The datacenter in which the agent is configured to run. Each node must be configured to report to its datacenter.
-
Server − It indicates whether the agent is running in server or client mode. Server nodes participates in the consensus quorum, storing cluster state and handling queries.
-
Client Addr − It is the address used for client interfaces by the agent. It includes the ports for the HTTP, DNS, and RPC interfaces.
-
Cluster Addr − It is the address and the set of ports used for communication between Consul Agents in a cluster. This address must be reachable by all other nodes.
在下一章中,我们将了解 Consul 的体系结构。
In the next chapter, we will understand the architecture for Consul.