Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,19 @@ GreptimeDB 采用 Parquet 格式进行读写;Kafka 使用其专有的 RecordBa

并不需要在每个节点上同时部署所有服务。对于小型集群,可以单独使用 3 台节点运行 Metasrv,而 Frontend 和 Datanode 可以部署在其他等量节点上,每个容器运行两个进程。

更多部署建议请参考[容量规划文档](/user-guide/administration/capacity-plan)。
更多部署建议请参考[容量规划文档](/user-guide/administration/capacity-plan.md)。

### 最新版本的 Flow Engine(预计算功能)是否支持 PromQL 语法进行计算?

目前 Flow Engine 暂不支持 PromQL 语法计算。我们会对该需求进行评估,从理论上看似乎是可行的。

### Metasrv 是否会支持 MySQL 或 PostgreSQL 作为存储后端?

最新版本的 GreptimeDB 已支持 PostgreSQL 作为 Metasrv 的存储后端。具体信息请参考[这里](/user-guide/deployments/configuration#仅限于-metasrv-的配置)。
最新版本的 GreptimeDB 已支持 PostgreSQL 作为 Metasrv 的存储后端。具体信息请参考[这里](/user-guide/deployments/configuration.md#仅限于-metasrv-的配置)。

### 如何最佳地对成千上万台计算机中多个网卡的接口流量速率(每 30 秒取最大值)进行降采样,以便长期保存(如多年的数据)?

使用流表(Flow Table)是完成此任务的最佳工具。一个简单的流任务即可满足需求。流任务的输出会存储到普通表中,支持长期保存。请阅读 [Flow 指南](/user-guide/flow-computation/overview)。
使用流表(Flow Table)是完成此任务的最佳工具。一个简单的流任务即可满足需求。流任务的输出会存储到普通表中,支持长期保存。请阅读 [Flow 指南](/user-guide/flow-computation/overview.md)。

### GreptimeDB 是否支持动态的按天分区?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ GreptimeDB 采用 Parquet 格式进行读写;Kafka 使用其专有的 RecordBa

并不需要在每个节点上同时部署所有服务。对于小型集群,可以单独使用 3 台节点运行 Metasrv,而 Frontend 和 Datanode 可以部署在其他等量节点上,每个容器运行两个进程。

更多部署建议请参考[容量规划文档](/user-guide/administration/capacity-plan)。
更多部署建议请参考[容量规划文档](/user-guide/administration/capacity-plan.md)。

### 最新版本的 Flow Engine(预计算功能)是否支持 PromQL 语法进行计算?

目前 Flow Engine 暂不支持 PromQL 语法计算。我们会对该需求进行评估,从理论上看似乎是可行的。

### Metasrv 是否会支持 MySQL 或 PostgreSQL 作为存储后端?

最新版本的 GreptimeDB 已支持 PostgreSQL 作为 Metasrv 的存储后端。具体信息请参考[这里](/user-guide/deployments/configuration#仅限于-metasrv-的配置)。
最新版本的 GreptimeDB 已支持 PostgreSQL 作为 Metasrv 的存储后端。具体信息请参考[这里](/user-guide/deployments/configuration.md#仅限于-metasrv-的配置)。

### 如何最佳地对成千上万台计算机中多个网卡的接口流量速率(每 30 秒取最大值)进行降采样,以便长期保存(如多年的数据)?

Expand Down
218 changes: 218 additions & 0 deletions i18n/zh/docusaurus-plugin-content-docs/version-0.15.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
{
"sidebar.docs.doc.Overview": {
"message": "概述",
"description": "The ZH label for Overview"
},
"sidebar.docs.category.Getting Started": {
"message": "立即开始",
"description": "The label for category Getting Started in sidebar docs"
},
"sidebar.docs.category.Installation": {
"message": "安装",
"description": "The label for category Installation in sidebar docs"
},
"sidebar.docs.category.User Guide": {
"message": "用户指南",
"description": "The label for category User Guide in sidebar docs"
},
"sidebar.docs.category.Concepts": {
"message": "基础概念",
"description": "The label for category Concepts in sidebar docs"
},
"sidebar.docs.category.Migrate to GreptimeDB": {
"message": "迁移到 GreptimeDB",
"description": "The label for category Migrate to GreptimeDB in sidebar docs"
},
"sidebar.docs.category.Write Data": {
"message": "写入数据",
"description": "The label for category Write Data in sidebar docs"
},
"sidebar.docs.category.Query Data": {
"message": "查询数据",
"description": "The label for category Query Data in sidebar docs"
},
"sidebar.docs.category.Flow Computation": {
"message": "流计算",
"description": "The label for category Flow Computation in sidebar docs"
},
"sidebar.docs.category.Logs": {
"message": "日志",
"description": "The label for category Logs in sidebar docs"
},
"sidebar.docs.category.Client Libraries": {
"message": "客户端库",
"description": "The label for category Client Libraries in sidebar docs"
},
"sidebar.docs.category.Administration": {
"message": "运维管理",
"description": "The label for category Operations in sidebar docs"
},
"sidebar.docs.category.Authentication": {
"message": "鉴权",
"description": "The label for category Authentication in sidebar docs"
},
"sidebar.docs.category.Deployments & Administration": {
"message": "运维部署及管理",
"description": "The label for category Deployments & Administration in sidebar docs"
},
"sidebar.docs.category.Write-Ahead Logging (WAL)": {
"message": "预写日志(WAL)",
"description": "The label for category Write-Ahead Logging (WAL) in sidebar docs"
},
"sidebar.docs.category.Performance Tuning": {
"message": "性能调优",
"description": "The label for category Performance Tuning in sidebar docs"
},
"sidebar.docs.category.Deployments": {
"message": "部署",
"description": "The label for category Deployments in sidebar docs"
},
"sidebar.docs.category.Deploy on Kubernetes": {
"message": "部署到 Kubernetes",
"description": "The label for category Deploy on Kubernetes in sidebar docs"
},
"sidebar.docs.category.Manage GreptimeDB Operator": {
"message": "管理 GreptimeDB Operator",
"description": "The label for category Deploy on Kubernetes in sidebar docs"
},
"sidebar.docs.category.Disaster Recovery": {
"message": "灾难恢复",
"description": "The label for category Disaster Recovery in sidebar docs"
},
"sidebar.docs.category.Remote WAL": {
"message": "Remote WAL",
"description": "The label for category Remote WAL in sidebar docs"
},
"sidebar.docs.category.GreptimeCloud": {
"message": "GreptimeCloud",
"description": "The label for category GreptimeCloud in sidebar docs"
},
"sidebar.docs.category.Integrations": {
"message": "集成",
"description": "The label for category Integrations in sidebar docs"
},
"sidebar.docs.category.Prometheus": {
"message": "Prometheus",
"description": "The label for category Prometheus in sidebar docs"
},
"sidebar.docs.category.SDK Libraries": {
"message": "SDK Libraries",
"description": "The label for category SDK Libraries in sidebar docs"
},
"sidebar.docs.category.Migrate to GreptimeCloud": {
"message": "迁移到 GreptimeCloud",
"description": "The label for category Migrate to GreptimeCloud in sidebar docs"
},
"sidebar.docs.category.Usage & Billing": {
"message": "用量及费用",
"description": "The label for category Usage & Billing in sidebar docs"
},
"sidebar.docs.category.Tutorials": {
"message": "教程",
"description": "The label for category Tutorials in sidebar docs"
},
"sidebar.docs.category.Monitor Host Metrics": {
"message": "监控 Host Metrics",
"description": "The label for category Monitor Host Metrics in sidebar docs"
},
"sidebar.docs.category.GreptimeDB Enterprise": {
"message": "GreptimeDB 企业版",
"description": "The label for category GreptimeDB Enterprise in sidebar docs"
},
"sidebar.docs.category.Reference": {
"message": "Reference",
"description": "The label for category Reference in sidebar docs"
},
"sidebar.docs.category.GreptimeDB Command Line Interface": {
"message": "GreptimeDB 命令行工具",
"description": "The label for category GreptimeDB Command Line Interface in sidebar docs"
},
"sidebar.docs.category.Utilities": {
"message": "实用工具",
"description": "The label for category Utilities in sidebar docs"
},
"sidebar.docs.category.SQL": {
"message": "SQL",
"description": "The label for category SQL in sidebar docs"
},
"sidebar.docs.category.Functions": {
"message": "Functions",
"description": "The label for category Functions in sidebar docs"
},
"sidebar.docs.category.Information Schema": {
"message": "Information Schema",
"description": "The label for category Information Schema in sidebar docs"
},
"sidebar.docs.category.Contributor Guide": {
"message": "贡献者指南",
"description": "The label for category Contributor Guide in sidebar docs"
},
"sidebar.docs.category.Frontend": {
"message": "Frontend",
"description": "The label for category Frontend in sidebar docs"
},
"sidebar.docs.category.Datanode": {
"message": "Datanode",
"description": "The label for category Datanode in sidebar docs"
},
"sidebar.docs.category.Metasrv": {
"message": "Metasrv",
"description": "The label for category Metasrv in sidebar docs"
},
"sidebar.docs.category.Flownode": {
"message": "Flownode",
"description": "The label for category Flownode in sidebar docs"
},
"sidebar.docs.category.Tests": {
"message": "测试",
"description": "The label for category Tests in sidebar docs"
},
"sidebar.docs.category.How To": {
"message": "指南",
"description": "The label for category How To in sidebar docs"
},
"sidebar.docs.category.FAQ and Others": {
"message": "常见问题及其他",
"description": "The label for category FAQ and Others in sidebar docs"
},
"sidebar.docs.link.Release Notes": {
"message": "Release Notes",
"description": "The label for link Release Notes in sidebar docs, linking to /release-notes"
},
"sidebar.docs.category.Ingest Data": {
"message": "写入数据",
"description": "The label for category Ingest Data in sidebar docs"
},
"sidebar.docs.category.For observability": {
"message": "可观测场景",
"description": "The label for category For observability in sidebar docs"
},
"sidebar.docs.category.For IoT": {
"message": "物联网(IoT)场景",
"description": "The label for category For IoT in sidebar docs"
},
"sidebar.docs.category.gRPC SDKs": {
"message": "gRPC SDKs",
"description": "The label for category gRPC SDKs in sidebar docs"
},
"sidebar.docs.category.Manage Data": {
"message": "管理数据",
"description": "The label for category Manage Data in sidebar docs"
},
"sidebar.docs.category.Manage Metadata": {
"message": "管理元数据",
"description": "The label for category Manage Metadata in sidebar docs"
},
"sidebar.docs.category.Protocols": {
"message": "协议",
"description": "The label for category Manage Data in sidebar docs"
},
"sidebar.docs.category.Monitoring": {
"message": "监控",
"description": "The label for category Monitoring in sidebar docs"
},
"sidebar.docs.category.Vector Storage": {
"message": "向量存储",
"description": "The label for category Vector Storage in sidebar docs"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
keywords: [数据持久化, 索引机制, SST 文件, 倒排索引]
description: 介绍了 GreptimeDB 的数据持久化和索引机制,包括 SST 文件格式、数据持久化过程和倒排索引的实现。
---

# 数据持久化与索引

与所有类似 LSMT 的存储引擎一样,MemTables 中的数据被持久化到耐久性存储,例如本地磁盘文件系统或对象存储服务。GreptimeDB 采用 [Apache Parquet][1] 作为其持久文件格式。

## SST 文件格式

Parquet 是一种提供快速数据查询的开源列式存储格式,已经被许多项目采用,例如 Delta Lake。

Parquet 具有层次结构,类似于“行组 - 列-数据页”。Parquet 文件中的数据被水平分区为行组(row group),在其中相同列的所有值一起存储以形成数据页(data pages)。数据页是最小的存储单元。这种结构极大地提高了性能。

首先,数据按列聚集,这使得文件扫描更加高效,特别是当查询只涉及少数列时,这在分析系统中非常常见。

其次,相同列的数据往往是同质的(比如具备近似的值),这有助于在采用字典和 Run-Length Encoding(RLE)等技术进行压缩。

<img src="/parquet-file-format.png" alt="Parquet file format" width="500"/>

## 数据持久化

GreptimeDB 提供了 `storage.flush.global_write_buffer_size` 的配置项来设置全局的 Memtable 大小阈值。当数据库所有 MemTable 中的数据量之和达到阈值时将自动触发持久化操作,将 MemTable 的数据 flush 到 SST 文件中。


## SST 文件中的索引数据

Apache Parquet 文件格式在列块和数据页的头部提供了内置的统计信息,用于剪枝和跳过。

<img src="/column-chunk-header.png" alt="Column chunk header" width="350"/>

例如,在上述 Parquet 文件中,如果你想要过滤 `name` 等于 `Emily` 的行,你可以轻松跳过行组 0,因为 `name` 字段的最大值是 `Charlie`。这些统计信息减少了 IO 操作。


## 索引文件

对于每个 SST 文件,GreptimeDB 不但维护 SST 文件内部索引,还会单独生成一个文件用于存储针对该 SST 文件的索引结构。

索引文件采用 [Puffin][3] 格式,这种格式具有较大的灵活性,能够存储更多的元数据,并支持更多的索引结构。

![Puffin](/puffin.png)

目前,倒排索引是 GreptimeDB 第一个支持的单独索引结构,以 Blob 的形式存储在索引文件中。


## 倒排索引

在 v0.7 版本中,GreptimeDB 引入了倒排索引(Inverted Index)来加速查询。

倒排索引是一种常见的用于全文搜索的索引结构,它将文档中的每个单词映射到包含该单词的文档列表,GreptimeDB 把这项源自于搜索引擎的技术应用到了时间序列数据库中。

搜索引擎和时间序列数据库虽然运行在不同的领域,但是应用的倒排索引技术背后的原理是相似的。这种相似性需要一些概念上的调整:
1. 单词:在 GreptimeDB 中,指时间线的列值。
2. 文档:在 GreptimeDB 中,指包含多个时间线的数据段。

倒排索引的引入,使得 GreptimeDB 可以跳过不符合查询条件的数据段,从而提高扫描效率。

![Inverted index searching](/inverted-index-searching.png)

例如,上述查询使用倒排索引来定位数据段,数据段满足条件:`job` 等于 `apiserver`,`handler` 符合正则匹配 `.*users` 及 `status` 符合正则匹配 `4..`,然后扫描这些数据段以产生满足所有条件的最终结果,从而显着减少 IO 操作的次数。

### 倒排索引格式

![Inverted index format](/inverted-index-format.png)

GreptimeDB 按列构建倒排索引,每个倒排索引包含一个 FST 和多个 Bitmap。

FST(Finite State Transducer)允许 GreptimeDB 以紧凑的格式存储列值到 Bitmap 位置的映射,并且提供了优秀的搜索性能和支持复杂搜索(例如正则表达式匹配);Bitmap 则维护了数据段 ID 列表,每个位表示一个数据段。


### 索引数据段

GreptimeDB 把一个 SST 文件分割成多个索引数据段,每个数据段包含相同行数的数据。这种分段的目的是通过只扫描符合查询条件的数据段来优化查询性能。

例如,当数据段的行数为 1024,如果查询条件应用倒排索引后,得到的数据段列表为 `[0, 2]`,那么只需扫描 SST 文件中的第 0 和第 2 个数据段(即第 0 行到第 1023 行和第 2048 行到第 3071 行)即可。

数据段的行数由引擎选项 `index.inverted_index.segment_row_count` 控制,默认为 `1024`。较小的值意味着更精确的索引,往往会得到更好的查询性能,但会增加索引存储成本。通过调整该选项,可以在存储成本和查询性能之间进行权衡。


## 统一数据访问层:OpenDAL

GreptimeDB 使用 [OpenDAL][2] 提供统一的数据访问层,因此,存储引擎无需与不同的存储 API 交互,数据可以无缝迁移到基于云的存储,如 AWS S3。

[1]: https://parquet.apache.org
[2]: https://github.com/datafuselabs/opendal
[3]: https://iceberg.apache.org/puffin-spec
Loading