0/ Environment:
Config Host file:#HOST FILE:
chattr -i -f /etc/hosts
cp -vR /etc/hosts /etc/hosts-
#{
cat <<EOF > /etc/hosts
#!/bin/bash
127.0.0.1 localhost
10.0.2.111 srv111
10.0.2.112 srv112
10.0.2.113 srv113
10.0.2.114 srv114
#
10.0.2.111 etcd1.mgiay.local etcd1
10.0.2.112 etcd2.mgiay.local etcd2
10.0.2.113 etcd3.mgiay.local etcd3
10.0.2.114 etcd4.mgiay.local etcd4
#THE-END
EOF
cat /etc/hosts
chattr +i -f /etc/hosts
#}
#
1/ Install ETCD on new node: node4
REF: https://www.mgiay.com/2020/10/how-to-install-etcd-from-source-code.html
2/ Copy script to new node: node4
REF: https://www.mgiay.com/2020/10/how-to-install-etcd-cluster-3-node-on.html
#Script name:
/opt/script/etcd-initial.sh
/opt/script/etcd-stop.sh
/opt/script/etcd-log.sh
/opt/script/etcd-members.sh
/opt/script/etcd-status.sh
3/ Update config of "/opt/script/etcd-restart.sh":
..
#_______________________________________________________________ETCD_CONFIG:BEGIN
#REF: https://etcd.io/docs/v3.4.0/op-guide/clustering/
etcd \
--name etcd4 \
--data-dir=$ETCD_DATA \
--initial-advertise-peer-urls http://10.0.2.114:2380 \
--listen-peer-urls http://10.0.2.114:2380 \
--listen-client-urls http://0.0.0.0:2379 \
--advertise-client-urls http://10.0.2.114:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster etcd1=http://10.0.2.111:2380,etcd2=http://10.0.2.112:2380,etcd3=http://10.0.2.113:2380,etcd4=http://10.0.2.114:2380 \
--initial-cluster-state existing > $ETCD_LOG 2>&1 &
#_______________________________________________________________ETCD_CONFIG:END
..
4/ Add new node (node4) to existed cluster:
root@srv113:~# etcd-members.sh
…
ETCD MEMBERs:
1b1776006795f774: name=etcd1 peerURLs=http://10.0.2.111:2380 clientURLs=http://10.0.2.111:2379 isLeader=true
89df995ba1c163a3: name=etcd3 peerURLs=http://10.0.2.113:2380 clientURLs=http://10.0.2.113:2379 isLeader=false
9e01e0d9b238a128: name=etcd2 peerURLs=http://10.0.2.112:2380 clientURLs=http://10.0.2.112:2379 isLeader=false
#ADDING NEW MEMBER TO EXISTED CLUSTER:
root@srv113:~# etcdctl member add etcd4 http://etcd4:2380
Added member named etcd4 with ID ea59efe5cd5e204e to cluster
ETCD_NAME="etcd4"
ETCD_INITIAL_CLUSTER="etcd1=http://10.0.2.111:2380,etcd3=http://10.0.2.113:2380,etcd2=http://10.0.2.112:2380,etcd4=http://etcd4:2380"
ETCD_INITIAL_CLUSTER_STATE="existing"
5/ Result:
root@srv111:/# cd /;date; etcd-members.sh; etcdctl cluster-health
Wed Oct 21 08:32:00 +07 2020
..
ETCD MEMBERs:
1b1776006795f774: name=etcd1 peerURLs=http://10.0.2.111:2380 clientURLs=http://10.0.2.111:2379 isLeader=true
89df995ba1c163a3: name=etcd3 peerURLs=http://10.0.2.113:2380 clientURLs=http://10.0.2.113:2379 isLeader=false
9e01e0d9b238a128: name=etcd2 peerURLs=http://10.0.2.112:2380 clientURLs=http://10.0.2.112:2379 isLeader=false
ea59efe5cd5e204e: name=etcd4 peerURLs=http://etcd4:2380 clientURLs=http://10.0.2.114:2379 isLeader=false
member 1b1776006795f774 is healthy: got healthy result from http://10.0.2.111:2379
member 89df995ba1c163a3 is healthy: got healthy result from http://10.0.2.113:2379
member 9e01e0d9b238a128 is healthy: got healthy result from http://10.0.2.112:2379
member ea59efe5cd5e204e is healthy: got healthy result from http://10.0.2.114:2379
cluster is healthy
root@srv111:/#
root@srv112:/var/cache/apt# cd /;date; etcd-members.sh; etcdctl cluster-health
Wed Oct 21 08:32:52 +07 2020
..
ETCD MEMBERs:
1b1776006795f774: name=etcd1 peerURLs=http://10.0.2.111:2380 clientURLs=http://10.0.2.111:2379 isLeader=true
89df995ba1c163a3: name=etcd3 peerURLs=http://10.0.2.113:2380 clientURLs=http://10.0.2.113:2379 isLeader=false
9e01e0d9b238a128: name=etcd2 peerURLs=http://10.0.2.112:2380 clientURLs=http://10.0.2.112:2379 isLeader=false
ea59efe5cd5e204e: name=etcd4 peerURLs=http://etcd4:2380 clientURLs=http://10.0.2.114:2379 isLeader=false
member 1b1776006795f774 is healthy: got healthy result from http://10.0.2.111:2379
member 89df995ba1c163a3 is healthy: got healthy result from http://10.0.2.113:2379
member 9e01e0d9b238a128 is healthy: got healthy result from http://10.0.2.112:2379
member ea59efe5cd5e204e is healthy: got healthy result from http://10.0.2.114:2379
cluster is healthy
root@srv112:/#
root@srv113:~# cd /;date; etcd-members.sh; etcdctl cluster-health
Wed Oct 21 08:32:54 +07 2020
..
ETCD MEMBERs:
1b1776006795f774: name=etcd1 peerURLs=http://10.0.2.111:2380 clientURLs=http://10.0.2.111:2379 isLeader=true
89df995ba1c163a3: name=etcd3 peerURLs=http://10.0.2.113:2380 clientURLs=http://10.0.2.113:2379 isLeader=false
9e01e0d9b238a128: name=etcd2 peerURLs=http://10.0.2.112:2380 clientURLs=http://10.0.2.112:2379 isLeader=false
ea59efe5cd5e204e: name=etcd4 peerURLs=http://etcd4:2380 clientURLs=http://10.0.2.114:2379 isLeader=false
member 1b1776006795f774 is healthy: got healthy result from http://10.0.2.111:2379
member 89df995ba1c163a3 is healthy: got healthy result from http://10.0.2.113:2379
member 9e01e0d9b238a128 is healthy: got healthy result from http://10.0.2.112:2379
member ea59efe5cd5e204e is healthy: got healthy result from http://10.0.2.114:2379
cluster is healthy
root@srv113:/#
root@srv114 /# cd /;date; etcd-members.sh; etcdctl cluster-health
Wed Oct 21 08:33:00 +07 2020
..
ETCD MEMBERs:
1b1776006795f774: name=etcd1 peerURLs=http://10.0.2.111:2380 clientURLs=http://10.0.2.111:2379 isLeader=true
89df995ba1c163a3: name=etcd3 peerURLs=http://10.0.2.113:2380 clientURLs=http://10.0.2.113:2379 isLeader=false
9e01e0d9b238a128: name=etcd2 peerURLs=http://10.0.2.112:2380 clientURLs=http://10.0.2.112:2379 isLeader=false
ea59efe5cd5e204e: name=etcd4 peerURLs=http://etcd4:2380 clientURLs=http://10.0.2.114:2379 isLeader=false
member 1b1776006795f774 is healthy: got healthy result from http://10.0.2.111:2379
member 89df995ba1c163a3 is healthy: got healthy result from http://10.0.2.113:2379
member 9e01e0d9b238a128 is healthy: got healthy result from http://10.0.2.112:2379
member ea59efe5cd5e204e is healthy: got healthy result from http://10.0.2.114:2379
cluster is healthy
root@srv114 /#
No comments:
Post a Comment