In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to install Consul". In daily operation, I believe many people have doubts about how to install Consul. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to install Consul". Next, please follow the editor to study!
What is consul?
Consul is a solution of Service Grid (service mesh). Consul is a full-function control plane with service discovery, configuration and segmentation functions. These functions can be used individually as needed, or together to build a complete service grid. Consul requires a data plane and supports both agent and native integration models. Consul comes with a simple built-in agent, so it works right out of the box, but it also supports third-party agent integration such as Envoy.
Consul actually addresses the network and security challenges of running microservices and cloud-native infrastructure. Consul provides a cloud native software-driven routing and segmentation approach. It also brings other benefits, such as fault handling, retry and network observability.
The above mentioned service grid and data plane, service grid is usually said together with micro-services, do not expand here to talk about service grid, there will be a special article that belongs to the popular cloud native concept, RedHat has a good article introduction, I need to see the address: https://www.redhat.com/en/topics/microservices/what-is-a-service-mesh. The data plane is well understood as the layer in the software and service architecture that handles data requests. By contrast, the control plane is the software part that configures and shuts down the data plane, where Consul acts as the control plane.
The main features of Consul are as follows:
Service discovery
Clients of Consul can register services, such as api or mysql, and clients can use Consul to discover registered services. With DNS or HTTP, applications can easily find the services they depend on.
Health examination
The Consul client can provide any number of health checks, which can be related to a given service ("whether the Web server returns 200 OK") or a local node ("memory utilization less than 90%"). You can use this information to monitor the health of the cluster, and the service discovery component can use this information to divert traffic away from abnormal hosts.
KV storage
Your application can use Consul's hierarchical key / value storage for a variety of purposes, not limited to dynamic configuration, functional tagging, coordination, cluster leader elections, and so on. The simple HTTP API provided by Consul makes it very easy to use.
Secure service communication
Consul can generate and distribute TLS certificates for services and then establish mutual TLS connections. Intent is used to define which services are allowed to communicate. The intent can be changed in real time to easily manage service segments without using complex network topologies and static firewall rules.
Multiple data centers
Consul supports multiple data centers right out of the box. This means that users of Consul do not have to worry about building other abstraction layers to extend to multiple areas
Consul is designed to be very friendly to the DevOps community and application developers, making it well suited to a modern, flexible infrastructure.
The basic architecture of Consul
Consul is a distributed, highly available system. This section introduces the basics and intentionally omits some unnecessary details to get a quick idea of how Consul works.
Each node that provides services to Consul runs Consul's agent, which may not be needed when used to discover services or obtain configured key-value pairs of data. The agent is responsible for the services on the node and the health inspection of the node itself.
The agent communicates with one or more Consul servers. The Consul server is the place where data is stored and copied. The server itself elects a leader. Although Consul can run on one server, three to five nodes are recommended to avoid data loss due to failure. It is recommended that you use a Consul server cluster for each data center.
The server maintains a directory that is generated by summarizing the data submitted by the agent. This directory maintains a high-level view of the cluster, including which services are available, which nodes are running these services, health information, and so on.
You need to discover the underlying components of other services or nodes, and you can query any Consul server or any Consul agent. The agent automatically forwards the query to the server.
Each data center runs a cluster of Consul servers. When a service discovery or configuration request is made across the data center, the local Consul server forwards the request to the remote data center and returns the result.
Consul installation here for the convenience of the environment, using the docker way, before also tried the virtual machine, notebook physical machine and so on, are not as convenient as using docker installation.
Get the image file
Docker pull consul
If the network is slow, it may take about a few minutes to execute. It can be solved by configuring docker image. I configured Ali image.
Check to see if the download is complete
➜docker images-f 'reference=consul' REPOSITORY TAG IMAGE ID CREATED SIZE consul latest 2823bc69f80f 4 weeks ago 120MB
Start the Consul server
➜docker images-f 'reference=consul' REPOSITORY TAG IMAGE ID CREATED SIZE consul latest 2823bc69f80f 4 weeks ago 120MB
-d: indicates that the background starts
-p: indicates that native 8500 and 8600 are mapped to the 8500 and 8600/udp ports of the docker container
The last line is the command for consul to start the server
Observe the startup log
Because it was started in the background just now, and you can't see the log, you can check it in the following way
The id after ➜docker logs d2806ac2b7e1 / / is the id of the container, which can be viewed through docker-ps-l
When you see such a log, it shows that it is no problem to start.
= = > Starting Consul agent... Version: '1.9.1' Node ID: '5cea9bb5-53f2mure71eMur1a46Mub 23f188da307' Node name:' server-1' Datacenter: 'dc1' (Segment:'') Server: true (Bootstrap: true) Client Addr: [0.0.0.0] (HTTP: 8500, HTTPS:-1, gRPC:-1 DNS: 8600) Cluster Addr: 172.17.0.2 (LAN: 8301, WAN: 8302) Encrypt: Gossip: false, TLS-Outgoing: false, TLS. = > Consul agent running!
Now that the server is started, you should start a client to connect to the server. Here is a question: how do I know the IP address and port number of the server I started? docker provides a way to execute Consul commands in the container directly.
➜docker exec d2806ac2b7e1 consul members Node Address Status Type Build Protocol DC Segment server-1 172.17.0.2:8301 alive server 1.9.1 2 dc1
Of course, you can also go directly to the inside of the container, using the exec command.
Docker exec-it d2806ac2b7e1 / bin/sh / / then execute consul members
Docker executes commands supported in the container as follows:
Docker exec consul members
It is found here that the address of the server is 172.17.0.2purl 8301.
Configure the running client
Docker run\-name=test-1\ consul agent-node=client-1-join=172.17.0.2
There is no problem when you see the output below. Note that name refers to the container parameters.
= = > Starting Consul agent... = = > Joining cluster... Join completed. Synced with 1 initial agents = > Consul agent running! Version: 'v1.4.4' Node ID:' 4b6da3c6-b13f-eba2-2b78-446ffa627633' Node name: 'client-1' Datacenter:' dc1' (Segment:'') Server: false (Bootstrap: false) Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS:-1, gRPC:-1 DNS: 8600) Cluster Addr: 172.17.0.4 (LAN: 8301, WAN: 8302) Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false
Check whether the client has joined by executing the consul Members command in the container again
Docker exec d2806ac2b7e1 consul members
It is found that it has become two, and the states are all available.
Docker exec d2806ac2b7e1 consul members Node Address Status Type Build Protocol DC Segment server-1 172.17.0.2:8301 alive server 1.9.1 2 dc1 client-1 172.17.0.3:8301 alive client 1.9.1 2 dc1
Now that you have a small data center, you can register services or configure data to play with.
In fact, the way to view the data center can also be viewed through web. The default http interface of Consul is port 8500. The ui interface launched by this port can easily manage and configure the data center. Open as shown in the figure and click NODES to view the node.
Click on the node, and on the right you can see the health status of the node, whether the agent is available, etc.
At this point, the study on "how to install Consul" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.