如何在ubuntu上启动etcd服务

   2024-09-30 8560
核心提示:要在 Ubuntu 上启动 etcd 服务,请按照以下步骤操作:首先,确保已经安装了 etcd。如果还没有安装,可以通过以下命令安装:sudo

要在 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

 
举报打赏
 
更多>同类物流大全
推荐图文
推荐物流大全
点击排行

网站首页  |  关于我们  |  联系方式 | 网站留言    |  赣ICP备2021007278号