https://etcd.io/docs/v3.6/install/


Install pre-built binaries

  1. Download the compressed archive file for your platform from Releases
ETCD_VER=v3.6.6

# choose either URL
GOOGLE_URL=https://storage.googleapis.com/etcd
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
DOWNLOAD_URL=${GOOGLE_URL}

curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
  1. Unpack the archive file. This results in a directory containing the binaries.
tar xvf etcd-${ETCD_VER}-linux-amd64.tar.gz
  1. Add the executable binaries to your path. For example, rename and/or move the binaries to a directory in your path (like /usr/local/bin), or add the directory created by the previous step to your path.
cd etcd-${ETCD_VER}-linux-amd64
sudo mv etcd etcdctl etcdutl /usr/local/bin/
  1. From a shell, test that etcd is in your path:
$ etcd --version
etcd Version: 3.6.6
...


Add etcd to systemd

  1. Start by creating a configuration and data directory for the etcd service.
$ sudo mkdir -p /var/lib/etcd/default
$ sudo mkdir /etc/etcd/
  1. Change the ownership of the /var/lib/etcd directory to your target user.
$ sudo useradd etcd -r -s /sbin/nologin
$ sudo chown -R etcd:etcd /var/lib/etcd
  1. Create /etc/systemd/system/etcd.service and add the following content to it.
[Unit]
Description=etcd - highly-available key value store
Documentation=https://etcd.io/docs
After=network.target
Wants=network-online.target

[Service]
# Using non-login system users.
User=etcd
Group=etcd

# Load environment variables from an optional configuration file
# For example: /etc/default/etcd
EnvironmentFile=-/etc/default/%p

# Set the working directory of the process
WorkingDirectory=/var/lib/etcd/default

Type=notify

# The main command to start etcd
# $DAEMON_ARGS will be replaced by the value in the EnvironmentFile or the Environment directive.
ExecStart=/usr/local/bin/etcd $DAEMON_ARGS
Restart=on-abnormal
RestartSec=10s

# Set a high file descriptor limit for etcd
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
  1. Configuration file /etc/default/etcd

A single-node etcd instance (used for development or simple applications).

DAEMON_ARGS="\
  --name etcd-node1 \
  --data-dir /var/lib/etcd/default \
  --listen-client-urls http://172.20.42.221:2379,http://127.0.0.1:2379 \
  --advertise-client-urls http://172.20.42.221:2379 \
"
  1. Run the etcd
sudo systemctl daemon-reload
sudo systemctl start etcd


%p is a specifier provided by systemd, and can be considered a dynamic variable.

  • Meaning: It represents the “prefix name” or “primary name” of the unit. Specifically, it’s the part of the unit filename without the type suffix (.service, .target, etc.).

  • In your example:

    • Your service filename is etcd.service.

    • When systemd parses this file, it automatically replaces %p with etcd.

    • Therefore, the line EnvironmentFile=-/etc/default/%p is ultimately interpreted as EnvironmentFile=-/etc/default/etcd.


EnvironmentFile=:Load environment variable file

This command tells systemd to read environment variables from a specified file before starting the service.

  • Function:

    i. systemd will open this file.

    ii. It will read the file content line by line, looking for lines in the format KEY=VALUE.

    iii. For each valid key-value pair, systemd will set an environment variable with the same name for the service process that is about to start.

  • File Format: This file is a simple list of key-value pairs, and comments can begin with #. For example, the content of the /etc/default/etcd file could be:

    # /etc/default/etcd
    #
    # Etcd daemon arguments
    DAEMON_ARGS="--name my-etcd-1 --initial-cluster-token etcd-cluster-1 --listen-client-urls http://0.0.0.0:2379"
    
    # Other environment variables
    ETCD_HEARTBEAT_INTERVAL=100
    ETCD_ELECTION_TIMEOUT=1000

    When the service starts, $DAEMON_ARGS in the command ExecStart=/usr/local/bin/etcd $DAEMON_ARGS will be replaced with the long string defined above.

Last modified: March 21, 2026

Comments

Write a Reply or Comment

Your email address will not be published.

The maximum upload file size: 80 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop files here