Install etcd on RHEL 8|CentOS 8|Rocky Linux 8|AlmaLinux 8

Posted on 77 views

This guide will explain how to install etcd on RHEL 8 / CentOS 8 / Rocky Linux 8 / AlmaLinux 8 Linux machine. Etcd is a simple, reliable, fast and secure open source key-value store written in Go. It uses the Raft consensus algorithm to manage a highly-available replicated log. The installation shared here is not for use in Production environments as it is on a single node (one member etcd).

Note: This is a single node cluster setup, for three node cluster, refer to the guide below.

Install etcd on RHEL 8 / CentOS 8 / Rocky Linux 8 / AlmaLinux 8

Being written in Go, etcd is distributed as a binary package but installation from source is also available. In this guide, we’re going to download a pre-built binary package.

Ensure you have vim and wget installed on your RHEL 8 / CentOS 8 / Rocky Linux 8 / AlmaLinux 8 server.

sudo dnf -y install curl wget vim

Step 1: Download Etcd binary

Check the latest release on releases page before you proceed to get the latest release tag.

ETCD_RELEASE=$(curl -s|grep tag_name | cut -d '"' -f 4)

Extract downloaded archive file.

tar xvf etcd-$ETCD_RELEASE-linux-amd64.tar.gz

Change to new file directory

cd etcd-$ETCD_RELEASE-linux-amd64

Move etcd and etcdctl binary files to /usr/local/bin directory.

sudo mv etcd* /usr/local/bin 

List binary files and scripts executable in /usr/local/bin directory:

$ ls /usr/local/bin 
etcd  etcdctl  etcdutl

Confirm version.

$ etcd --version
etcd Version: 3.5.2
Git SHA: 99018a77b
Go Version: go1.16.3
Go OS/Arch: linux/amd64

$ etcdctl version
etcdctl version: 3.5.2
API version: 3.5

$ etcdutl version
etcdutl version: 3.5.2
API version: 3.5

Step 2: Configure Etcd Systemd service

We’re going to use systemd to manage etcd service. First, create data directory for etcd.

sudo mkdir -p /var/lib/etcd/
sudo mkdir /etc/etcd

Create etcd system user

sudo groupadd --system etcd
sudo useradd -s /sbin/nologin --system -g etcd etcd

Set /var/lib/etcd/ directory ownership to etcd user.

sudo chown -R etcd:etcd /var/lib/etcd/
sudo chmod 0775 /var/lib/etcd/

Configure Systemd and start etcd service

Create a new systemd service file for etcd.

sudo vim /etc/systemd/system/etcd.service

Paste below contents to the file.

Description=etcd key-value store



Reload systemd service and start etcd on RHEL 8 / CentOS 8 / Rocky Linux 8 / AlmaLinux 8 system.

sudo systemctl daemon-reload
sudo systemctl start etcd.service

Enable service to start when system is rebooted

$ sudo systemctl enable etcd.service
Created symlink /etc/systemd/system/ → /etc/systemd/system/etcd.service.

If you have SELinux running in enforcing mode, then generate a local policy module to allow access to data directories.

sudo ausearch -c '(etcd)' --raw | audit2allow -M my-etcd

To make this policy package active, execute:

sudo semodule -X 300 -i my-etcd.pp
sudo restorecon -Rv /usr/local/bin/etcd

Restart etcd service.

sudo systemctl restart etcd

Check service status to confirm it is running.

$ systemctl status etcd
● etcd.service - etcd key-value store
   Loaded: loaded (/etc/systemd/system/etcd.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2022-02-04 08:24:44 UTC; 1min 4s ago
 Main PID: 15332 (etcd)
    Tasks: 9 (limit: 49496)
   Memory: 10.6M
   CGroup: /system.slice/etcd.service
           └─15332 /usr/local/bin/etcd

The service will start on localhost address port 2379

$ ss -tunelp | grep 2379
tcp   LISTEN 0 128*  uid:998 ino:72981 sk:45c <-> 

$ etcdctl member list
8e9e05c52164694d, started, 81ba7538b1b7d8a45871e0bfc6afa64d, http://localhost:2380, http://localhost:2379, false

Checking health status of the etcd node:

$ etcdctl endpoint health is healthy: successfully committed proposal: took = 1.711475ms

$ etcdctl endpoint status, 8e9e05c52164694d, 3.5.2, 20 kB, true, false, 2, 6, 6,

Step 3: Test Etcd Installation

Test your etcd installation on RHEL 8 / CentOS 8 / Rocky Linux 8 / AlmaLinux 8 by writing to etcd.

$ etcdctl put welcome "Hello World"

Read the value of message back:

$ etcdctl get welcome
Hello World

To delete the key run:

$ etcdctl del welcome

$ etcdctl get welcome

There you have it. Etcd has been installed on RHEL 8 / CentOS 8 / Rocky Linux 8 / AlmaLinux 8 system. For the Ubuntu systems, check how to install etcd on Ubuntu.


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.