Skip to content

Commit

Permalink
feat: adds admin functions and doc to zh folder
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed May 18, 2024
1 parent e03454d commit a89ac02
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
1 change: 0 additions & 1 deletion docs/nightly/en/reference/sql/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ select compact_table("test");
```



## Time and Date

### `date_trunc`
Expand Down
17 changes: 17 additions & 0 deletions docs/nightly/en/user-guide/operations/region-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,20 @@ select migrate_region(region_id, from_peer_id, to_peer_id, replay_timeout);
| `from_peer_id` | The peer id of the migration source(Datanode). | **Required** | |
| `to_peer_id` | The peer id of the migration destination(Datanode). | **Required** | |
| `replay_timeout` | The timeout(secs) of replay data. If the new Region fails to replay the data within the specified timeout, the migration will fail, however the data in the old Region will not be lost. | Optional | |

## Query the migration state

The `migrate_region` function returns the procedure id that executes the migration, queries the procedure state by it:

```sql
select procedure_state('538b7476-9f79-4e50-aa9c-b1de90710839')
```

If it's done, outputs the state in JSON:

```json
{"status":"Done"}
```

Of course, you can confirm the region distribution by querying from `region_peers` and `partitions` in `information_schema`.

20 changes: 20 additions & 0 deletions docs/nightly/zh/reference/sql/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ arrow_cast(expression, datatype)

请参考 [API 文档](https://greptimedb.rs/script/python/rspython/builtins/greptime_builtin/index.html#functions)

### 管理函数

GreptimeDB 提供了一些管理函数来管理数据库和数据:

* `flush_table(table_name)` 通过表名将表的内存表刷写到 SST 文件。
* `flush_region(region_id)` 通过 Region Id 将 Region 的内存表刷写到 SST 文件。可以通过 [REGION_PEERS](./information-schema/region-peers.md) 表查找 Region Id。
* `compact_table(table_name)` 通过表名为表发起compaction 任务。
* `compact_region(region_id)` 通过 Region Id 为 Region 发起 compaction 任务。
* `migrate_region(region_id, from_peer, to_peer, [timeout])` 在 Datanode 之间迁移 Region,请阅读 [ Region迁移](/user-guide/operations/region-migration)
* `procedure_state(procedure_id)` 通过 Procedure Id 查询 Procedure 状态。

例如:
```sql
-- 刷新表 test --
select flush_table("test");

-- 为表 test 启动一个 compaction 任务 --
select compact_table("test");
```

## Time and Date

### `date_trunc`
Expand Down
16 changes: 16 additions & 0 deletions docs/nightly/zh/user-guide/operations/region-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,19 @@ select migrate_region(region_id, from_peer_id, to_peer_id, replay_timeout);
| `from_peer_id` | 迁移起始节点(Datanode) 的 peer id。 | **Required** | |
| `to_peer_id` | 迁移目标节点(Datanode) 的 peer id。 | **Required** | |
| `replay_timeout` | 迁移时回放数据的超时时间(单位:秒)。如果新 Region 未能在指定时间内回放数据,迁移将失败,旧 Region 中的数据不会丢失。 | Optional | |

## 查询迁移状态

`migrate_region` 函数将返回执行迁移的 Procedure Id,可以通过它查询过程状态:

```sql
select procedure_state('538b7476-9f79-4e50-aa9c-b1de90710839')
```

如果顺利完成,将输出 JSON 格式的状态:

```json
{"status":"Done"}
```

当然,最终可以通过从 `information_schema` 中查询 `region_peers``partitions` 来确认 Region 分布是否符合预期。

0 comments on commit a89ac02

Please sign in to comment.