Skip to content

Commit

Permalink
tools: add more sub commands for tikv-ctl (#572)
Browse files Browse the repository at this point in the history
Signed-off-by: qupeng <qupeng@pingcap.com>
  • Loading branch information
hicqu committed Aug 17, 2018
1 parent 55c8a86 commit a5a1e83
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tools/tikv-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ TiKV Control (`tikv-ctl`) is a command line tool of TiKV, used to manage the clu
$ tikv-ctl --ca-path ca.pem --cert-path client.pem --key-path client-key.pem --host 127.0.0.1:21060 <subcommands>
```

However, sometimes `tikv-ctl` communicates with PD instead of TiKV. In this case, you need to use the `--pd` option instead of `--host`. Here is an example:

```
$ tikv-ctl --pd 127.0.0.1:2379 compact-cluster
store:"127.0.0.1:20160" compact db:KV cf:default range:([], []) success!
```

- Local mode: use the `--db` option to specify the local TiKV data directory path

Unless otherwise noted, all commands supports both the remote mode and the local mode.
Expand Down Expand Up @@ -99,6 +106,26 @@ In this command, the key is also the escaped form of raw key.

To print the value of a key, use the `print` command.

### Print some properties about Region

In order to record Region state details, TiKV writes some statistics into the SST files of Regions. To view these properties, run `tikv-ctl` with the `region-properties` sub-command:

```bash
$ tikv-ctl --host localhost:20160 region-properties -r 2
num_files: 0
num_entries: 0
num_deletes: 0
mvcc.min_ts: 18446744073709551615
mvcc.max_ts: 0
mvcc.num_rows: 0
mvcc.num_puts: 0
mvcc.num_versions: 0
mvcc.max_row_versions: 0
middle_key_by_approximate_size:
```

The properties can be used to check whether the Region is healthy or not. If not, you can use them to fix the Region. For example, spliting the Region manually by `middle_key_approximate_size`.

### 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.
Expand Down Expand Up @@ -156,6 +183,10 @@ DebugClient::check_region_consistency: RpcFailure(RpcStatus { status: Unknown, d
> - This command only supports the remote mode.
> - Even if this command returns `success!`, you need to check whether TiKV panics. This is because this command is only a proposal that requests a consistency check for the leader, and you cannot know from the client whether the whole check process is successful or not.
### Dump snapshot meta
This sub-command is used to parse a snapshot meta file at given path and print the result.
### Print the Regions where the Raft state machine corrupts
To avoid checking the Regions while TiKV is started, you can use the `tombstone` command to set the Regions where the Raft state machine reports an error to Tombstone. Before running this command, use the `bad-regions` command to find out the Regions with errors, so as to combine multiple tools for automated processing.
Expand Down

0 comments on commit a5a1e83

Please sign in to comment.