Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Crowdin updates #358

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,51 +147,43 @@ service cnosdb-meta start
> If there are multiple `meta` services in your cluster, you only need to execute the initialization command on one of the `meta` services.

```shell
curl http://meta1.cnosdb.com:8901/init -d '{}'
cnosdb-meta init --bind meta1.cnosdb.com:8901
```

#### Add other `meta` service instances

```shell
curl http://meta1.cnosdb.com:8901/add-learner -H "Content-Type: application/json" -d '[2, "meta2.cnosdb.com:8901"]' | jq
curl http://meta1.cnosdb.com:8901/add-learner -H "Content-Type: application/json" -d '[3, "meta3.cnosdb.com:8901"]' | jq
cnosdb-meta add-node --bind meta1.cnosdb.com:8901 --addr meta2.cnosdb.com:8901
cnosdb-meta add-node --bind meta1.cnosdb.com:8901 --addr meta3.cnosdb.com:8901
```

#### Reset cluster members to make the cluster take effect
#### 查看集群节点状态

> Executing the following command can modify the cluster members. If there are multiple `meta` services in your cluster, use the node that initially performed the initialization to execute this command.
分别指定不同的节点,执行以下命令,查看集群中各节点的状态。

```shell
curl http://meta1.cnosdb.com:8901/change-membership -H "Content-Type: application/json" -d '[1,2,3]' | jq
cnosdb-meta show-nodes --bind meta1.cnosdb.com:8901
```

#### View Cluster Status

Specify different nodes separately, perform the following commands to view cluster status.
If the cluster installation is successful, the following content should be returned:

> Replace `<n>` in the command to specify a different `meta` service instance.
> `state` may also be `Follower`.

```shell
curl http://meta<n>.cnosdb.com:8901/metrics | jq
```
Node ID Address State Term Last_Log_index Last_Applied Leader Members
1 meta1.cnosdb.com:8901 Leader 1 7 7 1 [1, 2, 3]
2 meta2.cnosdb.com:8901 Follower 1 7 7 1 [1, 2, 3]
3 meta3.cnosdb.com:8901 Follower 1 7 7 1 [1, 2, 3]
```

If the cluster installation is successful, the following content should be returned:

> `state` may also be `Follower`.
#### 删除集群中的节点

```json
{
"Ok": {
"running_state": {
"Ok": null
},
"id": 1,
... ...
"state": "Leader",
... ...
}
```shell
cnosdb-meta remove-node --bind meta1.cnosdb.com:8901 --addr meta2.cnosdb.com:8901
```

> 若删除的是leader节点,之后集群的bind地址会变化,请参照系统提示进行输入

### Launch the `cnosdb` service

#### Edit profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,51 +141,43 @@ service cnosdb-meta start
> If there are multiple `meta` services in your cluster, you only need to execute the initialization command on one of the `meta` services.

```shell
curl http://meta1.cnosdb.com:8901/init -d '{}'
cnosdb-meta init --bind meta1.cnosdb.com:8901
```

#### Add other `meta` service instances

```shell
curl http://meta1.cnosdb.com:8901/add-learner -H "Content-Type: application/json" -d '[2, "meta2.cnosdb.com:8901"]' | jq
curl http://meta1.cnosdb.com:8901/add-learner -H "Content-Type: application/json" -d '[3, "meta3.cnosdb.com:8901"]' | jq
cnosdb-meta add-node --bind meta1.cnosdb.com:8901 --addr meta2.cnosdb.com:8901
cnosdb-meta add-node --bind meta1.cnosdb.com:8901 --addr meta3.cnosdb.com:8901
```

#### Reset cluster members to make the cluster take effect
#### 查看集群节点状态

> Executing the following command can modify the cluster members. If there are multiple `meta` services in your cluster, use the node that initially performed the initialization to execute this command.
分别指定不同的节点,执行以下命令,查看集群中各节点的状态。

```shell
curl http://meta1.cnosdb.com:8901/change-membership -H "Content-Type: application/json" -d '[1,2,3]' | jq
cnosdb-meta show-nodes --bind meta1.cnosdb.com:8901
```

#### View Cluster Status

Specify different nodes separately, perform the following commands to view cluster status.
If the cluster installation is successful, the following content should be returned:

> Replace `<n>` in the command to specify a different `meta` service instance.
> `state` may also be `Follower`.

```shell
curl http://meta<n>.cnosdb.com:8901/metrics | jq
```
Node ID Address State Term Last_Log_index Last_Applied Leader Members
1 meta1.cnosdb.com:8901 Leader 1 7 7 1 [1, 2, 3]
2 meta2.cnosdb.com:8901 Follower 1 7 7 1 [1, 2, 3]
3 meta3.cnosdb.com:8901 Follower 1 7 7 1 [1, 2, 3]
```

If the cluster installation is successful, the following content should be returned:

> `state` may also be `Follower`.
#### 删除集群中的节点

```json
{
"Ok": {
"running_state": {
"Ok": null
},
"id": 1,
... ...
"state": "Leader",
... ...
}
```shell
cnosdb-meta remove-node --bind meta1.cnosdb.com:8901 --addr meta2.cnosdb.com:8901
```

> 若删除的是leader节点,之后集群的bind地址会变化,请参照系统提示进行输入

### Launch the `cnosdb` service

#### Edit profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,149 +4,98 @@ sidebar_position: 3

# Backup and Restore

The CnosDB backup and restore tool is a command line tool for exporting, importing, and migrating CnosDB cluster data.This tool supports the backup of metadata and user data, as well as data migration between clusters.

:::tip

Data export produces more than one file: `meta_data.src`, `schema_data.src` and data files.

The `meta_data.src`, `schema_data.src` file will be exported to the node running the `cnosdb-imexport` command.

The data file is exported to the requested node and vice versa.

:::

### Install

Make sure you have installed CnosDB backup and restore tools on your system.You can get this tool from official channels and install it according to the relevant documents.
CnosDB 备份和还原工具是一个用于导出、导入 CnosDB 集群数据的命令行工具。该工具支持备份元数据和用户数据。

### Command Overview

`cnosdb-imexport <COMMAND>`
`cnosdb-meta <COMMAND>`

#### Parameter Description

| Name | Description |
| --------- | ---------------------- |
| `export` | Full export data |
| `import` | Full import data |
| `migrate` | Migrating data |
| `help` | Print help information |
| Name | Description |
| ---------- | ---------------------- |
| `dump` | Full export data |
| `restore` | Full import data |
| `dump-sql` | 以sql导出指定cluster的数据 |
| `help` | Print help information |

### `export`
### `dump`

> Export metadata and user data

#### Usage

```shell
cnosdb-imexport export [OPTIONS] --src <SRC> --path <PATH>
cnosdb-meta dump --bind <ADDR> --file <PATH>
```

#### Options

| Name | Description |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `-s, --src <SRC>` | (Required) Connection information of the source cluster (example: root:[email protected]:8902) |
| `-p, --path <PATH>` | (Required) Data storage path |
| `-c, --conn <CONN>` | (Optional) Connection configuration for cloud storage |
| `-h, --help` | Print help information |
| Name | Description |
| --------------- | ----------------------------------------------------------------------------------------------- |
| `--bind <ADDR>` | (必需)源集群的连接信息(示例:127.0.0.1:8902) |
| `--file <PATH>` | (Required) Data storage path |
| `--help` | Print help information |

#### Example

##### Backup data to local directory

```shell
cnosdb-imexport export --src <user>:<password>@<ip>:<port> --path ./backup
cnosdb-meta dump --src <user>:<password>@<ip>:<port> --file ./backup
```

### `import`
### `restore`

> Import metadata and user data

#### Usage

```shell
cnosdb-imexport import [OPTIONS] --path <PATH> --dst <DST>
cnosdb-meta restore --bind <ADDR> --file <PATH>
```

#### Options

| Name | Description |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `-p, --path <PATH>` | (Required) Data storage path |
| `-d, --dst <DST>` | (Required) Connection information of the source cluster (example: root:[email protected]:8902) |
| `-c, --conn <CONN>` | (Optional) Connection configuration for cloud storage |
| `-h, --help` | Print help information |
| Name | Description |
| --------------- | ----------------------------------------------------------------------------------------------- |
| `--bind <ADDR>` | (必需)源集群的连接信息(示例:127.0.0.1:8902) |
| `--file <PATH>` | (Required) Data storage path |
| `--help` | Print help information |

#### Example

##### Restore data backed up locally to the specified cluster

```shell
cnosdb-imexport import --path ./backup --dst <user>:<password>@<ip>:<port>
cnosdb-meta restore --bind <ip>:<port> --file ./backup
```

#####

### `migrate`
### `dump-sql`

> Migrate data between clusters
> 以sql形式导出指定cluster内的scheme数据

#### Usage

```shell
cnosdb-imexport migrate [OPTIONS] --src <SRC> --dst <DST> --path <PATH>
cnosdb-meta dump-sql --bind <ADDR> --cluster <NAME> --file <PATH>
```

#### Options

| Name | Description |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `s, --src <SRC>` | (Required) Connection information of the source cluster (example: root:[email protected]:8902) |
| `-d, --dst <DST>` | (Required) Connection information of the source cluster (example: root:[email protected]:8902) |
| `-p, --path <PATH>` | (Required) Data temporary storage directory |
| `-c, --conn <CONN>` | (Optional) Connection configuration for cloud storage |
| `-h, --help` | Print help information |
| Name | Description |
| ------------------ | ---------------------------------------------------------------------------------------------- |
| `--bind <ADDR>` | (必需)集群的连接信息(示例:127.0.0.1:8902) |
| `--cluster <NAME>` | (必需)集群的名称 |
| `--file <PATH>` | (Required) Data temporary storage directory |
| `-h, --help` | Print help information |

#### Example

##### Migrate data to other clusters

```shell
cnosdb-imexport migrate --src <user>:<passowrd>@<ip>:<port> --dst <user>:<passowrd>@<ip>:<port> --path ./staging
```

## Backup DDL statements

dump command

```shell
cnosdb-cli dump-ddl [--tenant TENANT]
```

When a tenant is specified, only users, roles, databases, and tables related to the tenant will be dumped.

restore command

```shell
cnosdb-cli [--error-stop] restore-dump-ddl DUMP_FILE
```

When --error-stop is specified, recovery will be interrupted in case of errors during recovery process

cnosdb-cli supports more parameters, the parameters can be referred to in the [documentation](../reference/tools.md#client-command-line-program), where the parameters should be placed before dump-ddl and restore-dump-ddl

## Example

dump

```shell
cnosdb-cli --host 127.0.0.1 --port 8902 dump-ddl --tenant cnosdb > dump.sql
```

restore

```shell
cnosdb-cli --host 127.0.0.1 --port 8902 restore-dump-ddl dump.sql
cnosdb-meta dump-sql --bind <ip>:<port> --cluster cluster_xxx --file ./dump_sql
```