etcdctl ?endpoint status --endpoints=https://192.168.17.1:2379,https://192.168.17.2:2379,https://192.168.17.3:2379 ?--cacert=/etc/kubernetes/ssl/ca.crt ?--cert=/etc/kubernetes/ssl/etcd_server.crt ?--key=/etc/kubernetes/ssl/etcd_server.key -w=table
etcdctl ? snapshot save /tmp/etcdbak-`date +%F`--endpoints=https://192.168.17.1:2379 --cacert=/etc/kubernetes/ssl/ca.crt ?--cert=/etc/kubernetes/ssl/etcd_server.crt ?--key=/etc/kubernetes/ssl/etcd_server.key -w=table
?scp 192.168.17.2:/tmp/etcdbak-2024-01-22 .
1)获取etcd名称
? ? ? ETCD_NAME=`cat /etc/etcd/etcd.conf | grep ETCD_NAME |awk -F \" '{print $2}'`
2)获取etcd集群信息
? ?ETCD_INITIAL_CLUSTER=`cat /etc/etcd/etcd.conf | grep ETCD_INITIAL_CLUSTER= | awk -F \" '{print $2}'`
3)获取etcd数据路径
? ?ETCD_DATA_DIR=`cat /etc/etcd/etcd.conf |grep ETCD_DATA_DIR | awk -F \" '{print $2}'`
4)获取etcd的 Token
? ?ETCD_INITIAL_CLUSTER_TOKEN=`cat /etc/etcd/etcd.conf |grep TOKEN |awk -F \" '{print $2}'`
5)获取etcd集群通告地址
? ?ADVERTISE_PEER_URLS=`cat /etc/etcd/etcd.conf |grep ADVERTISE_PEER_URLS |awk -F \" '{print $2}'`
etcdctl snapshot --cacert=$CA_PATH --cert=$CRT_PATH --key=$KEY_PATH ?restore /apps/etcd_data/etcdbak-2024-01-22 ?--name=$ETCD_NAME --data-dir=$ETCD_DATA_DIR --initial-cluster=$ETCD_INITIAL_CLUSTER --initial-cluster-token=$ETCD_INITIAL_CLUSTER_TOKEN --initial-advertise-peer-urls=$ADVERTISE_PEER_URLS?
?
?etcdctl snapshot --cacert=/etc/kubernetes/ssl/ca.crt --cert=/etc/kubernetes/ssl/etcd_server.crt --key=/etc/kubernetes/ssl/etcd_server.key restore /apps/etcd_data/etcdbak-2024-01-22 ?--name=etcd_159_1 --data-dir=/apps/etcd_data/etcd --initial-cluster=etcd_159_1=https://192.168.17.1:2380,etcd_159_2=https://192.168.17.2:2380,etcd_159_3=https://192.168.17.3:2380 ?--initial-cluster-token=cc34c326-4694-48c6-afdf-c317f40c1847 --initial-advertise-peer-urls=https://192.168.17.1:2380