From c010b6cf392641083f8363c6b85ceba4e325e39c Mon Sep 17 00:00:00 2001 From: Ivan Gao <92921813+IvanGao01@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:26:10 +0800 Subject: [PATCH 1/5] New translations centos_redhat.md (English) --- .../current/deploy/centos_redhat.md | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/deploy/centos_redhat.md b/i18n/en/docusaurus-plugin-content-docs/current/deploy/centos_redhat.md index 039fc2262..262fe8471 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/deploy/centos_redhat.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/deploy/centos_redhat.md @@ -147,49 +147,33 @@ 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 -``` - -#### View Cluster Status - -Specify different nodes separately, perform the following commands to view cluster status. - -> Replace `` in the command to specify a different `meta` service instance. - -```shell -curl http://meta.cnosdb.com:8901/metrics | jq +cnosdb-meta show-nodes --bind meta1.cnosdb.com:8901 ``` 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", - ... ... -} +``` +Node ID Address State Term Last_Log_index Last_Applied Leader Members +1 127.0.0.1:8901 Leader 1 7 7 1 [1, 2, 3] +2 127.0.0.1:8911 Follower 1 7 7 1 [1, 2, 3] +3 127.0.0.1:8921 Follower 1 7 7 1 [1, 2, 3] ``` ### Launch the `cnosdb` service From f6d7f4337d3c28914b32d6ab5edcd11ee361f7c4 Mon Sep 17 00:00:00 2001 From: Ivan Gao <92921813+IvanGao01@users.noreply.github.com> Date: Tue, 10 Dec 2024 19:40:54 +0800 Subject: [PATCH 2/5] New translations centos_redhat.md (English) --- .../current/deploy/centos_redhat.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/deploy/centos_redhat.md b/i18n/en/docusaurus-plugin-content-docs/current/deploy/centos_redhat.md index 262fe8471..a83befc79 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/deploy/centos_redhat.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/deploy/centos_redhat.md @@ -170,12 +170,20 @@ If the cluster installation is successful, the following content should be retur > `state` may also be `Follower`. ``` -Node ID Address State Term Last_Log_index Last_Applied Leader Members -1 127.0.0.1:8901 Leader 1 7 7 1 [1, 2, 3] -2 127.0.0.1:8911 Follower 1 7 7 1 [1, 2, 3] -3 127.0.0.1:8921 Follower 1 7 7 1 [1, 2, 3] +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] ``` +#### 删除集群中的节点 + +```shell +cnosdb-meta remove-node --bind meta1.cnosdb.com:8901 --addr meta2.cnosdb.com:8901 +``` + +> 若删除的是leader节点,之后集群的bind地址会变化,请参照系统提示进行输入 + ### Launch the `cnosdb` service #### Edit profile From 8d72e31809fee46f92170d7cc43e0f6906b79baf Mon Sep 17 00:00:00 2001 From: Ivan Gao <92921813+IvanGao01@users.noreply.github.com> Date: Tue, 10 Dec 2024 19:40:55 +0800 Subject: [PATCH 3/5] New translations ubuntu_debian.md (English) --- .../current/deploy/ubuntu_debian.md | 44 ++++++++----------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/deploy/ubuntu_debian.md b/i18n/en/docusaurus-plugin-content-docs/current/deploy/ubuntu_debian.md index e51536bfb..be7d76261 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/deploy/ubuntu_debian.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/deploy/ubuntu_debian.md @@ -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 `` in the command to specify a different `meta` service instance. +> `state` may also be `Follower`. -```shell -curl http://meta.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 From 354ab3527c41b6e10d5a37ffda1644ca12ccbcfb Mon Sep 17 00:00:00 2001 From: Ivan Gao <92921813+IvanGao01@users.noreply.github.com> Date: Tue, 10 Dec 2024 19:40:57 +0800 Subject: [PATCH 4/5] New translations backup_restore.md (English) --- .../current/manage/backup_restore.md | 119 +++++------------- 1 file changed, 34 insertions(+), 85 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/manage/backup_restore.md b/i18n/en/docusaurus-plugin-content-docs/current/manage/backup_restore.md index c6f18f392..9c72ac246 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/manage/backup_restore.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/manage/backup_restore.md @@ -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 ` +`cnosdb-meta ` #### 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 --path +cnosdb-meta dump --bind --file ``` #### Options -| Name | Description | -| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `-s, --src ` | (Required) Connection information of the source cluster (example: root:123456@127.0.0.1:8902) | -| `-p, --path ` | (Required) Data storage path | -| `-c, --conn ` | (Optional) Connection configuration for cloud storage | -| `-h, --help` | Print help information | +| Name | Description | +| --------------- | ----------------------------------------------------------------------------------------------- | +| `--bind ` | (必需)源集群的连接信息(示例:127.0.0.1:8902) | +| `--file ` | (Required) Data storage path | +| `--help` | Print help information | #### Example ##### Backup data to local directory ```shell -cnosdb-imexport export --src :@: --path ./backup +cnosdb-meta dump --src :@: --file ./backup ``` -### `import` +### `restore` > Import metadata and user data #### Usage ```shell -cnosdb-imexport import [OPTIONS] --path --dst +cnosdb-meta restore --bind --file ``` #### Options -| Name | Description | -| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `-p, --path ` | (Required) Data storage path | -| `-d, --dst ` | (Required) Connection information of the source cluster (example: root:123456@127.0.0.1:8902) | -| `-c, --conn ` | (Optional) Connection configuration for cloud storage | -| `-h, --help` | Print help information | +| Name | Description | +| --------------- | ----------------------------------------------------------------------------------------------- | +| `--bind ` | (必需)源集群的连接信息(示例:127.0.0.1:8902) | +| `--file ` | (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 :@: +cnosdb-meta restore --bind : --file ./backup ``` ##### -### `migrate` +### `dump-sql` -> Migrate data between clusters +> 以sql形式导出指定cluster内的scheme数据 #### Usage ```shell -cnosdb-imexport migrate [OPTIONS] --src --dst --path +cnosdb-meta dump-sql --bind --cluster --file ``` #### Options -| Name | Description | -| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `s, --src ` | (Required) Connection information of the source cluster (example: root:123456@127.0.0.1:8902) | -| `-d, --dst ` | (Required) Connection information of the source cluster (example: root:123456@127.0.0.1:8902) | -| `-p, --path ` | (Required) Data temporary storage directory | -| `-c, --conn ` | (Optional) Connection configuration for cloud storage | -| `-h, --help` | Print help information | +| Name | Description | +| ------------------ | ---------------------------------------------------------------------------------------------- | +| `--bind ` | (必需)集群的连接信息(示例:127.0.0.1:8902) | +| `--cluster ` | (必需)集群的名称 | +| `--file ` | (Required) Data temporary storage directory | +| `-h, --help` | Print help information | #### Example ##### Migrate data to other clusters ```shell -cnosdb-imexport migrate --src :@: --dst :@: --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 : --cluster cluster_xxx --file ./dump_sql ``` From a9b6a9f94d3d8c641614b5f322c7f2fd8727efb0 Mon Sep 17 00:00:00 2001 From: Ivan Gao <92921813+IvanGao01@users.noreply.github.com> Date: Fri, 9 May 2025 18:08:43 +0800 Subject: [PATCH 5/5] New translations upgrade_to_2.4.md (English) --- .../current/deploy/upgrade_to_2.4.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/deploy/upgrade_to_2.4.md diff --git a/i18n/en/docusaurus-plugin-content-docs/current/deploy/upgrade_to_2.4.md b/i18n/en/docusaurus-plugin-content-docs/current/deploy/upgrade_to_2.4.md new file mode 100644 index 000000000..d1feeb3da --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/deploy/upgrade_to_2.4.md @@ -0,0 +1,111 @@ +--- +sidebar_position: 5 +--- + +# 迁移至企业版 2.4 最佳实践 + +> 前置条件:已经搭建好 CnosDB 2.4 企业版集群 +> +> 本文档同样适用于社区版本单机和集群 + +1. 导出 2.3 集群的 DDL + +> 1) 如果还有其他租户,请更换`tenant`参数租户并多次执行(可是使用 `SELECT * FROM cluster_schema.tenants;` 检查) +> 2) 如果用户没有绑定角色,则不能导出,需要手动创建(可以使用`SELECT * FROM cluster_schema.users;`和导出的文件对比检查) +> 3) 创建用户可以参考 https://docs.cnosdb.com/docs/reference/sql/dcl#create-user +> 4) 密码无法手动导出导入,需要重新修改密码,可以参考 https://docs.cnosdb.com/docs/manage/tenant + +``` +cnosdb-cli dump-ddl --tenant cnosdb > tenant_cnosdb.sql +``` + +2. 启动单机版实例,用于存放迁移期间数据 + +``` +docker run -d -p 8902-8905:8902-8905 cnosdb/cnosdb:community-latest +``` + +3. 导入 DDL 到单机版实例 + +将第一步中导出的 .sql 文件恢复至单机版实例 + +如果还有其他租户,请更换`tenant`参数并多次执行 + +``` +cnosdb-cli restore-dump-ddl -t cnosdb tenant_cnosdb.sql +``` + +4. 切换流量到单机版实例 + +根据用户环境自行操作 + +5. 导出 2.3 集群中的数据 + +这是一个同步命令,如果想在后台(nohup)执行可以使用 cnosdb-cli --file 指定sql文件, + +cnosdb-cli --database benchmark --tenant cnosdb --file load.sql + +⚠️ 每个表的导出路径要不同 + +``` +COPY INTO 'file:///var/lib/backup/benchmark/diagnostics' +FROM "diagnostics" +FILE_FORMAT = ( + TYPE = 'PARQUET' +); +``` + +成功后,返回如下结果,请记住 rows 的值,设置导入的数据条数,用于之后导入验证数据是否完整: + +``` +benchmark ❯ COPY INTO 'file:///var/lib/backup/benchmark/diagnostics' +FROM "diagnostics" +FILE_FORMAT = ( + TYPE = 'PARQUET' +); ++-----------+ +| rows | ++-----------+ +| 575416055 | ++-----------+ +Query took 1160.660 seconds. +``` + +6. 导入 DDL 至 2.4 集群 + +同 第三步 一样 + +7. 新集群导入数据 + +路径尾部一定要追加一个`/`,否则系统找不到路径 + +同 导出数据一样,也可以通过 sql 文件的方式后台导入 + +``` +COPY INTO "diagnostics" +FROM 'file:///var/lib/backup/benchmark/diagnostics/' +FILE_FORMAT = ( + TYPE = 'PARQUET' +); +``` + +8. 验证数据正确性 + +导入导出都会提示数据条数,请对比,如下 + +``` +benchmark ❯ COPY INTO "diagnostics" +FROM 'file:///var/lib/backup/benchmark/diagnostics/' +FILE_FORMAT = ( + TYPE = 'PARQUET' +); ++-----------+ +| rows | ++-----------+ +| 575416055 | ++-----------+ +``` + +9. 切换流量到 2.4 集群 +10. 将单机实例中的数据导出,并导入到新集群(请参照第5, 7步) +