Skip to content

Commit

Permalink
add sql statement about pump and drainer (#3324)
Browse files Browse the repository at this point in the history
  • Loading branch information
WangXiangUSTC authored May 26, 2020
1 parent 682d1b6 commit bca4998
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 0 deletions.
5 changes: 5 additions & 0 deletions TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
71 changes: 71 additions & 0 deletions sql-statements/sql-statement-change-drainer.md
Original file line number Diff line number Diff line change
@@ -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)
71 changes: 71 additions & 0 deletions sql-statements/sql-statement-change-pump.md
Original file line number Diff line number Diff line change
@@ -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)
38 changes: 38 additions & 0 deletions sql-statements/sql-statement-show-drainer-status.md
Original file line number Diff line number Diff line change
@@ -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)
37 changes: 37 additions & 0 deletions sql-statements/sql-statement-show-master-status.md
Original file line number Diff line number Diff line change
@@ -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)
38 changes: 38 additions & 0 deletions sql-statements/sql-statement-show-pump-status.md
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit bca4998

Please sign in to comment.