etcd单节点数据备份与恢复

插入测试数据

# etcdctl put  smith  7369
# etcdctl put  allen  7499
# etcdctl put  ward   7521
# etcdctl put  jones  7566
# etcdctl put  martin 7654
# etcdctl put  blake  7698
# etcdctl put  clark  7782
# etcdctl put  scott  7788
# etcdctl put  king   7839
# etcdctl put  turner 7844
# etcdctl put  adams  7876
# etcdctl put  james  7900
# etcdctl put  ford   7902
# etcdctl put  miller 7934

查看数据

# etcdctl get --prefix ""
adams
7876
allen
7499
blake
7698
clark
7782
ford
7902
james
7900
jones
7566
king
7839
martin
7654
miller
7934
scott
7788
smith
7369
turner
7844
ward
7521

做快照

# etcdctl snapshot save backup.db
{"level":"info","ts":1570085496.5022638,"caller":"snapshot/v3_snapshot.go:109","msg":"created temporary db file","path":"backup.db.part"}
{"level":"warn","ts":"2019-10-03T14:51:36.503+0800","caller":"clientv3/retry_interceptor.go:116","msg":"retry stream intercept"}
{"level":"info","ts":1570085496.5036564,"caller":"snapshot/v3_snapshot.go:120","msg":"fetching snapshot","endpoint":"127.0.0.1:2379"}
{"level":"info","ts":1570085496.5214782,"caller":"snapshot/v3_snapshot.go:133","msg":"fetched snapshot","endpoint":"127.0.0.1:2379","took":0.018938519}
{"level":"info","ts":1570085496.521635,"caller":"snapshot/v3_snapshot.go:142","msg":"saved","path":"backup.db"}
Snapshot saved at backup.db

查看快照信息

# etcdctl snapshot status backup.db --write-out=table
+----------+----------+------------+------------+
|   HASH   | REVISION | TOTAL KEYS | TOTAL SIZE |
+----------+----------+------------+------------+
| 6d1803a9 |      110 |        146 |      37 kB |
+----------+----------+------------+------------+

清空数据

# etcdctl del --prefix ""
14

删除当前etcd的data目录,否则会报错目录已存在

# rm -rf /usr/local/etcd/data

恢复数据

# etcdctl snapshot restore backup.db --data-dir="/usr/local/etcd/data"
{"level":"info","ts":1570085656.639806,"caller":"snapshot/v3_snapshot.go:286","msg":"restoring snapshot","path":"backup.db","wal-dir":"/usr/local/etcd/data/member/wal","data-dir":"/usr/local/etcd/data","snap-dir":"/usr/local/etcd/data/member/snap"}
{"level":"info","ts":1570085656.7266932,"caller":"membership/cluster.go:392","msg":"added member","cluster-id":"cdf818194e3a8c32","local-member-id":"0","added-peer-id":"8e9e05c52164694d","added-peer-peer-urls":["http://localhost:2380"]}
{"level":"info","ts":1570085656.7834268,"caller":"snapshot/v3_snapshot.go:299","msg":"restored snapshot","path":"backup.db","wal-dir":"/usr/local/etcd/data/member/wal","data-dir":"/usr/local/etcd/data","snap-dir":"/usr/local/etcd/data/member/snap"}

恢复完成后需要将从备份重新生成的data目录的属主和属组修改为etcd系统服务中的对应属主和属组

# chown -R tnuser.dba /usr/local/etcd/data

重启etcd系统服务

# systemctl stop etcd
# systemctl start etcd

再次查看恢复的数据

# etcdctl get --prefix ""
adams
7876
allen
7499
blake
7698
clark
7782
ford
7902
james
7900
jones
7566
king
7839
martin
7654
miller
7934
scott
7788
smith
7369
turner
7844
ward
7521

原文地址:https://www.cnblogs.com/ilifeilong/p/11619795.html

时间: 2024-10-08 21:16:36

etcd单节点数据备份与恢复的相关文章

Etcd单节点扩容为三节点集群

参考文档 http://www.cnblogs.com/breg/p/5728237.html 开始环境是单节点,存储数据一段时间后发现需要集群高可用环境,幸亏etcd支持在线扩容 1,修改单节点配置并重启etcd [[email protected] etcd]# cat /etc/etcd/etcd.conf ETCD_NAME=k8s1 ETCD_DATA_DIR="/data/etcd" ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:

etcd 单节点部署、备份与恢复

etcd 部署 wget https://github.com/etcd-io/etcd/releases/download/v3.3.13/etcd-v3.3.13-linux-amd64.tar.gz tar -zxvf etcd-v3.3.13-linux-amd64.tar.gz cd etcd-v3.3.13-linux-amd64 目录下有两个可执行文件etcd 和 etcdctl cp etcd /usr/bin/ cp etcdctl /usr/bin/ 添加以下内容: $ ca

【大数据系列】hadoop单节点安装官方文档翻译

Hadoop: Setting up a Single Node Cluster. HADOOP:建立单节点集群 Purpose Prerequisites Supported Platforms Required Software Installing Software Download Prepare to Start the Hadoop Cluster Standalone Operation Pseudo-Distributed Operation Configuration Setu

大数据生态圈 —— 单节点伪分布式环境搭建

本文参考 关于环境搭建,imooc上关于Hadoop.hbase.spark等课程上有很多环境搭建的例子,但是有些并没有说明为什么选择这个的版本,我们知道这些开源的技术发展很快,所以有必要搞清楚如何对它们进行版本选择 环境 centos7.7(主机名hadoop0001,用户名hadoop) + spark 2.2.0 + scala 2.11.8 + hbase1.3.6 + Hadoop 2.6.5 + zookeeper 3.4.14 + kafka 0.8.2.1 + flume 1.6

k8s Kubernetes v1.10 单节点 kubeadm 快速安装

k8s Kubernetes v1.10 单节点 kubeadm 快速安装 # Master 单节点快速安装 # 傻瓜式安装,只为快速部署测试环境 #测试环境centos 7.4 #ubuntu环境应该也可以,没测验证过 #1 初始化环境 curl -s http://elven.vip/ks/k8s/oneinstall/0.set.sh |bash #2 下载镜像,安装kubeadm工具 curl http://elven.vip/ks/k8s/oneinstall/1.download.s

如何将Rancher 2.1.x 从单节点安装迁移到高可用安装

Rancher提供了两种安装方法,即单节点安装和高可用安装.单节点安装可以让用户快速部署适用于短期开发或PoC的Rancher 2.x,而高可用部署则明显更适合Rancher的长期部署.  要点须知 针对开源用户,对于从单个节点迁移到HA的工作,Rancher Labs不提供官方技术支持. 以防在此过程中出现问题,您应该熟悉Rancher架构以及故障排除的方法. 前期准备 为了顺利将单个节点Rancher安装迁移到高可用性安装,您必须做如下准备: 您需要运行Rancher的2.1.x版本以及RK

纯手工搭建K8s(单节点)

准备说明: 因为为纯手动搭建,所以针对安装时需要的一些安装包需提前下载好 cfssl_linux-amd64. cfssljson_linux-amd64. cfssl-certinfo_linux-amd64. etcd-v3.3.10-linux-amd64.tar.gz. flannel-v0.11.0-linux-amd64.tar.gz. kubernetes-server-linux-amd64.tar.gz(网络环境原因可以上github上下载或者找台vps下载好然后再从vps上拉

YUM仓库在线简易安装单节点K8S(纯实战)

使用YUM仓库在线简易安装单节点K8S 实验环境: 使用系统:centos7.4 名称 角色 IP地址 centos7-min2 master 192.168.142.220 centos7-4 node 192.168.142.136 实验实施步骤: 一.配置步骤目录 master端配置 node端配置 实验结果检查 二.master端配置 使用yum仓库安装atcd数据库.kubernetes组件.flannel网络组件 [[email protected] ~]# yum install

rancher server 单节点部署/K8S高可用部署

环境说明: # 操作系统:centos7 # docker版本:19.03.5 # rancher版本: latest # rancher server 节点IP :192.168.2.175 # rancher agent节点IP: 192.168.2.175,192.168.2.176,192.168.2.177,192.168.2.185,192.168.2.187 # K8S master 节点IP:192.168.2.176,192.168.2.177,192.168.2.185 #