Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a55b158
add sql-dignosis
reafans Mar 16, 2020
0ceb83a
fmt
reafans Mar 16, 2020
5e0f48a
fix lint
reafans Mar 16, 2020
5640320
Merge branch 'master' into sql-dignosis
reafans Mar 16, 2020
8d703b7
fix lint
reafans Mar 16, 2020
ef6f2e8
Merge branch 'sql-dignosis' of https://github.com/reafans/docs-cn int…
reafans Mar 16, 2020
879ba0a
split the sql-dignosis doc
reafans Mar 19, 2020
2934e47
refine doc
reafans Mar 19, 2020
a3b172c
fix lint
reafans Mar 19, 2020
1be1aa5
Merge branch 'master' into sql-dignosis
reafans Mar 19, 2020
2545f7a
add meta info
reafans Mar 20, 2020
e5a55d4
Merge branch 'sql-dignosis' of https://github.com/reafans/docs-cn int…
reafans Mar 20, 2020
f44276f
Merge branch 'master' of https://github.com/pingcap/docs-cn into sql-…
reafans Mar 20, 2020
fab9543
add æ‹sql copy
reafans Mar 20, 2020
edc30e5
refine doc
reafans Mar 20, 2020
91e2f47
Update reference/system-databases/sql-dignosis.md
crazycs520 Mar 25, 2020
236de52
Update reference/system-databases/sql-dignosis.md
crazycs520 Mar 25, 2020
7cbbe98
Update reference/system-databases/sql-dignosis.md
crazycs520 Mar 25, 2020
aaf04b6
Update reference/system-databases/sql-dignosis.md
crazycs520 Mar 25, 2020
76df3ee
Update reference/system-databases/cluster_hardware.md
crazycs520 Mar 25, 2020
76a7273
Update reference/system-databases/cluster_hardware.md
crazycs520 Mar 25, 2020
de9d5dd
Update reference/system-databases/cluster_hardware.md
crazycs520 Mar 25, 2020
c440c78
Update reference/system-databases/cluster_info.md
crazycs520 Mar 25, 2020
276f099
Update reference/system-databases/cluster_info.md
crazycs520 Mar 25, 2020
4a1607d
Update reference/system-databases/sql-dignosis.md
reafans Mar 25, 2020
742c352
Update reference/system-databases/sql-dignosis.md
reafans Mar 25, 2020
bba068d
Update reference/system-databases/cluster_info.md
reafans Mar 25, 2020
ee5ca59
Update reference/system-databases/sql-dignosis.md
reafans Mar 25, 2020
8711f0e
Update reference/system-databases/cluster_info.md
reafans Mar 25, 2020
b49a460
Update reference/system-databases/cluster_log.md
reafans Mar 25, 2020
a6c75f9
Update reference/system-databases/cluster_hardware.md
reafans Mar 25, 2020
0514530
address comment
reafans Mar 26, 2020
f4a674d
Merge branch 'master' of https://github.com/pingcap/docs-cn into sql-…
reafans Mar 26, 2020
04df9fa
refine doc
reafans Mar 26, 2020
943a9f2
refine punctuations and wording
TomShawn Mar 26, 2020
5e000e8
Merge branch 'master' into sql-dignosis
crazycs520 Mar 27, 2020
bc211ce
add more docs
crazycs520 Mar 27, 2020
a9224d8
Update reference/system-databases/sql-dignosis.md
crazycs520 Mar 27, 2020
2130a4e
Update reference/system-databases/sql-dignosis.md
crazycs520 Mar 27, 2020
40e2917
Merge branch 'sql-dignosis' of https://github.com/reafans/docs-cn int…
crazycs520 Mar 27, 2020
0277006
Merge branch 'master' of https://github.com/pingcap/docs-cn into sql-…
reafans Mar 31, 2020
452ef15
add sys tables to TOC
reafans Mar 31, 2020
d472c80
Merge branch 'sql-dignosis' of https://github.com/reafans/docs-cn int…
reafans Mar 31, 2020
b0862be
fix lint
reafans Mar 31, 2020
bef374e
Update reference/system-databases/sql-diagnosis.md
crazycs520 Apr 1, 2020
45b1d8e
update metrics_schema docs
crazycs520 Apr 1, 2020
e817985
add reference links and change file names
TomShawn Apr 1, 2020
344a622
Merge branch 'sql-dignosis' of https://github.com/reafans/docs-cn int…
TomShawn Apr 1, 2020
f46db32
fix dead links
TomShawn Apr 1, 2020
5f30f52
Update reference/system-databases/cluster-config.md
reafans Apr 3, 2020
ccb0a64
Update TOC.md
reafans Apr 3, 2020
2f0a3c9
Delete SELECT GREATEST(t1.avg_value,.sql
reafans Apr 3, 2020
0ac939b
reference: add summaries for newly added docs
TomShawn Apr 3, 2020
3cd1fe6
Merge branch 'master' into sql-dignosis
reafans Apr 3, 2020
eac7895
toc: fix a link placement issue
lilin90 Apr 3, 2020
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
13 changes: 13 additions & 0 deletions TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
- [分区表](/reference/sql/partitioning.md)
- [字符集](/reference/sql/character-set.md)
- [SQL 模式](/reference/sql/sql-mode.md)
- [SQL 诊断](/reference/system-databases/sql-diagnosis.md)
- [视图](/reference/sql/view.md)
+ 配置
+ tidb-server
Expand Down Expand Up @@ -247,6 +248,18 @@
+ 系统数据库
- [`mysql`](/reference/system-databases/mysql.md)
- [`information_schema`](/reference/system-databases/information-schema.md)
+ `sql-diagnosis`
- [`cluster_info`](/reference/system-databases/cluster-info.md)
- [`cluster_hardware`](/reference/system-databases/cluster-hardware.md)
- [`cluster_config`](/reference/system-databases/cluster-config.md)
- [`cluster_load`](/reference/system-databases/cluster-load.md)
- [`cluster_systeminfo`](/reference/system-databases/cluster-systeminfo.md)
- [`cluster_log`](/reference/system-databases/cluster-log.md)
- [`metrics_schema`](/reference/system-databases/metrics-schema.md)
- [`metrics_tables`](/reference/system-databases/metrics-tables.md)
- [`metrics_summary`](/reference/system-databases/metrics-summary.md)
- [`inspection_result`](/reference/system-databases/inspection-result.md)
- [`inspection_summary`](/reference/system-databases/inspection-summary.md)
- [错误码](/reference/error-codes.md)
- [支持的连接器和 API](/reference/supported-clients.md)
+ 垃圾回收 (GC)
Expand Down
54 changes: 54 additions & 0 deletions reference/system-databases/cluster-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: CLUSTER_CONFIG
category: reference
summary: 了解 TiDB 集群配置表 `CLUSTER_CONFIG`。
---

# CLUSTER_CONFIG

集群配置表 `CLUSTER_CONFIG` 用于获取集群当前所有 TiDB/PD/TiKV 节点的配置。对于 TiDB 4.0 以前的版本,用户需要逐个访问各个节点的 HTTP API 才能收集到所有组件配置。

{{< copyable "sql" >}}

```sql
desc cluster_config;
```

```
+----------+--------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+------+---------+-------+
| TYPE | varchar(64) | YES | | NULL | |
| INSTANCE | varchar(64) | YES | | NULL | |
| KEY | varchar(256) | YES | | NULL | |
| VALUE | varchar(128) | YES | | NULL | |
+----------+--------------+------+------+---------+-------+
```

字段解释:

* `TYPE`:节点的类型,可取值为 `tidb`,`pd` 或 `tikv`。
* `INSTANCE`:节点的服务地址。
* `KEY`:配置项名。
* `VALUE`:配置项值。

以下示例查询 TiKV 节点的 `coprocessor` 相关配置:

{{< copyable "sql" >}}

```sql
select * from cluster_config where type='tikv' and `key` like 'coprocessor%';
```

```
+------+-----------------+-----------------------------------+----------+
| TYPE | INSTANCE | KEY | VALUE |
+------+-----------------+-----------------------------------+----------+
| tikv | 127.0.0.1:20160 | coprocessor.batch-split-limit | 10 |
| tikv | 127.0.0.1:20160 | coprocessor.region-max-keys | 1.44e+06 |
| tikv | 127.0.0.1:20160 | coprocessor.region-max-size | 144MiB |
| tikv | 127.0.0.1:20160 | coprocessor.region-split-keys | 960000 |
| tikv | 127.0.0.1:20160 | coprocessor.region-split-size | 96MiB |
| tikv | 127.0.0.1:20160 | coprocessor.split-region-on-table | false |
+------+-----------------+-----------------------------------+----------+
```
62 changes: 62 additions & 0 deletions reference/system-databases/cluster-hardware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: CLUSTER_HARDWARE
summary: 了解 TiDB 集群配置表 `CLUSTER_HARDWARE`。
category: reference
---

# CLUSTER_HARDWARE

集群硬件表 `CLUSTER_HARDWARE` 提供了集群各节点所在服务器的硬件信息。

{{< copyable "sql" >}}

```sql
desc cluster_hardware;
```

```
+-------------+--------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+------+---------+-------+
| TYPE | varchar(64) | YES | | NULL | |
| INSTANCE | varchar(64) | YES | | NULL | |
| DEVICE_TYPE | varchar(64) | YES | | NULL | |
| DEVICE_NAME | varchar(64) | YES | | NULL | |
| NAME | varchar(256) | YES | | NULL | |
| VALUE | varchar(128) | YES | | NULL | |
+-------------+--------------+------+------+---------+-------+
```

字段解释:

* `TYPE`:对应节点信息表 `information_schema.cluster_info` 中的 `TYPE` 字段,可取值为 `tidb`,`pd` 或 `tikv`。
* `INSTANCE`:对应于节点信息表 `information_schema.cluster_info` 中的 `STATUS_ADDRESS` 字段。
* `DEVICE_TYPE`:硬件类型。目前可以查询的硬件类型有 `cpu`、`memory`、`disk` 和 `net`。
* `DEVICE_NAME`:硬件名。对于不同的 `DEVICE_TYPE`,`DEVICE_NAME` 的取值不同。
* `cpu`:硬件名为 cpu。
* `memory`:硬件名为 memory。
* `disk`:磁盘名。
* `net`:网卡名。
* `NAME`:硬件不同的信息名,比如 cpu 有 `cpu-logical-cores` , `cpu-physical-cores` 两个信息名,表示逻辑核心数量和物理核心数量。
* `VALUE`:对应硬件信息的值。例如磁盘容量和 CPU 核数。

查询集群 CPU 信息的示例如下:

{{< copyable "sql" >}}

```sql
select * from cluster_hardware where device_type='cpu' and device_name='cpu' and name like '%cores';
```

```
+------+-----------------+-------------+-------------+--------------------+-------+
| TYPE | INSTANCE | DEVICE_TYPE | DEVICE_NAME | NAME | VALUE |
+------+-----------------+-------------+-------------+--------------------+-------+
| tidb | 127.0.0.1:10080 | cpu | cpu | cpu-logical-cores | 8 |
| tidb | 127.0.0.1:10080 | cpu | cpu | cpu-physical-cores | 4 |
| pd | 127.0.0.1:2379 | cpu | cpu | cpu-logical-cores | 8 |
| pd | 127.0.0.1:2379 | cpu | cpu | cpu-physical-cores | 4 |
| tikv | 127.0.0.1:20160 | cpu | cpu | cpu-logical-cores | 8 |
| tikv | 127.0.0.1:20160 | cpu | cpu | cpu-physical-cores | 4 |
+------+-----------------+-------------+-------------+--------------------+-------+
```
56 changes: 56 additions & 0 deletions reference/system-databases/cluster-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: CLUSTER_INFO
summary: 了解 TiDB 集群配置表 `CLUSTER_INFO`。
category: reference
---

# CLUSTER_INFO

集群拓扑表 `CLUSTER_INFO` 提供集群当前的拓扑信息,以及各个节点的版本信息、版本对应的 Git Hash、各节点的启动时间、各节点的运行时间。

{{< copyable "sql" >}}

```sql
desc cluster_info;
```

```
+----------------+-------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+------+---------+-------+
| TYPE | varchar(64) | YES | | NULL | |
| INSTANCE | varchar(64) | YES | | NULL | |
| STATUS_ADDRESS | varchar(64) | YES | | NULL | |
| VERSION | varchar(64) | YES | | NULL | |
| GIT_HASH | varchar(64) | YES | | NULL | |
| START_TIME | varchar(32) | YES | | NULL | |
| UPTIME | varchar(32) | YES | | NULL | |
+----------------+-------------+------+------+---------+-------+
7 rows in set (0.00 sec)
```

字段解释:

* `TYPE`:节点类型,目前节点的可取值为 `tidb`,`pd` 或 `tikv`。
* `INSTANCE`:实例地址,为 `IP:PORT` 格式的字符串。
* `STATUS_ADDRESS`:HTTP API 的服务地址。部分 `tikv-ctl`、`pd-ctl` 或 `tidb-ctl` 命令会使用到 HTTP API 和该地址。用户也可以通过该地址获取一些额外的集群信息,详情可参考 HTTP API 官方文档。
* `VERSION`:对应节点的语义版本号。TiDB 版本为了兼容 MySQL 的版本号,以 `${mysql-version}-${tidb-version}` 的格式展示版本号。
* `GIT_HASH`:编译节点版本时的 Git Commit Hash,用于识别两个节点是否是绝对一致的版本。
* `START_TIME`:对应节点的启动时间。
* `UPTIME`:对应节点已经运行的时间。

{{< copyable "sql" >}}

```sql
select * from cluster_info;
```

```
+------+-----------------+-----------------+----------------------------------------+------------------------------------------+---------------------------+--------------+
| TYPE | INSTANCE | STATUS_ADDRESS | VERSION | GIT_HASH | START_TIME | UPTIME |
+------+-----------------+-----------------+----------------------------------------+------------------------------------------+---------------------------+--------------+
| tidb | 127.0.0.1:4000 | 127.0.0.1:10080 | 5.7.25-TiDB-v4.0.0-beta-195-gb5ea3232a | b5ea3232afa970f00db7a0fb13ed10857db1912e | 2020-03-02T16:27:28+08:00 | 4m18.845924s |
| pd | 127.0.0.1:2379 | 127.0.0.1:2379 | 4.1.0-alpha | 4b9bcbc1425c96848042b6d700eb63f84e72b338 | 2020-03-02T16:27:17+08:00 | 4m29.845928s |
| tikv | 127.0.0.1:20160 | 127.0.0.1:20180 | 4.1.0-alpha | 7c4202a1c8faf60eda659dfe0e64e31972488e78 | 2020-03-02T16:27:28+08:00 | 4m18.845929s |
+------+-----------------+-----------------+----------------------------------------+------------------------------------------+---------------------------+--------------+
```
65 changes: 65 additions & 0 deletions reference/system-databases/cluster-load.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: CLUSTER_LOAD
summary: 了解 TiDB 集群配置表 `CLUSTER_LOAD`。
category: reference
---

# CLUSTER_LOAD

集群负载表 `CLUSTER_LOAD` 提供集群各个节点所在服务器的的当前负载信息。

{{< copyable "sql" >}}

```sql
desc cluster_load;
```

```
+-------------+--------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+------+---------+-------+
| TYPE | varchar(64) | YES | | NULL | |
| INSTANCE | varchar(64) | YES | | NULL | |
| DEVICE_TYPE | varchar(64) | YES | | NULL | |
| DEVICE_NAME | varchar(64) | YES | | NULL | |
| NAME | varchar(256) | YES | | NULL | |
| VALUE | varchar(128) | YES | | NULL | |
+-------------+--------------+------+------+---------+-------+
```

字段解释:

* `TYPE`:对应于节点信息表 `information_schema.cluster_info` 中的 `TYPE` 字段,可取值为 `tidb`,`pd` 或 `tikv`。
* `INSTANCE`:对应于节点信息表 `information_schema.cluster_info` 中的 `STATUS_ADDRESS` 字段。
* `DEVICE_TYPE`:硬件类型,目前可以查询的硬件类型有 `cpu`、`memory`、`disk` 和 `net`。
* `DEVICE_NAME`:硬件名。对于不同的 `DEVICE_TYPE`,`DEVICE_NAME` 取值不同。
* `cpu`:硬件名为 cpu。
* `disk`:磁盘名。
* `net`:网卡名。
* `memory`:硬件名为 memory。
* `NAME`:不同的负载类型。例如 cpu 有 `load1`/`load5`/`load15` 三个负载类型,分别表示 cpu 在 `1min`/`5min`/`15min` 内的平均负载。
* `VALUE`:硬件负载的值,例如 cpu 在 `1min`/`5min`/`15min` 内的平均负载。

查询集群当前的 CPU 负载信息示例如下:

{{< copyable "sql" >}}

```sql
select * from cluster_load where device_type='cpu' and device_name='cpu';
```

```
+------+-----------------+-------------+-------------+--------+---------------+
| TYPE | INSTANCE | DEVICE_TYPE | DEVICE_NAME | NAME | VALUE |
+------+-----------------+-------------+-------------+--------+---------------+
| tidb | 127.0.0.1:10080 | cpu | cpu | load1 | 1.94 |
| tidb | 127.0.0.1:10080 | cpu | cpu | load5 | 2.16 |
| tidb | 127.0.0.1:10080 | cpu | cpu | load15 | 2.24 |
| pd | 127.0.0.1:2379 | cpu | cpu | load1 | 1.94 |
| pd | 127.0.0.1:2379 | cpu | cpu | load5 | 2.16 |
| pd | 127.0.0.1:2379 | cpu | cpu | load15 | 2.24 |
| tikv | 127.0.0.1:20160 | cpu | cpu | load1 | 1.94287109375 |
| tikv | 127.0.0.1:20160 | cpu | cpu | load5 | 2.15576171875 |
| tikv | 127.0.0.1:20160 | cpu | cpu | load15 | 2.2421875 |
+------+-----------------+-------------+-------------+--------+---------------+
```
Loading