ETCD 单机启动

etcd就两个可执行文件(截至到3.0.15前)。

下载地址:https://github.com/coreos/etcd/releases

注:etcd可以集群安装,在这里只想做一个单机测试,所以只是启动一个节点就可以。

1. 解压,并将文件放入系统路径中:

tar zxvf etcd-v3.0.15-linux-amd64.tar.gz

cp etcd /usr/bin/

cp etcdctl /usr/bin/

2. 创建一个服务描述文件,放入systemd的服务目录下

cat /usr/lib/systemd/system/etcd.service

[Unit]

Description=Etcd Server

After=network.target

[Service]

Type=simple

WorkingDirectory=/var/lib/etcd/

EnvironmentFile=-/etc/etcd/etcd.conf

ExecStart=/usr/bin/etcd

[Install]

WantedBy=multi-user.target

3. etcd的配置

cat /etc/etcd/etcd.conf

# [member]

ETCD_NAME=default

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"

ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"

4. 给etcd创建一个工作目录:

[root@localhost etcd]# mkdir /var/lib/etcd

5. 启动etcd,并测试

[root@localhost etcd]# systemctl daemon-reload

[root@localhost etcd]# systemctl start etcd

[root@localhost etcd]# systemctl enable etcd

Created symlink from/etc/systemd/system/multi-user.target.wants/etcd.service to/usr/lib/systemd/system/etcd.service.

[root@localhost etcd]# systemctl status etcd

[root@localhost etcd]# etcdctl cluster-health

member 8e9e05c52164694d is healthy: got healthyresult from http://localhost:2379

cluster is healthy

猜你喜欢

转载自kaixiansheng.iteye.com/blog/2401500