Contents
集群节点信息
Etcd是一个分布式键值存储系统,最小集群使用3台组建集群,则可容忍1台机器故障,使用5台组件集群,则可容忍2台机器故障。
etcd version: 3.5.4
OS version: CentOS Linux release 7.9
集群节点IP:
etcd0 :192.168.1.1
etcd1 :192.168.1.2
etcd2 :192.168.1.3
Etcd下载
1、从Github中下载Etcd二进制文件
# wget https://github.com/coreos/etcd/releases/download/v3.5.4/etcd-v3.5.4-linux-arm64.tar.gz
2、创建工作目录,解压二进制包
# mkdir -p /data4/etcd/{conf,logs,data,wal}
# tar xvf etcd-v3.5.4-linux-amd64.tar.gz && cd etcd-v3.5.4-linux-amd64 && cp -a etcd etcdctl /usr/bin/
创建etcd配置文件
192.168.1.1节点配置
# vim /opt/etcd/conf/conf.yml
name: etcd1
data-dir: /opt/etcd/data
log-outputs: [/opt/etcd/logs/etcd.log]
wal-dir: /opt/etcd/wal
initial-advertise-peer-urls: http://192.168.1.1:2380
listen-peer-urls: http://192.168.1.1:2380
listen-client-urls: http://192.168.1.1:2379
advertise-client-urls: http://192.168.1.1:2379
initial-cluster-token: etcd-milvus-token
quota-backend-bytes: 8589934592
auto-compaction-mode: revision
auto-compaction-retention: '1000'
max-request-bytes: 10485760
snapshot-count: 50000
initial-cluster: etcd1=http://192.168.1.1:2380,etcd2=http://192.168.1.2:2380,etcd3=http://192.168.1.3:2380
initial-cluster-state: new
192.168.1.2节点配置
# vim /opt/etcd/conf/etcd.conf
name: etcd2
data-dir: /opt/etcd/data
log-outputs: [/opt/etcd/logs/etcd.log]
wal-dir: /opt/etcd/wal
initial-advertise-peer-urls: http://192.168.1.2:2380
listen-peer-urls: http://192.168.1.2:2380
listen-client-urls: http://192.168.1.2:2379
advertise-client-urls: http://192.168.1.2:2379
initial-cluster-token: etcd-milvus-token
quota-backend-bytes: 8589934592
auto-compaction-mode: revision
auto-compaction-retention: '1000'
max-request-bytes: 10485760
snapshot-count: 50000
initial-cluster: etcd1=http://192.168.1.1:2380,etcd2=http://192.168.1.2:2380,etcd3=http://192.168.1.3:2380
initial-cluster-state: new
192.168.1.3节点配置
vim /opt/etcd/conf/etcd.conf
name: etcd3
data-dir: /opt/etcd/data
log-outputs: [/opt/etcd/logs/etcd.log]
wal-dir: /opt/etcd/wal
initial-advertise-peer-urls: http://192.168.1.3:2380
listen-peer-urls: http://192.168.1.3:2380
listen-client-urls: http://192.168.1.3:2379
advertise-client-urls: http://192.168.1.3:2379
initial-cluster-token: etcd-milvus-token
quota-backend-bytes: 8589934592
auto-compaction-mode: revision
auto-compaction-retention: '1000'
max-request-bytes: 10485760
snapshot-count: 50000
initial-cluster: etcd1=http://192.168.1.1:2380,etcd2=http://192.168.1.2:2380,etcd3=http://192.168.1.3:2380
initial-cluster-state: new
创建使用systemd进行管理etcd服务
官方文档:https://github.com/etcd-io/etcd/blob/main/contrib/systemd/etcd.service
# vim /usr/lib/systemd/system/etcd.service
[Unit]
Description=Etcd Server
Documentation=https://github.com/etcd-io/etcd
After=network-online.target local-fs.target remote-fs.target time-sync.target
Wants=network-online.target local-fs.target remote-fs.target time-sync.target
[Service]
Type=notify
ExecStart=/usr/bin/etcd --config-file=/opt/etcd/conf/conf.yml
Restart=on-failure
RestartSec=5s
LimitNOFILE=655360
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl start etcd && systemctl enable etcd
说明:
集群模式下,单独起一个节点的时候会挂起等待选举,而且等待超时之后服务状态是failed,不过其实服务已经正常启动了。为了防止这种情况,在超时时间之内把三个节点都启动就好了。这个超时时间也是可以设置的,以及如果超时服务状态failed时,只需要在三个节点都启动后再重启一次服务状态就正常了。
验证集群状态
集群健康状态:
# etcdctl --endpoints http://192.168.1.3:2379,192.168.1.2:2379,192.168.1.1:2379 endpoint health --write-out=table
查看集群详细信息(leader、存储使用量):
# etcdctl --endpoints http://192.168.1.3:2379,192.168.1.2:2379,192.168.1.1:2379 endpoint status --write-out=table
- 本文固定链接: http://www.jiagou.cc/708/
- 转载请注明: 摘星怪 于 架构迷 发表