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

tikv-control: support the Flashback command trigger #14133

Open
wants to merge 1 commit into
base: master
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
2 changes: 2 additions & 0 deletions pd-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ config show cluster-version
config set store-limit-version v2 // 使用 Store Limit v2
```

- `halt-scheduling` 用于停止调度。一旦它被打开,PD 将停止调度,且任何其他的调度配置都将被忽略。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `halt-scheduling` 用于停止调度。一旦它被打开,PD 将停止调度,且任何其他的调度配置都将被忽略
- `halt-scheduling` 用于停止调度。开启该配置后,PD 将停止调度,并且忽略其他的调度配置


- PD 会对流量信息的末尾数字进行四舍五入处理,减少 Region 流量信息变化引起的统计信息更新。该配置项用于指定对 Region 流量信息的末尾进行四舍五入的位数。例如流量 `100512` 会归约到 `101000`。默认值为 `3`。该配置替换了 `trace-region-flow`。

示例:将 `flow-round-by-digit` 的值设为 `4`:
Expand Down
26 changes: 26 additions & 0 deletions tikv-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,32 @@ success!
> - `-p` 选项指定 PD 的 endpoint,不使用 `http` 前缀,用于查询指定的 `region_id` 是否有效。
> - 对于指定 Region 的 peers 所在的每个 store,均须执行该命令。

### Flashback

TiDB v6.4.0 引入了 [FLASHBACK CLUSTER TO TIMESTAMP 语法](/sql-statements/sql-statement-flashback-to-timestamp.md),其功能是将集群的数据恢复到特定的时间点。为了更方便脱离 TiDB 进行使用,我们提供了 `flashback` 指令,支持在 TiKV 层面进行

- `--pd` 选项可以指定 PD 的 endpoints。
- `-v` 选项可以指定需要 Flashback 的时间点。
- 默认情况下,会对整个集群进行 Flashback。也提供如下方式对指定 Region 进行操作:
- 如果需要操作指定的 Region,可以使用 `-r` 选项,多个 Region 以 `,` 分隔
- 要操作某个 key 范围中的所有 Region,可在命令中使用 `--start` 和 `--end` 参数(默认不限范围,采用 Hex 格式)

需要对整个集群进行操作时,用法及输出内容如下所示:

```shell
tikv-ctl --pd 127.0.0.1:2379 flashback --version 430315739761082369
```

```
flashback all stores success!
```

> **注意:**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块拿到最前面吧,不然用户可能执行完了才看到这条,或者就作为步骤的一部分,而不是注意事项。

>
> - 在使用前,需要通过 `./pd-ctl config set halt-scheduling true` [停止 PD 调度](pd-control.md#config-show--set-option-value--placement-rules)。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先改成 code 调用吧,这样就不用加这个文档了

> - 该命令采用最新的时间戳写入特定时间点的旧数据,但不会删除当前数据,所以在使用前请确保集群有足够的存储空间来同时容纳旧数据和当前数据。
> - 该命令只支持本地模式。在运行成功后,会打印 `flashback all stores success!`。
Comment on lines +552 to +576
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Flashback
TiDB v6.4.0 引入了 [FLASHBACK CLUSTER TO TIMESTAMP 语法](/sql-statements/sql-statement-flashback-to-timestamp.md),其功能是将集群的数据恢复到特定的时间点。为了更方便脱离 TiDB 进行使用,我们提供了 `flashback` 指令,支持在 TiKV 层面进行
- `--pd` 选项可以指定 PD 的 endpoints。
- `-v` 选项可以指定需要 Flashback 的时间点。
- 默认情况下,会对整个集群进行 Flashback。也提供如下方式对指定 Region 进行操作:
- 如果需要操作指定的 Region,可以使用 `-r` 选项,多个 Region 以 `,` 分隔
- 要操作某个 key 范围中的所有 Region,可在命令中使用 `--start` 和 `--end` 参数(默认不限范围,采用 Hex 格式)
需要对整个集群进行操作时,用法及输出内容如下所示:
```shell
tikv-ctl --pd 127.0.0.1:2379 flashback --version 430315739761082369
```
```
flashback all stores success!
```
> **注意:**
>
> - 在使用前,需要通过 `./pd-ctl config set halt-scheduling true` [停止 PD 调度](pd-control.md#config-show--set-option-value--placement-rules)
> - 该命令采用最新的时间戳写入特定时间点的旧数据,但不会删除当前数据,所以在使用前请确保集群有足够的存储空间来同时容纳旧数据和当前数据。
> - 该命令只支持本地模式。在运行成功后,会打印 `flashback all stores success!`
### Flashback
TiDB v6.4.0 引入了 [`FLASHBACK CLUSTER TO TIMESTAMP`](/sql-statements/sql-statement-flashback-to-timestamp.md) 语法,其功能是将集群的数据恢复到特定的时间点。为了方便脱离 TiDB 使用,tikv-ctl 提供了 `flashback` 命令。该命令支持在 TiKV 层面进行 Flashback 操作。
> **注意:**
>
> - 在执行 `flashback` 命令前,需要先通过 `./pd-ctl config set halt-scheduling true` 命令[停止 PD 调度](pd-control.md#config-show--set-option-value--placement-rules)
> - 该命令是用最新的时间戳写入特定时间点的旧数据,但不会删除当前数据,所以在使用前请确保集群有足够的存储空间来同时容纳旧数据和当前数据。
> - 该命令只支持本地模式。运行成功后,会打印 `flashback all stores success!`
下面示例将整个集群的数据恢复到 430315739761082369 时间点:
```shell
tikv-ctl --pd 127.0.0.1:2379 flashback --version 430315739761082369
```
输出结果如下:
```
flashback all stores success!
```
上述命令中各选项的含义如下:
- `--pd` 用于指定 PD 的访问地址。
- `--version` 用于指定 Flashback 目标的时间点。
- 默认情况下,该命令会对整个集群进行 Flashback。如果需要对指定 Region 或 key 范围进行操作,可以:
- 使用 `-r` 选项指定 Region,多个 Region 之间用 `,` 分隔。
- 使用 `--start` 和 `--end` 指定某个 key 范围内的所有 Region(默认无范围限制,采用 Hex 格式)。


### Ldb 命令

`ldb` 命令行工具提供多种数据访问以及数据库管理命令。下方列出了一些示例用法。详细信息请在运行 `tikv-ctl ldb` 命令时查看帮助消息或查阅 RocksDB 文档。
Expand Down