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 49f6897
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 3 deletions.
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
4 changes: 2 additions & 2 deletions docs/nightly/en/summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@
- api
- cluster
- Operations:
# - overview
- admin
- configuration
- back-up-&-restore-data
- kubernetes
- gtctl
- run-on-android
Expand All @@ -81,7 +82,6 @@
# - alert
# - import-data
# - export-data
# - back-up-&-restore-data
# - capacity-planning
- upgrade
- GreptimeCloud:
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
2 changes: 2 additions & 0 deletions docs/nightly/zh/summary-i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ Frontend: Frontend
Datanode: Datanode
Metasrv: Metasrv
Reference: Reference
Admin: 管理
back-up-&-restore-data: 备份和恢复
SDK: SDK
SQL: SQL
30 changes: 30 additions & 0 deletions docs/nightly/zh/user-guide/operations/admin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 管理

本文件介绍了在 GreptimeDB 系统运维和部署中使用的策略和实践。

## 数据库/集群管理

* GreptimeDB 的 [安装](/getting-started/installation/overview.md)[g-t-control](./gtctl.md) 命令行工具。
* 数据库配置,请阅读 [配置](./configuration.md) 参考。
* GreptimeDB 的 [监控](./monitoring.md)[链路追踪](./tracing.md)
* GreptimeDB 的 [备份与恢复方法](./back-up-\&-restore-data.md)

### 运行时信息

* 通过 [CLUSTER_INFO](/reference/sql/information-schema/cluster-info.md) 表查找集群的拓扑信息。
* 通过 [REGION_PEERS](/reference/sql/information-schema/region-peers.md) 表查找表的 Region 分布。

`INFORMATION_SCHEMA` 提供了对系统元数据的访问,如数据库或表的名称、列的数据类型等。请阅读 [参考文档](/reference/sql/information-schema/overview.md)

## 数据管理

* [存储位置说明](/user-guide/concepts/storage-location.md)
* 通过 [设置Remote WAL](./remote-wal/quick-start.md) 实现 GreptimeDB 的集群容灾。
* [Table 和 Region 的 Flush 和 Compaction](/reference/sql/functions#admin-functions)
* 通过 Region 对表进行分区,请阅读 [表的分片](./contributor-guide/frontend/table-sharding.md) 参考。
* [迁移 Region](./region-migration.md) 以实现负载均衡。
* [通过设置 TTL 过期数据](/user-guide/concepts/features-that-you-concern#can-i-set-ttl-or-retention-policy-for-different-tables-or-measurements)

## 最佳实践

TODO
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 49f6897

Please sign in to comment.