文档版本 v3.7-DRAFT 处于 草稿 状态。如需获取最新的稳定版文档,请参阅 v3.6。
如何保存数据库
etcd 数据库快照操作指南
先决条件
快照数据库
snapshot 用于保存 etcd 数据库的即时快照:
etcdctl --endpoints=$ENDPOINT snapshot save DB_NAME
全局选项
etcdctl
--endpoints=[127.0.0.1:2379], gRPC endpoints
快照只能从一个 etcd 节点请求,因此 --endpoints 标志应仅包含一个端点。
etcdutl
-w, --write-out string set the output format (fields, json, protobuf, simple, table) (default "simple")
示例

ENDPOINTS=$HOST_1:2379
etcdctl --endpoints=$ENDPOINTS snapshot save my.db
Snapshot saved at my.db
etcdutl --write-out=table snapshot status my.db
+---------+----------+------------+------------+
| HASH | REVISION | TOTAL KEYS | TOTAL SIZE |
+---------+----------+------------+------------+
| c55e8b8 | 9 | 13 | 25 kB |
+---------+----------+------------+------------+