部署etcd
修改hosts配置文件
vim /etc/hosts
200.100.128.13 sxsz-spzw-clddb1 1.mongodb.private 1.etcd.private
200.100.128.14 sxsz-spzw-clddb2 2.mongodb.private 2.etcd.private
200.100.128.15 sxsz-spzw-clddb3 3.mongodb.private 3.etcd.private
修改环境变量
vim /etc/profile
# etcd
export ETCD_UNSUPPORTED_ARCH=arm64
修改配置文件
vim /opt/etcd/etcd.yaml
data-dir: /data/etcd
debug: false
election-timeout: 1000
heartbeat-interval: 100
initial-advertise-peer-urls: http://3.etcd.private:2380
initial-cluster: 1.etcd.private=http://1.etcd.private:2380,2.etcd.private=http://2.etcd.private:2380,3.etcd.private=http://3.etcd.private:2380
initial-cluster-state: new
initial-cluster-token: test-etcd-cluster
listen-client-urls: http://200.100.128.15:2379
listen-peer-urls: http://200.100.128.15:2380
logger: zap
max-request-bytes: 10485760
max-snapshots: 5
max-wals: 5
name: 3.etcd.private
snapshot-count: 10000
启动ETCD
cd /opt/etcd
./start.sh
ps -ef | grep etcd
root 12913 1 1 22:38 pts/1 00:00:00 ./etcd --config-file etcd.yml
root 13011 5702 0 22:39 pts/1 00:00:00 grep --color=auto etcd
etcd 添加节点
查看etcd集群状态
export ETCDCTL_API=3
/opt/etcd/etcdctl --endpoints "1.etcd.private:2380" member list
64a01b5e3fd1cf8, started, 3.etcd.private, http://3.etcd.private:2380, http://localhost:2379
4f90f03639cbe614, started, 1.etcd.private, http://1.etcd.private:2380, http://localhost:2379
添加新的节点
/opt/etcd/etcdctl --endpoints "1.etcd.private:2380,3.etcd.private:2380" member add 2.etcd.private --peer-urls=http://2.etcd.private:2380
364a01b5e3fd1cf8, started, 3.etcd.private, http://3.etcd.private:2380, http://localhost:2379
4f90f03639cbe614, started, 1.etcd.private, http://1.etcd.private:2380, http://localhost:2379
ba38730b22aeca28, unstarted, , http://2.etcd.private:2380,
新节点启动
vim /opt/etcd/etcd.yml
initial-cluster-state: existing
新部署的时候是new
需要把new改为existing
更新新节点状态
/opt/etcd/etcdctl --endpoints "1.etcd.private:2380,3.etcd.private:2380" member update 31a4904602aedcf9 --peer-urls=http://2.etcd.private:2380
/opt/etcd/etcdctl --endpoints "1.etcd.private:2380" member list
364a01b5e3fd1cf8, started, 3.etcd.private, http://3.etcd.private:2380, http://localhost:2379
4f90f03639cbe614, started, 1.etcd.private, http://1.etcd.private:2380, http://localhost:2379
ba38730b22aeca28, started, 2.etcd.private, http://2.etcd.private:2380, http://localhost:2379