Skip to content

How to install Consul

Hashicorp consul tutorial complete guide
Share

Reading Time: 2 minutes

In this tutorial, you will learn How to install Consul on Centos or Linux systems. Consul is an important service discovery tool in the world of Devops. This tutorial covers in-depth working knowledge of Consul, its setup and deployment. I recommend you to go through the complete tutorial Hashicorp consul tutorial complete guide. Before installing any software, it’s a good practice to update your system packages to ensure you have the latest versions.

To install Consul on CentOS, you can follow these steps:

Update System Packages:

Before installing any software, it’s a good practice to update your system packages to ensure you have the latest versions.

sudo yum update

Download Consul:

You can download Consul from the HashiCorp website. Replace <VERSION> with the desired version number.
Download URL:

CONSUL_VERSION=<VERSION>
wget https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip

Install Unzip (if not installed):

If you don’t have the unzip utility installed, you’ll need it to extract the Consul archive

sudo yum install unzip

How to install Consul

Unzip the downloaded Consul archive and move the binary to a directory in your system’s PATH, like /usr/local/bin/.

unzip consul_${CONSUL_VERSION}_linux_amd64.zip
sudo mv consul /usr/local/bin/

Create a Systemd Service Unit:

Consul can be managed as a systemd service for easy start, stop, and management.
Create a Consul service unit file using your preferred text editor. For example:

$ sudo nano /etc/systemd/system/consul.service

Add the following content to the file, adjusting paths and configurations as needed:

[Unit]
Description=Consul
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target

[Service]
User=consul
Group=consul
ExecStart=/usr/local/bin/consul agent -config-dir=/etc/consul.d/
ExecReload=/usr/local/bin/consul reload
KillMode=process
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

Hashicorp consul tutorial complete guide

Create Consul Configuration Directory:

Create the directory for Consul configuration files.

$ sudo mkdir /etc/consul.d

Start and Enable Consul:

Start the Consul service and enable it to start on boot.

sudo systemctl start consul
sudo systemctl enable consul

Verify Installation:

$ sudo systemctl status consul

You’ve successfully installed Consul on CentOS and set it up as a systemd service. Remember to configure Consul’s settings and options in the /etc/consul.d/ directory to match your requirements.

You can read the complete tutorial of the consul here.


Share

Leave a Reply

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

?>