Skip to content

Commit

Permalink
Add tikv-br docs (#12188)
Browse files Browse the repository at this point in the history
* add tikv-br doc

Signed-off-by: haojinming <[email protected]>

* fix br and cdc link

Signed-off-by: haojinming <[email protected]>

* add cn link

Signed-off-by: haojinming <[email protected]>

* address review comments

Signed-off-by: haojinming <[email protected]>

* Update tikv-configuration-file.md

Co-authored-by: Ping Yu <[email protected]>

* Update br/rawkv-backup-and-restore.md

Co-authored-by: Ping Yu <[email protected]>

* Update release-6.4.0.md

Signed-off-by: haojinming <[email protected]>
Co-authored-by: Ping Yu <[email protected]>
Co-authored-by: shichun-0415 <[email protected]>
  • Loading branch information
3 people authored Dec 9, 2022
1 parent 6131ac0 commit 4f2ed84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 67 deletions.
57 changes: 3 additions & 54 deletions br/rawkv-backup-and-restore.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,10 @@
---
title: 备份与恢复 RawKV 数据
summary: 了解如何使用 br 命令行工具备份和恢复 RawKV 数据。
summary: 了解如何使用 tikv-br 命令行工具备份和恢复 RawKV 数据。
---

# 备份与恢复 RawKV 数据

> **警告:**
>
> 从 TiDB v6.2.0 开始,RawKV 备份和恢复功能废弃。
TiKV 可以独立于 TiDB,与 PD 构成 KV 数据库,此时的产品形态为 RawKV。TiKV-BR 工具支持对使用 RawKV 的产品进行备份和恢复。

TiKV 有时可以独立于 TiDB,与 PD 构成 KV 数据库,此时的产品形态为 RawKV。Backup & Restore (BR) 支持对使用 RawKV 的产品进行备份和恢复,本文介绍如何备份和恢复 RawKV。

## 备份 RawKV

在某些使用场景下,TiKV 可能会独立于 TiDB 运行。考虑到这点,br 命令行工具提供跳过 TiDB 层直接备份 TiKV 数据的功能:

```shell
br backup raw --pd $PD_ADDR \
--storage "local://$BACKUP_DIR" \
--start 31 \
--ratelimit 128 \
--end 3130303030303030 \
--format hex \
--cf default
```

以上命令会将 default CF 上 `[0x31, 0x3130303030303030)` 之间的所有键备份到 `$BACKUP_DIR`

这里,`--start``--end` 的参数会先依照 `--format` 指定的方式解码,再被发送到 TiKV 上去,目前支持以下解码方式:

- "raw":不进行任何操作,将输入的字符串直接编码为二进制格式的键。
- "hex":将输入的字符串视作十六进制数字。这是默认的编码方式。
- "escaped":对输入的字符串进行转义(backslash-escaped)之后,再编码为二进制格式,格式类似于 `abc\xFF\x00\r\n`

> **注意:**
>
> - 如果使用本地存储,在恢复前**必须**将所有备份的 SST 文件复制到各个 TiKV 节点上 ``--storage`` 指定的目录下。即使每个 TiKV 节点最后只需要读取部分 SST 文件,这些节点也需要有所有 SST 文件的完全访问权限。原因如下:
>
> - 数据被复制到了多个 Peer 中。在读取 SST 文件时,这些文件必须要存在于所有 Peer 中。这与数据的备份不同,在备份时,只需从单个节点读取。
> - 在数据恢复的时候,每个 Peer 分布的位置是随机的,事先并不知道哪个节点将读取哪个文件。
>
> - 使用共享存储可以避免这些情况。例如,在本地路径上安装 NFS,或使用 S3。利用这些网络存储,各个节点都可以自动读取每个 SST 文件,此时上述注意事项不再适用。
>
> - 同时,请注意同一时间对同一个集群只能运行一个恢复任务,否则可能会出现非预期的行为,详见[可以同时使用多个 br 工具进程对单个集群进行恢复吗](/faq/backup-and-restore-faq.md#可以同时启动多个恢复任务对单个集群进行恢复吗)
## 恢复 RawKV

[备份 RawKV](#备份-rawkv)相似,恢复 RawKV 的命令如下:

```shell
br restore raw --pd $PD_ADDR \
--storage "local://$BACKUP_DIR" \
--start 31 \
--end 3130303030303030 \
--ratelimit 128 \
--format hex \
--cf default
```

以上命令会将范围在 `[0x31, 0x3130303030303030)` 的已备份键恢复到 TiKV 集群中。这里键的编码方式和备份时相同。
更多信息,请参考 [TiKV-BR 用户文档](https://tikv.org/docs/latest/concepts/explore-tikv-features/backup-restore-cn/)
2 changes: 1 addition & 1 deletion releases/release-6.4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ TiDB 版本:6.4.0-DMR
| TiDB | [`pessimistic-txn.constraint-check-in-place-pessimistic`](/tidb-configuration-file.md#constraint-check-in-place-pessimistic-从-v640-版本开始引入) | 新增 | 用于控制系统变量 [`tidb_constraint_check_in_place_pessimistic`](/system-variables.md#tidb_constraint_check_in_place_pessimistic-从-v630-版本开始引入) 的默认值,默认值为 `true`。|
| TiDB | [`tidb_max_reuse_chunk`](/tidb-configuration-file.md#tidb_max_reuse_chunk-从-v640-版本开始引入) | 新增 | 用于控制每个连接最多缓存的 Chunk 对象数,默认值为 `64`。 |
| TiDB | [`tidb_max_reuse_column`](/tidb-configuration-file.md#tidb_max_reuse_column-从-v640-版本开始引入) | 新增 | 用于控制每个连接最多缓存的 column 对象数,默认值为 `256`。 |
| TiKV | [`cdc.raw-min-ts-outlier-threshold`](/tikv-configuration-file.md#raw-min-ts-outlier-threshold-从-v620-版本开始引入) | 废弃 | 该配置不再生效。|
| TiKV | [`cdc.raw-min-ts-outlier-threshold`](https://docs.pingcap.com/zh/tidb/v6.2/tikv-configuration-file#raw-min-ts-outlier-threshold-从-v620-版本开始引入) | 废弃 | 该配置不再生效。|
| TiKV | [`causal-ts.alloc-ahead-buffer`](/tikv-configuration-file.md#alloc-ahead-buffer-从-v640-版本开始引入) | 新增 | 预分配给 TSO 的缓存大小(以时长计算),默认值为 `3s`。|
| TiKV | [`causal-ts.renew-batch-max-size`](/tikv-configuration-file.md#renew-batch-max-size-从-v640-版本开始引入)| 新增 | 单次时间戳请求的最大数量,默认值为 `8192`。 |
| TiKV | [`raftstore.apply-yield-write-size`](/tikv-configuration-file.md#apply-yield-write-size-从-v640-版本开始引入) | 新增 | Apply 线程每一轮处理单个状态机写入的最大数据量,默认值为 `32KiB`。这是个软限制。|
Expand Down
14 changes: 2 additions & 12 deletions tikv-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,12 @@ TiKV 配置文件比命令行参数支持更多的选项。你可以在 [etc/con
+ 需要同时设置 `storage.enable-ttl = true`。由于 API V2 支持 TTL 特性,因此强制要求打开 `enable-ttl` 以避免这个参数出现歧义。
+ 启用 API V2 后需要在集群中额外部署至少一个 tidb-server 以回收过期数据。该 tidb-server 可同时提供数据库读写服务。可以部署多个 tidb-server 以保证高可用。
+ 需要客户端的支持。请参考对应客户端的 API V2 使用说明。
+ 从 v6.2.0 版本开始,你可以通过 [RawKV CDC](https://github.com/tikv/migration/tree/main/cdc) 组件实现 RawKV 的 Change Data Capture (CDC)。
+ 从 v6.2.0 版本开始,你可以通过 [RawKV CDC](https://tikv.org/docs/latest/concepts/explore-tikv-features/cdc/cdc-cn/) 组件实现 RawKV 的 Change Data Capture (CDC)。
+ 默认值:1

> **警告:**
>
> - 由于 API V1 和 API V2 底层存储格式不同,因此**仅当** TiKV 中只有 TiDB 数据时,可以平滑启用或关闭 API V2。其他情况下,需要新建集群,并使用 [TiKV Backup & Restore](https://github.com/tikv/migration/blob/main/br/README-cn.md) 工具进行数据迁移。
> - 由于 API V1 和 API V2 底层存储格式不同,因此**仅当** TiKV 中只有 TiDB 数据时,可以平滑启用或关闭 API V2。其他情况下,需要新建集群,并使用 [TiKV Backup & Restore](https://tikv.org/docs/latest/concepts/explore-tikv-features/backup-restore-cn/) 工具进行数据迁移。
> - 启用 API V2 后,**不能**将 TiKV 集群回退到 v6.1.0 之前的版本,否则可能导致数据损坏。
## storage.block-cache
Expand Down Expand Up @@ -1714,16 +1714,6 @@ Raft Engine 相关的配置项。
+ 默认值:6,即最多并发执行 6 个任务
+ 注意:`incremental-scan-concurrency` 需要大于等于 `incremental-scan-threads`,否则 TiKV 启动会报错。

### `raw-min-ts-outlier-threshold` <span class="version-mark">从 v6.2.0 版本开始引入</span>

> **警告:**
>
> 这个配置项自 v6.4.0 版本起废弃。
+ 对 RawKV 的 Resolved TS 进行异常检测的阈值。
+ 如果某个 Region 的 Resolved TS 延迟超过这个阈值,将进入异常检测流程。此时,Resolved TS 延迟超过 3 x [IQR](https://en.wikipedia.org/wiki/Interquartile_range) 的 Region 将被认为出现锁释放缓慢,并触发 TiKV-CDC 重新订阅该 Region 的数据变更,从而重置锁资源状态。
+ 默认值:60s

## resolved-ts

用于维护 Resolved TS 以服务 Stale Read 请求的相关配置项。
Expand Down

0 comments on commit 4f2ed84

Please sign in to comment.