Installation
We will be installing Consul on each machine. We are using the latest Consul version as of this writing (0.6.4).
Download the consul program from the Consul project's page and follow the steps below:
Download the version corresponding to your operating system and architecture. In this guide, since we are using 64-bit servers, we will use the "amd64" link under "linux".
In your terminal, change your directory to /usr/local/bin, where we will keep the executable.
root@server1:~#cd /usr/local/bin
root@server1:~#wget https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip
Now, we can extract the binary package and we can then remove the zipped file.
root@server1:~#unzip consul_0.6.4_linux_amd64.zip
root@server1:~#consul version
Consul v0.6.4
Consul Protocol: 3 (Understands back to: 1)
Repeat these steps on all your machines. You should now have the consul command available on all of your nodes.
Create the necessary directories
We can easily try out Consul in an unstructured way by using the consul
command. This will allow you to test out some functionality and to get familiar with the software. But in a real world environment having an organized directory structure makes things easier to maintain. Complete the following steps on each of your servers and clients.
We will run Consul processes with a dedicated user.
Create the user:
root@server1:~#useradd -m consul
root@server1:~#passwd consul
Enter new UNIX password: consul
Retype new UNIX password: consul
passwd: password updated successfully
root@server1:~#usermod -aG sudo consul
We will next create the configuration directories where we can store Consul configuration. We will make a parent consul.d
directory in /etc
and create a subdirectory server
for the server nodes and a client
directory for the client node. We can put our configuration as a JSON file inside these directories. Having this structure is not mandatory but it helps to keep things organized.
root@server1:~#mkdir -p /etc/consul.d/server
We also need to create a location where Consul can store persistant data between reboots. We will create this directory at /var/consul
and change its ownership to the consul
user so that it can manage the data:
root@server1:~#mkdir /var/consul
root@server1:~#chown consul: /var/consul
All our directories are now in place, now we will create configuration files on each node under /etc/consul.d/server/
Before creating the configuration files we need to understand what is bootstrapping.