How To Install Consul on Ubuntu 20.04 LTS

Consul is a free & open-source tool.It is used for service discovery and configuration. It is a backend storage used for storing key & values & it stores Vault’s data. Consul provides high Availability ,health checks, load balancing & a service graph & a configuration key-value store.

Install Consul on Ubuntu

Update the System.

apt-get update

Download the consul file.

wget https://releases.hashicorp.com/consul/1.3.0/consul_1.3.0_linux_amd64.zip

Extract the downloaded file.

apt-get install unzip
unzip consul_1.3.0_linux_amd64.zip

Move to extract download file to /usr/bin.

mv consul /usr/bin

Configure the SystemD service for Consul:

vim /etc/systemd/system/consul.service

Add the following lines:

[Unit]
Description=Consul
Documentation=https://www.consul.io/
 
[Service]
ExecStart=/usr/bin/consul agent -server -ui -data-dir=/tmp/consul -bootstrap-expect=1 
-node=vault -bind=server-ip/0.0.0.0 -config-dir=/etc/consul.d/
ExecReload=/bin/kill -HUP $MAINPID
LimitNOFILE=65536
 
[Install]
WantedBy=multi-user.target

Create a Consul.d folder.

mkdir /etc/consul.d/

Create a .json file.

vim /etc/consul.d/ui.json

Add the following lines:

{
  "addresses": {
    "http": "0.0.0.0"
  }
}

Reload the system & Start & Enable the Consul Service:

systemctl daemon-reload
systemctl start consul
systemctl enable consul

Check the Consul:

consul members

Here is the command output.

Node   Address             Status  Type    Build  Protocol  DC   Segment
vault  172.31.25.210:8301  alive   server  1.3.0  2         dc1  <all>

open the 8500 port number on ufw firewall.

ufw allow 8500/tcp

Access Consul web-interface

http://server-ip:8500

Here is the output.

 

Fig 1

  • Click on Key/value option.
  • Click on Create.

 

Fig 2

 

  • Provide Key or Folder name.
  • Provide the code value.

 

Fig. 3

 

  • Unable the code option.
  • Provide the value.
  • Click on Save.

 

Fig. 4

 

  • Key has been added successfully.

 

Fig. 7

 

Leave a Reply

Your email address will not be published. Required fields are marked *