docs: automatically add new databases for active-active replication

Relates to [TS-5606](https://jira.taosdata.com:18080/browse/TS-5606)
This commit is contained in:
Linhe Huo 2025-02-27 23:49:37 +08:00
parent 5d777f9bcf
commit 990b991633
2 changed files with 31 additions and 4 deletions

View File

@ -53,6 +53,8 @@ It is not necessary to configure your cluster specifically for active-active mod
- The sink endpoint is the FQDN of TDengine on the secondary node. - The sink endpoint is the FQDN of TDengine on the secondary node.
- You can use the native connection (port 6030) or WebSocket connection (port 6041). - You can use the native connection (port 6030) or WebSocket connection (port 6041).
- You can specify one or more databases to replicate only the data contained in those databases. If you do not specify a database, all databases on the node are replicated except for `information_schema`, `performance_schema`, `log`, and `audit`. - You can specify one or more databases to replicate only the data contained in those databases. If you do not specify a database, all databases on the node are replicated except for `information_schema`, `performance_schema`, `log`, and `audit`.
- New databases in both sides will be detected periodically to start replication, with optional `--new-database-checking-interval <SECONDS>` argument.
- New databases checking will be disabled with `--no-new-databases`.
When the command is successful, the replica ID is displayed. You can use this ID to add other databases to the replication task if necessary. When the command is successful, the replica ID is displayed. You can use this ID to add other databases to the replication task if necessary.
@ -97,7 +99,6 @@ You can manage your active-active deployment with the following commands:
:::note :::note
- This command cannot create duplicate tasks. It only adds the specified databases to the specified task. - This command cannot create duplicate tasks. It only adds the specified databases to the specified task.
- The replica ID is globally unique within a taosX instance and is independent of the source/sink combination. - The replica ID is globally unique within a taosX instance and is independent of the source/sink combination.
::: :::
2. Check the status of a task: 2. Check the status of a task:
@ -124,6 +125,8 @@ You can manage your active-active deployment with the following commands:
If you specify a database, replication for that database is stopped. If you do not specify a database, all replication tasks on the ID are stopped. If you do not specify an ID, all replication tasks on the instance are stopped. If you specify a database, replication for that database is stopped. If you do not specify a database, all replication tasks on the ID are stopped. If you do not specify an ID, all replication tasks on the instance are stopped.
Use `--no-new-databases` to not stop new-databases checking.
4. Restart a replication task: 4. Restart a replication task:
```shell ```shell
@ -132,6 +135,14 @@ You can manage your active-active deployment with the following commands:
If you specify a database, replication for that database is restarted. If you do not specify a database, all replication tasks in the instance are restarted. If you do not specify an ID, all replication tasks on the instance are restarted. If you specify a database, replication for that database is restarted. If you do not specify a database, all replication tasks in the instance are restarted. If you do not specify an ID, all replication tasks on the instance are restarted.
5. Update new databases checking interval:
```shell
taosx replica update id --new-database-checking-interval <SECONDS>
```
This command will only update the checking interval for new databases.
5. Check the progress of a replication task: 5. Check the progress of a replication task:
```shell ```shell

View File

@ -81,7 +81,12 @@ taosx replica start -f source_endpoint -t sink_endpoint [database...]
taosx replica start -f td1:6030 -t td2:6030 taosx replica start -f td1:6030 -t td2:6030
``` ```
该示例命令会自动创建除 information_schema、performance_schema、log、audit 库之外的同步任务。可以使用 `http://td2:6041` 指定该 endpoint 使用 websocket 接口默认是原生接口。也可以指定数据库同步taosx replica start -f td1:6030 -t td2:6030 db1 仅创建指定的数据库同步任务。 该示例命令会自动创建除 information_schema、performance_schema、log、audit 库之外的同步任务,并持续监听新增的数据库,当 td1 和 td2 中新增同名数据库时可自动启动新增数据库的数据复制任务。需要说明的是:
- 可以使用 `http://td2:6041` 指定该 endpoint 使用 websocket 接口(默认是原生接口)。
- 可以使用 `--new-database-checking-interval <SECONDS>` 指定新增数据库的检查间隔,默认为 30 分钟。
- 可以使用 `--no-new-databases` 禁用监听行为。
- 也可以指定数据库同步taosx replica start -f td1:6030 -t td2:6030 db1 仅创建指定的数据库同步任务。此时相当于配置了 `--no-new-databases`,不会开启新增数据库自动同步。
2. 方法二 2. 方法二
@ -121,6 +126,7 @@ taosx replica stop id [db...]
该命令作用如下: 该命令作用如下:
1. 停止指定 Replica ID 下所有或指定数据库的双副本同步任务。 1. 停止指定 Replica ID 下所有或指定数据库的双副本同步任务。
2. 使用 `taosx replica stop id1 db1` 表示停止 id1 replica 下 db1的同步任务。 2. 使用 `taosx replica stop id1 db1` 表示停止 id1 replica 下 db1的同步任务。
3. `--no-new-databases` 选项启用时,不停止新增数据库监听任务,仅停止当前同步中的数据库。
### 重启双活任务 ### 重启双活任务
@ -145,8 +151,8 @@ taosx replica diff id [db....]
| replica | database | source | sink | vgroup_id | current | latest | diff | | replica | database | source | sink | vgroup_id | current | latest | diff |
+---------+----------+----------+----------+-----------+---------+---------+------+ +---------+----------+----------+----------+-----------+---------+---------+------+
| a | opc | td1:6030 | td2:6030 | 2 | 17600 | 17600 | 0 | | a | opc | td1:6030 | td2:6030 | 2 | 17600 | 17600 | 0 |
| ad | opc | td2:6030 | td2:6030 | 3 | 17600 | 17600 | 0 | | a | opc | td2:6030 | td2:6030 | 3 | 17600 | 17600 | 0 |
``` ```
### 删除双活任务 ### 删除双活任务
@ -156,6 +162,16 @@ taosx replica remove id [--force]
删除当前所有双活同步任务。正常情况下要想删除同步任务,需要先 stop 该任务;但当 --force 启用时,会强制停止并清除任务。 删除当前所有双活同步任务。正常情况下要想删除同步任务,需要先 stop 该任务;但当 --force 启用时,会强制停止并清除任务。
`--no-new-databases` 选项启用时,不会删除新增数据库同步任务,仅删除当前数据库的同步任务。当 taosx 重启后,如果删除的数据库任务对应的数据库仍然存在,则会继续创建同步任务;不重启 taosx 或者不更新双活监听任务时,也不会再新建这些数据库的同步任务。
### 更新双活新增数据库检查间隔
```shell
taosx replica update id --new-database-checking-interval <SECONDS>
```
更新双活新增数据库的检查间隔,单位为秒。
### 推荐使用步骤 ### 推荐使用步骤
1. 假定在机器 A 上运行,需要首先使用 taosx replica start 来配置 taosX其输入参数是待同步的源端和目标端服务器地址 ,在完成配置后会自动启动同步服务和任务。此处假定 taosx 服务使用标准端口,同步任务使用原生连接。 1. 假定在机器 A 上运行,需要首先使用 taosx replica start 来配置 taosX其输入参数是待同步的源端和目标端服务器地址 ,在完成配置后会自动启动同步服务和任务。此处假定 taosx 服务使用标准端口,同步任务使用原生连接。