etcd Cluster
| Server IP | Host Role |
|---|---|
| 192.168.10.31 | etcd Node01 |
| 192.168.10.32 | etcd Node02 |
| 192.168.10.33 | etcd Node03 |
etcd Node01
-
Download the etcd installation package
- Servers with Internet Access
- Servers without Internet Access
wget https://pdpublic.mingdao.com/private-deployment/offline/common/etcd-v3.6.11-linux-amd64.tar.gz# etcd installation package download link. Download and upload it to the deployment server.https://pdpublic.mingdao.com/private-deployment/offline/common/etcd-v3.6.11-linux-amd64.tar.gz -
Create the etcd runtime user
useradd -M -s /sbin/nologin etcd -
Extract the etcd package and install the binaries
mkdir -p /usr/local/etcd/bintar -zxf etcd-v3.6.11-linux-amd64.tar.gzcp etcd-v3.6.11-linux-amd64/etcd /usr/local/etcd/bin/cp etcd-v3.6.11-linux-amd64/etcdctl /usr/local/etcd/bin/cp etcd-v3.6.11-linux-amd64/etcdutl /usr/local/etcd/bin/chmod +x /usr/local/etcd/bin/etcd*chown -R etcd:etcd /usr/local/etcd -
Create data and log directories
mkdir -p /data/etcdmkdir -p /data/logs/etcdchown -R etcd:etcd /data/etcd /data/logs/etcd -
Modify the etcd configuration file
cat > /usr/local/etcd/etcd.conf.yml <<'EOF'name: etcd-01data-dir: /data/etcdlisten-client-urls: http://192.168.10.31:2379,http://127.0.0.1:2379advertise-client-urls: http://192.168.10.31:2379listen-peer-urls: http://192.168.10.31:2380initial-advertise-peer-urls: http://192.168.10.31:2380listen-metrics-urls: http://192.168.10.31:2381,http://127.0.0.1:2381initial-cluster: etcd-01=http://192.168.10.31:2380,etcd-02=http://192.168.10.32:2380,etcd-03=http://192.168.10.33:2380initial-cluster-token: hap-milvus-etcdinitial-cluster-state: newauto-compaction-mode: periodicauto-compaction-retention: 10hquota-backend-bytes: 8589934592snapshot-count: 100000max-snapshots: 5max-wals: 5strict-reconfig-check: truepre-vote: trueenable-v2: falsemetrics: basiclogger: zaplog-level: infolog-outputs:- /data/logs/etcd/etcd.logenable-log-rotation: truelog-rotation-config-json: '{"maxsize":100,"maxage":180,"maxbackups":0,"localtime":true,"compress":true}'EOF- Replace the IP addresses in
listen-client-urlsandadvertise-client-urlswith the actual deployment server IP.
- Replace the IP addresses in
-
Configure systemd to manage etcd-01
cat > /etc/systemd/system/etcd-01.service <<'EOF'[Unit]Description=etcd member etcd-01Documentation=https://etcd.io/docs/After=network-online.targetWants=network-online.target[Service]Type=simpleUser=etcdGroup=etcdExecStart=/usr/local/etcd/bin/etcd --config-file=/usr/local/etcd/etcd.conf.ymlRestart=on-failureRestartSec=5sLimitNOFILE=65536LimitNPROC=65536OOMScoreAdjust=-999[Install]WantedBy=multi-user.targetEOF -
Start etcd-01 and enable startup on boot
systemctl daemon-reloadsystemctl start etcd-01systemctl enable etcd-01 -
Check Service Status
systemctl status etcd-01 --no-pager -
View Runtime Logs
journalctl -u etcd-01 -n 100 -l --no-pager
etcd Node02
-
Download the etcd installation package
- Servers with Internet Access
- Servers without Internet Access
wget https://pdpublic.mingdao.com/private-deployment/offline/common/etcd-v3.6.11-linux-amd64.tar.gz# etcd installation package download link. Download and upload it to the deployment server.https://pdpublic.mingdao.com/private-deployment/offline/common/etcd-v3.6.11-linux-amd64.tar.gz -
Create the etcd runtime user
useradd -M -s /sbin/nologin etcd -
Extract the etcd package and install the binaries
mkdir -p /usr/local/etcd/bintar -zxf etcd-v3.6.11-linux-amd64.tar.gzcp etcd-v3.6.11-linux-amd64/etcd /usr/local/etcd/bin/cp etcd-v3.6.11-linux-amd64/etcdctl /usr/local/etcd/bin/cp etcd-v3.6.11-linux-amd64/etcdutl /usr/local/etcd/bin/chmod +x /usr/local/etcd/bin/etcd*chown -R etcd:etcd /usr/local/etcd- Installation verification
/usr/local/etcd/bin/etcd --version/usr/local/etcd/bin/etcdctl version/usr/local/etcd/bin/etcdutl version -
Create data and log directories
mkdir -p /data/etcdmkdir -p /data/logs/etcdchown -R etcd:etcd /data/etcd /data/logs/etcd -
Modify the etcd configuration file
cat > /usr/local/etcd/etcd.conf.yml <<'EOF'name: etcd-02data-dir: /data/etcdlisten-client-urls: http://192.168.10.32:2379,http://127.0.0.1:2379advertise-client-urls: http://192.168.10.32:2379listen-peer-urls: http://192.168.10.32:2380initial-advertise-peer-urls: http://192.168.10.32:2380listen-metrics-urls: http://192.168.10.32:2381,http://127.0.0.1:2381initial-cluster: etcd-01=http://192.168.10.31:2380,etcd-02=http://192.168.10.32:2380,etcd-03=http://192.168.10.33:2380initial-cluster-token: hap-milvus-etcdinitial-cluster-state: newauto-compaction-mode: periodicauto-compaction-retention: 10hquota-backend-bytes: 8589934592snapshot-count: 100000max-snapshots: 5max-wals: 5strict-reconfig-check: truepre-vote: trueenable-v2: falsemetrics: basiclogger: zaplog-level: infolog-outputs:- /data/logs/etcd/etcd.logenable-log-rotation: truelog-rotation-config-json: '{"maxsize":100,"maxage":180,"maxbackups":0,"localtime":true,"compress":true}'EOF- Replace the IP addresses in
listen-client-urlsandadvertise-client-urlswith the actual deployment server IP.
- Replace the IP addresses in
-
Configure systemd to manage etcd-02
cat > /etc/systemd/system/etcd-02.service <<'EOF'[Unit]Description=etcd member etcd-02Documentation=https://etcd.io/docs/After=network-online.targetWants=network-online.target[Service]Type=simpleUser=etcdGroup=etcdExecStart=/usr/local/etcd/bin/etcd --config-file=/usr/local/etcd/etcd.conf.ymlRestart=on-failureRestartSec=5sLimitNOFILE=65536LimitNPROC=65536OOMScoreAdjust=-999[Install]WantedBy=multi-user.targetEOF -
Start etcd-02 and enable startup on boot
systemctl daemon-reloadsystemctl start etcd-02systemctl enable etcd-02 -
Check Service Status
systemctl status etcd-02 --no-pager -
View Runtime Logs
journalctl -u etcd-02 -n 100 -l --no-pager
etcd Node03
-
Download the etcd installation package
- Servers with Internet Access
- Servers without Internet Access
wget https://pdpublic.mingdao.com/private-deployment/offline/common/etcd-v3.6.11-linux-amd64.tar.gz# etcd installation package download link. Download and upload it to the deployment server.https://pdpublic.mingdao.com/private-deployment/offline/common/etcd-v3.6.11-linux-amd64.tar.gz -
Create the etcd runtime user
useradd -M -s /sbin/nologin etcd -
Extract the etcd package and install the binaries
mkdir -p /usr/local/etcd/bintar -zxf etcd-v3.6.11-linux-amd64.tar.gzcp etcd-v3.6.11-linux-amd64/etcd /usr/local/etcd/bin/cp etcd-v3.6.11-linux-amd64/etcdctl /usr/local/etcd/bin/cp etcd-v3.6.11-linux-amd64/etcdutl /usr/local/etcd/bin/chmod +x /usr/local/etcd/bin/etcd*chown -R etcd:etcd /usr/local/etcd- Installation verification
/usr/local/etcd/bin/etcd --version/usr/local/etcd/bin/etcdctl version/usr/local/etcd/bin/etcdutl version -
Create data and log directories
mkdir -p /data/etcdmkdir -p /data/logs/etcdchown -R etcd:etcd /data/etcd /data/logs/etcd -
Modify the etcd configuration file
cat > /usr/local/etcd/etcd.conf.yml <<'EOF'name: etcd-03data-dir: /data/etcdlisten-client-urls: http://192.168.10.33:2379,http://127.0.0.1:2379advertise-client-urls: http://192.168.10.33:2379listen-peer-urls: http://192.168.10.33:2380initial-advertise-peer-urls: http://192.168.10.33:2380listen-metrics-urls: http://192.168.10.33:2381,http://127.0.0.1:2381initial-cluster: etcd-01=http://192.168.10.31:2380,etcd-02=http://192.168.10.32:2380,etcd-03=http://192.168.10.33:2380initial-cluster-token: hap-milvus-etcdinitial-cluster-state: newauto-compaction-mode: periodicauto-compaction-retention: 10hquota-backend-bytes: 8589934592snapshot-count: 100000max-snapshots: 5max-wals: 5strict-reconfig-check: truepre-vote: trueenable-v2: falsemetrics: basiclogger: zaplog-level: infolog-outputs:- /data/logs/etcd/etcd.logenable-log-rotation: truelog-rotation-config-json: '{"maxsize":100,"maxage":180,"maxbackups":0,"localtime":true,"compress":true}'EOF- Replace the IP addresses in
listen-client-urlsandadvertise-client-urlswith the actual deployment server IP.
- Replace the IP addresses in
-
Configure systemd to manage etcd-03
cat > /etc/systemd/system/etcd-03.service <<'EOF'[Unit]Description=etcd member etcd-03Documentation=https://etcd.io/docs/After=network-online.targetWants=network-online.target[Service]Type=simpleUser=etcdGroup=etcdExecStart=/usr/local/etcd/bin/etcd --config-file=/usr/local/etcd/etcd.conf.ymlRestart=on-failureRestartSec=5sLimitNOFILE=65536LimitNPROC=65536OOMScoreAdjust=-999[Install]WantedBy=multi-user.targetEOF -
Start etcd-03 and enable startup on boot
systemctl daemon-reloadsystemctl start etcd-03systemctl enable etcd-03 -
Check Service Status
systemctl status etcd-03 --no-pager -
View Runtime Logs
journalctl -u etcd-03 -n 100 -l --no-pager
Verify the etcd Cluster
-
Set cluster endpoints
export ETCD_ENDPOINTS=http://192.168.10.31:2379,http://192.168.10.32:2379,http://192.168.10.33:2379 -
Check cluster health
/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} endpoint health -w table -
Check cluster status
/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} endpoint status -w table -
View the member list
/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} member list -w table -
Run write, read, and delete tests
/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} put /etcd-test/hello world/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} get /etcd-test/hello/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} del /etcd-test/hello
Enable Authentication
Run the following commands on any node.
-
Set variables
export ETCD_ENDPOINTS=http://192.168.10.31:2379,http://192.168.10.32:2379,http://192.168.10.33:2379export ETCD_ROOT_PASSWORD='replace_with_strong_root_password'ETCD_ENDPOINTSspecifies the three access endpoints of the cluster. All subsequent authentication-related commands use it.ETCD_ROOT_PASSWORDspecifies the root user password. Replace it with a strong password in production deployments.
-
Confirm that the root password variable is set
test -n "$ETCD_ROOT_PASSWORD" && echo "ETCD_ROOT_PASSWORD is set" || echo "ETCD_ROOT_PASSWORD is not set"- Check whether the root password variable is set to avoid using an empty password in later commands.
-
Create the root user
/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} user add "root:${ETCD_ROOT_PASSWORD}"user addcreates therootuser and sets its password.
-
Grant the root role
/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} user grant-role root rootuser grant-role root rootgrants therootrole to therootuser so that it has administrator privileges.
-
View root user information
/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} user get rootuser get rootdisplays information about therootuser and confirms that the user was created successfully.
-
Enable authentication
/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} auth enableauth enableenables etcd authentication. After it is enabled, client access must include user credentials.
-
Verify authentication
/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} --user="root:${ETCD_ROOT_PASSWORD}" auth status/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} --user="root:${ETCD_ROOT_PASSWORD}" endpoint health -w table/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} --user="root:${ETCD_ROOT_PASSWORD}" endpoint status -w table/usr/local/etcd/bin/etcdctl --endpoints=${ETCD_ENDPOINTS} --user="root:${ETCD_ROOT_PASSWORD}" member list -w tableauth statusshows the current authentication status and confirms whether authentication is enabled.endpoint health -w tablechecks endpoint health and confirms that the service remains accessible after authentication is enabled.endpoint status -w tableshows detailed endpoint status and confirms that the cluster is running normally.member list -w tableshows the member list and confirms that cluster member information is complete.