diff --git a/docs/getting-started/installation/greptimedb-standalone.md b/docs/getting-started/installation/greptimedb-standalone.md index f0cdb8cb9..85bd8f18c 100644 --- a/docs/getting-started/installation/greptimedb-standalone.md +++ b/docs/getting-started/installation/greptimedb-standalone.md @@ -68,7 +68,7 @@ You can: 1. Set `--security-opt seccomp=unconfined`, for example: - ```shell + ```shell docker run --security-opt seccomp=unconfined -p 4000-4003:4000-4003 \ -v "$(pwd)/greptimedb:/tmp/greptimedb" \ --name greptime --rm \ @@ -77,7 +77,7 @@ You can: --rpc-addr 0.0.0.0:4001 \ --mysql-addr 0.0.0.0:4002 \ --postgres-addr 0.0.0.0:4003 - ``` + ``` 2. Upgrade the Docker version to v23.0.0 or higher; ::: diff --git a/docs/greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb.md b/docs/greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb.md index 4004ef7cc..3d5d65d31 100644 --- a/docs/greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb.md +++ b/docs/greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb.md @@ -16,7 +16,7 @@ You can find the GreptimeDB URL, database name, as well as the username and pass - ```shell +```shell curl -X POST 'https:///v1/influxdb/api/v2/write?bucket=' \ -H 'authorization: token ' \ -d 'census,location=klamath,scientist=anderson bees=23 1566086400000000000' @@ -26,7 +26,7 @@ curl -X POST 'https:///v1/influxdb/api/v2/write?bucket=' \ - ```shell +```shell curl 'https:///v1/influxdb/write?db=&u=&p=' \ -d 'census,location=klamath,scientist=anderson bees=23 1566086400000000000' ``` @@ -44,7 +44,7 @@ curl 'https:///v1/influxdb/write?db=&u=&p= - ```toml +```toml [[outputs.influxdb_v2]] urls = ["https:///v1/influxdb"] token = ":" @@ -57,7 +57,7 @@ curl 'https:///v1/influxdb/write?db=&u=&p= - ```toml +```toml [[outputs.influxdb]] urls = ["https:///v1/influxdb"] database = "" @@ -77,7 +77,7 @@ curl 'https:///v1/influxdb/write?db=&u=&p= - ```js +```js 'use strict' /** @module write **/ diff --git a/docs/reference/sql/cast.md b/docs/reference/sql/cast.md index 6e9b33d0f..357d1918b 100644 --- a/docs/reference/sql/cast.md +++ b/docs/reference/sql/cast.md @@ -17,9 +17,9 @@ CAST (expression AS data_type) Convert a string to an integer: - ```sql +```sql SELECT CAST('123' AS INT) ; - ``` +``` ```sql +-------------+ diff --git a/docs/user-guide/cluster.md b/docs/user-guide/cluster.md index c46924e05..95acd6d0d 100644 --- a/docs/user-guide/cluster.md +++ b/docs/user-guide/cluster.md @@ -12,13 +12,13 @@ You can follow the steps to use SQL to play with distributed insertions and quer 1. Use MySQL cli to connect to Frontend. - ```shell + ```shell mysql -h 127.0.0.1 -P 4002 - ``` + ``` 2. Create a distributed table via `CREATE` statement. - ```SQL + ```SQL CREATE TABLE dist_table( ts TIMESTAMP DEFAULT current_timestamp(), n INT, @@ -32,11 +32,11 @@ You can follow the steps to use SQL to play with distributed insertions and quer n >= 9 ) engine=mito; - ``` + ``` The result looks like the following: - ```shell + ```shell mysql> CREATE TABLE dist_table( -> ts TIMESTAMP DEFAULT current_timestamp(), -> n INT, @@ -51,13 +51,13 @@ You can follow the steps to use SQL to play with distributed insertions and quer -> ) -> engine=mito; Query OK, 3 rows affected (0.09 sec) - ``` + ``` The `dist_table` is distributed among the `Datanode`s. You can refer to ["Table Sharding"](/contributor-guide/frontend/table-sharding.md) for more details. 3. Insert some data via `INSERT` statement. - ```SQL + ```SQL INSERT INTO dist_table(n, row_id) VALUES (1, 1); INSERT INTO dist_table(n, row_id) VALUES (2, 2); INSERT INTO dist_table(n, row_id) VALUES (3, 3); @@ -70,15 +70,15 @@ You can follow the steps to use SQL to play with distributed insertions and quer INSERT INTO dist_table(n, row_id) VALUES (10, 10); INSERT INTO dist_table(n, row_id) VALUES (11, 11); INSERT INTO dist_table(n, row_id) VALUES (12, 12); - ``` + ``` 4. Execute some queries via `SELECT` statement: - ```sql + ```sql SELECT * FROM dist_table ORDER BY n LIMIT 5; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ @@ -89,39 +89,39 @@ You can follow the steps to use SQL to play with distributed insertions and quer | 2022-11-14 12:02:32 | 5 | 5 | +---------------------+------+--------+ 5 rows in set (0.081 sec) - ``` + ``` - ```sql + ```sql SELECT MAX(n) FROM dist_table; - ``` + ``` - ```sql + ```sql +-------------------+ | MAX(dist_table.n) | +-------------------+ | 12 | +-------------------+ 1 row in set (0.057 sec) - ``` + ``` - ```sql + ```sql SELECT MIN(n) FROM dist_table; - ``` + ``` - ```sql + ```sql +-------------------+ | MIN(dist_table.n) | +-------------------+ | 1 | +-------------------+ 1 row in set (0.079 sec) - ``` + ``` - ```sql + ```sql SELECT * FROM dist_table WHERE n > 2 AND n < 10 ORDER BY row_id; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ @@ -134,17 +134,17 @@ You can follow the steps to use SQL to play with distributed insertions and quer | 2022-11-14 12:02:32 | 9 | 9 | +---------------------+------+--------+ 7 rows in set (0.02 sec) - ``` + ``` - ```sql + ```sql SELECT * FROM dist_table WHERE row_id = 10; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ | 2022-11-14 12:02:32 | 10 | 10 | +---------------------+------+--------+ 1 row in set (0.03 sec) - ``` + ``` diff --git a/docs/user-guide/ingest-data/for-iot/grpc-sdks/template.md b/docs/user-guide/ingest-data/for-iot/grpc-sdks/template.md index 2829d85eb..e8d6069f6 100644 --- a/docs/user-guide/ingest-data/for-iot/grpc-sdks/template.md +++ b/docs/user-guide/ingest-data/for-iot/grpc-sdks/template.md @@ -94,4 +94,35 @@ Streaming insert is useful when you want to insert a large amount of data such a + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/db-cloud-shared/clients/grafana-integration.md b/i18n/zh/docusaurus-plugin-content-docs/current/db-cloud-shared/clients/grafana-integration.md deleted file mode 100644 index 726fd44f6..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/db-cloud-shared/clients/grafana-integration.md +++ /dev/null @@ -1,68 +0,0 @@ - -GreptimeDB 服务可以配置为 [Grafana 数据源](https://grafana.com/docs/grafana/latest/datasources/add-a-data-source/)。 -你可以选择使用以下三个数据源之一连接 GreptimeDB 与 Grafana:GreptimeDB、Prometheus 或 MySQL。 - -## GreptimeDB 数据源插件 - -{props.children.filter(c => c.props.id == 'data-source-plugin-intro')} - -{props.children.filter(c => c.props.id == 'data-source-plugin-installation')} - -{props.children.filter(c => c.props.id == 'preview-greptimedb-using-docker')} - -{props.children.filter(c => c.props.id == 'connection-settings-title')} - -在 Grafana 中单击 Add data source 按钮,选择 GreptimeDB 作为类型。 - -{props.children.filter(c => c.props.id == 'grafana-add-greptimedb-data-source-img')} - -在 GreptimeDB server URL 中填写以下地址: - -{props.children.filter(c => c.props.id == 'greptime-data-source-connection-url')} - -接下来做如下配置: - -- Database Name:填写数据库名称 ``,留空则使用默认数据库 `public` -- 在 Auth 部分中单击 basic auth,并在 Basic Auth Details 中填写 GreptimeDB 的用户名和密码。未设置可留空: - - - User: `` - - Password: `` - -然后单击 Save & Test 按钮以测试连接。 - -{props.children.filter(c => c.props.id == 'create-a-dashboard')} - -## Prometheus 数据源 - -单击 Add data source 按钮,然后选择 Prometheus 作为类型。 - -在 HTTP 中填写 Prometheus server URL - -{props.children.filter(c => c.props.id == 'prometheus-server-url')} - -在 Auth 部分中单击 basic auth,并在 Basic Auth Details 中填写 GreptimeDB 的用户名和密码: - -- User: `` -- Password: `` - -在 Custom HTTP Headers 部分中点击 Add header: - -- Header: `x-greptime-db-name` -- Value: `` - -然后单击 Save & Test 按钮以测试连接。 - -## MySQL 数据源 - -单击 Add data source 按钮,然后选择 MySQL 作为类型。在 MySQL Connection 中填写以下信息: - -- Host: `:4002` -- Database: `` -- User: `` -- Password: `` -- Session timezone: `UTC` - -然后单击 Save & Test 按钮以测试连接。 - -注意目前我们只能使用 SQL 创建 Grafana Panel。由于时间戳数据类型的区别,Grafana -的 SQL Builder 暂时无法选择时间戳字段。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/installation/greptimedb-standalone.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/installation/greptimedb-standalone.md index ae770069c..ba92755df 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/installation/greptimedb-standalone.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/installation/greptimedb-standalone.md @@ -68,7 +68,7 @@ greptime/greptimedb:VAR::greptimedbVersion standalone start \ 1. 设置 `--security-opt seccomp=unconfined`: - ```shell + ```shell docker run --security-opt seccomp=unconfined -p 4000-4003:4000-4003 \ -v "$(pwd)/greptimedb:/tmp/greptimedb" \ --name greptime --rm \ @@ -77,7 +77,7 @@ greptime/greptimedb:VAR::greptimedbVersion standalone start \ --rpc-addr 0.0.0.0:4001 \ --mysql-addr 0.0.0.0:4002 \ --postgres-addr 0.0.0.0:4003 - ``` + ``` 2. 将 Docker 版本升级到 v23.0.0 或更高; ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/greptimecloud/usage-&-billing/share-storage-capacity.md b/i18n/zh/docusaurus-plugin-content-docs/current/greptimecloud/usage-&-billing/share-storage-capacity.md deleted file mode 100644 index 029ed012d..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/greptimecloud/usage-&-billing/share-storage-capacity.md +++ /dev/null @@ -1,3 +0,0 @@ -### 存储容量 - -GreptimeCloud 会将您的数据存储在对象存储中,例如 S3,并根据数据库中的总数据大小计算存储成本。你将按月支付所使用的服务费用。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/go.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/go.md deleted file mode 100644 index 3996bcd06..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/go.md +++ /dev/null @@ -1,337 +0,0 @@ -import DocTemplate from './template.md' - -# Go - - - -
- -GreptimeDB 提供的 Go Ingest SDK 是一个轻量级、并发安全的库,使用起来非常简单。 - -
- - -
- -使用下方的命令安装 Go Ingest SDK: - -```shell -go get -u github.com/GreptimeTeam/greptimedb-ingester-go@v0.5.0 -``` - -引入到代码中: - -```go -import ( - greptime "github.com/GreptimeTeam/greptimedb-ingester-go" - "github.com/GreptimeTeam/greptimedb-ingester-go/table" - "github.com/GreptimeTeam/greptimedb-ingester-go/table/types" -) -``` - -
- -
- -```go -cfg := greptime.NewConfig("127.0.0.1"). - // 将数据库名称更改为你的数据库名称 - WithDatabase("public"). - // 默认端口 4001 - // WithPort(4001). - // 如果服务配置了 TLS ,设置 TLS 选项来启用安全连接 - // WithInsecure(false). - // 设置鉴权信息 - WithAuth("username", "password") - -cli, _ := greptime.NewClient(cfg) -``` -
- -
- -```go -// 为 CPU 指标构建表结构 -cpuMetric, err := table.New("cpu_metric") -if err != nil { - // 处理错误 -} - -// 添加一个 'Tag' 列,用于主机标识符 -cpuMetric.AddTagColumn("host", types.STRING) -// 添加一个 'Timestamp' 列,用于记录数据收集的时间 -cpuMetric.AddTimestampColumn("ts", types.TIMESTAMP_MILLISECOND) -// 添加 'Field' 列,用于测量用户和系统 CPU 使用率 -cpuMetric.AddFieldColumn("cpu_user", types.FLOAT) -cpuMetric.AddFieldColumn("cpu_sys", types.FLOAT) - -// 插入示例数据 -// 注意:参数必须按照定义的表结构中的列的顺序排列:host, ts, cpu_user, cpu_sys -err = cpuMetric.AddRow("127.0.0.1", time.Now(), 0.1, 0.12) -err = cpuMetric.AddRow("127.0.0.1", time.Now(), 0.11, 0.13) -if err != nil { - // 处理错误 -} - -``` - -
- -
- -```go -cpuMetric, err := table.New("cpu_metric") -if err != nil { - // 处理错误 -} -cpuMetric.AddTagColumn("host", types.STRING) -cpuMetric.AddTimestampColumn("ts", types.TIMESTAMP_MILLISECOND) -cpuMetric.AddFieldColumn("cpu_user", types.FLOAT) -cpuMetric.AddFieldColumn("cpu_sys", types.FLOAT) -err = cpuMetric.AddRow("127.0.0.1", time.Now(), 0.1, 0.12) -if err != nil { - // 处理错误 -} - -memMetric, err := table.New("mem_metric") -if err != nil { - // 处理错误 -} -memMetric.AddTagColumn("host", types.STRING) -memMetric.AddTimestampColumn("ts", types.TIMESTAMP_MILLISECOND) -memMetric.AddFieldColumn("mem_usage", types.FLOAT) -err = memMetric.AddRow("127.0.0.1", time.Now(), 112) -if err != nil { - // 处理错误 -} -``` - -
- -
- -```go -resp, err := cli.Write(context.Background(), cpuMetric, memMetric) -if err != nil { - // 处理错误 -} -log.Printf("affected rows: %d\n", resp.GetAffectedRows().GetValue()) -``` - -
- -
- -```go -err := cli.StreamWrite(context.Background(), cpuMetric, memMetric) -if err != nil { - // 处理错误 -} -``` - -在所有数据写入完毕后关闭流式写入。 -一般情况下,连续写入数据时不需要关闭流式写入。 - -```go -affected, err := cli.CloseStream(ctx) -``` - -
- -
- -```go -type CpuMetric struct { - Host string `greptime:"tag;column:host;type:string"` - CpuUser float64 `greptime:"field;column:cpu_user;type:float64"` - CpuSys float64 `greptime:"field;column:cpu_sys;type:float64"` - Ts time.Time `greptime:"timestamp;column:ts;type:timestamp;precision:millisecond"` -} - -func (CpuMetric) TableName() string { - return "cpu_metric" -} - -cpuMetrics := []CpuMetric{ - { - Host: "127.0.0.1", - CpuUser: 0.10, - CpuSys: 0.12, - Ts: time.Now(), - } -} -``` - - - -
- -
- -```go -resp, err := cli.WriteObject(context.Background(), cpuMetrics) -log.Printf("affected rows: %d\n", resp.GetAffectedRows().GetValue()) -``` - -
- -
- -```go -err := streamClient.StreamWriteObject(context.Background(), cpuMetrics, memMetrics) -``` - -在所有数据写入完毕后关闭流式写入。 -一般情况下,连续写入数据时不需要关闭流式写入。 - -```go -affected, err := cli.CloseStream(ctx) -``` - -
- -
- -有关更多可运行的代码片段和常用方法的解释,请参阅[示例](https://github.com/GreptimeTeam/greptimedb-ingester-go/tree/main/examples)。 - -
- -
- -- [API 文档](https://pkg.go.dev/github.com/GreptimeTeam/greptimedb-ingester-go) - -
- - - - -
- -使用下方的命令安装 GORM: - -```shell -go get -u gorm.io/gorm -``` - -以 MySQL 为例安装 driver: - -```shell -go get -u gorm.io/driver/mysql -``` - -引入到代码中: - -```go -import ( - "gorm.io/gorm" - "gorm.io/driver/mysql" -) -``` - -
- - -
- -```go -type Mysql struct { - Host string - Port string - User string - Password string - Database string - - DB *gorm.DB -} - -m := &Mysql{ - Host: "127.0.0.1", - Port: "4002", // MySQL 协议的默认端口 - User: "username", - Password: "password", - Database: "public", -} - -dsn := fmt.Sprintf("tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", - m.Host, m.Port, m.Database) -dsn = fmt.Sprintf("%s:%s@%s", m.User, m.Password, dsn) -db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{}) -if err != nil { - // 错误处理 -} -m.DB = db -``` -
- -
- -下方的代码声明了一个 GORM 对象模型: - -```go -type CpuMetric struct { - Host string `gorm:"column:host;primaryKey"` - Ts time.Time `gorm:"column:ts;primaryKey"` - CpuUser float64 `gorm:"column:cpu_user"` - CpuSys float64 `gorm:"column:cpu_sys"` -} -``` - -如果你正在使用 [ORM API](#orm-api) 来插入数据,你可以在模型中同时声明 GORM 和 Greptime 标签。 - -```go -type CpuMetric struct { - Host string `gorm:"column:host;primaryKey" greptime:"tag;column:host;type:string"` - Ts time.Time `gorm:"column:ts;primaryKey" greptime:"timestamp;column:ts;type:timestamp;precision:millisecond"` - CpuUser float64 `gorm:"column:cpu_user" greptime:"field;column:cpu_user;type:float64"` - CpuSys float64 `gorm:"column:cpu_sys" greptime:"field;column:cpu_sys;type:float64"` -} -``` - -声明表名: - -```go -func (CpuMetric) TableName() string { - return "cpu_metric" -} -``` - -使用原始 SQL 查询数据: - -```go -var cpuMetric CpuMetric -db.Raw("SELECT * FROM cpu_metric LIMIT 10").Scan(&result) - -``` - -
- - - - -
\ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/java.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/java.md deleted file mode 100644 index 17b1421f6..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/java.md +++ /dev/null @@ -1,500 +0,0 @@ -import DocTemplate from './template.md' - -# Java - - - -
- -GreptimeDB 提供的 Java ingester SDK 是一个轻量级库,具有以下特点: - -- 基于 SPI 的可扩展网络传输层,提供了使用 gRPC 框架的默认实现。 -- 非阻塞、纯异步的易于使用的 API。 -- 默认情况下自动收集各种性能指标,然后可以配置并将其写入本地文件。 -- 能够对关键对象进行内存快照,配置并将其写入本地文件。这对于解决复杂问题很有帮助。 - -
- -
- -1. 安装 Java 开发工具包(JDK) - -确保你的系统已安装 JDK 8 或更高版本。有关如何检查 Java 版本并安装 JDK 的更多信息,请参见 [Oracle JDK 安装概述文档](https://www.oracle.com/java/technologies/javase-downloads.html) - -2. 将 GreptimeDB Java SDK 添加为依赖项 - -如果你使用的是 [Maven](https://maven.apache.org/),请将以下内容添加到 pom.xml 的依赖项列表中: - -```xml - - io.greptime - ingester-all - 0.7.3 - -``` - -最新版本可以在 [这里](https://central.sonatype.com/search?q=io.greptime&name=ingester-all) 查看。 - -配置依赖项后,请确保它们对项目可用,这可能需要在 IDE 中刷新项目或运行依赖项管理器。 - -
- -
- - -下方的代码展示了以最简单的配置连接到 GreptimeDB 的方法。 -如果想要自定义连接选项,请参考 [API 文档](#ingester-库参考)。 -请注意每个选项的注释,它们提供了对其各自角色的详细解释。 - -```java -// GreptimeDB 默认 database 为 "public",默认 catalog 为 "greptime", -// 我们可以将其作为测试数据库使用 -String database = "public"; -// 默认情况下,GreptimeDB 使用 gRPC 协议在监听端口 4001。 -// 我们可以提供多个指向同一 GreptimeDB 集群的 endpoints, -// 客户端将根据负载均衡策略调用这些 endpoints。 -String[] endpoints = {"127.0.0.1:4001"}; -// 设置鉴权信息 -AuthInfo authInfo = new AuthInfo("username", "password"); -GreptimeOptions opts = GreptimeOptions.newBuilder(endpoints, database) - // 如果数据库不需要鉴权,我们可以使用 AuthInfo.noAuthorization() 作为参数。 - .authInfo(authInfo) - // 如果服务配置了 TLS ,设置 TLS 选项来启用安全连接 - //.tlsOptions(new TlsOptions()) - // 好的开始 ^_^ - .build(); - -GreptimeDB client = GreptimeDB.create(opts); -``` - -
- -
- -```java -// 为 CPU 指标构建表结构 -TableSchema cpuMetricSchema = TableSchema.newBuilder("cpu_metric") - .addTag("host", DataType.String) // 主机的标识符 - .addTimestamp("ts", DataType.TimestampMillisecond) // 毫秒级的时间戳 - .addField("cpu_user", DataType.Float64) // 用户进程的 CPU 使用率 - .addField("cpu_sys", DataType.Float64) // 系统进程的 CPU 使用率 - .build(); - -// 根据定义的模式创建表 -Table cpuMetric = Table.from(cpuMetricSchema); - -// 单行的示例数据 -String host = "127.0.0.1"; // 主机标识符 -long ts = System.currentTimeMillis(); // 当前时间戳 -double cpuUser = 0.1; // 用户进程的 CPU 使用率(百分比) -double cpuSys = 0.12; // 系统进程的 CPU 使用率(百分比) - -// 将一行数据插入表中 -// 注意:参数必须按照定义的表结构的列顺序排列:host, ts, cpu_user, cpu_sys -cpuMetric.addRow(host, ts, cpuUser, cpuSys); -``` - -
- -
- -```java -// 创建表结构 -TableSchema cpuMetricSchema = TableSchema.newBuilder("cpu_metric") - .addTag("host", DataType.String) - .addTimestamp("ts", DataType.TimestampMillisecond) - .addField("cpu_user", DataType.Float64) - .addField("cpu_sys", DataType.Float64) - .build(); - -TableSchema memMetricSchema = TableSchema.newBuilder("mem_metric") - .addTag("host", DataType.String) - .addTimestamp("ts", DataType.TimestampMillisecond) - .addField("mem_usage", DataType.Float64) - .build(); - -Table cpuMetric = Table.from(cpuMetricSchema); -Table memMetric = Table.from(memMetricSchema); - -// 添加行数据 -for (int i = 0; i < 10; i++) { - String host = "127.0.0." + i; - long ts = System.currentTimeMillis(); - double cpuUser = i + 0.1; - double cpuSys = i + 0.12; - cpuMetric.addRow(host, ts, cpuUser, cpuSys); -} - -for (int i = 0; i < 10; i++) { - String host = "127.0.0." + i; - long ts = System.currentTimeMillis(); - double memUsage = i + 0.2; - memMetric.addRow(host, ts, memUsage); -} - -``` - -
- -
- -```java -// 插入数据 - -// 考虑到尽可能提升性能和降低资源占用,SDK 设计为纯异步的。 -// 返回值是一个 future 对象。如果你想立即获取结果,可以调用 `future.get()`。 -CompletableFuture> future = greptimeDB.write(cpuMetric, memMetric); - -Result result = future.get(); - -if (result.isOk()) { - LOG.info("Write result: {}", result.getOk()); -} else { - LOG.error("Failed to write: {}", result.getErr()); -} - -``` - -
- -
- - -```java -StreamWriter writer = greptimeDB.streamWriter(); - -// 写入数据到流中 -writer.write(cpuMetric); -writer.write(memMetric); - -// 你可以对流执行操作,例如删除前 5 行 -writer.write(cpuMetric.subRange(0, 5), WriteOp.Delete); -``` - -在所有数据写入完毕后关闭流式写入。 -一般情况下,连续写入数据时不需要关闭流式写入。 - -```java -// 完成流式写入 -CompletableFuture future = writer.completed(); -WriteOk result = future.get(); -LOG.info("Write result: {}", result); -``` - -
- -
- -#### 更新数据 - -关于更新机制,请参考 [更新数据](/user-guide/write-data/overview.md#更新数据)。 -下方代码首先保存了一行数据,然后使用相同的标签和时间索引来更新特定的行数据。 - -```java -Table cpuMetric = Table.from(myMetricCpuSchema); -// 插入一行数据 -long ts = 1703832681000L; -cpuMetric.addRow("host1", ts, 0.23, 0.12); -Result putResult = greptimeDB.write(cpuMetric).get(); - -// 更新行数据 -Table newCpuMetric = Table.from(myMetricCpuSchema); -// 相同的标签 `host1` -// 相同的时间索引 `1703832681000` -// 新的值:cpu_user = `0.80`, cpu_sys = `0.11` -long ts = 1703832681000L; -myMetricCpuSchema.addRow("host1", ts, 0.80, 0.11); - -// 覆盖现有数据 -CompletableFuture> future = greptimeDB.write(myMetricCpuSchema); -Result result = future.get(); -``` - -
- - -
- -GreptimeDB Java Ingester SDK 允许我们使用基本的 POJO 对象进行写入。虽然这种方法需要使用 Greptime 的注解,但它们很容易使用。 - -```java -@Metric(name = "cpu_metric") -public class Cpu { - @Column(name = "host", tag = true, dataType = DataType.String) - private String host; - - @Column(name = "ts", timestamp = true, dataType = DataType.TimestampMillisecond) - private long ts; - - @Column(name = "cpu_user", dataType = DataType.Float64) - private double cpuUser; - @Column(name = "cpu_sys", dataType = DataType.Float64) - private double cpuSys; - - // getters and setters - // ... -} - -@Metric(name = "mem_metric") -public class Memory { - @Column(name = "host", tag = true, dataType = DataType.String) - private String host; - - @Column(name = "ts", timestamp = true, dataType = DataType.TimestampMillisecond) - private long ts; - - @Column(name = "mem_usage", dataType = DataType.Float64) - private double memUsage; - // getters and setters - // ... -} - -// 添加行 -List cpus = new ArrayList<>(); -for (int i = 0; i < 10; i++) { - Cpu c = new Cpu(); - c.setHost("127.0.0." + i); - c.setTs(System.currentTimeMillis()); - c.setCpuUser(i + 0.1); - c.setCpuSys(i + 0.12); - cpus.add(c); -} - -List memories = new ArrayList<>(); -for (int i = 0; i < 10; i++) { - Memory m = new Memory(); - m.setHost("127.0.0." + i); - m.setTs(System.currentTimeMillis()); - m.setMemUsage(i + 0.2); - memories.add(m); -} -``` - -
- - -
- -写入 POJO 对象: - -```java -// 插入数据 - -CompletableFuture> puts = greptimeDB.writePOJOs(cpus, memories); - -Result result = puts.get(); - -if (result.isOk()) { - LOG.info("Write result: {}", result.getOk()); -} else { - LOG.error("Failed to write: {}", result.getErr()); -} -``` - -
- -
- -```java -StreamWriter, WriteOk> writer = greptimeDB.streamWriterPOJOs(); - -// 写入数据到流中 -writer.write(cpus); -writer.write(memories); - -// 你可以对流执行操作,例如删除前 5 行 -writer.write(cpus.subList(0, 5), WriteOp.Delete); -``` - -在所有数据写入完毕后关闭流式写入。 -一般情况下,连续写入数据时不需要关闭流式写入。 - -```java -// 完成流式写入 -CompletableFuture future = writer.completed(); -WriteOk result = future.get(); -LOG.info("Write result: {}", result); -``` - -
- -
- -#### 更新数据 - -关于更新机制,请参考 [更新数据](/user-guide/write-data/overview.md#更新数据)。 -下方代码首先保存了一行数据,然后使用相同的标签和时间索引来更新特定的行数据。 - -```java -Cpu cpu = new Cpu(); -cpu.setHost("host1"); -cpu.setTs(1703832681000L); -cpu.setCpuUser(0.23); -cpu.setCpuSys(0.12); - -// 插入一行数据 -Result putResult = greptimeDB.writePOJOs(cpu).get(); - -// 更新该行数据 -Cpu newCpu = new Cpu(); -// 相同的标签 `host1` -newCpu.setHost("host1"); -// 相同的时间索引 `1703832681000` -newCpu.setTs(1703832681000L); -// 新的值: cpu_user = `0.80`, cpu_sys = `0.11` -cpu.setCpuUser(0.80); -cpu.setCpuSys(0.11); - -// 覆盖现有数据 -Result updateResult = greptimeDB.writePOJOs(newCpu).get(); -``` - -请参考[此处](https://github.com/GreptimeTeam/greptimedb-ingester-java/tree/main/ingester-example/src/main/java/io/greptime)获取更多代码示例。 - -
- - -
- -### 调试日志 - -ingester SDK 提供了用于调试的指标和日志。 -请参考 [Metrics & Display](https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/main/docs/metrics-display.md) 和 [Magic Tools](https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/main/docs/magic-tools.md) 了解如何启用或禁用日志。 - -
- -
- -请参考[示例](https://github.com/GreptimeTeam/greptimedb-ingester-java/tree/main/ingester-example/src/main/java/io/greptime)获取更多完全可运行的代码片段和常用方法的解释。 - -
- -
- -- [API 文档](https://javadoc.io/doc/io.greptime/ingester-protocol/latest/index.html) - -
- - - -
- -如果你使用的是 [Maven](https://maven.apache.org/),请将以下内容添加到 pom.xml 的依赖项列表中: - -```xml - - - mysql - mysql-connector-java - 8.0.33 - -``` - -
- -
- -这里我们使用 MySQL 作为示例来演示如何连接到 GreptimeDB。 - -```java - -public static Connection getConnection() throws IOException, ClassNotFoundException, SQLException { - Properties prop = new Properties(); - prop.load(QueryJDBC.class.getResourceAsStream("/db-connection.properties")); - - String dbName = (String) prop.get("db.database-driver"); - - String dbConnUrl = (String) prop.get("db.url"); - String dbUserName = (String) prop.get("db.username"); - String dbPassword = (String) prop.get("db.password"); - - Class.forName(dbName); - Connection dbConn = DriverManager.getConnection(dbConnUrl, dbUserName, dbPassword); - - return Objects.requireNonNull(dbConn, "Failed to make connection!"); -} - -``` - -你需要一个 properties 文件来存储数据库连接信息,将其放在 Resources 目录中并命名为 `db-connection.properties`。文件内容如下: - -```txt -# DataSource -db.database-driver=com.mysql.cj.jdbc.Driver -db.url=jdbc:mysql://localhost:4002/public -db.username= -db.password= -``` - -或者你可以从[这里](https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/main/ingester-example/src/main/resources/db-connection.properties)获取文件。 - -#### 时区 - -通过设置 URL 参数来设置 JDBC 时区: - -```txt -jdbc:mysql://127.0.0.1:4002?connectionTimeZone=Asia/Shanghai&forceConnectionTimeZoneToSession=true -``` - -* `connectionTimeZone={LOCAL|SERVER|user-defined-time-zone}` 配置连接时区。 -* `forceConnectionTimeZoneToSession=true` 使 session `time_zone` 变量被设置为 `connectionTimeZone` 指定的值。 -
- -
- -```java -try (Connection conn = getConnection()) { - Statement statement = conn.createStatement(); - - // DESC table; - ResultSet rs = statement.executeQuery("DESC cpu_metric"); - LOG.info("Column | Type | Key | Null | Default | Semantic Type "); - while (rs.next()) { - LOG.info("{} | {} | {} | {} | {} | {}", - rs.getString(1), - rs.getString(2), - rs.getString(3), - rs.getString(4), - rs.getString(5), - rs.getString(6)); - } - - // SELECT COUNT(*) FROM cpu_metric; - rs = statement.executeQuery("SELECT COUNT(*) FROM cpu_metric"); - while (rs.next()) { - LOG.info("Count: {}", rs.getInt(1)); - } - - // SELECT * FROM cpu_metric ORDER BY ts DESC LIMIT 5; - rs = statement.executeQuery("SELECT * FROM cpu_metric ORDER BY ts DESC LIMIT 5"); - LOG.info("host | ts | cpu_user | cpu_sys"); - while (rs.next()) { - LOG.info("{} | {} | {} | {}", - rs.getString("host"), - rs.getTimestamp("ts"), - rs.getDouble("cpu_user"), - rs.getDouble("cpu_sys")); - } -} - -``` - -请参考[此处](https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/main/ingester-example/src/main/java/io/greptime/QueryJDBC.java)获取更多可执行代码。 - -
- - - -
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/overview.md deleted file mode 100644 index 351716cc9..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/overview.md +++ /dev/null @@ -1,7 +0,0 @@ -# 概述 - -使用客户端库将 GreptimeDB 集成到您的应用程序中。 -本指南将演示如何使用客户端库在 GreptimeDB 中写入和查询数据。 - -- [Go](go.md) -- [Java](java.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/template.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/template.md deleted file mode 100644 index a76ab2788..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/client-libraries/template.md +++ /dev/null @@ -1,130 +0,0 @@ - -GreptimeDB 使用不同的客户端库来写入和查询数据。 -你根据需求可以选择合适的客户端库。 - -## 写入数据 - -GreptimeDB 提供了一个 ingester 库来帮助你写入数据。 -它使用 gRPC 协议,支持自动生成表结构,无需在写入数据前创建表。 -更多信息请参考 [自动生成表结构](/user-guide/write-data/overview.md#自动生成表结构)。 - -{props.children.filter(c => c.props.id == 'ingester-lib-introduction')} - -### 安装 - -{props.children.filter(c => c.props.id == 'ingester-lib-installation')} - -### 连接数据库 - -连接 GreptimeDB 时,通常需要用户名和密码。 -关于如何设置 GreptimeDB 的鉴权方式,请参考[鉴权](/user-guide/clients/authentication.md)。 -这里我们在使用 ingester 库连接 GreptimeDB 时设置用户名和密码。 - -{props.children.filter(c => c.props.id == 'ingester-lib-connect')} - -### 数据模型 - -表中的每条行数据包含三种类型的列:`Tag`、`Timestamp` 和 `Field`。更多信息请参考 [数据模型](/user-guide/concepts/data-model.md)。 -列值的类型可以是 `String`、`Float`、`Int`、`Timestamp` 等。更多信息请参考 [数据类型](/reference/sql/data-types.md)。 - -### 低层级 API - -GreptimeDB 的低层级 API 通过向具有预定义模式的 `table` 对象添加 `row` 来写入数据。 - -#### 创建行数据 - -以下代码片段首先构建了一个名为 `cpu_metric` 的表,其中包括 `host`、`cpu_user`、`cpu_sys` 和 `ts` 列。 -随后,它向表中插入了一行数据。 - -该表包含三种类型的列: - -- `Tag`:`host` 列,值类型为 `String`。 -- `Field`:`cpu_user` 和 `cpu_sys` 列,值类型为 `Float`。 -- `Timestamp`:`ts` 列,值类型为 `Timestamp`。 - -{props.children.filter(c => c.props.id == 'low-level-object')} - -为了提高写入数据的效率,你可以一次创建多行数据以便写入到 GreptimeDB。 - -{props.children.filter(c => c.props.id == 'create-rows')} - -#### 插入数据 - -下方示例展示了如何向 GreptimeDB 的表中插入行数据。 - -{props.children.filter(c => c.props.id == 'insert-rows')} - -#### 流式插入 - -当你需要插入大量数据时,例如导入历史数据,流式插入是非常有用的。 - -{props.children.filter(c => c.props.id == 'streaming-insert')} - -{props.children.filter(c => c.props.id == 'update-rows')} - - - -### 高层级 API - -SDK 的高层级 API 使用 ORM 风格的对象写入数据, -它允许你以更面向对象的方式创建、插入和更新数据,为开发者提供了更友好的体验。 -然而,高层级 API 不如低层级 API 高效。 -这是因为 ORM 风格的对象在转换对象时可能会消耗更多的资源和时间。 - -#### 创建行数据 - -{props.children.filter(c => c.props.id == 'high-level-style-object')} - -#### 插入数据 - -{props.children.filter(c => c.props.id == 'high-level-style-insert-data')} - -#### 流式插入 - -当你需要插入大量数据时,例如导入历史数据,流式插入是非常有用的。 - -{props.children.filter(c => c.props.id == 'high-level-style-streaming-insert')} - -{props.children.filter(c => c.props.id == 'high-level-style-update-data')} - -### 更多示例 - -{props.children.filter(c => c.props.id == 'more-ingestion-examples')} - -{props.children.filter(c => c.props.id == 'ingester-lib-debug-logs')} - -### Ingester 库参考 - -{props.children.filter(c => c.props.id == 'ingester-lib-reference')} - -## 查询数据 - -GreptimeDB 使用 SQL 作为主要查询语言,兼容 MySQL 和 PostgreSQL。 -因此,我们推荐使用成熟的 SQL 驱动来查询数据。 - -### 推荐的查询库 - -{props.children.filter(c => c.props.id == 'recommended-query-library')} - -### 安装 - -{props.children.filter(c => c.props.id == 'query-library-installation')} - -### 连接数据库 - -下方的例子展示了如何连接到 GreptimeDB: - -{props.children.filter(c => c.props.id == 'query-library-connect')} - -### Raw SQL - -我们推荐使用 Raw SQL 来体验 GreptimeDB 的全部功能。 -下面的例子展示了如何使用 Raw SQL 查询数据: - -{props.children.filter(c => c.props.id == 'query-library-raw-sql')} - -### 查询库参考 - -有关如何使用查询库的更多信息,请参考相应库的文档: - -{props.children.filter(c => c.props.id == 'query-lib-doc-link')} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/cluster.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/cluster.md index 78081fb14..51161d5e1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/cluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/cluster.md @@ -12,13 +12,13 @@ 1. 使用 MySQL cli 连接到 Frontend。 - ```shell + ```shell mysql -h 127.0.0.1 -P 4002 - ``` + ``` 2. 通过 `CREATE` 语句创建一个分布式表。 - ```SQL + ```SQL CREATE TABLE dist_table( ts TIMESTAMP DEFAULT current_timestamp(), n INT, @@ -32,11 +32,11 @@ n >= 9 ) engine=mito; - ``` + ``` 结果如下: - ```shell + ```shell mysql> CREATE TABLE dist_table( -> ts TIMESTAMP DEFAULT current_timestamp(), -> n INT, @@ -51,13 +51,13 @@ -> ) -> engine=mito; Query OK, 3 rows affected (0.09 sec) - ``` + ``` `dist_table` 被分布在 `Datanode` 中。你可以参考 ["Table Sharding"](/contributor-guide/frontend/table-sharding.md) 了解更多细节。 3. 通过 `INSERT` 语句输入一些数据。 - ```SQL + ```SQL INSERT INTO dist_table(n, row_id) VALUES (1, 1); INSERT INTO dist_table(n, row_id) VALUES (2, 2); INSERT INTO dist_table(n, row_id) VALUES (3, 3); @@ -70,15 +70,15 @@ INSERT INTO dist_table(n, row_id) VALUES (10, 10); INSERT INTO dist_table(n, row_id) VALUES (11, 11); INSERT INTO dist_table(n, row_id) VALUES (12, 12); - ``` + ``` 4. 通过 `SELECT` 语句执行查询: - ```sql + ```sql SELECT * FROM dist_table ORDER BY n LIMIT 5; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ @@ -89,39 +89,39 @@ | 2022-11-14 12:02:32 | 5 | 5 | +---------------------+------+--------+ 5 rows in set (0.081 sec) - ``` + ``` - ```sql + ```sql SELECT MAX(n) FROM dist_table; - ``` + ``` - ```sql + ```sql +-------------------+ | MAX(dist_table.n) | +-------------------+ | 12 | +-------------------+ 1 row in set (0.057 sec) - ``` + ``` - ```sql + ```sql SELECT MIN(n) FROM dist_table; - ``` + ``` - ```sql + ```sql +-------------------+ | MIN(dist_table.n) | +-------------------+ | 1 | +-------------------+ 1 row in set (0.079 sec) - ``` + ``` - ```sql + ```sql SELECT * FROM dist_table WHERE n > 2 AND n < 10 ORDER BY row_id; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ @@ -134,18 +134,18 @@ | 2022-11-14 12:02:32 | 9 | 9 | +---------------------+------+--------+ 7 rows in set (0.02 sec) - ``` + ``` - ```sql + ```sql SELECT * FROM dist_table WHERE row_id = 10; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ | 2022-11-14 12:02:32 | 10 | 10 | +---------------------+------+--------+ 1 row in set (0.03 sec) - ``` + ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/influxdb-line.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/influxdb-line.md deleted file mode 100644 index ff7015c32..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/influxdb-line.md +++ /dev/null @@ -1,40 +0,0 @@ -# InfluxDB Line Protocol - -GreptimeDB 支持 HTTP InfluxDB Line 协议。 - -## 数据模型 - -要了解 InfluxDB 和 GreptimeDB 的数据模型之间的差异,请参考从 Influxdb 迁移到 GreptimeDB 文档中的[数据模型差异](../migrate-to-greptimedb/migrate-from-influxdb.md#数据模型的区别)。 - -## 写入新数据 - -你可以通过 `/influxdb/write` API 写入数据。 -以下是一个示例: - -```shell -curl -i -XPOST "http://localhost:4000/v1/influxdb/write?db=public&precision=ms" \ ---data-binary \ -'monitor,host=127.0.0.1 cpu=0.1,memory=0.4 1667446797450 - monitor,host=127.0.0.2 cpu=0.2,memory=0.3 1667446798450 - monitor,host=127.0.0.1 cpu=0.5,memory=0.2 1667446798450' -``` - -`/influxdb/write` 支持查询参数,包括: - -* `db`:指定要写入的数据库。默认值为 `public`。 -* `precision`:定义请求体中提供的时间戳的精度,可接受的值为 `ns`(纳秒)、`us`(微秒)、`ms`(毫秒)和 `s`(秒),默认值为 `ns`(纳秒)。该 API 写入的时间戳类型为 `TimestampNanosecond`,因此默认精度为 `ns`(纳秒)。如果你在请求体中使用了其他精度的的时间戳,需要使用此参数指定精度。该参数确保时间戳能够被准确解释并以纳秒精度存储。 - -你还可以在发送请求时省略 timestamp,GreptimeDB 将使用主机机器的当前系统时间(UTC 时间)作为 timestamp。例如: - -```shell -curl -i -XPOST "http://localhost:4000/v1/influxdb/write?db=public&precision=ms" \ ---data-binary \ -'monitor,host=127.0.0.1 cpu=0.1,memory=0.4 - monitor,host=127.0.0.2 cpu=0.2,memory=0.3 - monitor,host=127.0.0.1 cpu=0.5,memory=0.2' -``` - -## 参考 - -[InfluxDB Line protocol](https://docs.influxdata.com/influxdb/v2.7/reference/syntax/line-protocol/) - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/opentsdb.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/opentsdb.md deleted file mode 100644 index 013922e75..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/opentsdb.md +++ /dev/null @@ -1,59 +0,0 @@ -# OpenTSDB - -GreptimeDB支持通过 HTTP API 使用 OpenTSDB 协议。 - -## 写入新数据 - -### HTTP API - -GreptimeDB 还支持通过 HTTP 接口插入 OpenTSDB 数据,接口是 `/opentsdb/api/put`,使用的请求和响应格式与 OpenTSDB 的 `/api/put` 接口相同。 - -GreptimeDB 的 HTTP Server 默认监听 `4000` 端口。例如使用 curl 写入一个指标数据: - -```shell -curl -X POST http://127.0.0.1:4000/v1/opentsdb/api/put -d ' -{ - "metric": "sys.cpu.nice", - "timestamp": 1667898896, - "value": 18, - "tags": { - "host": "web01", - "dc": "hz" - } -} -' -``` - -插入多个指标数据: - -```shell -curl -X POST http://127.0.0.1:4000/v1/opentsdb/api/put -d ' -[ - { - "metric": "sys.cpu.nice", - "timestamp": 1667898896, - "value": 1, - "tags": { - "host": "web02", - "dc": "hz" - } - }, - { - "metric": "sys.cpu.nice", - "timestamp": 1667898897, - "value": 9, - "tags": { - "host": "web03", - "dc": "sh" - } - } -] -' -``` - -:::tip 注意 -记得在路径前加上 GreptimeDB 的 HTTP API 版本 `v1`。 -::: - - - \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/overview.md deleted file mode 100644 index 3aa5827a2..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/overview.md +++ /dev/null @@ -1,44 +0,0 @@ -# 概述 - -在向 GreptimeDB 写入数据之前,你需要先与数据库[建立连接](../clients/overview.md). - -## 插入数据 - -### 自动生成表结构 - -GreptimeDB 的自动生成表结构功能可以使你在写入数据之前无需提前创建表。当使用协议支持 gRPC 协议的 [SDK](/user-guide/client-libraries/overview.md)、[InfluxDB](./influxdb-line.md)、[OpenTSDB](./opentsdb.md) 和 [Prometheus](./prometheus.md) 写入数据时,表和列将会被自动创建。必要时,GreptimeDB 会自动添加所需的列,以确保用户的数据正确保存。 - -## 更新数据 - -可以通过插入数据来实现数据的更新。如果插入的数据和表中某行数据的标签列及时间索引列的值相同,旧数据将会被新数据替换。GreptimeDB 中的标签与时间索引相当于其他 TSDB 中的时间线的概念。 - -:::tip 注意 -更新的性能与插入相同,但过多的更新可能会损害查询性能。 -::: - -关于列类型,请参考[数据模型](../concepts/data-model.md)。 - -## 删除数据 - -你可以通过标签及时间索引列有效地删除数据。使用其他查询条件(不包含标签和时间索引列)删除数据不是高效的操作,因为这种删除需要两个步骤:查询数据,然后通过再通过标签及时间索引删除它。 - -:::tip 注意 -过多的删除操作可能会损害查询性能。 -::: - -关于列类型,请参考[数据模型](../concepts/data-model.md)。 - -## 客户端 - -## 协议或语言 - -- [SQL](./sql.md) -- [InfluxDB line](./influxdb-line.md) -- [OpenTSDB](./opentsdb.md) -- [Prometheus Storage](./prometheus.md) - -## 客户端库 - -客户端库提供了一种方便的方式来连接 GreptimeDB 并与数据交互。 -它们提供了写入和查询数据的功能,使得将 GreptimeDB 集成到你的应用程序中变得更加容易。 -请参考[客户端库](/user-guide/client-libraries/overview.md)文档获取更多信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/prometheus.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/prometheus.md deleted file mode 100644 index ec1679015..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/prometheus.md +++ /dev/null @@ -1,108 +0,0 @@ -# Prometheus - -GreptimeDB 可以作为 Prometheus 的长期存储。使用 GreptimeDB 作为 Prometheus 的后端存储可以获得无缝体验。由于 Prometheus 支持在配置远程写和读的过程中设置基本的认证信息,你只需要把配置的用户名和密码添加到配置 YAML 文件中就可以了。 - -请按照 [Prometheus configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#configuration-file) (`prometheus.yml`) 中的设置进行配置: - -```yaml -remote_write: -- url: http://localhost:4000/v1/prometheus/write?db=public&physical_table=greptime_physical_table -# basic_auth: -# username: greptime_user -# password: greptime_pwd - -remote_read: -- url: http://localhost:4000/v1/prometheus/read?db=public -# basic_auth: -# username: greptime_user -# password: greptime_pwd -``` - -:::tip 注意 -请将 `greptime_user(username)`, `greptime_pwd(password)` 替换为用户自己的用户名和密码,详情请参考客户端[鉴权认证](../clients/authentication.md)。 -::: - -URL 中的 `db` 参数表示我们要写入的数据库,是可选的,默认为 `public`。 -如果你想要写入到其他数据库,可以[创建新数据库](../table-management.md#create-a-database)并将 `public` 替换为新的数据库名称。 - -GreptimeDB 将多个 Prometheus 指标[自动组合](../clients/prometheus#数据模型)到相应的逻辑表中,因此你无需在 `remote_write` 的 URL 中指定逻辑表。 - -URL 中的 `physical_table` 参数可选,表示数据被写入的[物理表](/contributor-guide/datanode/metric-engine.md#物理表), -它可以减少小表的存储开销,提高列压缩效率。 -在不指定该参数的情况下默认使用 `greptime_physical_table` 表。如果指定的物理表不存在,该表会被自动创建。 - -在配置文件中启用 [`with_metric_engine`](/user-guide/operations/configuration.md#协议选项) 时,`physical_table` 参数才会生效。 -该配置默认启用。 - -下面是 URL 参数的表格: - -| 参数 | 是否必须 | 默认值 | -| -------------- | -------- | ----------------------- | -| db | 可选 | public | -| physical_table | 可选 | greptime_physical_table | - -写入数据成功后,使用下面的命令展示数据库中的表: - -```sql -show tables; -``` - -```sql -+---------------------------------------------------------------+ -| Tables | -+---------------------------------------------------------------+ -| go_memstats_heap_inuse_bytes | -| go_memstats_last_gc_time_seconds | -| net_conntrack_listener_conn_closed_total | -| prometheus_remote_storage_enqueue_retries_total | -| prometheus_remote_storage_exemplars_pending | -| prometheus_remote_storage_read_request_duration_seconds_count | -| prometheus_rule_group_duration_seconds | -| prometheus_rule_group_duration_seconds_count | -| ...... | -+---------------------------------------------------------------+ -``` - -## GreptimeDB 中的 Prometheus 指标 - -当指标被远程写入 GreptimeDB 时,它们将被转换为下面这样: - -| Sample Metrics | In GreptimeDB | GreptimeDB Data Types | -| :------------- | :-------------------------- | :-------------------- | -| Name | Table (Auto-created) Name | String | -| Value | Column (greptime_value) | Double | -| Timestamp | Column (greptime_timestamp) | Timestamp | -| Label | Column | String | - -所有标签列将会被自动创建为主键。当添加新的标签时,它也会自动添加到主键中。 - -## 举例: GreptimeDB 表中的 Prometheus 指标 - -```txt -prometheus_remote_storage_samples_total{instance="localhost:9090", job="prometheus", -remote_name="648f0c", url="http://localhost:4000/v1/prometheus/write"} 500 -``` - -上面这个例子将被转化为表 `prometheus_remote_storage_samples_total` 中的一行: - -| Column | Value | Column Data Type | -| :----------------- | :------------------------------------------ | :----------------- | -| instance | localhost:9090 | String | -| job | prometheus | String | -| remote_name | 648f0c | String | -| url | `http://localhost:4000/v1/prometheus/write` | String | -| greptime_value | 500 | Double | -| greptime_timestamp | The sample's unix timestamp | Timestamp | - -## VictoriaMetrics remote write 协议支持 - -VictoriaMetrics 微调了 Prometheus remote write 协议,通过 zstd 压缩试图获取更好 -的压缩率和更低资源消耗。当你配置了支持该协议的后端时,`vmagent` 工具会自动切换到 -VictoriaMetrics remote write 协议。 - -GreptimeDB 也支持了这个变种协议。用户只需要将 GreptimeDB 的 remote write 路径配 -置给 `vmagent` 就可以达到效果。例如,对本地安装的 GreptimeDB 来说: - -```shell -vmagent -remoteWrite.url=http://localhost:4000/v1/prometheus/write -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/sql.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/sql.md deleted file mode 100644 index 3640a082a..000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/write-data/sql.md +++ /dev/null @@ -1,187 +0,0 @@ -# SQL - -我们将使用 `monitor` 表作为示例来展示如何写入数据。有关如何创建 `monitor` 表的 SQL 示例,请参见[表管理](./../table-management.md#创建表)。 - -## 插入数据 - -让我们向 `monitor` 表中插入一些测试数据。你可以使用 `INSERT INTO` 语句: - -```sql -INSERT INTO monitor -VALUES - ("127.0.0.1", 1702433141000, 0.5, 0.2), - ("127.0.0.2", 1702433141000, 0.3, 0.1), - ("127.0.0.1", 1702433146000, 0.3, 0.2), - ("127.0.0.2", 1702433146000, 0.2, 0.4), - ("127.0.0.1", 1702433151000, 0.4, 0.3), - ("127.0.0.2", 1702433151000, 0.2, 0.4); -``` - -```sql -Query OK, 6 rows affected (0.01 sec) -``` - -你还可以插入数据时指定列名: - -```sql -INSERT INTO monitor (host, ts, cpu, memory) -VALUES - ("127.0.0.1", 1702433141000, 0.5, 0.2), - ("127.0.0.2", 1702433141000, 0.3, 0.1), - ("127.0.0.1", 1702433146000, 0.3, 0.2), - ("127.0.0.2", 1702433146000, 0.2, 0.4), - ("127.0.0.1", 1702433151000, 0.4, 0.3), - ("127.0.0.2", 1702433151000, 0.2, 0.4); -``` - -通过上面的语句,我们成功的向 `monitor` 表中插入了六条数据。请参考 [`INSERT`](/reference/sql/insert.md) 获得更多写入数据的相关信息。 - -### HTTP API - -使用 `POST` 方法来写入新数据: - -```shell -curl -X POST \ - -H 'authorization: Basic {{authorization if exists}}' \ - -H 'Content-Type: application/x-www-form-urlencoded' \ - -d 'sql=INSERT INTO monitor VALUES ("127.0.0.1", 1667446797450, 0.1, 0.4), ("127.0.0.2", 1667446798450, 0.2, 0.3), ("127.0.0.1", 1667446798450, 0.5, 0.2)' \ -http://localhost:4000/v1/sql?db=public -``` - -结果如下: - -```json -{ "code": 0, "output": [{ "affectedrows": 3 }], "execution_time_ms": 0 } -``` - -请参考 [API document](/reference/sql/http-api.md) 获取更多信息。 - - -## 更新数据 - -你可以通过插入和已存在的数据具有相同的标签和时间戳索引的数据来更新已有数据。 -例如,我们首先向 `monitor` 表中插入一行新数据: - -```sql -INSERT INTO monitor (host, ts, cpu, memory) -VALUES - ("127.0.0.1", 1702433141000, 0.8, 0.1); -``` - -在[创建表](../table-management.md#创建表)一节中,我们已经介绍了 `host` 是标签,`ts` 是时间索引。 -你可以使用相同的 `host` 和 `ts` 值来更新数据,并将新的 `cpu` 值设置为 `0.5`: - -```sql -INSERT INTO monitor (host, ts, cpu, memory) -VALUES - -- The same tag `127.0.0.1` and the same time index 1702433141000 - ("127.0.0.1", 1702433141000, 0.5, 0.1); -``` - -新的数据如下: - -```sql -+-----------+---------------------+------+--------+ -| host | ts | cpu | memory | -+-----------+---------------------+------+--------+ -| 127.0.0.1 | 2023-12-13 02:05:41 | 0.5 | 0.1 | -+-----------+---------------------+------+--------+ -``` - -注意,如果你只想更新一列,`INSERT INTO` 语句中的其他列**不能被省略** 。 -如果你省略了其他列,它们将被默认值覆盖。例如: - -```sql -INSERT INTO monitor (host, ts, cpu) -VALUES - ("127.0.0.1", 1702433141000, 0.5); -``` - -`memory` 列的默认值是 `NULL`。因此,新的数据如下: - -```sql -+-----------+---------------------+------+--------+ -| host | ts | cpu | memory | -+-----------+---------------------+------+--------+ -| 127.0.0.1 | 2023-12-13 02:05:41 | 0.5 | NULL | -+-----------+---------------------+------+--------+ -``` - -## 删除数据 - -通过标签 `host` 和时间戳索引 `ts` 删除一行数据: - -```sql -DELETE FROM monitor WHERE host='127.0.0.2' and ts=1667446798450; -``` - -```sql -Query OK, 1 row affected (0.00 sec) -``` - -请参考 [SQL DELETE](/reference/sql/delete.md) 获取更多信息。 - -### HTTP API - -使用 `POST` 方法来写入一条新数据: - -```shell -curl -X POST \ - -H 'authorization: Basic {{authorization if exists}}' \ - -H 'Content-Type: application/x-www-form-urlencoded' \ - -d "sql=DELETE FROM monitor WHERE host = '127.0.0.2' and ts = 1667446798450" \ -http://localhost:4000/v1/sql?db=public -``` - -结果如下: - -```json -{ "code": 0, "output": [{ "affectedrows": 1 }], "execution_time_ms": 1 } -``` - -请参考 [API 文档](/reference/sql/http-api.md)获取更多信息。 - -## 时区 - -SQL 客户端中指定的时区将影响没有时区信息的字符串格式的时间戳。 -该时间戳值将会自动添加客户端的时区信息。 - -例如,下面的 SQL 将时区设置为 `+8:00`: - -```sql -SET time_zone = '+8:00'; -``` - -然后向 `monitor` 表中插入值: - -```sql -INSERT INTO monitor (host, ts, cpu, memory) -VALUES - ("127.0.0.1", "2024-01-01 00:00:00", 0.4, 0.1), - ("127.0.0.2", "2024-01-01 00:00:00+08:00", 0.5, 0.1); -``` - -第一个时间戳值 `2024-01-01 00:00:00` 没有时区信息,因此它将自动添加客户端的时区信息。 -在插入数据后,它将等同于第二个值 `2024-01-01 00:00:00+08:00`。 - -`+8:00` 时区下的结果如下: - -```sql -+-----------+---------------------+------+--------+ -| host | ts | cpu | memory | -+-----------+---------------------+------+--------+ -| 127.0.0.1 | 2024-01-01 00:00:00 | 0.4 | 0.1 | -| 127.0.0.2 | 2024-01-01 00:00:00 | 0.5 | 0.1 | -+-----------+---------------------+------+--------+ -``` - -`UTC` 时区下的结果如下: - -```sql -+-----------+---------------------+------+--------+ -| host | ts | cpu | memory | -+-----------+---------------------+------+--------+ -| 127.0.0.1 | 2023-12-31 16:00:00 | 0.4 | 0.1 | -| 127.0.0.2 | 2023-12-31 16:00:00 | 0.5 | 0.1 | -+-----------+---------------------+------+--------+ -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/db-cloud-shared/tutorials/monitor-host-metrics/prometheus-demo.md b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/db-cloud-shared/tutorials/monitor-host-metrics/prometheus-demo.md index d4553b348..ec7d3d2f4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/db-cloud-shared/tutorials/monitor-host-metrics/prometheus-demo.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/db-cloud-shared/tutorials/monitor-host-metrics/prometheus-demo.md @@ -11,7 +11,7 @@ ```yaml services: prometheus: - image: prom/prometheus:v2.52.0 + image: prom/prometheus:VAR::prometheusVersion container_name: prometheus depends_on: - node_exporter @@ -21,7 +21,7 @@ services: - ./prometheus-greptimedb.yml:/etc/prometheus/prometheus.yml:ro node_exporter: - image: quay.io/prometheus/node-exporter:v1.8.0 + image: quay.io/prometheus/node-exporter:VAR::nodeExporterVersion container_name: node_exporter ports: - 9100:9100 diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/getting-started/installation/greptimedb-cluster.md b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/getting-started/installation/greptimedb-cluster.md index 2da335030..9ef9fd6e4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/getting-started/installation/greptimedb-cluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/getting-started/installation/greptimedb-cluster.md @@ -11,13 +11,13 @@ GreptimeDB 可以运行于 [cluster](/contributor-guide/overview.md) 模式以 ### 步骤 1: 下载 Docker Compose 的 YAML 文件 ``` -wget https://raw.githubusercontent.com/GreptimeTeam/greptimedb/v0.9.1/docker/docker-compose/cluster-with-etcd.yaml +wget https://raw.githubusercontent.com/GreptimeTeam/greptimedb/VAR::greptimedbVersion/docker/docker-compose/cluster-with-etcd.yaml ``` ### 步骤 2: 启动集群 ``` -GREPTIMEDB_VERSION=v0.9.1 \ +GREPTIMEDB_VERSION=VAR::greptimedbVersion \ GREPTIMEDB_REGISTRY=greptime-registry.cn-hangzhou.cr.aliyuncs.com \ ETCD_REGISTRY=greptime-registry.cn-hangzhou.cr.aliyuncs.com \ docker compose -f ./cluster-with-etcd.yaml up diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/getting-started/installation/greptimedb-standalone.md b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/getting-started/installation/greptimedb-standalone.md index 3c64c399d..ba92755df 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/getting-started/installation/greptimedb-standalone.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/getting-started/installation/greptimedb-standalone.md @@ -14,7 +14,7 @@ ```shell curl -fsSL \ - https://raw.githubusercontent.com/greptimeteam/greptimedb/main/scripts/install.sh | sh -s v0.9.1 + https://raw.githubusercontent.com/greptimeteam/greptimedb/main/scripts/install.sh | sh -s VAR::greptimedbVersion ``` 下载完成后,binary 文件 `greptime` 将存储在当前的目录中。 @@ -45,7 +45,7 @@ curl -fsSL \ docker run -p 127.0.0.1:4000-4003:4000-4003 \ -v "$(pwd)/greptimedb:/tmp/greptimedb" \ --name greptime --rm \ -greptime/greptimedb:v0.9.1 standalone start \ +greptime/greptimedb:VAR::greptimedbVersion standalone start \ --http-addr 0.0.0.0:4000 \ --rpc-addr 0.0.0.0:4001 \ --mysql-addr 0.0.0.0:4002 \ @@ -68,16 +68,16 @@ greptime/greptimedb:v0.9.1 standalone start \ 1. 设置 `--security-opt seccomp=unconfined`: - ```shell + ```shell docker run --security-opt seccomp=unconfined -p 4000-4003:4000-4003 \ -v "$(pwd)/greptimedb:/tmp/greptimedb" \ --name greptime --rm \ - greptime/greptimedb:v0.9.1 standalone start \ + greptime/greptimedb:VAR::greptimedbVersion standalone start \ --http-addr 0.0.0.0:4000 \ --rpc-addr 0.0.0.0:4001 \ --mysql-addr 0.0.0.0:4002 \ --postgres-addr 0.0.0.0:4003 - ``` + ``` 2. 将 Docker 版本升级到 v23.0.0 或更高; ::: @@ -110,7 +110,7 @@ GreptimeDB 默认绑定地址为 `127.0.0.1`。如果你需要能够接收来自 docker run -p 0.0.0.0:4000-4003:4000-4003 \ -v "$(pwd)/greptimedb:/tmp/greptimedb" \ --name greptime --rm \ -greptime/greptimedb:v0.9.1 standalone start \ +greptime/greptimedb:VAR::greptimedbVersion standalone start \ --http-addr 0.0.0.0:4000 \ --rpc-addr 0.0.0.0:4001 \ --mysql-addr 0.0.0.0:4002 \ diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/cluster.md b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/cluster.md index 78081fb14..51161d5e1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/cluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/cluster.md @@ -12,13 +12,13 @@ 1. 使用 MySQL cli 连接到 Frontend。 - ```shell + ```shell mysql -h 127.0.0.1 -P 4002 - ``` + ``` 2. 通过 `CREATE` 语句创建一个分布式表。 - ```SQL + ```SQL CREATE TABLE dist_table( ts TIMESTAMP DEFAULT current_timestamp(), n INT, @@ -32,11 +32,11 @@ n >= 9 ) engine=mito; - ``` + ``` 结果如下: - ```shell + ```shell mysql> CREATE TABLE dist_table( -> ts TIMESTAMP DEFAULT current_timestamp(), -> n INT, @@ -51,13 +51,13 @@ -> ) -> engine=mito; Query OK, 3 rows affected (0.09 sec) - ``` + ``` `dist_table` 被分布在 `Datanode` 中。你可以参考 ["Table Sharding"](/contributor-guide/frontend/table-sharding.md) 了解更多细节。 3. 通过 `INSERT` 语句输入一些数据。 - ```SQL + ```SQL INSERT INTO dist_table(n, row_id) VALUES (1, 1); INSERT INTO dist_table(n, row_id) VALUES (2, 2); INSERT INTO dist_table(n, row_id) VALUES (3, 3); @@ -70,15 +70,15 @@ INSERT INTO dist_table(n, row_id) VALUES (10, 10); INSERT INTO dist_table(n, row_id) VALUES (11, 11); INSERT INTO dist_table(n, row_id) VALUES (12, 12); - ``` + ``` 4. 通过 `SELECT` 语句执行查询: - ```sql + ```sql SELECT * FROM dist_table ORDER BY n LIMIT 5; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ @@ -89,39 +89,39 @@ | 2022-11-14 12:02:32 | 5 | 5 | +---------------------+------+--------+ 5 rows in set (0.081 sec) - ``` + ``` - ```sql + ```sql SELECT MAX(n) FROM dist_table; - ``` + ``` - ```sql + ```sql +-------------------+ | MAX(dist_table.n) | +-------------------+ | 12 | +-------------------+ 1 row in set (0.057 sec) - ``` + ``` - ```sql + ```sql SELECT MIN(n) FROM dist_table; - ``` + ``` - ```sql + ```sql +-------------------+ | MIN(dist_table.n) | +-------------------+ | 1 | +-------------------+ 1 row in set (0.079 sec) - ``` + ``` - ```sql + ```sql SELECT * FROM dist_table WHERE n > 2 AND n < 10 ORDER BY row_id; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ @@ -134,18 +134,18 @@ | 2022-11-14 12:02:32 | 9 | 9 | +---------------------+------+--------+ 7 rows in set (0.02 sec) - ``` + ``` - ```sql + ```sql SELECT * FROM dist_table WHERE row_id = 10; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ | 2022-11-14 12:02:32 | 10 | 10 | +---------------------+------+--------+ 1 row in set (0.03 sec) - ``` + ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/go.md b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/go.md index 467e15ce8..9760cf3f2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/go.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/go.md @@ -16,7 +16,7 @@ GreptimeDB 提供的 Go Ingest SDK 是一个轻量级、并发安全的库,使 使用下方的命令安装 Go Ingest SDK: ```shell -go get -u github.com/GreptimeTeam/greptimedb-ingester-go@v0.5.0 +go get -u github.com/GreptimeTeam/greptimedb-ingester-go@VAR::goSdkVersion ``` 引入到代码中: diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/java.md b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/java.md index c96b8e48d..f23486d32 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/java.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/java.md @@ -29,7 +29,7 @@ GreptimeDB 提供的 Java ingester SDK 是一个轻量级库,具有以下特 io.greptime ingester-all - 0.7.3 + VAR::javaSdkVersion ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/operations/configuration.md b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/operations/configuration.md index 4ec286820..3fa690ecd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/operations/configuration.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-0.9/user-guide/operations/configuration.md @@ -51,11 +51,11 @@ greptime standalone start -c standalone.example.toml 以下是每个 GreptimeDB 组件的示例配置文件,包括所有可用配置项。 在实际场景中,你只需要配置所需的选项,不需要像示例文件中那样配置所有选项。 -- [独立模式](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/standalone.example.toml) -- [前端](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/frontend.example.toml) -- [数据节点](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/datanode.example.toml) -- [流节点](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/flownode.example.toml) -- [元服务](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/metasrv.example.toml) +- [独立模式](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/standalone.example.toml) +- [前端](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/frontend.example.toml) +- [数据节点](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/datanode.example.toml) +- [流节点](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/flownode.example.toml) +- [元服务](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/metasrv.example.toml) ### 环境变量 diff --git a/versioned_docs/version-0.9/db-cloud-shared/tutorials/monitor-host-metrics/prometheus-demo.md b/versioned_docs/version-0.9/db-cloud-shared/tutorials/monitor-host-metrics/prometheus-demo.md index 3a934f5c6..286d3167c 100644 --- a/versioned_docs/version-0.9/db-cloud-shared/tutorials/monitor-host-metrics/prometheus-demo.md +++ b/versioned_docs/version-0.9/db-cloud-shared/tutorials/monitor-host-metrics/prometheus-demo.md @@ -11,7 +11,7 @@ To begin, create a new directory named `quick-start-prometheus` to host our proj ```yaml services: prometheus: - image: prom/prometheus:v2.52.0 + image: prom/prometheus:VAR::prometheusVersion container_name: prometheus depends_on: - node_exporter @@ -21,7 +21,7 @@ services: - ./prometheus-greptimedb.yml:/etc/prometheus/prometheus.yml:ro node_exporter: - image: quay.io/prometheus/node-exporter:v1.8.0 + image: quay.io/prometheus/node-exporter:VAR::nodeExporterVersion container_name: node_exporter ports: - 9100:9100 diff --git a/versioned_docs/version-0.9/getting-started/installation/greptimedb-cluster.md b/versioned_docs/version-0.9/getting-started/installation/greptimedb-cluster.md index a244b753d..2993ff752 100644 --- a/versioned_docs/version-0.9/getting-started/installation/greptimedb-cluster.md +++ b/versioned_docs/version-0.9/getting-started/installation/greptimedb-cluster.md @@ -11,13 +11,13 @@ Using Docker Compose is the easiest way to run the GreptimeDB cluster. Before st ### Step1: Download the YAML file for Docker Compose ``` -wget https://raw.githubusercontent.com/GreptimeTeam/greptimedb/v0.9.1/docker/docker-compose/cluster-with-etcd.yaml +wget https://raw.githubusercontent.com/GreptimeTeam/greptimedb/VAR::greptimedbVersion/docker/docker-compose/cluster-with-etcd.yaml ``` ### Step2: Start the cluster ``` -GREPTIMEDB_VERSION=v0.9.1 \ +GREPTIMEDB_VERSION=VAR::greptimedbVersion \ docker compose -f ./cluster-with-etcd.yaml up ``` diff --git a/versioned_docs/version-0.9/getting-started/installation/greptimedb-standalone.md b/versioned_docs/version-0.9/getting-started/installation/greptimedb-standalone.md index 140a99b48..85bd8f18c 100644 --- a/versioned_docs/version-0.9/getting-started/installation/greptimedb-standalone.md +++ b/versioned_docs/version-0.9/getting-started/installation/greptimedb-standalone.md @@ -14,7 +14,7 @@ For Linux and macOS users, you can download the latest build of the `greptime` b ```shell curl -fsSL \ - https://raw.githubusercontent.com/greptimeteam/greptimedb/main/scripts/install.sh | sh -s v0.9.1 + https://raw.githubusercontent.com/greptimeteam/greptimedb/main/scripts/install.sh | sh -s VAR::greptimedbVersion ``` Once the download is completed, the binary file `greptime` will be stored in your current directory. @@ -45,7 +45,7 @@ Make sure the [Docker](https://www.docker.com/) is already installed. If not, yo docker run -p 127.0.0.1:4000-4003:4000-4003 \ -v "$(pwd)/greptimedb:/tmp/greptimedb" \ --name greptime --rm \ -greptime/greptimedb:v0.9.1 standalone start \ +greptime/greptimedb:VAR::greptimedbVersion standalone start \ --http-addr 0.0.0.0:4000 \ --rpc-addr 0.0.0.0:4001 \ --mysql-addr 0.0.0.0:4002 \ @@ -68,16 +68,16 @@ You can: 1. Set `--security-opt seccomp=unconfined`, for example: - ```shell + ```shell docker run --security-opt seccomp=unconfined -p 4000-4003:4000-4003 \ -v "$(pwd)/greptimedb:/tmp/greptimedb" \ --name greptime --rm \ - greptime/greptimedb:v0.9.1 standalone start \ + greptime/greptimedb:VAR::greptimedbVersion standalone start \ --http-addr 0.0.0.0:4000 \ --rpc-addr 0.0.0.0:4001 \ --mysql-addr 0.0.0.0:4002 \ --postgres-addr 0.0.0.0:4003 - ``` + ``` 2. Upgrade the Docker version to v23.0.0 or higher; ::: @@ -110,7 +110,7 @@ If the computer running GreptimeDB is directly exposed to the internet, binding docker run -p 0.0.0.0:4000-4003:4000-4003 \ -v "$(pwd)/greptimedb:/tmp/greptimedb" \ --name greptime --rm \ -greptime/greptimedb:v0.9.1 standalone start \ +greptime/greptimedb:VAR::greptimedbVersion standalone start \ --http-addr 0.0.0.0:4000 \ --rpc-addr 0.0.0.0:4001 \ --mysql-addr 0.0.0.0:4002 \ diff --git a/versioned_docs/version-0.9/greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb.md b/versioned_docs/version-0.9/greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb.md index a2b5bb3de..3d5d65d31 100644 --- a/versioned_docs/version-0.9/greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb.md +++ b/versioned_docs/version-0.9/greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb.md @@ -21,7 +21,7 @@ curl -X POST 'https:///v1/influxdb/api/v2/write?bucket=' \ -H 'authorization: token ' \ -d 'census,location=klamath,scientist=anderson bees=23 1566086400000000000' ``` - +
@@ -30,7 +30,7 @@ curl -X POST 'https:///v1/influxdb/api/v2/write?bucket=' \ curl 'https:///v1/influxdb/write?db=&u=&p=' \ -d 'census,location=klamath,scientist=anderson bees=23 1566086400000000000' ``` - + @@ -52,7 +52,7 @@ curl 'https:///v1/influxdb/write?db=&u=&p= @@ -64,7 +64,7 @@ curl 'https:///v1/influxdb/write?db=&u=&p= @@ -75,6 +75,8 @@ curl 'https:///v1/influxdb/write?db=&u=&p= + + ```js 'use strict' /** @module write @@ -97,11 +99,12 @@ const point1 = new Point('temperature') writeApi.writePoint(point1) ``` - + + - + ```python import influxdb_client @@ -128,7 +131,7 @@ write_api.write(bucket=bucket, org=org, record=p) - + ```go bucket := "" @@ -149,7 +152,7 @@ client.Close() - + ```java private static String url = "https:///v1/influxdb"; @@ -173,7 +176,7 @@ public static void main(final String[] args) { - + ```php $client = new Client([ diff --git a/versioned_docs/version-0.9/reference/sql/cast.md b/versioned_docs/version-0.9/reference/sql/cast.md index 6e9b33d0f..357d1918b 100644 --- a/versioned_docs/version-0.9/reference/sql/cast.md +++ b/versioned_docs/version-0.9/reference/sql/cast.md @@ -17,9 +17,9 @@ CAST (expression AS data_type) Convert a string to an integer: - ```sql +```sql SELECT CAST('123' AS INT) ; - ``` +``` ```sql +-------------+ diff --git a/versioned_docs/version-0.9/reference/sql/range.md b/versioned_docs/version-0.9/reference/sql/range.md index 26050e8b6..e8d5e93d6 100644 --- a/versioned_docs/version-0.9/reference/sql/range.md +++ b/versioned_docs/version-0.9/reference/sql/range.md @@ -168,7 +168,7 @@ The result of each `FILL` option is as follows: -```sql +```sql [FILL Constant Value 6.0] > SELECT ts, host, min(val) RANGE '5s' FILL 6 FROM host ALIGN '5s'; @@ -188,6 +188,8 @@ The result of each `FILL` option is as follows: + + If there are multiple Range expressions but only one of them specifies the `Fill` option, the other Range expressions will use the `FILL NULL` method to fill in the missing time slots. diff --git a/versioned_docs/version-0.9/user-guide/cluster.md b/versioned_docs/version-0.9/user-guide/cluster.md index c46924e05..95acd6d0d 100644 --- a/versioned_docs/version-0.9/user-guide/cluster.md +++ b/versioned_docs/version-0.9/user-guide/cluster.md @@ -12,13 +12,13 @@ You can follow the steps to use SQL to play with distributed insertions and quer 1. Use MySQL cli to connect to Frontend. - ```shell + ```shell mysql -h 127.0.0.1 -P 4002 - ``` + ``` 2. Create a distributed table via `CREATE` statement. - ```SQL + ```SQL CREATE TABLE dist_table( ts TIMESTAMP DEFAULT current_timestamp(), n INT, @@ -32,11 +32,11 @@ You can follow the steps to use SQL to play with distributed insertions and quer n >= 9 ) engine=mito; - ``` + ``` The result looks like the following: - ```shell + ```shell mysql> CREATE TABLE dist_table( -> ts TIMESTAMP DEFAULT current_timestamp(), -> n INT, @@ -51,13 +51,13 @@ You can follow the steps to use SQL to play with distributed insertions and quer -> ) -> engine=mito; Query OK, 3 rows affected (0.09 sec) - ``` + ``` The `dist_table` is distributed among the `Datanode`s. You can refer to ["Table Sharding"](/contributor-guide/frontend/table-sharding.md) for more details. 3. Insert some data via `INSERT` statement. - ```SQL + ```SQL INSERT INTO dist_table(n, row_id) VALUES (1, 1); INSERT INTO dist_table(n, row_id) VALUES (2, 2); INSERT INTO dist_table(n, row_id) VALUES (3, 3); @@ -70,15 +70,15 @@ You can follow the steps to use SQL to play with distributed insertions and quer INSERT INTO dist_table(n, row_id) VALUES (10, 10); INSERT INTO dist_table(n, row_id) VALUES (11, 11); INSERT INTO dist_table(n, row_id) VALUES (12, 12); - ``` + ``` 4. Execute some queries via `SELECT` statement: - ```sql + ```sql SELECT * FROM dist_table ORDER BY n LIMIT 5; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ @@ -89,39 +89,39 @@ You can follow the steps to use SQL to play with distributed insertions and quer | 2022-11-14 12:02:32 | 5 | 5 | +---------------------+------+--------+ 5 rows in set (0.081 sec) - ``` + ``` - ```sql + ```sql SELECT MAX(n) FROM dist_table; - ``` + ``` - ```sql + ```sql +-------------------+ | MAX(dist_table.n) | +-------------------+ | 12 | +-------------------+ 1 row in set (0.057 sec) - ``` + ``` - ```sql + ```sql SELECT MIN(n) FROM dist_table; - ``` + ``` - ```sql + ```sql +-------------------+ | MIN(dist_table.n) | +-------------------+ | 1 | +-------------------+ 1 row in set (0.079 sec) - ``` + ``` - ```sql + ```sql SELECT * FROM dist_table WHERE n > 2 AND n < 10 ORDER BY row_id; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ @@ -134,17 +134,17 @@ You can follow the steps to use SQL to play with distributed insertions and quer | 2022-11-14 12:02:32 | 9 | 9 | +---------------------+------+--------+ 7 rows in set (0.02 sec) - ``` + ``` - ```sql + ```sql SELECT * FROM dist_table WHERE row_id = 10; - ``` + ``` - ```sql + ```sql +---------------------+------+--------+ | ts | n | row_id | +---------------------+------+--------+ | 2022-11-14 12:02:32 | 10 | 10 | +---------------------+------+--------+ 1 row in set (0.03 sec) - ``` + ``` diff --git a/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/go.md b/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/go.md index f0cf39dd8..c5c7e6516 100644 --- a/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/go.md +++ b/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/go.md @@ -17,7 +17,7 @@ concurrent-safe library that is easy to use with the metric struct. Use the following command to install the GreptimeDB client library for Go: ```shell -go get -u github.com/GreptimeTeam/greptimedb-ingester-go@v0.5.0 +go get -u github.com/GreptimeTeam/greptimedb-ingester-go@VAR::goSdkVersion ``` Import the library in your code: diff --git a/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/java.md b/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/java.md index 1a23f1398..7d75dcf41 100644 --- a/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/java.md +++ b/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/java.md @@ -31,7 +31,7 @@ dependencies list: io.greptime ingester-all - 0.7.3 + VAR::javaSdkVersion ``` diff --git a/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/template.md b/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/template.md index 73c7519a0..e8d6069f6 100644 --- a/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/template.md +++ b/versioned_docs/version-0.9/user-guide/ingest-data/for-iot/grpc-sdks/template.md @@ -125,3 +125,4 @@ The following example shows how to use raw SQL to query data. For more information about how to use the query library, please see the documentation of the corresponding library: --> + diff --git a/versioned_docs/version-0.9/user-guide/migrate-to-greptimedb/migrate-from-influxdb.md b/versioned_docs/version-0.9/user-guide/migrate-to-greptimedb/migrate-from-influxdb.md index 911be01d0..00381c4e3 100644 --- a/versioned_docs/version-0.9/user-guide/migrate-to-greptimedb/migrate-from-influxdb.md +++ b/versioned_docs/version-0.9/user-guide/migrate-to-greptimedb/migrate-from-influxdb.md @@ -42,7 +42,7 @@ For detailed configuration instructions, please refer to the [Ingest Data via Te -```js +```js [Node.js] 'use strict' /** @module write **/ @@ -67,7 +67,6 @@ writeApi.writePoint(point1) - ```python diff --git a/versioned_docs/version-0.9/user-guide/operations/configuration.md b/versioned_docs/version-0.9/user-guide/operations/configuration.md index 9a6ede26c..7a1d5439c 100644 --- a/versioned_docs/version-0.9/user-guide/operations/configuration.md +++ b/versioned_docs/version-0.9/user-guide/operations/configuration.md @@ -54,11 +54,11 @@ including all available configurations. In actual scenarios, you only need to configure the required options and do not need to configure all options as in the sample file. -- [standalone](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/standalone.example.toml) -- [frontend](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/frontend.example.toml) -- [datanode](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/datanode.example.toml) -- [flownode](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/flownode.example.toml) -- [metasrv](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/metasrv.example.toml) +- [standalone](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/standalone.example.toml) +- [frontend](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/frontend.example.toml) +- [datanode](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/datanode.example.toml) +- [flownode](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/flownode.example.toml) +- [metasrv](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/metasrv.example.toml) ### Environment variable @@ -98,7 +98,7 @@ GREPTIMEDB_METASRV__META_CLIENT__METASRV_ADDRS=127.0.0.1:3001,127.0.0.1:3002,127 ## Options In this section, we will introduce some main configuration options. -For all options, refer to the [Configuration Reference](https://github.com/GreptimeTeam/greptimedb/blob/v0.9.1/config/config.md) on Github. +For all options, refer to the [Configuration Reference](https://github.com/GreptimeTeam/greptimedb/blob/VAR::greptimedbVersion/config/config.md) on Github. ### Protocol options diff --git a/versioned_docs/version-0.9/user-guide/operations/disaster-recovery/dr-solution-based-on-cross-region-deployment-in-single-cluster.md b/versioned_docs/version-0.9/user-guide/operations/disaster-recovery/dr-solution-based-on-cross-region-deployment-in-single-cluster.md index bb99cd796..b4efaac7d 100644 --- a/versioned_docs/version-0.9/user-guide/operations/disaster-recovery/dr-solution-based-on-cross-region-deployment-in-single-cluster.md +++ b/versioned_docs/version-0.9/user-guide/operations/disaster-recovery/dr-solution-based-on-cross-region-deployment-in-single-cluster.md @@ -118,4 +118,4 @@ Here is the content formatted into a table: | Metadata across 2 regions, data in the same region | - 2ms latency in the same region
- 30ms latency in two regions | - A single AZ is unavailable with the same performance
- A single DC is unavailable with almost the same performance | | Data across 2 regions | - 2ms latency in the same region
- 30ms latency in two regions | - A single AZ is unavailable with the same performance
- A single DC is unavailable with degraded performance | | Metadata across 3 regions, data across 2 regions | - 2ms latency in the same region
- 7ms latency in two adjacent regions
- 30ms latency in two distant regions | - A single AZ is unavailable with the same performance
- A single DC is unavailable with the same performance
- A single region(city) is unavailable with slightly degraded performance | -| Data across 3 regions | - 2ms latency in the same region
- 7ms latency in two adjacent regions
- 30ms latency in two distant regions | - A single AZ is unavailable with the same performance
- A single DC is unavailable with the same performance
- A single region(city) is unavailable with degraded performance | +| Data across 3 regions | - 2ms latency in the same region
- 7ms latency in two adjacent regions
- 30ms latency in two distant regions | - A single AZ is unavailable with the same performance
- A single DC is unavailable with the same performance
- A single region(city) is unavailable with degraded performance | diff --git a/versioned_sidebars/version-0.9-sidebars.json b/versioned_sidebars/version-0.9-sidebars.json index e899765f2..68e04b85a 100644 --- a/versioned_sidebars/version-0.9-sidebars.json +++ b/versioned_sidebars/version-0.9-sidebars.json @@ -91,7 +91,13 @@ "user-guide/query-data/query-external-data" ] }, - { "type": "category", "label": "Manage Data", "items": ["user-guide/manage-data/overview"] }, + { + "type": "category", + "label": "Manage Data", + "items": [ + "user-guide/manage-data/overview" + ] + }, { "type": "category", "label": "Clients", @@ -110,7 +116,13 @@ "user-guide/clients/emqx" ] }, - { "type": "category", "label": "Migrate to GreptimeDB", "items": ["user-guide/migrate-to-greptimedb/migrate-from-influxdb"] }, + { + "type": "category", + "label": "Migrate to GreptimeDB", + "items": [ + "user-guide/migrate-to-greptimedb/migrate-from-influxdb" + ] + }, { "type": "category", "label": "Continuous Aggregation", @@ -168,7 +180,10 @@ { "type": "category", "label": "Remote WAL", - "items": ["user-guide/operations/remote-wal/quick-start", "user-guide/operations/remote-wal/cluster-deployment"] + "items": [ + "user-guide/operations/remote-wal/quick-start", + "user-guide/operations/remote-wal/cluster-deployment" + ] }, "user-guide/operations/region-migration", "user-guide/operations/region-failover", @@ -207,7 +222,10 @@ { "type": "category", "label": "Prometheus", - "items": ["greptimecloud/integrations/prometheus/quick-setup", "greptimecloud/integrations/prometheus/rule-management"] + "items": [ + "greptimecloud/integrations/prometheus/quick-setup", + "greptimecloud/integrations/prometheus/rule-management" + ] }, "greptimecloud/integrations/grafana", "greptimecloud/integrations/mysql", @@ -221,11 +239,20 @@ { "type": "category", "label": "SDK Libraries", - "items": ["greptimecloud/integrations/sdk-libraries/go", "greptimecloud/integrations/sdk-libraries/java"] + "items": [ + "greptimecloud/integrations/sdk-libraries/go", + "greptimecloud/integrations/sdk-libraries/java" + ] } ] }, - { "type": "category", "label": "Migrate to GreptimeCloud", "items": ["greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb"] }, + { + "type": "category", + "label": "Migrate to GreptimeCloud", + "items": [ + "greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb" + ] + }, { "type": "category", "label": "Usage & Billing", @@ -293,7 +320,14 @@ "reference/sql/with", "reference/sql/alter", "reference/sql/explain", - { "type": "category", "label": "Functions", "items": ["reference/sql/functions/overview", "reference/sql/functions/df-functions"] }, + { + "type": "category", + "label": "Functions", + "items": [ + "reference/sql/functions/overview", + "reference/sql/functions/df-functions" + ] + }, "reference/sql/compatibility", { "type": "category", @@ -365,7 +399,11 @@ { "type": "category", "label": "Flownode", - "items": ["contributor-guide/flownode/overview", "contributor-guide/flownode/dataflow", "contributor-guide/flownode/arrangement"] + "items": [ + "contributor-guide/flownode/overview", + "contributor-guide/flownode/dataflow", + "contributor-guide/flownode/arrangement" + ] }, { "type": "category", @@ -393,6 +431,13 @@ "label": "Release Notes", "href": "/release-notes" }, - { "type": "category", "label": "FAQ and Others", "items": ["faq-and-others/overview", "faq-and-others/faq"] } + { + "type": "category", + "label": "FAQ and Others", + "items": [ + "faq-and-others/overview", + "faq-and-others/faq" + ] + } ] }