etcd备份

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值