Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sql statement about pump and drainer #3324

Merged
merged 21 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
12b5051
add sql statement about pump and drainer
WangXiangUSTC May 25, 2020
6dd5eaf
minor update
WangXiangUSTC May 25, 2020
169e748
update toc
WangXiangUSTC May 25, 2020
c0d62a4
Merge branch 'docs-special-week' into xiang/tools_sql
WangXiangUSTC May 25, 2020
e33f41e
add show master status
WangXiangUSTC May 25, 2020
16a67f0
Merge branch 'xiang/tools_sql' of https://github.com/WangXiangUSTC/do…
WangXiangUSTC May 25, 2020
08db095
Merge branch 'docs-special-week' into xiang/tools_sql
WangXiangUSTC May 25, 2020
ae23638
merge and resolve conflicts
WangXiangUSTC May 26, 2020
b9a7197
Merge branch 'xiang/tools_sql' of https://github.com/WangXiangUSTC/do…
WangXiangUSTC May 26, 2020
336ae37
Merge branch 'docs-special-week' into xiang/tools_sql
WangXiangUSTC May 26, 2020
f977d2a
Apply suggestions from code review
WangXiangUSTC May 26, 2020
34bf3ec
add sql
WangXiangUSTC May 26, 2020
56665e7
Merge branch 'docs-special-week' into xiang/tools_sql
WangXiangUSTC May 26, 2020
c737fd4
Merge branch 'docs-special-week' into xiang/tools_sql
WangXiangUSTC May 26, 2020
b3cfa72
Update sql-statements/sql-statement-change-drainer.md
WangXiangUSTC May 26, 2020
1b4daca
Update sql-statements/sql-statement-change-pump.md
WangXiangUSTC May 26, 2020
c66c23f
Merge branch 'docs-special-week' into xiang/tools_sql
WangXiangUSTC May 26, 2020
ed5d8c4
Apply suggestions from code review
WangXiangUSTC May 26, 2020
bb3f2b6
Merge branch 'docs-special-week' into xiang/tools_sql
bb7133 May 26, 2020
e4334ea
Merge branch 'docs-special-week' into xiang/tools_sql
yikeke May 26, 2020
1aefe43
Merge branch 'docs-special-week' into xiang/tools_sql
sre-bot May 26, 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
5 changes: 5 additions & 0 deletions TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,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 @@ -304,6 +306,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 @@ -313,8 +316,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 @@
---
yikeke marked this conversation as resolved.
Show resolved Hide resolved
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 信息。
WangXiangUSTC marked this conversation as resolved.
Show resolved Hide resolved

## 示例

{{< 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 信息。
WangXiangUSTC marked this conversation as resolved.
Show resolved Hide resolved

## 另请参阅

* [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)