From dca16339fdcd4f6117055fb3ba61f04724a27337 Mon Sep 17 00:00:00 2001 From: Liqi Geng Date: Tue, 30 Jun 2020 16:25:49 +0800 Subject: [PATCH 1/3] update tikv control Signed-off-by: Liqi Geng --- tikv-control.md | 79 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/tikv-control.md b/tikv-control.md index be2bc975633d2..b54a986b0ba9a 100644 --- a/tikv-control.md +++ b/tikv-control.md @@ -7,9 +7,33 @@ aliases: ['/docs/dev/tikv-control/','/docs/dev/reference/tools/tikv-control/'] # TiKV Control User Guide -TiKV Control (`tikv-ctl`) is a command line tool of TiKV, used to manage the cluster. +TiKV Control (`tikv-ctl`) is a command line tool of TiKV, used to manage the cluster. Its installation directory is as follows: -When you compile TiKV, the `tikv-ctl` command is also compiled at the same time. If the cluster is deployed using TiDB Ansible, the `tikv-ctl` binary file exists in the corresponding `tidb-ansible/resources/bin` directory. If the cluster is deployed using the binary, the `tikv-ctl` file is in the `bin` directory together with other files such as `tidb-server`, `pd-server`, `tikv-server`, etc. +* If the cluster is deployed using TiDB Ansible, it exists in the `resources/bin` subdirectory under the `ansible` directory. +* If the cluster is deployed using TiUP, it exists in `~/.tiup/components/ctl/{VERSION}/` directory. + +[TiUP](https://github.com/pingcap-incubator/tiuptiup) is a deployment tool introduced later than `tidb-ansible`, and its usage is more simplified. `tikv-ctl` is also integrated in the `tiup` command. Execute the following command to call the `tikv-ctl` tool: + +{{< copyable "shell-regular" >}} + +```bash +tiup ctl tikv +``` + +``` +Starting component `ctl`: ~/.tiup/components/ctl/v4.0.0-rc.2/ctl tikv +TiKV Control (tikv-ctl) +Release Version: 4.0.0-rc.2 +Edition: Community +Git Commit Hash: 2fdb2804bf8ffaab4b18c4996970e19906296497 +Git Commit Branch: heads/refs/tags/v4.0.0-rc.2 +UTC Build Time: 2020-05-15 11:58:49 +Rust Version: rustc 1.42.0-nightly (0de96d37f 2019-12-19) +Enable Features: jemalloc portable sse protobuf-codec +Profile: dist_release +``` + +You can add the appropriate parameters and subcommands behind `tiup ctl tikv`. ## General options @@ -149,7 +173,11 @@ The properties can be used to check whether the Region is healthy or not. If not ### Compact data of each TiKV manually -Use the `compact` command to manually compact data of each TiKV. If you specify the `--from` and `--to` options, then their flags are also in the form of escaped raw key. You can use the `--db` option to specify the RocksDB that you need to compact. The optional values are `kv` and `raft`. Also, the `--threads` option allows you to specify the concurrency that you compact and its default value is 8. Generally, a higher concurrency comes with a faster compact speed, which might yet affect the service. You need to choose an appropriate concurrency based on the scenario. +Use the `compact` command to manually compact data of each TiKV. If you specify the `--from` and `--to` options, then their flags are also in the form of escaped raw key. + +- Use the `--host` option to specify the TiKV that you need to compact. +- Use the `-d` option to specify the RocksDB that you need to compact. The optional values are `kv` and `raft`. +- Use the `--threads` option allows you to specify the concurrency that you compact and its default value is 8. Generally, a higher concurrency comes with a faster compact speed, which might yet affect the service. You need to choose an appropriate concurrency based on the scenario. ```bash $ tikv-ctl --db /path/to/tikv/db compact -d kv @@ -164,29 +192,39 @@ Use the `compact-cluster` command to manually compact data of the whole TiKV clu The `tombstone` command is usually used in circumstances where the sync-log is not enabled, and some data written in the Raft state machine is lost caused by power down. -In a TiKV instance, you can use this command to set the status of some Regions to Tombstone. Then when you restart the instance, those Regions are skipped. Those Regions need to have enough healthy replicas in other TiKV instances to be able to continue writing and reading through the Raft mechanism. +In a TiKV instance, you can use this command to set the status of some Regions to Tombstone. Then when you restart the instance, those Regions are skipped so as to avoid the failure to restart because those Regions's Raft state machine are damaged. Those Regions need to have enough healthy replicas in other TiKV instances to be able to continue writing and reading through the Raft mechanism. -Follow the two steps to set a Region to Tombstone: +Under normal circumstances, you can remove the corresponding Peer of this Region using `remove-peer` command: -1. Remove the corresponding Peer of this Region on the machine in `pd-ctl`: +{{< copyable "shell-regular" >}} - {{< copyable "shell-regular" >}} +```shell +pd-ctl operator add remove-peer +``` - ```shell - pd-ctl operator add remove-peer - ``` +Then use the tikv-ctl to set a Region to Tombstone in the corresponding TiKV instance so it will skip this Region's health check at startup: + +{{< copyable "shell-regular" >}} -2. Use the `tombstone` command to set a Region to Tombstone: +```shell +tikv-ctl --db /path/to/tikv/db tombstone -p 127.0.0.1:2379 -r +``` - {{< copyable "shell-regular" >}} +``` +success! +``` - ```shell - tikv-ctl --db /path/to/tikv/db tombstone -p 127.0.0.1:2379 -r - ``` +However, in some cases, when it is not convenient to remove this Peer of this Region from PD, you can specify the `--force` option of tikv-ctl to force it to tombstone: - ``` - success! - ``` +{{< copyable "shell-regular" >}} + +```shell +tikv-ctl --db /path/to/tikv/db tombstone -p 127.0.0.1:2379 -r , --force +``` + +``` +success! +``` > **Note:** > @@ -277,7 +315,8 @@ success! Use the `recover-mvcc` command in circumstances where TiKV cannot run normally caused by MVCC data corruption. It cross-checks 3 CFs ("default", "write", "lock") to recover from various kinds of inconsistency. -Use the `-r` option to specify involved Regions by `region_id`. Use the `-p` option to specify PD endpoints. +- Use the `-r` option to specify involved Regions by `region_id`. +- Use the `-p` option to specify PD endpoints. ```bash $ tikv-ctl --db /path/to/tikv/db recover-mvcc -r 1001,1002 -p 127.0.0.1:2379 @@ -292,7 +331,7 @@ success! ### Ldb Command -The ldb command line tool offers multiple data access and database administration commands. Some examples are listed below. +The `ldb` command line tool offers multiple data access and database administration commands. Some examples are listed below. For more information, refer to the help message displayed when running `tikv-ctl ldb` or check the documents from RocksDB. Examples of data access sequence: From a33fe6d0ed13387d0246eca581aa5ad5ace5ae54 Mon Sep 17 00:00:00 2001 From: Liqi Geng Date: Mon, 6 Jul 2020 16:40:49 +0800 Subject: [PATCH 2/3] address comments Signed-off-by: Liqi Geng --- tikv-control.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tikv-control.md b/tikv-control.md index b54a986b0ba9a..d81af3dc09967 100644 --- a/tikv-control.md +++ b/tikv-control.md @@ -9,10 +9,10 @@ aliases: ['/docs/dev/tikv-control/','/docs/dev/reference/tools/tikv-control/'] TiKV Control (`tikv-ctl`) is a command line tool of TiKV, used to manage the cluster. Its installation directory is as follows: -* If the cluster is deployed using TiDB Ansible, it exists in the `resources/bin` subdirectory under the `ansible` directory. -* If the cluster is deployed using TiUP, it exists in `~/.tiup/components/ctl/{VERSION}/` directory. +* If the cluster is deployed using TiDB Ansible, `tikv-ctl` directory is in the `resources/bin` subdirectory under the `ansible` directory. +* If the cluster is deployed using TiUP, `tikv-ctl` directory is in the in `~/.tiup/components/ctl/{VERSION}/` directory. -[TiUP](https://github.com/pingcap-incubator/tiuptiup) is a deployment tool introduced later than `tidb-ansible`, and its usage is more simplified. `tikv-ctl` is also integrated in the `tiup` command. Execute the following command to call the `tikv-ctl` tool: +[TiUP](https://github.com/pingcap-incubator/tiuptiup) is a deployment tool introduced later than TiDB Ansible, and its usage is simpler. `tikv-ctl` is also integrated in the `tiup` command. Execute the following command to call the `tikv-ctl` tool: {{< copyable "shell-regular" >}} @@ -33,7 +33,7 @@ Enable Features: jemalloc portable sse protobuf-codec Profile: dist_release ``` -You can add the appropriate parameters and subcommands behind `tiup ctl tikv`. +You can add corresponding parameters and subcommands after `tiup ctl tikv`. ## General options @@ -192,9 +192,9 @@ Use the `compact-cluster` command to manually compact data of the whole TiKV clu The `tombstone` command is usually used in circumstances where the sync-log is not enabled, and some data written in the Raft state machine is lost caused by power down. -In a TiKV instance, you can use this command to set the status of some Regions to Tombstone. Then when you restart the instance, those Regions are skipped so as to avoid the failure to restart because those Regions's Raft state machine are damaged. Those Regions need to have enough healthy replicas in other TiKV instances to be able to continue writing and reading through the Raft mechanism. +In a TiKV instance, you can use this command to set the status of some Regions to Tombstone. Then when you restart the instance, those Regions are skipped to avoid the restart failure caused by damaged Raft state machines of those Regions. Those Regions need to have enough healthy replicas in other TiKV instances to be able to continue the reads and writes through the Raft mechanism. -Under normal circumstances, you can remove the corresponding Peer of this Region using `remove-peer` command: +In general cases, you can remove the corresponding Peer of this Region using the `remove-peer` command: {{< copyable "shell-regular" >}} @@ -202,7 +202,7 @@ Under normal circumstances, you can remove the corresponding Peer of this Region pd-ctl operator add remove-peer ``` -Then use the tikv-ctl to set a Region to Tombstone in the corresponding TiKV instance so it will skip this Region's health check at startup: +Then use the `tikv-ctl` tool to set a Region to tombstone on the corresponding TiKV instance to skip the health check for this Region at startup: {{< copyable "shell-regular" >}} @@ -214,7 +214,7 @@ tikv-ctl --db /path/to/tikv/db tombstone -p 127.0.0.1:2379 -r success! ``` -However, in some cases, when it is not convenient to remove this Peer of this Region from PD, you can specify the `--force` option of tikv-ctl to force it to tombstone: +However, in some cases, you cannot easily remove this Peer of this Region from PD, so you can specify the `--force` option in `tikv-ctl` to forcibly set the Peer to tombstone: {{< copyable "shell-regular" >}} From 719898bf2079e6b91322cd5cc6bffd00e4ec68fa Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Tue, 7 Jul 2020 18:28:29 +0800 Subject: [PATCH 3/3] Update tikv-control.md --- tikv-control.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tikv-control.md b/tikv-control.md index d81af3dc09967..9d0765e17a9c9 100644 --- a/tikv-control.md +++ b/tikv-control.md @@ -192,7 +192,7 @@ Use the `compact-cluster` command to manually compact data of the whole TiKV clu The `tombstone` command is usually used in circumstances where the sync-log is not enabled, and some data written in the Raft state machine is lost caused by power down. -In a TiKV instance, you can use this command to set the status of some Regions to Tombstone. Then when you restart the instance, those Regions are skipped to avoid the restart failure caused by damaged Raft state machines of those Regions. Those Regions need to have enough healthy replicas in other TiKV instances to be able to continue the reads and writes through the Raft mechanism. +In a TiKV instance, you can use this command to set the status of some Regions to tombstone. Then when you restart the instance, those Regions are skipped to avoid the restart failure caused by damaged Raft state machines of those Regions. Those Regions need to have enough healthy replicas in other TiKV instances to be able to continue the reads and writes through the Raft mechanism. In general cases, you can remove the corresponding Peer of this Region using the `remove-peer` command: