如何保存数据库

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")

示例

11_etcdctl_snapshot_2016051001

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

最后修改于 2025 年 7 月 6 日: etcd-网站: 重组 v3.7 (c159c16)