Deploying an etcd Cluster Using Static Configuration

To deploy a highly available etcd cluster using static configuration, each node must be explicitly defined at startup. This method requires specifying all peer endpoints in advance and is suitable for environments with fixed infrastructure.

Key etcd Startup Parameters

  • --data-dir: Directory for storing node data such as snapshots, WAL files (unless --wal-dir is set), and cluster metadata.
  • --wal-dir: Optional directory for Write-Ahead Log (WAL) files.
  • --name: Unique identifier for the node within the cluster.
  • --initial-advertise-peer-urls: URLs this node advertises to peers during cluster bootstrap.
  • --listen-peer-urls: Local addresses on which the node listens for peer communication.
  • --advertise-client-urls: URLs advertised to clients for accessing the etcd service.
  • --listen-client-urls: Local addresses for client connections.
  • --initial-cluster-token: Shared token identifying the cluster.
  • --initial-cluster: Comma-separated list of all initial cluster members in the format name=url.
  • --initial-cluster-state: Must be new for initial cluster creation.

Environment Setup

Assume three nodes:

Hostname IP Address
etcd1 192.168.123.160
etcd2 192.168.123.161
etcd3 192.168.123.162

Before proceeeding:

  • Disable firewlals and SELinux to avoid connectivity issues.
  • Ensure consistent time across all nodes using NTP or similar.
  • Optionally configure /etc/hosts for name resolution:
192.168.123.160 etcd1
192.168.123.161 etcd2
192.168.123.162 etcd3

Binary Installation

Download etcd v3.5.4 from GitHub releases:

tar -xzf etcd-v3.5.4-linux-amd64.tar.gz
sudo cp etcd-v3.5.4-linux-amd64/etcd* /usr/bin/

Repeat this step on all nodes, or copy binaries via scp:

scp etcd-v3.5.4-linux-amd64/etcd* etcd2:/usr/bin/
scp etcd-v3.5.4-linux-amd64/etcd* etcd3:/usr/bin/

Verify installation:

ssh etcd2 'etcd --version'
ssh etcd3 'etcd --version'

Create a dedicated data directory on each node:

sudo mkdir -p /data/etcdData

Systemd Service Configuration

Create /usr/lib/systemd/system/etcd.service on each node with node-specific parameters.

etcd1:

[Unit]
Description=etcd service
Documentation=https://github.com/etcd-io/etcd

[Service]
User=root
Type=notify
ExecStart=/usr/bin/etcd \
  --name etcd1 \
  --data-dir /data/etcdData \
  --initial-advertise-peer-urls http://192.168.123.160:2380 \
  --listen-peer-urls http://192.168.123.160:2380 \
  --listen-client-urls http://192.168.123.160:2379,http://127.0.0.1:2379 \
  --advertise-client-urls http://192.168.123.160:2379 \
  --initial-cluster-token etcd-cluster \
  --initial-cluster etcd1=http://192.168.123.160:2380,etcd2=http://192.168.123.161:2380,etcd3=http://192.168.123.162:2380 \
  --initial-cluster-state new \
  --heartbeat-interval 1000 \
  --election-timeout 5000
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

etcd2: Replace --name with etcd2 and update all IP addresses to 192.168.123.161.

etcd3: Replace --name with etcd3 and update all IP addresses to 192.168.123.162.

After creating or modifying the service file on any node, reload systemd:

sudo systemctl daemon-reload

Starting the Cluster

Start the services in sequence, but note that the first node may appear to hang or fail initially because it waits for other members:

# On etcd1
sudo systemctl start etcd

# On etcd2
sudo systemctl start etcd

# On etcd3
sudo systemctl start etcd

If the first node reports failure, restart it after the others are up:

sudo systemctl restart etcd

This behavior occurs because etcd requires quorum to form a cluster; a single node cannot achieve quorum in a 3-node setup.

Verification

Check cluster membership from any node:

etcdctl member list --write-out=table

Expected output:

+------------------+---------+-------+-----------------------------+-----------------------------+------------+
|        ID        | STATUS  | NAME  |         PEER ADDRS          |        CLIENT ADDRS         | IS LEARNER |
+------------------+---------+-------+-----------------------------+-----------------------------+------------+
| 2f107ed12dcf060d | started | etcd2 | http://192.168.123.161:2380 | http://192.168.123.161:2379 |      false |
| 4f36d86f7d67fa14 | started | etcd1 | http://192.168.123.160:2380 | http://192.168.123.160:2379 |      false |
| 89d28152c949347f | started | etcd3 | http://192.168.123.162:2380 | http://192.168.123.162:2379 |      false |
+------------------+---------+-------+-----------------------------+-----------------------------+------------+

Tags: etcd distributed-systems cluster-setup static-configuration systemd

Posted on Sat, 04 Jul 2026 16:36:18 +0000 by sn0n