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

update tikv-ctl doc #3254

Merged
merged 8 commits into from
May 26, 2020
Merged
Changes from 1 commit
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
Next Next commit
update tikv-ctl doc
Signed-off-by: qupeng <qupeng@pingcap.com>
  • Loading branch information
hicqu committed May 22, 2020
commit bc6fddc9d5b7cc92ec6b0074ee9ab19ee999d675
23 changes: 19 additions & 4 deletions tikv-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aliases: ['/docs-cn/dev/reference/tools/tikv-control/']

TiKV Control(以下简称 tikv-ctl)是 TiKV 的命令行工具,用于管理 TiKV 集群。

编译 TiKV 的同时也会编译 tikv-ctl 命令。如果通过 Ansible 部署集群,则对应的 `tidb-ansible/resources/bin` 目录下会存在 `tikv-ctl` 二进制文件。如果使用二进制文件部署集群,bin 目录下会包含 `tikv-ctl` 文件及 `tidb-server`、`pd-server`、以及 `tikv-server` 等其他文件。
编译 TiKV 的同时也会编译 tikv-ctl 命令。如果通过 Ansible 部署集群,则对应的 `tidb-ansible/resources/bin` 目录下会存在 `tikv-ctl` 二进制文件。
Copy link
Contributor

Choose a reason for hiding this comment

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

用户不太关心 tikv-ctl 是如何产生的,只需要告诉他在什么地方就可以了,ansible 这部分需要改成 tiup


## 通用参数
Copy link
Contributor

Choose a reason for hiding this comment

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

目前 这几个 ctl 工具,都可以 tiup ctl 调用,举个例子说明下吧。


Expand Down Expand Up @@ -192,16 +192,20 @@ success!

`compact-cluster` 命令可以对整个 TiKV 集群进行手动 compact。该命令参数的含义和使用与 `compact` 命令一样。

### 设置一个 Region tombstone
### 设置一个 Region 副本为 tombstone
Copy link
Contributor

Choose a reason for hiding this comment

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

tombstone 状态?


`tombstone` 命令常用于没有开启 sync-log,因为机器掉电导致 Raft 状态机丢失部分写入的情况。它可以在一个 TiKV 实例上将一些 Region 设置为 Tombstone 状态,从而在重启时跳过这些 Region。这些 Region 应该在其他 TiKV 上有足够多的健康的副本以便能够继续通过 Raft 机制进行读写。
`tombstone` 命令常用于没有开启 sync-log,因为机器掉电导致 Raft 状态机丢失部分写入的情况。它可以在一个 TiKV 实例上将一些 Region 的副本设置为 Tombstone 状态,从而在重启时跳过这些 Region,避免因为这些 Region 的副本的 Raft 状态机损坏而无法启动服务。这些 Region 应该在其他 TiKV 上有足够多的健康的副本以便能够继续通过 Raft 机制进行读写。

一般情况下,我们可以先在 PD 上将 Region 的副本通过 remove-peer 命令删除掉:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
一般情况下,我们可以先在 PD 上将 Region 的副本通过 remove-peer 命令删除掉:
一般情况下,可以先在 PD 上将 Region 的副本通过 `remove-peer` 命令删除掉:


{{< copyable "" >}}

```shell
pd-ctl>> operator add remove-peer <region_id> <store_id>
```

然后再用 tikv-ctl 在那个 TiKV 实例上将 Region 的副本标记为 tombstone 以便跳过启动时对他的健康检查:

{{< copyable "shell-regular" >}}

```shell
Expand All @@ -212,10 +216,21 @@ tikv-ctl --db /path/to/tikv/db tombstone -p 127.0.0.1:2379 -r <region_id>
success!
```

但是有些情况下,当不能方便地从 PD 上移除这个副本时,可以指定 tikv-ctl 的 --force 选项来强制设置它为 tombstone:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
但是有些情况下,当不能方便地从 PD 上移除这个副本时,可以指定 tikv-ctl 的 --force 选项来强制设置它为 tombstone:
但是有些情况下,当不能方便地从 PD 上移除这个副本时,可以指定 tikv-ctl 的 `--force` 选项来强制设置它为 tombstone:


```shell
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
```shell
{{< copyable "shell-regular" >}}
```shell

tikv-ctl --db /path/to/tikv/db tombstone -p 127.0.0.1:2379 -r <region_id>,<region_id> --force
Copy link
Contributor

Choose a reason for hiding this comment

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

Why there are two region_id here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's expected. Just show multiple region id can be specified.

```

```
success!
```


> **注意:**
>
> - **该命令只支持本地模式**
> - `-p` 选项的参数指定 PD 的 endpoints,无需 `http` 前缀。指定 PD 的 endpoints 是为了询问 PD 是否可以安全切换至 Tombstone 状态。因此,在将 PD 置为 Tombstone 之前往往还需要在 `pd-ctl` 中把该 Region 在机器上的对应 Peer 拿掉。
> - `-p` 选项的参数指定 PD 的 endpoints,无需 `http` 前缀。指定 PD 的 endpoints 是为了询问 PD 是否可以安全切换至 Tombstone 状态。

### 向 TiKV 发出 consistency-check 请求

Expand Down