Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
53 changes: 53 additions & 0 deletions docs/en/14-reference/01-components/01-taosd.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,63 @@ The command line parameters for taosd are as follows:
- -s: Prints SDB information.
- -C: Prints configuration information.
- -e: Specifies environment variables, formatted like `-e 'TAOS_FQDN=td1'`.
- -r: Starts repair mode. Currently supports `--mode copy` (copy vnode data from a healthy source node).
- -k: Retrieves the machine code.
- -dm: Enables memory scheduling.
- -V: Prints version information.

## Copy Mode Repair

Copy mode copies files for specified vnodes directly from a healthy source node to the current (target) node. This is intended for scenarios where the volume of corrupted data is too large for regular repair mode to handle within acceptable time.

### Syntax

```bash
taosd -r --mode copy --node-type vnode --source-cfg <path> \
[--source-host <host>] --vnode <id>[,<id>|<id>-<id>]...
```

### Options

| Option | Required | Description |
| --- | --- | --- |
| `--source-cfg` | Yes | Path to the source node's `taos.cfg` configuration file, or the directory containing it |
| `--source-host` | No | SSH host of the source node; omit for local source |
| `--vnode` | Yes | Comma-separated list of vnode IDs to copy; ranges with `-` are supported (e.g., `3,5-8,10`) |

### Limitations

- Only `--node-type vnode` is supported.
- Windows is not currently supported for copy mode.
- Remote mode requires passwordless SSH access (BatchMode).

### Examples

Copy a single vnode from a local source node:

```bash
taosd -r --mode copy --node-type vnode \
--source-cfg /data/source-cluster/taos.cfg \
--vnode 3
```

Copy multiple vnodes from a local source node (specifying config directory):

```bash
taosd -r --mode copy --node-type vnode \
--source-cfg /etc/taos/ \
--vnode 3,5,8
```

Copy vnodes from a remote source node:

```bash
taosd -r --mode copy --node-type vnode \
--source-cfg /etc/taos/taos.cfg \
--source-host 192.168.1.100 \
--vnode 3,5
```

## Configuration Parameters

:::note
Expand Down
53 changes: 53 additions & 0 deletions docs/zh/14-reference/01-components/01-taosd.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,63 @@ taosd 命令行参数如下:
- -e:指定环境变量的字符串,例如 `-e 'TAOS_FQDN=td1'`。
- -E:指定环境变量的文件路径,默认是 `./.env`,.env 文件中的内容可以是 `TAOS_FQDN=td1`。
- -o:指定日志输入方式,可选 `stdout`、`stderr`、`/dev/null`、`<directory>`、`<directory>/<filename>`、`<filename>`。
- -r:启动修复模式。当前支持 `--mode copy`(从健康的源节点拷贝 vnode 数据)。
- -k:获取机器码
- -dm:启用内存调度
- -V:打印版本信息

## 拷贝模式修复

拷贝模式用于从健康的源节点直接拷贝指定 vnode 的文件到当前(目标)节点。适用于损坏的数据量巨大、常规修复模式的性能无法满足要求的场景。

### 语法

```bash
taosd -r --mode copy --node-type vnode --source-cfg <path> \
[--source-host <host>] --vnode <id>[,<id>|<id>-<id>]...
```

### 参数

| 参数 | 必填 | 说明 |
| --- | --- | --- |
| `--source-cfg` | 是 | 源节点 `taos.cfg` 配置文件的路径,也可以指定配置文件所在目录 |
| `--source-host` | 否 | 源节点的 SSH 主机地址;省略时表示源数据在本地 |
| `--vnode` | 是 | 要拷贝的 vnode ID 列表,多个 ID 用逗号分隔,支持用 `-` 指定范围(如 `3,5-8,10`) |

### 限制

- 当前只支持 `--node-type vnode`。
- Windows 平台暂不支持拷贝模式。
- 远程模式需要 SSH 免密登录(BatchMode)。

### 示例

从本地源节点拷贝单个 vnode:

```bash
taosd -r --mode copy --node-type vnode \
--source-cfg /data/source-cluster/taos.cfg \
--vnode 3
```

从本地源节点拷贝多个 vnode(指定配置目录):

```bash
taosd -r --mode copy --node-type vnode \
--source-cfg /etc/taos/ \
--vnode 3,5,8
```

从远程源节点拷贝 vnode:

```bash
taosd -r --mode copy --node-type vnode \
--source-cfg /etc/taos/taos.cfg \
--source-host 192.168.1.100 \
--vnode 3,5
```

## 配置参数

:::note
Expand Down
49 changes: 49 additions & 0 deletions include/common/dmRepairCopy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _TD_DM_REPAIR_COPY_H_
#define _TD_DM_REPAIR_COPY_H_

#include "os.h"
#include "tarray.h"
#include "tdef.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct SRepairCopyOpts {
bool enabled;
char modeStr[32];
char nodeType[32];
char sourceHost[256];
char sourceCfg[PATH_MAX];
SArray *vnodeIds; // sorted ascending, deduplicated array of int32_t
} SRepairCopyOpts;

// Parse a vnode ID list string like "2-5,8,3,2" into a sorted, deduplicated
// SArray of int32_t. Caller must call taosArrayDestroy() on the result.
// Returns NULL on parse error.
SArray *dmParseVnodeIds(const char *str);

// Execute copy-mode repair. Returns exit code: 0=all ok, 1=bad args,
// 2=SSH fail, 3=partial failure, 4=all failed.
int32_t dmRepairCopyMode(const SRepairCopyOpts *pOpts);

#ifdef __cplusplus
}
#endif

#endif /* _TD_DM_REPAIR_COPY_H_ */
2 changes: 2 additions & 0 deletions source/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ target_include_directories(

PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
PRIVATE "${GRANT_CFG_INCLUDE_DIR}"
PRIVATE "${TD_SOURCE_DIR}/include/libs/tfs"
PRIVATE "${TD_SOURCE_DIR}/include/libs/monitor"
)

if(${TD_WINDOWS})
Expand Down
Loading
Loading