Skip to content

Commit 0d80edf

Browse files
authored
tools: add TiDB Controller guide (#432)
* tools: add TiDB Controller guide Via: pingcap/docs-cn#683 * Address comments * tools: address controller comments
1 parent ec54196 commit 0d80edf

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
- [Loader User Guide](tools/loader.md)
109109
- [TiDB-Binlog User Guide](tools/tidb-binlog-kafka.md)
110110
- [PD Control User Guide](tools/pd-control.md)
111+
- [TiDB Controller User Guide](tools/tidb-controller.md)
111112
+ The TiDB Connector for Spark
112113
- [Quick Start Guide](tispark/tispark-quick-start-guide.md)
113114
- [User Guide](tispark/tispark-user-guide.md)

tools/tidb-controller.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
title: TiDB Controller User Guide
3+
category: tools
4+
---
5+
6+
# TiDB Controller User Guide
7+
8+
TiDB Controller is a command line tool of TiDB, usually used to obtain the status information of TiDB for debugging.
9+
10+
## Compile from source code
11+
12+
- Compilation environment requirement: [Go](https://golang.org/) Version 1.7 or later
13+
- Compilation procedures: Go to the root directory of the [TiDB Controller project](https://github.com/pingcap/tidb-ctl), use the `make` command to compile, and generate `tidb-ctl`.
14+
- Compilation documentation: you can find the help files in the `doc` directory; if the help files are lost or you want to update them, use the `make doc` command to generate the help files.
15+
16+
## Usage introduction
17+
18+
The usage of `tidb-ctl` consists of command (including subcommand), option, and flag.
19+
20+
- command: characters without `-` or `--`
21+
- option: characters with `-` or `--`
22+
- flag: characters exactly following the command or option, passing value to the command or option
23+
24+
Usage example: `tidb-ctl schema in mysql -n db`
25+
26+
- `schema`: the command
27+
- `in`: the subcommand of schema
28+
- `mysql`: the flag of `in`
29+
- `-n`: the option
30+
- `db`: the flag of `-n`
31+
32+
### Get help
33+
34+
Use `tidb-ctl -h/--help` to get the help information. `tidb-ctl` consists of multiple layers of commands. You can use `-h/--help` to get the help information of `tidb-ctl` and all other subcommands.
35+
36+
### Connect
37+
38+
```
39+
tidb-ctl -H/--host {TiDB service address} -P/--port {TiDB service port}
40+
```
41+
42+
If you do not add an address or a port, the default value is used. The default address is `127.0.0.1` (service address must be the IP address); the default port is `10080`. Connection options are top-level options and apply to all of the following commands.
43+
44+
Currently, TiDB Controller can obtain four categories of information using the following four commands:
45+
46+
- `tidb-ctl mvcc`: MVCC information
47+
- `tidb-ctl region`: Region information
48+
- `tidb-ctl schema`: Schema information
49+
- `tidb-ctl table`: Table information
50+
51+
### Examples
52+
53+
The following example shows how to obtain the schema information:
54+
55+
Use `tidb-ctl schema -h` to get the help information of the subcommands. `schema` has two subcommands: `in` and `tid`.
56+
57+
- `in` is used to obtain the table schema of all tables in the database through the database name.
58+
- `tid` is used to obtain the table schema through the unique `table_id` in the whole database.
59+
60+
#### The `in` command
61+
62+
You can also use `tidb-ctl schema in -h/--help` to get the help information of the `in` subcommand.
63+
64+
##### Basic usage
65+
66+
```
67+
tidb-ctl schema in {database name}
68+
```
69+
70+
For example, `tidb-ctl schema in mysql` returns the following result:
71+
72+
```text
73+
[
74+
{
75+
"id": 13,
76+
"name": {
77+
"O": "columns_priv",
78+
"L": "columns_priv"
79+
},
80+
...
81+
"update_timestamp": 399494726837600268,
82+
"ShardRowIDBits": 0,
83+
"Partition": null
84+
}
85+
]
86+
```
87+
88+
The result is long and displayed in JSON. The above result is a truncated one.
89+
90+
- If you want to specify the table name, use `tidb-ctl schema in {database} -n {table name}` to filter.
91+
92+
For example, `tidb-ctl schema in mysql -n db` returns the table schema of the `db` table in the `mysql` database:
93+
94+
```text
95+
{
96+
"id": 9,
97+
"name": {
98+
"O": "db",
99+
"L": "db"
100+
},
101+
...
102+
"Partition": null
103+
}
104+
```
105+
106+
The above result is a truncated one, too.
107+
108+
- If you want to specify the server address, use the `-H -P` option.
109+
110+
For example, `tidb-ctl -H 127.0.0.1 -P 10080 schema in mysql -n db`.

0 commit comments

Comments
 (0)