First, Introduction
Consul ([K?nsl], Kang Search) is a registration center, service providers, service consumers and so on to register to Consul, so that the service provider, service consumers can be isolated. In addition to consul, there are Eureka, zookeeper and other similar software. Consul is the server that stores the service name and IP and port correspondence
Consul is Google Open source, a service discovery, Configuration Management Center service developed using the Go language. Built-in service registration and discovery Framework, distributed consistency Protocol implementation, health check, Key/value storage, multi-datacenter scenarios, no longer rely on other tools (such as zookeeper, etc.). Service deployment is simple and only one binary package can be run. Each node needs to run the agent, and he has two modes of running mode server and client. Each data center is officially recommended to require 3 or 5 server nodes to ensure data security, while ensuring that server-leader elections are carried out correctly.
@client
The client represents the consul, which is the clients mode. is a mode of the consul node, in which all services registered to the current node are forwarded to the server, which itself is not persisted in this information.
@server
Server represents the Consul server mode, indicating that this consul is a server, in this mode, the function and the client are the same, the only difference is that it will persist all the information locally, so that the failure, information can be retained.
@server-leader
In the middle of the server there are leader words, indicating that the server is their boss, and it is not the same as other servers, it needs to be responsible for synchronizing the registration of information to other servers, but also responsible for the health monitoring of each node.
@raft
Data consistency between server nodes guarantees that the conformance protocol uses raft, and the PAXOS,ETCD used by zookeeper is also Taft.
@ Service Discovery Protocol
Consul uses HTTP and DNS protocols, ETCD only supports HTTP
@ Service Registration
Consul support two ways to implement service registration, one is to register the HTTP API through the Consul service, the service calls the API to implement the registration, the other way is through the JSON is a configuration file implementation of registration, the need to register the service in JSON format configuration file. The second approach is recommended by the official consul.
@ Service Discovery
Consul supports two ways to implement service discovery, one is to query what services are available through the HTTP API, and the other is through DNS (port 8600) with the consul agent. The domain name is given in the form of NAME.service.consul, which is the name of the service in the defined service configuration file. The DNS method can be checked to check the service.
@ Inter-Service Communication protocol
Consul uses the gossip protocol to manage membership, broadcast messages to the entire cluster, he has two gossip pool (LAN pool and WAN pool), LAN pool is communication within the same data center, WAN pool is multiple data center communication, LAN There are multiple pool, only one WAN pool.
Second, installation
Consul official website: https://www.consul.io/
1) Download
wget https://releases.hashicorp.com/consul/1.3.0/consul_1.3.0_linux_amd64.zip
2) Unzip
Unzip Consul_1.3.0_linux_amd64.zip
3) Copy to USR directory
MV Consul/ usr
4) See if the installation was successful
./consul
5) Start
. / consul agent - dev - UI - node = consul - dev - client = 192.168. *. * * # IP virtual machines
6) After the http://192.168*.**:8500 in the browser will be able to access the
CentOS Installation Consul Micro-service