Skip to content

Commit c5078c4

Browse files
drmingdrmerBohuTANG
authored andcommitted
refactor: meta-service backup
1 parent 4bc67ce commit c5078c4

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

docs/en/guides/10-deploy/01-deploy/02-production/30-metasrv-backup-restore.md

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ description: How to back up and restore Meta Service cluster data
66

77
This guideline will introduce how to back up and restore the meta service cluster data.
88

9-
## Export Data From Meta Service
9+
## Export Data From databend-meta
1010

11-
It supports to export from a databend-meta data dir or from a running databend-meta server.
11+
It supports to export either from a databend-meta data dir or from a running databend-meta server.
12+
Since Raft replicates the data to all nodes, it is enough to export from any one node.
1213

13-
### Export from a running server
14+
### Export from running databend-meta
1415

1516
Similar to exporting from data dir, but with the service endpoint argument `--grpc-api-address <ip:port>` in place of the `--raft-dir`,
1617
where `<ip:port>` is the `grpc_api_address` in [databend-meta.toml](https://github.com/datafuselabs/databend/blob/main/scripts/distribution/configs/databend-meta.toml), e.g.:
@@ -27,7 +28,7 @@ databend-metactl export --grpc-api-address "127.0.0.1:9191" --db <output_fn>
2728

2829
Shutdown the `databend-meta` service.
2930

30-
Then export sled DB from the dir(`<your_meta_dir>`) in which the `databend-meta` stores meta to a local file `output_fn`, in multi-line JSON format.
31+
Then export the data from the dir(`<your_meta_dir>`) in which the `databend-meta` stores meta to a local file `output_fn`, in multi-line JSON format.
3132
E.g., every line in the output file is a JSON of an exported key-value record.
3233

3334
```sh
@@ -46,13 +47,13 @@ Note: without the `--db` argument, the exported data will output to the stdio in
4647

4748
## Restore a databend-meta
4849

49-
The following command rebuild a meta service db in `<your_meta_dir>` from
50-
exported metadata:
50+
To restore a databend-meta node, use the following command.
5151

5252
```sh
5353
databend-metactl import --raft-dir "<your_meta_dir>" --db <output_fn>
5454

55-
databend-meta --raft-dir "<your_meta_dir>" ...
55+
# Then it is ready to start the databend-meta node.
56+
# databend-meta --raft-dir "<your_meta_dir>" ...
5657
```
5758

5859
Note: without the `--db` argument, the import data come from stdio instead, like:
@@ -61,22 +62,39 @@ Note: without the `--db` argument, the import data come from stdio instead, like
6162
cat "<output_fn>" | databend-metactl import --raft-dir "<your_meta_dir>"
6263
```
6364

64-
**Caveat**: Data in `<your_meta_dir>` will be cleared.
65+
Note that the backup data contains node id,
66+
so it is necessary to ensure the node id in the backup data is consistent with the node id in the restored databend-meta node.
67+
To restore a different node, i.e., restore node-2 with the backup data of node-1, you need to specify the cluster config when importing, see the next section.
68+
69+
**Caveat**: Data in `<your_meta_dir>` will be cleared when importing.
6570

6671
## Import data as a new databend-meta cluster
6772

68-
With specifies the `--initial-cluster` argument, the `databend-metactl` can import the data as a new cluster.
69-
The `--initial-cluster` format is: `node_id=raft_advertise_host:raft_api_port`, each node config is separated by space, the meaning of `raft_advertise_host`,`raft_api_port` is the same in raft config.
73+
With the `--initial-cluster` argument, the `databend-metactl` import the data and re-initialize the cluster info and node ids.
74+
The `--initial-cluster` value format is: `<node_id>=<raft_advertise_host>:<raft_api_port`,
75+
`raft_advertise_host`,`raft_api_port` is the same as the fields in the toml config file.
7076

71-
E.g.:
77+
For example, to restore a databend-meta cluster with three nodes:
7278

7379
```
74-
databend-metactl import --raft-dir ./.databend/new_meta1 --id=1 --db meta.db --initial-cluster 1=localhost:29103 --initial-cluster 2=localhost:29203 --initial-cluster 3=localhost:29303
75-
databend-metactl import --raft-dir ./.databend/new_meta2 --id=2 --db meta.db --initial-cluster 1=localhost:29103 --initial-cluster 2=localhost:29203 --initial-cluster 3=localhost:29303
76-
databend-metactl import --raft-dir ./.databend/new_meta3 --id=3 --db meta.db --initial-cluster 1=localhost:29103 --initial-cluster 2=localhost:29203 --initial-cluster 3=localhost:29303
80+
databend-metactl import --raft-dir ./.databend/new_meta1 --db meta.db \
81+
--id=1 \
82+
--initial-cluster 1=localhost:29103 \
83+
--initial-cluster 2=localhost:29203 \
84+
--initial-cluster 3=localhost:29303
85+
databend-metactl import --raft-dir ./.databend/new_meta2 --db meta.db \
86+
--id=2 \
87+
--initial-cluster 1=localhost:29103 \
88+
--initial-cluster 2=localhost:29203 \
89+
--initial-cluster 3=localhost:29303
90+
databend-metactl import --raft-dir ./.databend/new_meta3 --db meta.db \
91+
--id=3 \
92+
--initial-cluster 1=localhost:29103 \
93+
--initial-cluster 2=localhost:29203 \
94+
--initial-cluster 3=localhost:29303
7795
```
7896

79-
The script above imports the exported data from `meta.db` and initializes the three cluster nodes: id 1, which raft directory is `./.databend/new_meta1`, and so are id 2 and 3 with different raft directory.
80-
Note that the `--initial-cluster` argument in these three command line is the same.
97+
In the above commands, the cluster info are all identical.
98+
But each databend-meta node has a different node id specified.
8199

82-
After that, can start a new three nodes databend-meta cluster with the new config and imported data.
100+
After that, it is ready to start a new three nodes databend-meta cluster.

0 commit comments

Comments
 (0)