要在 Ubuntu 上啟動 etcd 服務,請按照以下步驟操作:
sudo apt-get update
sudo apt-get install etcd
/var/lib/etcd
的目錄:sudo mkdir -p /var/lib/etcd
/etc/systemd/system/etcd.service
的文件,并使用以下內容進行編輯:[Unit]
Description=etcd key-value store
Documentation=https://github.com/etcd-io/etcd
After=network.target
[Service]
User=etcd
Type=notify
ExecStart=/usr/bin/etcd \
--name=$(hostname) \
--data-dir=/var/lib/etcd \
--listen-client-urls http://0.0.0.0:2379 \
--advertise-client-urls http://$(hostname -i):2379 \
--listen-peer-urls http://0.0.0.0:2380 \
--initial-cluster-token etcd-cluster \
--initial-cluster-state new \
--initial-advertise-peer-urls http://$(hostname -i):2380 \
--initial-cluster-token etcd-cluster \
--initial-cluster $(hostname)=http://$(hostname -i):2380
Restart=on-failure
RestartSec=5
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start etcd
sudo systemctl enable etcd
現在,etcd 服務應該已經在 Ubuntu 上啟動并運行??梢允褂靡韵旅顧z查 etcd 服務的狀態:
sudo systemctl status etcd
如果需要停止 etcd 服務,可以使用以下命令:
sudo systemctl stop etcd