基于Kubernetes的ETCD备份与恢复

半兽人 发表于: 2020-11-16   最后更新时间: 2020-11-16  

查询集群成员

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



您需要解锁本帖隐藏内容请: 点击这里
本帖隐藏的内容




上一条: ETCD命令大全
下一条: 已经是最后了!