插入测试数据

# etcdctl put  smith
# etcdctl put allen
# etcdctl put ward
# etcdctl put jones
# etcdctl put martin
# etcdctl put blake
# etcdctl put clark
# etcdctl put scott
# etcdctl put king
# etcdctl put turner
# etcdctl put adams
# etcdctl put james
# etcdctl put ford
# etcdctl put miller

查看数据

# etcdctl get --prefix ""
adams allen blake clark ford james jones king martin miller scott smith turner ward

做快照

# 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 | | | kB |
+----------+----------+------------+------------+

清空数据

# etcdctl del --prefix ""

删除当前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":"","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 allen blake clark ford james jones king martin miller scott smith turner ward

最新文章

  1. linux的虚拟内存是4G,而每个进程都有自己独立的4G内存空间,怎么理解?
  2. java基础知识回顾之---java StringBuilder与StringBuffer异同点
  3. HashMap的使用方法及注意事项
  4. JavaScript—DOM操作
  5. php中二维数组如何使用
  6. Javascript面对对象. 第五篇
  7. 20130620—ant和java杂学随笔
  8. 轻松学JVM(四)——垃圾回收算法
  9. .NET Core跨平台的奥秘[上篇]:历史的枷锁
  10. Flutter 即学即用系列博客——07 RenderFlex overflowed 引发的思考
  11. 老男孩Python全栈学习 S9 日常作业 010
  12. pandas的分布式执行框架之modin
  13. docker之tomcat简单部署
  14. 使用Python在自己博客上进行自动翻页
  15. centos7搭建elasticsearch
  16. zookeeper安装(Linux)
  17. efcore从数据库快速生成实体及context
  18. 一、Redis数据备份与恢复
  19. TLS反调试
  20. mysql内存管理

热门文章

  1. javascript中constructor指向问题
  2. python 的pip安装
  3. jquery grid 显示隐藏列
  4. vue实现v-model父子组件间的双向通信
  5. UOJ #455 [UER #8]雪灾与外卖 (贪心、模拟费用流)
  6. vue中使用iconfont和在旧有的iconfont中添加新的图标
  7. python学习之路(21)
  8. JAVA源文件中可以包含多个类
  9. pygame的常用模块
  10. 当 LAST_INSERT_ID() 带有参数时# 清空重来