基于Kubernetes的ETCD备份与恢复

半兽人 发表于: 2020-11-16   最后更新时间: 2020-11-16 20:18:23  
{{totalSubscript}} 订阅, 2,289 游览

查询集群成员

ETCDCTL_API=3 \
etcdctl --cacert="/etc/kubernetes/pki/etcd/server.crt" \
        --cert="/etc/kubernetes/pki/etcd/peer.crt" \
        --key="/etc/kubernetes/pki/etcd/peer.key" \
        --endpoints="https://127.0.0.1:2379" \
        member list

保存快照

export ETCDCTL_API=3
etcdctl --cacert="/etc/kubernetes/pki/etcd/server.crt" \
        --cert="/etc/kubernetes/pki/etcd/peer.crt" \
        --key="/etc/kubernetes/pki/etcd/peer.key" \
        --endpoints="https://127.0.0.1:2379" \
        snapshot save /data/backup/etcd-snapshot.db

恢复快照

export ETCDCTL_API=3
etcdctl --name=m1 \
        --initial-advertise-peer-urls=https://10.211.55.5:2380 \
        --initial-cluster=m1=https://10.211.55.5:2380 \
        --data-dir=/var/lib/etcd \
        snapshot restore /srv/data/etcd-snapshot-previous.db
注:如果没有etcdctl命令的话,可以从docker中复制etcdctl命令
docker cp 371f3ff1f43b:/usr/local/bin/etcdctl /usr/local/bin/etcdctl

多集群可参考:https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/recovery.md

更新于 2020-11-16

查看etcd更多相关的文章或提一个关于etcd的问题,也可以与我们一起分享文章