From bca49982211e3bc304e46051046f8e1bb0012821 Mon Sep 17 00:00:00 2001 From: WangXiangUSTC Date: Tue, 26 May 2020 16:38:02 +0800 Subject: [PATCH] add sql statement about pump and drainer (#3324) --- TOC.md | 5 ++ .../sql-statement-change-drainer.md | 71 +++++++++++++++++++ sql-statements/sql-statement-change-pump.md | 71 +++++++++++++++++++ .../sql-statement-show-drainer-status.md | 38 ++++++++++ .../sql-statement-show-master-status.md | 37 ++++++++++ .../sql-statement-show-pump-status.md | 38 ++++++++++ 6 files changed, 260 insertions(+) create mode 100644 sql-statements/sql-statement-change-drainer.md create mode 100644 sql-statements/sql-statement-change-pump.md create mode 100644 sql-statements/sql-statement-show-drainer-status.md create mode 100644 sql-statements/sql-statement-show-master-status.md create mode 100644 sql-statements/sql-statement-show-pump-status.md diff --git a/TOC.md b/TOC.md index c29ccf3c4739..7d01050e3683 100644 --- a/TOC.md +++ b/TOC.md @@ -247,6 +247,8 @@ - [`ANALYZE TABLE`](/sql-statements/sql-statement-analyze-table.md) - [`BEGIN`](/sql-statements/sql-statement-begin.md) - [`COMMIT`](/sql-statements/sql-statement-commit.md) + - [`CHANGE DRAINER`](/sql-statements/sql-statement-change-drainer.md) + - [`CHANGE PUMP`](/sql-statements/sql-statement-change-pump.md) - [`CREATE BINDING`](/sql-statements/sql-statement-create-binding.md) - [`CREATE DATABASE`](/sql-statements/sql-statement-create-database.md) - [`CREATE INDEX`](/sql-statements/sql-statement-create-index.md) @@ -303,6 +305,7 @@ - [`SHOW CREATE TABLE`](/sql-statements/sql-statement-show-create-table.md) - [`SHOW CREATE USER`](/sql-statements/sql-statement-show-create-user.md) - [`SHOW DATABASES`](/sql-statements/sql-statement-show-databases.md) + - [`SHOW DRAINER STATUS`](/sql-statements/sql-statement-show-drainer-status.md) - [`SHOW ENGINES`](/sql-statements/sql-statement-show-engines.md) - [`SHOW ERRORS`](/sql-statements/sql-statement-show-errors.md) - [`SHOW [FULL] FIELDS FROM`](/sql-statements/sql-statement-show-fields-from.md) @@ -312,8 +315,10 @@ - [`SHOW INDEXES [FROM|IN]`](/sql-statements/sql-statement-show-indexes.md) - [`SHOW INDEX [FROM|IN]`](/sql-statements/sql-statement-show-index.md) - [`SHOW KEYS [FROM|IN]`](/sql-statements/sql-statement-show-keys.md) + - [`SHOW MASTER STATUS`](/sql-statements/sql-statement-show-master-status.md) - [`SHOW PRIVILEGES`](/sql-statements/sql-statement-show-privileges.md) - [`SHOW [FULL] PROCESSSLIST`](/sql-statements/sql-statement-show-processlist.md) + - [`SHOW PUMP STATUS`](/sql-statements/sql-statement-show-pump-status.md) - [`SHOW SCHEMAS`](/sql-statements/sql-statement-show-schemas.md) - [`SHOW [FULL] TABLES`](/sql-statements/sql-statement-show-tables.md) - [`SHOW TABLE REGIONS`](/sql-statements/sql-statement-show-table-regions.md) diff --git a/sql-statements/sql-statement-change-drainer.md b/sql-statements/sql-statement-change-drainer.md new file mode 100644 index 000000000000..d6c0c0615291 --- /dev/null +++ b/sql-statements/sql-statement-change-drainer.md @@ -0,0 +1,71 @@ +--- +title: CHANGE DRAINER +summary: TiDB 数据库中 CHANGE DRAINER 的使用概况。 +category: reference +--- + +# CHANGE DRAINER + +`CHANGE DRAINER` 语句用于修改集群中 Drainer 的状态信息。 + +> **注意:** +> +> Drainer 在正常运行时会自动上报状态到 PD,仅在 Drainer 处于异常情况导致实际状态与 PD 中保存的状态信息不一致时,使用该语句修改 PD 中存储的 Drainer 状态信息。 + +## 示例 + +{{< copyable "sql" >}} + +```sql +SHOW DRAINER STATUS; +``` + +```sql ++----------|----------------|--------|--------------------|---------------------| +| NodeID | Address | State | Max_Commit_Ts | Update_Time | ++----------|----------------|--------|--------------------|---------------------| +| drainer1 | 127.0.0.3:8249 | Online | 408553768673342532 | 2019-04-30 00:00:03 | ++----------|----------------|--------|--------------------|---------------------| +| drainer2 | 127.0.0.4:8249 | Online | 408553768673345531 | 2019-05-01 00:00:04 | ++----------|----------------|--------|--------------------|---------------------| +2 rows in set (0.00 sec) +``` + +可以看出 `drainer1` 已经超过一天没有更新状态,该 Drainer 处于异常状态,但是 State 仍然为 `Online`,使用 `CHANGE DRAINER` 将该 Drainer 状态修改为 `paused`: + +{{< copyable "sql" >}} + +```sql +CHANGE DRAINER TO NODE_STATE ='paused' FOR NODE_ID 'drainer1'; +``` + +```sql +Query OK, 0 rows affected (0.01 sec) +``` + +{{< copyable "sql" >}} + +```sql +SHOW DRAINER STATUS; +``` + +```sql ++----------|----------------|--------|--------------------|---------------------| +| NodeID | Address | State | Max_Commit_Ts | Update_Time | ++----------|----------------|--------|--------------------|---------------------| +| drainer1 | 127.0.0.3:8249 | Paused | 408553768673342532 | 2019-04-30 00:00:03 | ++----------|----------------|--------|--------------------|---------------------| +| drainer2 | 127.0.0.4:8249 | Online | 408553768673345531 | 2019-05-01 00:00:04 | ++----------|----------------|--------|--------------------|---------------------| +2 rows in set (0.00 sec) +``` + +## MySQL 兼容性 + +MySQL 无此功能。 + +## 另请参阅 + +* [SHOW PUMP STATUS](/sql-statements/sql-statement-show-pump-status.md) +* [SHOW DRAINER STATUS](/sql-statements/sql-statement-show-drainer-status.md) +* [CHANGE PUMP STATUS](/sql-statements/sql-statement-change-pump.md) diff --git a/sql-statements/sql-statement-change-pump.md b/sql-statements/sql-statement-change-pump.md new file mode 100644 index 000000000000..16a54160bfc3 --- /dev/null +++ b/sql-statements/sql-statement-change-pump.md @@ -0,0 +1,71 @@ +--- +title: CHANGE PUMP +summary: TiDB 数据库中 CHANGE PUMP 的使用概况。 +category: reference +--- + +# CHANGE PUMP + +`CHANGE PUMP` 语句用于修改集群中 Pump 的状态信息。 + +> **注意:** +> +> Pump 在正常运行时会自动上报状态到 PD,仅在 Pump 处于异常情况导致实际状态与 PD 中保存的状态信息不一致时,使用该语句修改 PD 中存储的 Pump 状态信息。 + +## 示例 + +{{< copyable "sql" >}} + +```sql +SHOW PUMP STATUS; +``` + +```sql ++--------|----------------|--------|--------------------|---------------------| +| NodeID | Address | State | Max_Commit_Ts | Update_Time | ++--------|----------------|--------|--------------------|---------------------| +| pump1 | 127.0.0.1:8250 | Online | 408553768673342237 | 2019-04-30 00:00:01 | ++--------|----------------|--------|--------------------|---------------------| +| pump2 | 127.0.0.2:8250 | Online | 408553768673342335 | 2019-05-01 00:00:02 | ++--------|----------------|--------|--------------------|---------------------| +2 rows in set (0.00 sec) +``` + +可以看出 `pump1` 已经超过一天没有更新状态,该 Pump 处于异常状态,但是 State 仍然为 `Online`,使用 `CHANGE PUMP` 将该 Pump 状态修改为 `paused`: + +{{< copyable "sql" >}} + +```sql +CHANGE PUMP TO NODE_STATE ='paused' FOR NODE_ID 'pump1'; +``` + +```sql +Query OK, 0 rows affected (0.01 sec) +``` + +{{< copyable "sql" >}} + +```sql +SHOW PUMP STATUS; +``` + +```sql ++--------|----------------|--------|--------------------|---------------------| +| NodeID | Address | State | Max_Commit_Ts | Update_Time | ++--------|----------------|--------|--------------------|---------------------| +| pump1 | 127.0.0.1:8250 | Paused | 408553768673342237 | 2019-04-30 00:00:01 | ++--------|----------------|--------|--------------------|---------------------| +| pump2 | 127.0.0.2:8250 | Online | 408553768673342335 | 2019-05-01 00:00:02 | ++--------|----------------|--------|--------------------|---------------------| +2 rows in set (0.00 sec) +``` + +## MySQL 兼容性 + +MySQL 无此功能。 + +## 另请参阅 + +* [SHOW PUMP STATUS](/sql-statements/sql-statement-show-pump-status.md) +* [SHOW DRAINER STATUS](/sql-statements/sql-statement-show-drainer-status.md) +* [CHANGE DRAINER STATUS](/sql-statements/sql-statement-change-drainer.md) diff --git a/sql-statements/sql-statement-show-drainer-status.md b/sql-statements/sql-statement-show-drainer-status.md new file mode 100644 index 000000000000..86e2dcb15681 --- /dev/null +++ b/sql-statements/sql-statement-show-drainer-status.md @@ -0,0 +1,38 @@ +--- +title: SHOW DRAINER STATUS +summary: TiDB 数据库中 SHOW DRAINER STATUS 的使用概况。 +category: reference +--- + +# SHOW DRAINER STATUS + +`SHOW DRAINER STATUS` 语句用于显示集群中所有 Drainer 的状态信息。 + +## 示例 + +{{< copyable "sql" >}} + +```sql +SHOW DRAINER STATUS; +``` + +```sql ++----------|----------------|--------|--------------------|---------------------| +| NodeID | Address | State | Max_Commit_Ts | Update_Time | ++----------|----------------|--------|--------------------|---------------------| +| drainer1 | 127.0.0.3:8249 | Online | 408553768673342532 | 2019-05-01 00:00:03 | ++----------|----------------|--------|--------------------|---------------------| +| drainer2 | 127.0.0.4:8249 | Online | 408553768673345531 | 2019-05-01 00:00:04 | ++----------|----------------|--------|--------------------|---------------------| +2 rows in set (0.00 sec) +``` + +## MySQL 兼容性 + +MySQL 无此功能。 + +## 另请参阅 + +* [SHOW PUMP STATUS](/sql-statements/sql-statement-show-pump-status.md) +* [CHANGE PUMP STATUS](/sql-statements/sql-statement-change-pump.md) +* [CHANGE DRAINER STATUS](/sql-statements/sql-statement-change-drainer.md) diff --git a/sql-statements/sql-statement-show-master-status.md b/sql-statements/sql-statement-show-master-status.md new file mode 100644 index 000000000000..2e33d0b3da4a --- /dev/null +++ b/sql-statements/sql-statement-show-master-status.md @@ -0,0 +1,37 @@ +--- +title: SHOW MASTER STATUS +summary: TiDB 数据库中 SHOW MASTER STATUS 的使用概况。 +category: reference +--- + +# SHOW MASTER STATUS + +`SHOW MASTER STATUS` 语句用于显示集群当前最新的 TSO 信息。 + +## 示例 + +{{< copyable "sql" >}} + +```sql +SHOW MASTER STATUS; +``` + +```sql ++-------------+--------------------+--------------+------------------+-------------------+ +| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | ++-------------+--------------------+--------------+------------------+-------------------+ +| tidb-binlog | 416916363252072450 | | | | ++-------------+--------------------+--------------+------------------+-------------------+ +1 row in set (0.00 sec) +``` + +## MySQL 兼容性 + +`SHOW MASTER STATUS` 语句与 MySQL 兼容,但是执行结果有差异,在 MySQL 中执行结果为 binlog 的位置信息,而在 TiDB 中为最新的 TSO 信息。 + +## 另请参阅 + +* [SHOW PUMP STATUS](/sql-statements/sql-statement-show-pump-status.md) +* [SHOW DRAINER STATUS](/sql-statements/sql-statement-show-drainer-status.md) +* [CHANGE PUMP STATUS](/sql-statements/sql-statement-change-pump.md) +* [CHANGE DRAINER STATUS](/sql-statements/sql-statement-change-drainer.md) diff --git a/sql-statements/sql-statement-show-pump-status.md b/sql-statements/sql-statement-show-pump-status.md new file mode 100644 index 000000000000..fb99c7a663eb --- /dev/null +++ b/sql-statements/sql-statement-show-pump-status.md @@ -0,0 +1,38 @@ +--- +title: SHOW PUMP STATUS +summary: TiDB 数据库中 SHOW PUMP STATUS 的使用概况。 +category: reference +--- + +# SHOW PUMP STATUS + +`SHOW PUMP STATUS` 语句用于显示集群中所有 Pump 的状态信息。 + +## 示例 + +{{< copyable "sql" >}} + +```sql +SHOW PUMP STATUS; +``` + +```sql ++--------|----------------|--------|--------------------|---------------------| +| NodeID | Address | State | Max_Commit_Ts | Update_Time | ++--------|----------------|--------|--------------------|---------------------| +| pump1 | 127.0.0.1:8250 | Online | 408553768673342237 | 2019-05-01 00:00:01 | ++--------|----------------|--------|--------------------|---------------------| +| pump2 | 127.0.0.2:8250 | Online | 408553768673342335 | 2019-05-01 00:00:02 | ++--------|----------------|--------|--------------------|---------------------| +2 rows in set (0.00 sec) +``` + +## MySQL 兼容性 + +MySQL 无此功能。 + +## 另请参阅 + +* [SHOW DRAINER STATUS](/sql-statements/sql-statement-show-drainer-status.md) +* [CHANGE PUMP STATUS](/sql-statements/sql-statement-change-pump.md) +* [CHANGE DRAINER STATUS](/sql-statements/sql-statement-change-drainer.md)