How to Install Consul Server on Ubuntu 22.04
Last Updated :
26 Aug, 2024
Consul is a free and open-source service discovery by Hashicorp. It's available on every Linux distribution, including Debian/Ubuntu, and RHEL/CentOS distributions. It is used for service discovery.
Required Ubuntu Version
Generally, we should use the latest Ubuntu versions currently 22.04 but this method works for 18.04 and above versions.
Ubuntu InfoWhy use Consul Servers?
Services require the network locations (IP addresses and ports) of the other services to communicate with each other. Earlier before Consul, we had to write code for each of the services in the service configuration console, which can be time-consuming and error-prone. If a service's location changes, all dependent services are to be updated manually.
Consul helps services find each other. Now instead of hard-coding network locations, services are dynamically recognized and connected to other services.
How do Consul Servers work?
Services register themselves with Consul by providing their details (name, address, port, MAC Address, etc.) either through DNS or HTTP requests.. Console servers can be used to monitor the console of other machines, support data centers, and remotely solve issues. They enable administrators to remotely access the consoles of different machines. It's like viewing and interacting with the system consoles as if they were physically present. This is a centralized management system and is highly efficient.
Consul features include a Service Mesh that provides secure connections with TLS(Transport Layer Security) and provides authorization between services.
Prerequisite:- Ensure that you have Ubuntu updated and sudo privileges given on servers.
1. To update, download, and install the latest packages in your system use the Command :
sudo apt-update
sudo apt-get update
2. Now download the latest version of consul 1.8.4 :
wget https://releases.hashicorp.com/consul/1.8.4/consul_1.8.4_linux_amd64.zip
This command will download the Consul ZIP file to your current directory. wget is a command used to download files from the internet. It supports HTTP, HTTPS, and FTP protocols.
3. Unzip the zip file using command :
unzip consul_1.8.4_linux_amd64.zip
4.Move the consul binary to the /usr/local/bin directory with the following command : sudo mv consul /usr/local/bin/ .This is done so that when the Consul binary is in /usr/local/bin/, it becomes available for execution from any directory in the terminal. The Consul binary is the executable file for the Consul software, which is used for service discovery. Use ls command to check the files in the directory.
5. To versify the version installed
consul --version
Hence, Consul Version 1.8.4 is installed in your Ubuntu (linux) System properly.
Setting Up UFW
UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables firewall rules. It serves as an interface to iptables, simplifying the configuration of your firewall. UFW is generally installed by default on Ubuntu. If it is uninstalled, you can install it with the following command:
sudo apt install ufw
Step 1: Enable IPv6
If IPv6 (Internet Protocol Version 6) is not enabled already, you need to enable it:
1. Open the UFW configuration file:
sudo nano /etc/default/ufw
2. Find the line that sets the IPV6 variable and change its value to yes:
IPV6=yes
Save and close the file.
Step 2: Check Default Firewall Policies
Default firewall policies control how to handle traffic that does not match any other rules. By default, UFW is set to deny all incoming connections and allow all outgoing connections. You can configure these settings manually using the following commands:
To set the default incoming policy to deny
sudo ufw default deny incoming
To set the default outgoing policy to allow
sudo ufw default allow outgoing
Step 3: Allow the OpenSSH UFW Application Profile
To ensure that you can connect to your server via SSH, you need to allow the OpenSSH application profile:
Run the following command to create firewall rules that allow all connections on port 22, the default port for SSH:
sudo ufw allow OpenSSH
Step 4: Enable the Firewall
Once you have configured the necessary rules, you can enable the firewall with the following command:
sudo ufw enable
Step 5: Allow HTTP/HTTPS Connections
For common web traffic, you may want to allow HTTP and HTTPS connections:
Allow HTTP connections
sudo ufw allow http
Allow HTTPS connections
sudo ufw allow https
UFW policies set to correct values
Similar Reads
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read
Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
Linux Commands Cheat Sheet Linux, often associated with being a complex operating system primarily used by developers, may not necessarily fit that description entirely. While it can initially appear challenging for beginners, once you immerse yourself in the Linux world, you may find it difficult to return to your previous W
13 min read
CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi
6 min read
What is Vacuum Circuit Breaker? A vacuum circuit breaker is a type of breaker that utilizes a vacuum as the medium to extinguish electrical arcs. Within this circuit breaker, there is a vacuum interrupter that houses the stationary and mobile contacts in a permanently sealed enclosure. When the contacts are separated in a high vac
13 min read
Linux/Unix Tutorial Linux is one of the most widely used open-source operating systems. It's fast, secure, stable, and powers everything from smartphones and servers to cloud platforms and IoT devices. Linux is especially popular among developers, system administrators, and DevOps professionals.Linux is:A Unix-like OS
10 min read