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

pdctl: add store label and restore store command documents #11318

Merged
merged 20 commits into from
Sep 19, 2022
Merged
Changes from 17 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
48 changes: 38 additions & 10 deletions pd-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -1247,9 +1247,11 @@ scheduler config balance-hot-region-scheduler // 显示 balance-hot-region 调

### `store [delete | cancel-delete | label | weight | remove-tombstone | limit ] <store_id> [--jq="<query string>"]`

用于显示 store 信息或者删除指定 store。使用 jq 格式化输出请参考 [jq 格式化 json 输出示例](#jq-格式化-json-输出示例)。示例如下
使用 jq 格式化输出请参考 [jq 格式化 json 输出示例](#jq-格式化-json-输出示例)。

显示所有 store 信息:
#### 查询 store

通过 `store` 显示所有 store 信息:
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

{{< copyable "" >}}

Expand All @@ -1276,6 +1278,8 @@ store 1
......
```

#### 下线 store

下线 store id 为 1 的 store:

{{< copyable "" >}}
Expand All @@ -1284,39 +1288,62 @@ store 1
store delete 1
```

撤销已使用 store delete 下线并处于 Offline 状态的 store。撤销后,该 store 会从 Offline 状态变为 Up 状态。注意,该命令无法使 Tombstone 状态的 store 变回 Up 状态。以下示例撤销已使用 store delete 下线的 store,其 store id 为 1:
你可以撤销已使用 `store delete` 下线并处于 Offline 状态的 store。撤销后,该 store 会从 Offline 状态变为 Up 状态。注意,该命令无法使 Tombstone 状态的 store 变回 Up 状态。以下示例撤销已使用 `store delete` 下线的 store id 为 1 的 store,并删除所有 Tombstone 状态的 store
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

{{< copyable "" >}}

```bash
store cancel-delete 1
store cancel-delete 1 // 取消下线
store remove-tombstone // 删除所有 Tombstone 状态的 store
```

> **注意:**
>
> 若下线过程中切换了 PD leader,需要手动修改 store limit。

设置 store id 为 1 的 store 的键为 "zone" 的 label 的值为 "cn":
#### 管理 store label

`store label` 命令用于管理 store label。

为 store id 为 1 的 store 添加键为 `"zone"` 的值为 `"cn"` 的 label:
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

{{< copyable "" >}}

```bash
store label 1 zone=cn
```

更新 store id 为 1 的 label:
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

{{< copyable "" >}}

```bash
store label 1 zone cn
store label 1 zone=us
```

清除 store id 为 1 label:
通过 `--rewrite` 重写 store id 为 1 的所有 label,之前有的 label 会被覆盖
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

{{< copyable "" >}}

```bash
store label 1 --force
store label 1 region=us-est-1 disk=ssd --rewrite
```

删除指定 store 的对应 label:
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

{{< copyable "" >}}

```bash
store label 1 disk --delete
```

> **注意:**
>
> - store 的 label 更新方法使用的是合并策略。如果修改了 TiKV 配置文件中的 store label,进程重启之后,PD 会将自身存储的 store label 与其进行合并更新,并持久化合并后的结果。
> - 如果希望使用 TiUP 统一管理 store label 的话,可以在集群重启前,使用 PD Control 的 `store label <id> --force` 命令将 PD 存储的 store label 清空。

#### store weight 命令
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

设置 store id 为 1 的 store 的 leader weight 为 5,Region weight 为 10:
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

{{< copyable "" >}}
Expand All @@ -1325,10 +1352,11 @@ store label 1 --force
store weight 1 5 10
```

{{< copyable "" >}}
#### store limit 命令
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

关于 `store limit` 的原理和使用方法,请参考 [`store limit`](/configure-store-limit.md)。
Oreoxmt marked this conversation as resolved.
Show resolved Hide resolved

```bash
>> store remove-tombstone // 删除所有 tombstone 状态的 store
>> store limit // 显示所有 store 添加和删除 peer 的速度上限
>> store limit add-peer // 显示所有 store 添加 peer 的速度上限
>> store limit remove-peer // 显示所有 store 删除 peer 的速度上限
Expand Down