一个键值存储仓库,用于配置共享和服务发现,专注于:
使用etcd的场景默认处理的数据都是控制数据,对于应用数据,只推荐数据量很小,但是更新访问频繁的情况
下载
shell script
https://github.com/etcd-io/etcd/releases
安装版本
shell script
etcd Version: 3.3.15
初始化环境 ```shell script mkdir -p /etc/etcd/ mkdir -p /var/lib/etcd/
- etcd 配置文件
```shell script
vi /etc/etcd/etcd.conf
#[Member]
ETCD_NAME="etcd-01"
ETCD_DATA_DIR="/var/lib/etcd/"
ETCD_LISTEN_PEER_URLS="http://172.31.32.25:2380"
ETCD_LISTEN_CLIENT_URLS="http://172.31.32.25:2379,http://127.0.0.1:2379"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://172.31.32.25:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://172.31.32.25:2379"
ETCD_INITIAL_CLUSTER="etcd-01=http://172.31.32.25:2380,etcd-02=http://172.31.32.26:2380,etcd-03=http://172.31.32.27:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
[Service] Type=notify TimeoutStartSec=0 Restart=always WorkingDirectory=/var/lib/etcd EnvironmentFile=-/etc/etcd/etcd.conf ExecStart=/usr/bin/etcd \ --name=${ETCD_NAME} \ --data-dir=${ETCD_DATA_DIR} \ --listen-peer-urls=${ETCD_LISTEN_PEER_URLS} \ --listen-client-urls=${ETCD_LISTEN_CLIENT_URLS}\ --advertise-client-urls=${ETCD_ADVERTISE_CLIENT_URLS} \ --initial-advertise-peer-urls=${ETCD_INITIAL_ADVERTISE_PEER_URLS} \ --initial-cluster=${ETCD_INITIAL_CLUSTER} \ --initial-cluster-token=${ETCD_INITIAL_CLUSTER_TOKEN}
[Install] WantedBy=multi-user.target
- 启动etcd
```shell script
systemctl daemon-reload
systemctl enable etcd.service --now
systemctl status etcd
集群其他节点部署
需要修改配置文件/etc/etcd/etcd.conf中
ETCD_LISTEN_PEER_URLS、ETCD_LISTEN_CLIENT_URLS、ETCD_INITIAL_ADVERTISE_PEER_URLS、ETCD_ADVERTISE_CLIENT_URLS为当前node内网ip
ETCD_NAME改为当前node的etcd命名。
健康检查
shell script
etcdctl --endpoints="http://172.31.32.25:2379,http://172.31.32.26:2379,http://172.31.32.27:2379" cluster-health
查看member
shell script
etcdctl member list