要在 Ubuntu 上启动 etcd 服务,请按照以下步骤操作:
首先,确保已经安装了 etcd。如果还没有安装,可以通过以下命令安装:sudo apt-get updatesudo apt-get install etcd创建一个用于存储 etcd 数据的目录。例如,可以创建一个名为 /var/lib/etcd 的目录:sudo mkdir -p /var/lib/etcd设置 etcd 服务的配置文件。创建一个名为 /etc/systemd/system/etcd.service 的文件,并使用以下内容进行编辑:[Unit]Description=etcd key-value storeDocumentation=https://github.com/etcd-io/etcdAfter=network.target[Service]User=etcdType=notifyExecStart=/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):2380Restart=on-failureRestartSec=5LimitNOFILE=65536[Install]WantedBy=multi-user.target重新加载 systemd 配置:sudo systemctl daemon-reload启动 etcd 服务:sudo systemctl start etcd设置 etcd 服务开机自启动:sudo systemctl enable etcd现在,etcd 服务应该已经在 Ubuntu 上启动并运行。可以使用以下命令检查 etcd 服务的状态:
sudo systemctl status etcd如果需要停止 etcd 服务,可以使用以下命令:
sudo systemctl stop etcd 

