diff --git a/README-CN.md b/README-CN.md index b86e2d83b5d1e45d3b07796418116ed8d4e6f33a..e29495fdd0278ef4d1814a9f528cbed5fae1758b 100644 --- a/README-CN.md +++ b/README-CN.md @@ -126,7 +126,7 @@ sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfi 注意:由于 snappy 缺乏 pkg-config 支持 (参考 [链接](https://github.com/google/snappy/pull/86)),会导致 - cmake 提示无法发现 libsnappy,实际上工作正常。 +cmake 提示无法发现 libsnappy,实际上工作正常。 ## 获取源码 @@ -229,13 +229,17 @@ cmake .. && cmake --build . # 安装 -生成完成后,安装 TDengine(下文给出的指令以 Linux 为例,如果是在 Windows 下,那么对应的指令会是 `nmake install`): +## Linux 系统 + +生成完成后,安装 TDengine: ```bash sudo make install ``` 用户可以在[文件目录结构](https://www.taosdata.com/cn/documentation/administrator#directories)中了解更多在操作系统中生成的目录或文件。 +从 2.0 版本开始, 从源代码安装也会为 TDengine 配置服务管理。 +用户也可以选择[从安装包中安装](https://www.taosdata.com/en/getting-started/#Install-from-Package)。 安装成功后,在终端中启动 TDengine 服务: @@ -251,6 +255,40 @@ taos 如果 TDengine Shell 连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印出错误消息。 +## Windows 系统 + +生成完成后,安装 TDengine: + +```cmd +nmake install +``` + +## macOS 系统 + +生成完成后,安装 TDengine: + +```bash +sudo make install +``` + +安装成功后,如果想以服务形式启动,先配置 `.plist` 文件,在终端中执行: + +```bash +sudo cp ../packaging/macOS/com.taosdata.tdengine.plist /Library/LaunchDaemons +``` + +在终端中启动 TDengine 服务: + +```bash +sudo launchctl load /Library/LaunchDaemons/com.taosdata.tdengine.plist +``` + +在终端中停止 TDengine 服务: + +```bash +sudo launchctl unload /Library/LaunchDaemons/com.taosdata.tdengine.plist +``` + ## 快速运行 如果不希望以服务方式运行 TDengine,也可以在终端中直接运行它。也即在生成完成后,执行以下命令(在 Windows 下,生成的可执行文件会带有 .exe 后缀,例如会名为 taosd.exe ): @@ -271,7 +309,7 @@ taos 在 TDengine 终端中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行插入查询操作。 -```bash +```sql CREATE DATABASE demo; USE demo; CREATE TABLE t (ts TIMESTAMP, speed INT); @@ -325,8 +363,8 @@ TDengine 的测试框架和所有测试例全部开源。 # 加入技术交流群 -TDengine 官方社群「物联网大数据群」对外开放,欢迎您加入讨论。搜索微信号 "tdengine",加小T为好友,即可入群。 +TDengine 官方社群「物联网大数据群」对外开放,欢迎您加入讨论。搜索微信号 "tdengine",加小 T 为好友,即可入群。 -# [谁在使用TDengine](https://github.com/taosdata/TDengine/issues/2432) +# [谁在使用 TDengine](https://github.com/taosdata/TDengine/issues/2432) 欢迎所有 TDengine 用户及贡献者在 [这里](https://github.com/taosdata/TDengine/issues/2432) 分享您在当前工作中开发/使用 TDengine 的故事。 diff --git a/README.md b/README.md index 204dc98725fbf37b96d1273036b8bb8dc3716fb4..07d70c2dd133f2864de7fab35eb0daaed20f38ce 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ TDengine can be widely applied to Internet of Things (IoT), Connected Vehicles, # Documentation For user manual, system design and architecture, engineering blogs, refer to [TDengine Documentation](https://www.taosdata.com/en/documentation/)(中文版请点击[这里](https://www.taosdata.com/cn/documentation20/)) - for details. The documentation from our website can also be downloaded locally from *documentation/tdenginedocs-en* or *documentation/tdenginedocs-cn*. +for details. The documentation from our website can also be downloaded locally from _documentation/tdenginedocs-en_ or _documentation/tdenginedocs-cn_. # Building @@ -258,7 +258,9 @@ cmake .. && cmake --build . # Installing -After building successfully, TDengine can be installed by: (On Windows platform, the following command should be `nmake install`) +## On Linux platform + +After building successfully, TDengine can be installed by ```bash sudo make install @@ -281,7 +283,7 @@ taos If TDengine shell connects the server successfully, welcome messages and version info are printed. Otherwise, an error message is shown. -## Install TDengine by apt-get +### Install TDengine by apt-get If you use Debian or Ubuntu system, you can use 'apt-get' command to install TDengine from official repository. Please use following commands to setup: @@ -294,6 +296,40 @@ apt-cache policy tdengine sudo apt-get install tdengine ``` +## On Windows platform + +After building successfully, TDengine can be installed by: + +```cmd +nmake install +``` + +## On macOS platform + +After building successfully, TDengine can be installed by: + +```bash +sudo make install +``` + +To start the service after installation, config `.plist` file first, in a terminal, use: + +```bash +sudo cp ../packaging/macOS/com.taosdata.tdengine.plist /Library/LaunchDaemons +``` + +To start the service, in a terminal, use: + +```bash +sudo launchctl load /Library/LaunchDaemons/com.taosdata.tdengine.plist +``` + +To stop the service, in a terminal, use: + +```bash +sudo launchctl unload /Library/LaunchDaemons/com.taosdata.tdengine.plist +``` + ## Quick Run If you don't want to run TDengine as a service, you can run it in current shell. For example, to quickly start a TDengine server after building, run the command below in terminal: (We take Linux as an example, command on Windows will be `taosd.exe`) @@ -315,13 +351,17 @@ option "-c test/cfg" specifies the system configuration file directory. It is easy to run SQL commands from TDengine shell which is the same as other SQL databases. ```sql -create database db; -use db; -create table t (ts timestamp, a int); -insert into t values ('2019-07-15 00:00:00', 1); -insert into t values ('2019-07-15 01:00:00', 2); -select * from t; -drop database db; +CREATE DATABASE demo; +USE demo; +CREATE TABLE t (ts TIMESTAMP, speed INT); +INSERT INTO t VALUES('2019-07-15 00:00:00', 10); +INSERT INTO t VALUES('2019-07-15 01:00:00', 20); +SELECT * FROM t; + ts | speed | +=================================== + 19-07-15 00:00:00.000| 10| + 19-07-15 01:00:00.000| 20| +Query OK, 2 row(s) in set (0.001700s) ``` # Developing with TDengine @@ -348,8 +388,8 @@ The TDengine community has also kindly built some of their own connectors! Follo # How to run the test cases and how to add a new test case - TDengine's test framework and all test cases are fully open source. - Please refer to [this document](https://github.com/taosdata/TDengine/blob/develop/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md) for how to run test and develop new test case. +TDengine's test framework and all test cases are fully open source. +Please refer to [this document](https://github.com/taosdata/TDengine/blob/develop/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md) for how to run test and develop new test case. # TDengine Roadmap diff --git a/alert/README.md b/alert/README.md index b8b8c92a2797bf58ca9f80b1781fc1f5d7555f6b..8567c3b1671197d8878385b30a79ab077ea1c354 100644 --- a/alert/README.md +++ b/alert/README.md @@ -1,6 +1,6 @@ # Alert -The Alert application reads data from [TDEngine](https://www.taosdata.com/), calculating according to predefined rules to generate alerts, and pushes alerts to downstream applications like [AlertManager](https://github.com/prometheus/alertmanager). +The Alert application reads data from [TDengine](https://www.taosdata.com/), calculating according to predefined rules to generate alerts, and pushes alerts to downstream applications like [AlertManager](https://github.com/prometheus/alertmanager). ## Install @@ -22,7 +22,7 @@ $ ./install_driver.sh Two prerequisites are required to install from source. -1. TDEngine server or client must be installed. +1. TDengine server or client must be installed. 2. Latest [Go](https://golang.org) language must be installed. When these two prerequisites are ready, please follow steps below to build the application: @@ -61,13 +61,13 @@ The use of each configuration item is: * **port**: This is the `http` service port which enables other application to manage rules by `restful API`. * **database**: rules are stored in a `sqlite` database, this is the path of the database file (if the file does not exist, the alert application creates it automatically). -* **tdengine**: connection string of `TDEngine` server (please refer the documentation of GO connector for the detailed format of this string), note the database name should be put in the `sql` field of a rule in most cases, thus it should NOT be included in the string. +* **tdengine**: connection string of `TDengine` server (please refer the documentation of GO connector for the detailed format of this string), note the database name should be put in the `sql` field of a rule in most cases, thus it should NOT be included in the string. * **log > level**: log level, could be `production` or `debug`. * **log > path**: log output file path. * **receivers > alertManager**: the alert application pushes alerts to `AlertManager` at this URL. * **receivers > console**: print out alerts to console (stdout) or not. -When the configruation file is ready, the alert application can be started with below command (`alert.cfg` is the path of the configuration file): +When the configuration file is ready, the alert application can be started with below command (`alert.cfg` is the path of the configuration file): ``` $ ./alert -cfg alert.cfg @@ -75,7 +75,7 @@ $ ./alert -cfg alert.cfg ## Prepare an alert rule -From technical aspect, an alert could be defined as: query and filter recent data from `TDEngine`, and calculating out a boolean value from these data according to a formula, and trigger an alert if the boolean value last for a certain duration. +From technical aspect, an alert could be defined as: query and filter recent data from `TDengine`, and calculating out a boolean value from these data according to a formula, and trigger an alert if the boolean value last for a certain duration. This is a rule example in `json` format: @@ -98,8 +98,8 @@ This is a rule example in `json` format: The fields of the rule is explained below: * **name**: the name of the rule, must be unique. -* **sql**: this is the `sql` statement used to query data from `TDEngine`, columns of the query result are used in later processing, so please give the column an alias if aggregation functions are used. -* **expr**: an expression whose result is a boolean value, arithmatic and logical calculations can be included in the expression, and builtin functions (see below) are also supported. Alerts are only triggered when the expression evaluates to `true`. +* **sql**: this is the `sql` statement used to query data from `TDengine`, columns of the query result are used in later processing, so please give the column an alias if aggregation functions are used. +* **expr**: an expression whose result is a boolean value, arithmetic and logical calculations can be included in the expression, and builtin functions (see below) are also supported. Alerts are only triggered when the expression evaluates to `true`. * **for**: this item is a duration which default value is zero second. when `expr` evaluates to `true` and last at least this duration, an alert is triggered. * **period**: the interval for the alert application to check the rule, default is 1 minute. * **labels**: a label list, labels are used to generate alert information. note if the `sql` statement includes a `group by` clause, the `group by` columns are inserted into this list automatically. diff --git a/alert/README_cn.md b/alert/README_cn.md index f659e997e3ea8ec8acef8cc3eb6e41a4c692a476..cc9907f32c3c765472d3fe59f32067beab543e88 100644 --- a/alert/README_cn.md +++ b/alert/README_cn.md @@ -1,6 +1,6 @@ # Alert -报警监测程序,从 [TDEngine](https://www.taosdata.com/) 读取数据后,根据预定义的规则计算和生成报警,并将它们推送到 [AlertManager](https://github.com/prometheus/alertmanager) 或其它下游应用。 +报警监测程序,从 [TDengine](https://www.taosdata.com/) 读取数据后,根据预定义的规则计算和生成报警,并将它们推送到 [AlertManager](https://github.com/prometheus/alertmanager) 或其它下游应用。 ## 安装 @@ -20,7 +20,7 @@ $ ./install_driver.sh ### 从源码安装 -从源码安装需要在您用于编译的计算机上提前安装好 TDEngine 的服务端或客户端,如果您还没有安装,可以参考 TDEngine 的文档。 +从源码安装需要在您用于编译的计算机上提前安装好 TDengine 的服务端或客户端,如果您还没有安装,可以参考 TDengine 的文档。 报警监测程序使用 [Go语言](https://golang.org) 开发,请安装最新版的 Go 语言编译环境。 @@ -58,7 +58,7 @@ $ go build * **port**:报警监测程序支持使用 `restful API` 对规则进行管理,这个参数用于配置 `http` 服务的侦听端口。 * **database**:报警监测程序将规则保存到了一个 `sqlite` 数据库中,这个参数用于指定数据库文件的路径(不需要提前创建这个文件,如果它不存在,程序会自动创建它)。 -* **tdengine**:`TDEngine` 的连接字符串(这个字符串的详细格式说明请见 GO 连接器的文档),一般来说,数据库名应该在报警规则的 `sql` 语句中指定,所以这个字符串中 **不** 应包含数据库名。 +* **tdengine**:`TDengine` 的连接字符串(这个字符串的详细格式说明请见 GO 连接器的文档),一般来说,数据库名应该在报警规则的 `sql` 语句中指定,所以这个字符串中 **不** 应包含数据库名。 * **log > level**:日志的记录级别,可选 `production` 或 `debug`。 * **log > path**:日志文件的路径。 * **receivers > alertManager**:报警监测程序会将报警推送到 `AlertManager`,在这里指定 `AlertManager` 的接收地址。 @@ -72,7 +72,7 @@ $ ./alert -cfg alert.cfg ## 编写报警规则 -从技术角度,可以将报警描述为:从 `TDEngine` 中查询最近一段时间、符合一定过滤条件的数据,并基于这些数据根据定义好的计算方法得出一个结果,当结果符合某个条件且持续一定时间后,触发报警。 +从技术角度,可以将报警描述为:从 `TDengine` 中查询最近一段时间、符合一定过滤条件的数据,并基于这些数据根据定义好的计算方法得出一个结果,当结果符合某个条件且持续一定时间后,触发报警。 根据上面的描述,可以很容易的知道报警规则中需要包含的大部分信息。 以下是一个完整的报警规则,采用标准 `json` 格式: @@ -95,7 +95,7 @@ $ ./alert -cfg alert.cfg 其中: * **name**:用于为规则指定一个唯一的名字。 -* **sql**:从 `TDEngine` 中查询数据时使用的 `sql` 语句,查询结果中的列将被后续计算使用,所以,如果使用了聚合函数,请为这一列指定一个别名。 +* **sql**:从 `TDengine` 中查询数据时使用的 `sql` 语句,查询结果中的列将被后续计算使用,所以,如果使用了聚合函数,请为这一列指定一个别名。 * **expr**:一个计算结果为布尔型的表达式,支持算数运算、逻辑运算,并且内置了部分函数,也可以引用查询结果中的列。 当表达式计算结果为 `true` 时,进入报警状态。 * **for**:当表达式计算结果为 `true` 的连续时长超过这个选项时,触发报警,否则报警处于“待定”状态。默认为0,表示一旦计算结果为 `true`,立即触发报警。 * **period**:规则的检查周期,默认1分钟。 diff --git a/docs-cn/01-intro/01-intro.md b/docs-cn/01-intro/01-intro.md index 7d807be15eefb5acb1350330d557f91805bd1898..492f729fb41626e28b85d48d19fbd8b1fc35daf5 100644 --- a/docs-cn/01-intro/01-intro.md +++ b/docs-cn/01-intro/01-intro.md @@ -4,36 +4,71 @@ title: 产品简介 toc_max_heading_level: 2 --- -## TDengine 简介 +## TDengine 主要功能 -TDengine 是一款高性能、分布式、支持 SQL 的时序数据库。而且除时序数据库功能外,它还提供[缓存](/develop/cache/)、数据订阅、流式计算等功能,最大程度减少研发和运维的复杂度,且核心代码,包括集群功能全部开源(开源协议,AGPL v3.0)。与其他时序数据数据库相比,TDengine 有以下特点: +TDengine 是一款高性能、分布式、支持 SQL 的时序数据库,其核心代码,包括集群功能全部开源(开源协议,AGPL v3.0)。TDengine 能被广泛运用于物联网、工业互联网、车联网、IT 运维、金融等领域。除核心的时序数据库功能外,TDengine 还提供[缓存](/develop/cache/)、[数据订阅](/develop/subscribe)、[流式计算](/develop/continuous-query)等大数据平台所需要的系列功能,最大程度减少研发和运维的复杂度。主要功能如下: -- **高性能**:通过创新的存储引擎设计,无论是数据写入还是查询,TDengine 的性能比通用数据库快 10 倍以上,也远超其他时序数据库,而且存储空间也大为节省。 +1. 高速数据写入,除 [SQL 写入](/develop/insert-data/sql-writing)外,还支持 [Schemaless 写入](/reference/schemaless/),支持 [InfluxDB LINE 协议](/develop/insert-data/influxdb-line),[OpenTSDB Telnet](/develop/insert-data/opentsdb-telnet), [OpenTSDB JSON ](/develop/insert-data/opentsdb-json)等协议写入; +2. 第三方数据采集工具 [Telegraf](/third-party/telegraf),[Prometheus](/third-party/prometheus),[StatsD](/third-party/statsd),[collectd](/third-party/collectd),[icinga2](/third-party/icinga2), [Tcollector](/third-party/tcollector), [EMQ](/third-party/emq-broker), [HiveMQ](/third-party/hive-mq-broker) 等都可以进行配置后,不用任何代码,即可将数据写入; +3. 支持[各种查询](/query-data),包括聚合查询、嵌套查询、降采样查询、插值等 +4. 支持[用户自定义函数](/develop/udf) +5. 支持[缓存](/develop/cache),将每张表的最后一条记录缓存起来,这样无需 Redis +6. 支持[连续查询](/develop/continuous-query)(Continuous Query) +7. 支持[数据订阅](/develop/subscribe),而且可以指定过滤条件 +8. 支持[集群](/cluster/),可以通过多节点进行水平扩展,并通过多副本实现高可靠 +9. 提供[命令行程序](/reference/taos-shell),便于管理集群,检查系统状态,做即席查询 +10. 提供多种数据的[导入](/operation/import)、[导出](/operation/export) +11. 支持对[TDengine 集群本身的监控](/operation/monitor) +12. 提供 [C/C++](/reference/connector/cpp), [Java](/reference/connector/java), [Python](/reference/connector/python), [Go](/reference/connector/go), [Rust](/reference/connector/rust), [Node.js](/reference/connector/node) 等多种编程语言的[连接器](/reference/connector/) +13. 支持 [REST 接口](/reference/rest-api/) +14. 支持与[ Grafana 无缝集成](/third-party/grafana) +15. 支持与 Google Data Studio 无缝集成 -- **分布式**:通过原生分布式的设计,TDengine 提供了水平扩展的能力,只需要增加节点就能获得更强的数据处理能力,同时通过多副本机制保证了系统的高可用。 +更多细小的功能,请阅读整个文档。 -- **支持 SQL**:TDengine 采用 SQL 作为数据查询语言,减少学习和迁移成本,同时提供 SQL 扩展来处理时序数据特有的分析,而且支持方便灵活的 schemaless 数据写入。 +## TDengine 主要亮点 + +由于 TDengine 充分利用了[时序数据特点](https://www.taosdata.com/blog/2019/07/09/105.html),比如结构化、无需事务、很少删除或更新、写多读少等等,设计了全新的针对时序数据的存储引擎和计算引擎,因此与其他时序数据库相比,TDengine 有以下特点: + +- **[高性能](https://www.taosdata.com/fast)**:通过创新的存储引擎设计,无论是数据写入还是查询,TDengine 的性能比通用数据库快 10 倍以上,也远超其他时序数据库,而且存储空间也大为节省。 + +- **[分布式](https://www.taosdata.com/scalable)**:通过原生分布式的设计,TDengine 提供了水平扩展的能力,只需要增加节点就能获得更强的数据处理能力,同时通过多副本机制保证了系统的高可用。 + +- **[支持 SQL](https://www.taosdata.com/sql-support)**:TDengine 采用 SQL 作为数据查询语言,减少学习和迁移成本,同时提供 SQL 扩展来处理时序数据特有的分析,而且支持方便灵活的 schemaless 数据写入。 - **All in One**:将数据库、消息队列、缓存、流式计算等功能融合一起,应用无需再集成 Kafka/Redis/HBase/Spark 等软件,大幅降低应用开发和维护成本。 - **零管理**:安装、集群几秒搞定,无任何依赖,不用分库分表,系统运行状态监测能与 Grafana 或其他运维工具无缝集成。 -- **零学习成本**:采用 SQL 查询语言,支持 Python, Java, C/C++, Go, Rust, Node.js 等多种编程语言,与 MySQL 相似,零学习成本。 +- **零学习成本**:采用 SQL 查询语言,支持 C/C++、Python、Java、Go、Rust、Node.js、C#、Lua(社区贡献)、PHP(社区贡献) 等多种编程语言,与 MySQL 相似,零学习成本。 -- **无缝集成**:不用一行代码,即可与 Telegraf, Grafana, EMQX, Prometheus, StatsD, collectd, Matlab, R 等第三方工具无缝集成。 +- **无缝集成**:不用一行代码,即可与 Telegraf、Grafana、Prometheus、EMQX、HiveMQ、StatsD、collectd、icinga、TCollector、Matlab、R 等第三方工具无缝集成。 - **互动 Console**: 通过命令行 console,不用编程,执行 SQL 语句就能做即席查询、各种数据库的操作、管理以及集群的维护. -采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。表现在几个方面,1:由于其超强性能,它能将系统需要的计算资源和存储资源大幅降低;2:因为采用SQL接口,能与众多第三放软件无缝集成,学习迁移成本大幅下降;3:因为其All In One的特性,系统复杂度降低,能降研发成本;4:因为运维维护简单,运营维护成本能大幅降低。 +采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。表现在几个方面: + +1. 由于其超强性能,它能将系统需要的计算资源和存储资源大幅降低 +2. 因为采用 SQL 接口,能与众多第三放软件无缝集成,学习迁移成本大幅下降 +3. 因为其 All In One 的特性,系统复杂度降低,能降研发成本 +4. 因为运维维护简单,运营维护成本能大幅降低 + +## TDengine 技术生态 + +在整个时序大数据平台中,TDengine 在其中扮演的角色如下: + +
-在整个时序大数据平台中,TDengine在其中扮演的角色如下: ![TDengine技术生态图](eco_system.png) +
图 1. TDengine技术生态图
+上图中,左侧是各种数据采集或消息队列,包括 OPC-UA、MQTT、Telegraf、也包括 Kafaka, 他们的数据将被源源不断的写入到 TDengine。右侧则是可视化、BI 工具、组态软件、应用程序。下侧则是 TDengine 自身提供的命令行程序 (CLI) 以及可视化管理管理。 + ## TDengine 总体适用场景 -作为一个高性能、分布式、支持 SQL 的时序数据库,TDengine 的典型适用场景包括但不限于 IoT、工业互联网、车联网、IT运维、能源、金融证券等领域。需要指出的是,TDengine是针对时序数据场景设计的专用数据库和专用大数据处理工具,因充分利用了时序大数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。本文对适用场景做更多详细的分析。 +作为一个高性能、分布式、支持 SQL 的时序数据库,TDengine 的典型适用场景包括但不限于 IoT、工业互联网、车联网、IT 运维、能源、金融证券等领域。需要指出的是,TDengine 是针对时序数据场景设计的专用数据库和专用大数据处理工具,因充分利用了时序大数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。本文对适用场景做更多详细的分析。 ### 数据源特点和需求 diff --git a/docs-cn/02-concept/02-concept.md b/docs-cn/02-concept/02-concept.md index b1638e838d9b2da35018b4d24640b98d5e476e47..8224c3f268a0f8c328ab6c136ffe1fa514d3f0a0 100644 --- a/docs-cn/02-concept/02-concept.md +++ b/docs-cn/02-concept/02-concept.md @@ -2,175 +2,172 @@ title: 数据模型和基本概念 --- -## 物联网典型场景 - -在典型的物联网、车联网、运维监测场景中,往往有多种不同类型的数据采集设备或采集点,采集一个到多个不同的物理量。而同一种采集设备类型,往往又有多个具体的采集设备分布在不同的地点。采集的物理量都带有时间标签,而且数据量随时间不断增长,但每个数据采集设备或采集点还有自身的静态属性。对于同一类设备,其采集的数据以及静态属性都是很规则的。以智能电表为例,假设每个智能电表采集电流、电压、相位三个量,其采集的数据类似如下的表格: +为了便于解释基本概念,便于撰写示例程序,整个 TDengine 文档以智能电表作为典型时序数据场景。假设每个智能电表采集电流、电压、相位三个量,有多个智能电表,每个电表有位置 location 和分组 group ID 的静态属性. 其采集的数据类似如下的表格: +
- - - - + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + +
设备ID时间戳采集量标签Device IDTime StampCollected MetricsTags
Device IDTime StampcurrentvoltagephaselocationgroupIdDevice IDTime StampcurrentvoltagephaselocationgroupId
d1001153854868500010.32190.31Beijing.Chaoyang2d1001153854868500010.32190.31Beijing.Chaoyang2
d1002153854868400010.22200.23Beijing.Chaoyang3d1002153854868400010.22200.23Beijing.Chaoyang3
d1003153854868650011.52210.35Beijing.Haidian3d1003153854868650011.52210.35Beijing.Haidian3
d1004153854868550013.42230.29Beijing.Haidian2d1004153854868550013.42230.29Beijing.Haidian2
d1001153854869500012.62180.33Beijing.Chaoyang2d1001153854869500012.62180.33Beijing.Chaoyang2
d1004153854869660011.82210.28Beijing.Haidian2d1004153854869660011.82210.28Beijing.Haidian2
d1002153854869665010.32180.25Beijing.Chaoyang3d1002153854869665010.32180.25Beijing.Chaoyang3
d1001153854869680012.32210.31Beijing.Chaoyang2d1001153854869680012.32210.31Beijing.Chaoyang2
+表 1:智能电表数据示例 +
-
表 1:智能电表数据示例
- -每一条记录都有设备 ID,时间戳,采集的物理量(如上图中的电流、电压、相位),还有与每个设备相关的静态标签(如上述表 1 中的位置 location 和分组 groupId)。每个设备是受外界的触发,或按照设定的周期采集数据。采集的数据点是时序的,是一个数据流。 - -## 数据特征 - -除时序特征外,仔细研究发现,物联网、车联网、运维监测类数据及其应用还具有很多其他明显的特征。 - -1. 数据是结构化的; -2. 数据极少有更新或删除操作; -3. 无需传统数据库的事务处理; -4. 相对互联网应用,写多读少; -5. 流量平稳,根据设备数量和采集频次,可以预测出来; -6. 用户关注的是一段时间的趋势,而不是某一特点时间点的值; -7. 数据是有保留期限的; -8. 数据的查询分析一定是基于时间段和地理区域的; -9. 系统需要各种实时计算和统计操作,包括降采样、插值等特种操作; -10. 数据量巨大,一天采集的数据就可以超过 100 亿条。 - -充分利用上述特征,TDengine 采取了一特殊的优化的存储和计算设计来处理时序数据,能将系统处理能力显著提高。 - -## 采集量(Metric) - -采集量是指传感器、设备或其他类型采集点采集的物理量,比如电流、电压、温度、压力、GPS位置等,是随时间变化的,数据类型可以是整型、浮点型、布尔型,也可是字符串。随着时间的推移,存储的采集量的数据量越来越大。 +每一条记录都有设备 ID,时间戳,采集的物理量以及每个设备相关的静态标签。每个设备是受外界的触发,或按照设定的周期采集数据。采集的数据点是时序的,是一个数据流。 -## 标签(Label/Tag) +## 采集量 (Metric) -标签是指传感器、设备或其他类型采集点的静态属性,不是随时间变化的,比如设备型号、颜色、设备的所在地等,数据类型可以是任何类型。虽然是静态的,但TDengine容许用户修改、删除或增加标签值。与采集量不一样的是,随时间的推移,存储的标签的数据量不会有什么变化。 +采集量是指传感器、设备或其他类型采集点采集的物理量,比如电流、电压、温度、压力、GPS 位置等,是随时间变化的,数据类型可以是整型、浮点型、布尔型,也可是字符串。随着时间的推移,存储的采集量的数据量越来越大。 -## 数据采集点(Data Colletion Point) +## 标签 (Label/Tag) -数据采集点是指按照预设时间周期或受事件触发采集物理量的硬件或软件。一个数据采集点可以采集一个或多个物理量,**但这些物理量都是同一时刻采集的,具有相同的时间戳**。对于复杂的设备,往往有多个数据采集点,每个采集点采集的周期都可能不一样,而且完全独立,不同步。比如对于一台汽车,有数据采集点专门采集GPS位置,有数据采集点专门采集发动机状态,有数据采集点专门采集车内的环境,这样一台汽车就有三个数据采集点。 +标签是指传感器、设备或其他类型采集点的静态属性,不是随时间变化的,比如设备型号、颜色、设备的所在地等,数据类型可以是任何类型。虽然是静态的,但 TDengine 容许用户修改、删除或增加标签值。与采集量不一样的是,随时间的推移,存储的标签的数据量不会有什么变化。 -## 关系型数据库模型 +## 数据采集点 (Data Collection Point) -因为采集的数据一般是结构化数据,同时为降低学习门槛,TDengine 采用传统的关系型数据库模型管理数据。用户需要先创建库,然后创建表,之后才能插入或查询数据。TDengine 采用的是结构化存储,而不是 NoSQL 的 key-value 存储。 +数据采集点是指按照预设时间周期或受事件触发采集物理量的硬件或软件。一个数据采集点可以采集一个或多个采集量,**但这些采集量都是同一时刻采集的,具有相同的时间戳**。对于复杂的设备,往往有多个数据采集点,每个数据采集点采集的周期都可能不一样,而且完全独立,不同步。比如对于一台汽车,有数据采集点专门采集 GPS 位置,有数据采集点专门采集发动机状态,有数据采集点专门采集车内的环境,这样一台汽车就有三个数据采集点。 -与通用数据库相比,TDengine通过一个数据采集点一张表,来大幅提高单个数据采集点的插入和查询速度。同时TDengine引入了超级表的概念,让每个表都带有标签,解决多个数据采集点之间的聚合分析问题。 +## 表 (Table) -## 一个数据采集点一张表 +因为采集量一般是结构化数据,同时为降低学习门槛,TDengine 采用传统的关系型数据库模型管理数据。用户需要先创建库,然后创建表,之后才能插入或查询数据。 -为充分利用其数据的时序性和其他数据特点,TDengine 要求**对每个数据采集点单独建表**(比如有一千万个智能电表,就需创建一千万张表,上述表格中的 d1001,d1002,d1003,d1004 都需单独建表),用来存储这个采集点所采集的时序数据。这种设计有几大优点: +为充分利用其数据的时序性和其他数据特点,TDengine 采取**一个数据采集点一张表**的策略,要求对每个数据采集点单独建表(比如有一千万个智能电表,就需创建一千万张表,上述表格中的 d1001,d1002,d1003,d1004 都需单独建表),用来存储这个数据采集点所采集的时序数据。这种设计有几大优点: -1. 由于不同采集设备产生数据的过程完全独立,每个设备的数据源是唯一的,一张表也就只有一个写入者,这样就可采用无锁方式来写,写入速度就能大幅提升。 +1. 由于不同数据采集点产生数据的过程完全独立,每个数据采集点的数据源是唯一的,一张表也就只有一个写入者,这样就可采用无锁方式来写,写入速度就能大幅提升。 2. 对于一个数据采集点而言,其产生的数据是按照时间排序的,因此写的操作可用追加的方式实现,进一步大幅提高数据写入速度。 3. 一个数据采集点的数据是以块为单位连续存储的。如果读取一个时间段的数据,它能大幅减少随机读取操作,成数量级的提升读取和查询速度。 4. 一个数据块内部,采用列式存储,对于不同数据类型,采用不同压缩算法,而且由于一个数据采集点的采集量的变化是缓慢的,压缩率更高。 -如果采用传统的方式,将多个设备的数据写入一张表,由于网络延时不可控,不同设备的数据到达服务器的时序是无法保证的,写入操作是要有锁保护的,而且一个设备的数据是难以保证连续存储在一起的。**采用一个数据采集点一张表的方式,能最大程度的保证单个数据采集点的插入和查询的性能是最优的。** +如果采用传统的方式,将多个数据采集点的数据写入一张表,由于网络延时不可控,不同数据采集点的数据到达服务器的时序是无法保证的,写入操作是要有锁保护的,而且一个数据采集点的数据是难以保证连续存储在一起的。**采用一个数据采集点一张表的方式,能最大程度的保证单个数据采集点的插入和查询的性能是最优的。** -TDengine 建议用数据采集点的名字(如上表中的 D1001)来做表名。每个数据采集点可能同时采集多个物理量(如上表中的 curent,voltage,phase),每个物理量对应一张表中的一列,数据类型可以是整型、浮点型、字符串等。除此之外,表的第一列必须是时间戳,即数据类型为 timestamp。对采集的数据,TDengine 将自动按照时间戳建立索引,但对采集的物理量不建任何索引。数据用列式存储方式保存。 +TDengine 建议用数据采集点的名字(如上表中的 D1001)来做表名。每个数据采集点可能同时采集多个采集量(如上表中的 curent,voltage,phase),每个采集量对应一张表中的一列,数据类型可以是整型、浮点型、字符串等。除此之外,表的第一列必须是时间戳,即数据类型为 timestamp。对采集量,TDengine 将自动按照时间戳建立索引,但对采集量本身不建任何索引。数据用列式存储方式保存。 对于复杂的设备,比如汽车,它有多个数据采集点,那么就需要为一台汽车建立多张表。 -## 超级表:同一类型数据采集点的集合 +## 超级表 (STable) 由于一个数据采集点一张表,导致表的数量巨增,难以管理,而且应用经常需要做采集点之间的聚合操作,聚合的操作也变得复杂起来。为解决这个问题,TDengine 引入超级表(Super Table,简称为 STable)的概念。 超级表是指某一特定类型的数据采集点的集合。同一类型的数据采集点,其表的结构是完全一样的,但每个表(数据采集点)的静态属性(标签)是不一样的。描述一个超级表(某一特定类型的数据采集点的集合),除需要定义采集量的表结构之外,还需要定义其标签的 schema,标签的数据类型可以是整数、浮点数、字符串,标签可以有多个,可以事后增加、删除或修改。如果整个系统有 N 个不同类型的数据采集点,就需要建立 N 个超级表。 -在 TDengine 的设计里,**表用来代表一个具体的数据采集点,超级表用来代表一组相同类型的数据采集点集合**。当为某个具体数据采集点创建表时,用户使用超级表的定义做模板,同时指定该具体采集点(表)的标签值。与传统的关系型数据库相比,表(一个数据采集点)是带有静态标签的,而且这些标签可以事后增加、删除、修改。超级表与与基于超级表建立的子表之间的关系表现在: +在 TDengine 的设计里,**表用来代表一个具体的数据采集点,超级表用来代表一组相同类型的数据采集点集合**。 + +## 子表 (Subtable) + +当为某个具体数据采集点创建表时,用户可以使用超级表的定义做模板,同时指定该具体采集点(表)的具体标签值来创建该表。**通过超级表创建的表称之为子表**。正常的表与子表的差异在于: + +1. 子表就是表,因此所有正常表的SQL操作都可以在子表上执行。 +2. 子表在正常表的基础上有扩展,它是带有静态标签的,而且这些标签可以事后增加、删除、修改,而正常的表没有。 +3. 子表一定属于一张超级表,但普通表不属于任何超级表 +4. 普通表无法转为子表,子表也无法转为普通表。 + +超级表与与基于超级表建立的子表之间的关系表现在: 1. 一张超级表包含有多张子表,这些子表具有相同的采集量 schema,但带有不同的标签值。 2. 不能通过子表调整数据或标签的模式,对于超级表的数据模式修改立即对所有的子表生效。 3. 超级表只定义一个模板,自身不存储任何数据或标签信息。因此,不能向一个超级表写入数据,只能将数据写入子表中。 -针对超级表的查询,TDengine将把所有子表中的数据视为一个整体数据集进行处理,会先把满足标签过滤条件的表从超级表中找出来,然后再扫描这些表的时序数据,进行聚合操作,这样需要扫描的数据集会大幅减少,从而显著提高查询的性能。本质上,TDengine通过对超级表查询的支持,实现了多个同类数据采集点的高效聚合。 +查询既可以在表上进行,也可以在超级表上进行。针对超级表的查询,TDengine 将把所有子表中的数据视为一个整体数据集进行处理,会先把满足标签过滤条件的表从超级表中找出来,然后再扫描这些表的时序数据,进行聚合操作,这样需要扫描的数据集会大幅减少,从而显著提高查询的性能。本质上,TDengine 通过对超级表查询的支持,实现了多个同类数据采集点的高效聚合。 + +TDengine系统建议给一个数据采集点建表,需要通过超级表建表,而不是建普通表。 + +## 库 (database) + +库是指一组表的集合。TDengine 容许一个运行实例有多个库,而且每个库可以配置不同的存储策略。不同类型的数据采集点往往具有不同的数据特征,包括数据采集频率的高低,数据保留时间的长短,副本的数目,数据块的大小,是否允许更新数据等等。为了在各种场景下 TDengine 都能最大效率的工作,TDengine 建议将不同数据特征的超级表创建在不同的库里。 + +一个库里,可以有一到多个超级表,但一个超级表只属于一个库。一个超级表所拥有的子表全部存在一个库里。 ## FQDN & End Point -FQDN (fully qualified domain name, 完全限定域名)是 Internet 上特定计算机或主机的完整域名。FQDN由两部分组成:主机名和域名。例如,假设邮件服务器的FQDN可能是mail.tdengine.com。主机名是mail,主机位于域名tdengine.com中。DNS(Domain Name System),负责将FQDN翻译成IP,是互联网应用的寻址方式。对于没有DNS的系统,可以通过配置hosts文件来解决。 +FQDN (fully qualified domain name, 完全限定域名)是 Internet 上特定计算机或主机的完整域名。FQDN 由两部分组成:主机名和域名。例如,假设邮件服务器的 FQDN 可能是 mail.tdengine.com。主机名是 mail,主机位于域名 tdengine.com 中。DNS(Domain Name System),负责将 FQDN 翻译成 IP,是互联网应用的寻址方式。对于没有 DNS 的系统,可以通过配置 hosts 文件来解决。 -TDengine集群的每个节点是由End Point来唯一标识的,End Point是由 FQDN 外加 Port 组成,比如 h1.tdengine.com:6030。这样当IP发生变化的时候,我们依然可以使用 FQDN 来动态找到节点,不需要更改集群的任何配置。而且采用 FQDN,便于内网和外网对同一个集群的统一访问。 +TDengine 集群的每个节点是由 End Point 来唯一标识的,End Point 是由 FQDN 外加 Port 组成,比如 h1.tdengine.com:6030。这样当 IP 发生变化的时候,我们依然可以使用 FQDN 来动态找到节点,不需要更改集群的任何配置。而且采用 FQDN,便于内网和外网对同一个集群的统一访问。 -TDengine 不建议采用直接的IP地址访问集群,不利于管理。不了解 FQDN 概念,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。 +TDengine 不建议采用直接的 IP 地址访问集群,不利于管理。不了解 FQDN 概念,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。 diff --git a/docs-cn/04-develop/01-connect/_connect_cs.mdx b/docs-cn/04-develop/01-connect/_connect_cs.mdx index 204173dd329f6f214a9ea44c2f360be2cdbfdab8..821820e8fe1d87a35e01943530179eeb6e0f48be 100644 --- a/docs-cn/04-develop/01-connect/_connect_cs.mdx +++ b/docs-cn/04-develop/01-connect/_connect_cs.mdx @@ -1,7 +1,8 @@ ```csharp title="原生连接" {{#include docs-examples/csharp/ConnectExample.cs}} ``` + :::info C# 连接器目前只支持原生连接。 -::: \ No newline at end of file +::: diff --git a/docs-cn/04-develop/01-connect/_connect_go.mdx b/docs-cn/04-develop/01-connect/_connect_go.mdx index 4e4f189672f2fda4b807fe628d4455a41ac4cb69..478768caaacc8aceb9a3f5a85f008dde00125eb7 100644 --- a/docs-cn/04-develop/01-connect/_connect_go.mdx +++ b/docs-cn/04-develop/01-connect/_connect_go.mdx @@ -1,15 +1,17 @@ #### 使用数据库访问统一接口 + ```go title="原生连接" {{#include docs-examples/go/connect/cgoexample/main.go}} ``` + ```go title="REST 连接" {{#include docs-examples/go/connect/restexample/main.go}} ``` + #### 使用高级封装 + 也可以使用 driver-go 的 af 包建立连接。这个模块封装了 TDengine 的高级功能, 如:参数绑定、订阅等。 ```go title="使用 af 包建立原生连接" {{#include docs-examples/go/connect/afconn/main.go}} ``` - - diff --git a/docs-cn/04-develop/01-connect/_connect_java.mdx b/docs-cn/04-develop/01-connect/_connect_java.mdx index cd6d7c4cab9a84abb22895c704debd260884081f..635f39ceb28ffc3fd0b0d8edb057d9aa01c593de 100644 --- a/docs-cn/04-develop/01-connect/_connect_java.mdx +++ b/docs-cn/04-develop/01-connect/_connect_java.mdx @@ -1,11 +1,15 @@ ```java title="原生连接" {{#include docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java}} ``` + ```java title="REST 连接" {{#include docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}} ``` -使用REST 连接时,如果查询数据量比较大,还可开启批量拉取功能。 + +使用 REST 连接时,如果查询数据量比较大,还可开启批量拉取功能。 + ```java title="开启批量拉取功能" {4} {{#include docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}} ``` -更多连接参数配置,参考[Java 连接器](/reference/connector/java) \ No newline at end of file + +更多连接参数配置,参考[Java 连接器](/reference/connector/java) diff --git a/docs-cn/04-develop/01-connect/_connect_node.mdx b/docs-cn/04-develop/01-connect/_connect_node.mdx index 8a259888f87d4d441c58b9a8a9008b19273c1a58..199a6e3faa88fcb295379309a250990bf97fa973 100644 --- a/docs-cn/04-develop/01-connect/_connect_node.mdx +++ b/docs-cn/04-develop/01-connect/_connect_node.mdx @@ -1,6 +1,7 @@ ```js title="原生连接" {{#include docs-examples/node/nativeexample/connect.js}} ``` + ```js title="REST 连接" {{#include docs-examples/node/restexample/connect.js}} -``` \ No newline at end of file +``` diff --git a/docs-cn/04-develop/01-connect/_connect_php.mdx b/docs-cn/04-develop/01-connect/_connect_php.mdx new file mode 100644 index 0000000000000000000000000000000000000000..2431df2a722659ae6e5962a955fba139be3e5f67 --- /dev/null +++ b/docs-cn/04-develop/01-connect/_connect_php.mdx @@ -0,0 +1,3 @@ +```php title="原生连接" +{{#include docs-examples/php/connect.php}} +``` diff --git a/docs-cn/04-develop/01-connect/_connect_python.mdx b/docs-cn/04-develop/01-connect/_connect_python.mdx index 331ec0f693601baeb28ede7b0278e67f1471c187..43e13ab56eeada9d86eae057a1ab0eafcd5247de 100644 --- a/docs-cn/04-develop/01-connect/_connect_python.mdx +++ b/docs-cn/04-develop/01-connect/_connect_python.mdx @@ -1,3 +1,3 @@ ```python title="原生连接" {{#include docs-examples/python/connect_exmaple.py}} -``` \ No newline at end of file +``` diff --git a/docs-cn/04-develop/01-connect/_connect_r.mdx b/docs-cn/04-develop/01-connect/_connect_r.mdx index a69a57f66be3672d61cb0f84f43aba123cfbd5aa..8aab6121a66b38540bf1b8ebf5b48a513282ac7a 100644 --- a/docs-cn/04-develop/01-connect/_connect_r.mdx +++ b/docs-cn/04-develop/01-connect/_connect_r.mdx @@ -1,3 +1,3 @@ ```r title="原生连接" {{#include docs-examples/R/connect_native.r:demo}} -``` \ No newline at end of file +``` diff --git a/docs-cn/04-develop/01-connect/_connect_rust.mdx b/docs-cn/04-develop/01-connect/_connect_rust.mdx index b051108452d16f207ce10b128f5de2e5f507200f..9e64724c178ba2c72e14fc9878bf9c3237bb50e7 100644 --- a/docs-cn/04-develop/01-connect/_connect_rust.mdx +++ b/docs-cn/04-develop/01-connect/_connect_rust.mdx @@ -1,6 +1,7 @@ ```rust title="原生连接/REST 连接" {{#include docs-examples/rust/nativeexample/examples/connect.rs}} ``` + :::note 对于 Rust 连接器, 连接方式的不同只体现在使用的特性不同。如果启用了 "rest" 特性,那么只有 RESTful 的实现会被编译进来。 diff --git a/docs-cn/04-develop/01-connect/index.md b/docs-cn/04-develop/01-connect/index.md index 07bcc8ea125a0e4bc8f40a1bd2fab3a568b3402d..e83e3451c2c7f39f38c57672e63234117b3ac4b7 100644 --- a/docs-cn/04-develop/01-connect/index.md +++ b/docs-cn/04-develop/01-connect/index.md @@ -13,18 +13,19 @@ import ConnPythonNative from "./_connect_python.mdx"; import ConnCSNative from "./_connect_cs.mdx"; import ConnC from "./_connect_c.mdx"; import ConnR from "./_connect_r.mdx"; +import ConnPHP from "./_connect_php.mdx"; import InstallOnWindows from "../../14-reference/03-connector/_linux_install.mdx"; import InstallOnLinux from "../../14-reference/03-connector/_windows_install.mdx"; import VerifyLinux from "../../14-reference/03-connector/_verify_linux.mdx"; import VerifyWindows from "../../14-reference/03-connector/_verify_windows.mdx"; -TDengine 提供 REST API,容许在任何平台的任何应用程序通过它访问 TDengine 运行实例,详细介绍请看 [REST API](/reference/rest-api/)。除 REST API 之外,TDengine 还提供多种编程语言的连接器方便用户开发应用程序,其中包括 C/C++、Java、Python、Go、Node.js、C# 等。 本节介绍如何使用连接器建立与 TDengine 的连接,给出连接器安装、连接的简单说明。关于各连接器的详细功能说明,请查看[连接器](https://docs.taosdata.com/reference/connector/) +TDengine 提供了丰富的应用程序开发接口,为了便于用户快速开发自己的应用,TDengine 支持了多种编程语言的连接器,其中官方连接器包括支持 C/C++、Java、Python、Go、Node.js、C#、Rust、Lua(社区贡献)和 PHP (社区贡献)的连接器。这些连接器支持使用原生接口(taosc)和 REST 接口(部分语言暂不支持)连接 TDengine 集群。社区开发者也贡献了多个非官方连接器,例如 ADO.NET 连接器、Lua 连接器和 PHP 连接器。 ## 连接器建立连接的方式 连接器建立连接的方式,TDengine 提供两种: -1. 通过 taosAdapter 组件提供的 REST API 建立与 taosd 的连接,这种连接方式下文中简称"REST 连接“ +1. 通过 taosAdapter 组件提供的 REST API 建立与 taosd 的连接,这种连接方式下文中简称“REST 连接” 2. 通过客户端驱动程序 taosc 直接与服务端程序 taosd 建立连接,这种连接方式下文中简称“原生连接”。 无论使用何种方式建立连接,连接器都提供了相同或相似的 API 操作数据库,都可以执行 SQL 语句,只是初始化连接的方式稍有不同,用户在使用上不会感到什么差别。 @@ -200,6 +201,46 @@ install.packages("RJDBC") 如果已经安装了 TDengine 服务端软件或 TDengine 客户端驱动 taosc, 那么已经安装了 C 连接器,无需额外操作。
+ + + +**下载代码并解压:** + +```shell +curl -L -o php-tdengine.tar.gz https://github.com/Yurunsoft/php-tdengine/archive/refs/tags/v1.0.2.tar.gz \ +&& mkdir php-tdengine \ +&& tar -xzf php-tdengine.tar.gz -C php-tdengine --strip-components=1 +``` + +> 版本 `v1.0.0` 可替换为任意更新的版本,可在 Release 中查看最新版本。 + +**非 Swoole 环境:** + +```shell +phpize && ./configure && make -j && make install +``` + +**手动指定 tdengine 目录:** + +```shell +phpize && ./configure --with-tdengine-dir=/usr/local/Cellar/tdengine/2.4.0.0 && make -j && make install +``` + +> `--with-tdengine-dir=` 后跟上 tdengine 目录。 +> 适用于默认找不到的情况,或者 MacOS 系统用户。 + +**Swoole 环境:** + +```shell +phpize && ./configure --enable-swoole && make -j && make install +``` + +**启用扩展:** + +方法一:在 `php.ini` 中加入 `extension=tdengine` + +方法二:运行带参数 `php -dextension=tdengine test.php + @@ -232,6 +273,9 @@ install.packages("RJDBC") + + + :::tip diff --git a/docs-cn/04-develop/03-insert-data/01-sql-writing.mdx b/docs-cn/04-develop/03-insert-data/01-sql-writing.mdx index 7a4ab3eb72f6bf41e863ba26aa7ef97b503349d8..e63ffce6dd07366da99fe1f41d0a2a8d7a623f31 100644 --- a/docs-cn/04-develop/03-insert-data/01-sql-writing.mdx +++ b/docs-cn/04-develop/03-insert-data/01-sql-writing.mdx @@ -18,6 +18,8 @@ import CsSQL from "./_cs_sql.mdx"; import CsStmt from "./_cs_stmt.mdx"; import CSQL from "./_c_sql.mdx"; import CStmt from "./_c_stmt.mdx"; +import PhpSQL from "./_php_sql.mdx"; +import PhpStmt from "./_php_stmt.mdx"; ## SQL 写入简介 @@ -88,6 +90,9 @@ INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, + + + :::note @@ -125,5 +130,8 @@ TDengine 也提供了支持参数绑定的 Prepare API,与 MySQL 类似,这 + + + diff --git a/docs-cn/04-develop/03-insert-data/_category_.yml b/docs-cn/04-develop/03-insert-data/_category_.yml index 9e76a57abd132b528bbd692f03439649ab83425d..430b3e4209ec12c6abdbfa825c9a95582376d058 100644 --- a/docs-cn/04-develop/03-insert-data/_category_.yml +++ b/docs-cn/04-develop/03-insert-data/_category_.yml @@ -1,5 +1 @@ -label: 写入数据 -link: - type: generated-index - slug: /insert-data/ - description: "TDengine 支持多种写入协议,包括 SQL,InfluxDB Line 协议, OpenTSDB Telnet 协议,OpenTSDB JSON 格式协议。数据可以单条插入,也可以批量插入,可以插入一个数据采集点的数据,也可以同时插入多个数据采集点的数据。同时,TDengine 支持多线程插入,支持时间乱序数据插入,也支持历史数据插入。InfluxDB Line 协议、OpenTSDB Telnet 协议和 OpenTSDB JSON 格式协议是 TDengine 支持的三种无模式写入协议。使用无模式方式写入无需提前创建超级表和子表,并且引擎能自适用数据对表结构做调整。" +label: 写入数据 \ No newline at end of file diff --git a/docs-cn/04-develop/03-insert-data/_php_sql.mdx b/docs-cn/04-develop/03-insert-data/_php_sql.mdx new file mode 100644 index 0000000000000000000000000000000000000000..42d6a548479d526e7ecdba12807cf9cafb911ee5 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_php_sql.mdx @@ -0,0 +1,3 @@ +```php +{{#include docs-examples/php/insert.php}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_php_stmt.mdx b/docs-cn/04-develop/03-insert-data/_php_stmt.mdx new file mode 100644 index 0000000000000000000000000000000000000000..c1ba4ed3b160514fafb50886d799fc27e60927ed --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_php_stmt.mdx @@ -0,0 +1,3 @@ +```php +{{#include docs-examples/php/insert_stmt.php}} +``` diff --git a/docs-cn/04-develop/03-insert-data/index.md b/docs-cn/04-develop/03-insert-data/index.md new file mode 100644 index 0000000000000000000000000000000000000000..55a28e4a8ba13501e2f481c9aba67b7300da98d0 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/index.md @@ -0,0 +1,12 @@ +--- +title: 写入数据 +--- + +TDengine 支持多种写入协议,包括 SQL,InfluxDB Line 协议, OpenTSDB Telnet 协议,OpenTSDB JSON 格式协议。数据可以单条插入,也可以批量插入,可以插入一个数据采集点的数据,也可以同时插入多个数据采集点的数据。同时,TDengine 支持多线程插入,支持时间乱序数据插入,也支持历史数据插入。InfluxDB Line 协议、OpenTSDB Telnet 协议和 OpenTSDB JSON 格式协议是 TDengine 支持的三种无模式写入协议。使用无模式方式写入无需提前创建超级表和子表,并且引擎能自适用数据对表结构做调整。 + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-cn/04-develop/04-query-data/_php.mdx b/docs-cn/04-develop/04-query-data/_php.mdx new file mode 100644 index 0000000000000000000000000000000000000000..6264bd99f534fbd800f1f349d93ac69b31c77397 --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_php.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs-examples/php/query.php}} +``` diff --git a/docs-cn/04-develop/04-query-data/index.mdx b/docs-cn/04-develop/04-query-data/index.mdx index 829280fba5b1e5a956b79699df39f9bb2c1cb177..6b7edc123097b48510d4debcd414fbad5e0c4987 100644 --- a/docs-cn/04-develop/04-query-data/index.mdx +++ b/docs-cn/04-develop/04-query-data/index.mdx @@ -13,6 +13,7 @@ import RustQuery from "./_rust.mdx"; import NodeQuery from "./_js.mdx"; import CsQuery from "./_cs.mdx"; import CQuery from "./_c.mdx"; +import PhpQuery from "./_php.mdx"; import PyAsync from "./_py_async.mdx"; import NodeAsync from "./_js_async.mdx"; import CsAsync from "./_cs_async.mdx"; @@ -150,12 +151,15 @@ Query OK, 5 row(s) in set (0.001521s) + + + :::note 1. 无论是使用 REST 连接还是原生连接的连接器,以上示例代码都能正常工作。 -2. 唯一需要注意的是:由于 RESTful 接口无状态, 不能使用 `use db` 语句来切换数据库。 +2. 唯一需要注意的是:由于 REST 接口无状态, 不能使用 `use db` 语句来切换数据库。 ::: diff --git a/docs-cn/04-develop/_category_.yml b/docs-cn/04-develop/_category_.yml index b17f078b9a42143b8eb42a04909d5c881dcaad9d..509a9405c42939a4819b87669a4c5b244bd29a8b 100644 --- a/docs-cn/04-develop/_category_.yml +++ b/docs-cn/04-develop/_category_.yml @@ -1,5 +1 @@ -label: 开发指南 -link: - type: generated-index - slug: /develop - description: "开始指南是对开发者友好的使用教程,既包括数据建模、写入、查询等基础功能的使用,也包括数据订阅、连续查询等高级功能的使用。对于每个主题,都配有各编程语言的连接器的示例代码,方便开发者快速上手。如果想更深入地了解各连接器的使用,请阅读连接器参考指南。" +label: 开发指南 \ No newline at end of file diff --git a/docs-cn/04-develop/index.md b/docs-cn/04-develop/index.md new file mode 100644 index 0000000000000000000000000000000000000000..8ae15e3bdf49c71f402ecf4e977e5f00d55a8aa5 --- /dev/null +++ b/docs-cn/04-develop/index.md @@ -0,0 +1,12 @@ +--- +title: 开发指南 +--- + +开始指南是对开发者友好的使用教程,既包括数据建模、写入、查询等基础功能的使用,也包括数据订阅、连续查询等高级功能的使用。对于每个主题,都配有各编程语言的连接器的示例代码,方便开发者快速上手。如果想更深入地了解各连接器的使用,请阅读连接器参考指南。 + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-cn/10-cluster/_category_.yml b/docs-cn/10-cluster/_category_.yml index df953cb6dd297c91f1e6d1e2d30690afab293982..3cee5ce4cdc29e7febf456e567ba08cf2753d305 100644 --- a/docs-cn/10-cluster/_category_.yml +++ b/docs-cn/10-cluster/_category_.yml @@ -1,12 +1 @@ label: 集群管理 -link: - type: generated-index - slug: /cluster/ - description: "TDengine支持以集群方式部署,以提升系统的处理能力和高可用性。TDengine集群支持任意数据的多副本从而提升高可用性,并自动实现负载均衡。同时TDengine集群具有很好的横向扩展能力以处理更多的数据采集点和更大的数据量。" - keywords: - [ - 集群, - 高可用, - 负载均衡, - 横向扩展 - ] diff --git a/docs-cn/10-cluster/index.md b/docs-cn/10-cluster/index.md new file mode 100644 index 0000000000000000000000000000000000000000..515e137a8cd8bd85bb4040fcb96f31bc2bc53e09 --- /dev/null +++ b/docs-cn/10-cluster/index.md @@ -0,0 +1,12 @@ +--- +title: 集群管理 +--- + +TDengine支持以集群方式部署,以提升系统的处理能力和高可用性。TDengine集群支持任意数据的多副本从而提升高可用性,并自动实现负载均衡。同时TDengine集群具有很好的横向扩展能力以处理更多的数据采集点和更大的数据量。 + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-cn/12-taos-sql/02-database.md b/docs-cn/12-taos-sql/02-database.md index 5d358193f96b9c3258d1236f8d11341f8889b8e5..6ea8b1568e1ae46b710e45df98b6e91fc826dbaa 100644 --- a/docs-cn/12-taos-sql/02-database.md +++ b/docs-cn/12-taos-sql/02-database.md @@ -19,7 +19,23 @@ CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep] [DAYS days] [UPDATE 1]; 4. 更多关于 UPDATE 参数的用法,请参考[FAQ](/train-faq/faq)。 3. 数据库名最大长度为 33; 4. 一条 SQL 语句的最大长度为 65480 个字符; -5. 数据库还有更多与数据库相关的配置参数,如 cache, blocks, days, keep, minRows, maxRows, wal, fsync, update, cacheLast, replica, quorum, maxVgroupsPerDb, ctime, comp, prec, 具体细节请参见 [配置参数](/reference/config/) 章节。 +5. 创建数据库时可用的参数有: + - cache: [Description](/reference/config/#cache) + - blocks: [Description](/reference/config/#blocks) + - days: [Description](/reference/config/#days) + - keep: [Description](/reference/config/#keep) + - minRows: [Description](/reference/config/#minrows) + - maxRows: [Description](/reference/config/#maxrows) + - wal: [Description](/reference/config/#wallevel) + - fsync: [Description](/reference/config/#fsync) + - update: [Description](/reference/config/#update) + - cacheLast: [Description](/reference/config/#cachelast) + - replica: [Description](/reference/config/#replica) + - quorum: [Description](/reference/config/#quorum) + - maxVgroupsPerDb: [Description](/reference/config/#maxvgroupsperdb) + - comp: [Description](/reference/config/#comp) + - precision: [Description](reference/config/#precision) +6. 请注意上面列出的所有参数都可以配置在配置文件 `taosd.cfg` 中作为创建数据库时使用的默认配置, `create database` 的参数中明确指定的会覆盖配置文件中的设置。 ::: diff --git a/docs-cn/12-taos-sql/07-function.md b/docs-cn/12-taos-sql/07-function.md index de993020740abe39a177f8107f0388dcc439a17e..f6e564419ddaa18931b0f0e0e4e7b5b3219a92f6 100644 --- a/docs-cn/12-taos-sql/07-function.md +++ b/docs-cn/12-taos-sql/07-function.md @@ -915,9 +915,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### CSUM - ```sql +```sql SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:累加和(Cumulative sum),输出行与输入行数相同。 @@ -937,9 +937,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### MAVG - ```sql +```sql SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**: 计算连续 k 个值的移动平均数(moving average)。如果输入行数小于 k,则无结果输出。参数 k 的合法输入范围是 1≤ k ≤ 1000。 @@ -959,9 +959,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### SAMPLE - ```sql +```sql SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 @@ -980,9 +980,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### ASIN - ```sql +```sql SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:获得指定列的反正弦结果 @@ -1000,9 +1000,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### ACOS - ```sql +```sql SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:获得指定列的反余弦结果 @@ -1020,9 +1020,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### ATAN - ```sql +```sql SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:获得指定列的反正切结果 @@ -1040,9 +1040,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### SIN - ```sql +```sql SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:获得指定列的正弦结果 @@ -1060,9 +1060,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### COS - ```sql +```sql SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:获得指定列的余弦结果 @@ -1080,9 +1080,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### TAN - ```sql +```sql SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:获得指定列的正切结果 @@ -1100,9 +1100,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### POW - ```sql +```sql SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:获得指定列的指数为 power 的幂 @@ -1120,9 +1120,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### LOG - ```sql +```sql SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:获得指定列对于底数 base 的对数 @@ -1140,9 +1140,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### ABS - ```sql +```sql SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:获得指定列的绝对值 @@ -1160,9 +1160,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### SQRT - ```sql +```sql SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:获得指定列的平方根 @@ -1180,9 +1180,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### CAST - ```sql +```sql SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:数据类型转换函数,输入参数 expression 支持普通列、常量、标量函数及它们之间的四则运算,不支持 tag 列,只适用于 select 子句中。 @@ -1206,9 +1206,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### CONCAT - ```sql +```sql SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:字符串连接函数。 @@ -1226,9 +1226,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### CONCAT_WS - ``` +``` SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:带分隔符的字符串连接函数。 @@ -1246,9 +1246,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### LENGTH - ``` +``` SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:以字节计数的字符串长度。 @@ -1265,9 +1265,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### CHAR_LENGTH - ``` +``` SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:以字符计数的字符串长度。 @@ -1284,9 +1284,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### LOWER - ``` +``` SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:将字符串参数值转换为全小写字母。 @@ -1303,9 +1303,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### UPPER - ``` +``` SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:将字符串参数值转换为全大写字母。 @@ -1322,9 +1322,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### LTRIM - ``` +``` SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:返回清除左边空格后的字符串。 @@ -1341,9 +1341,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### RTRIM - ``` +``` SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:返回清除右边空格后的字符串。 @@ -1360,9 +1360,9 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### SUBSTR - ``` +``` SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` **功能说明**:从源字符串 str 中的指定位置 pos 开始取一个长度为 len 的子串并返回。 @@ -1461,7 +1461,7 @@ Query OK, 6 row(s) in set (0.002791s) ### STATEDURATION -``` +```sql SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause]; ``` diff --git a/docs-cn/12-taos-sql/index.md b/docs-cn/12-taos-sql/index.md index c34c1e5dc812ad589a0c4fdf89a8d02ff4fd18a4..269bc1d2b5ddfa25c42652d8f639bfe2fb1d42e5 100644 --- a/docs-cn/12-taos-sql/index.md +++ b/docs-cn/12-taos-sql/index.md @@ -30,4 +30,11 @@ taos> DESCRIBE meters; groupid | INT | 4 | TAG | ``` -数据集包含 4 个智能电表的数据,按照 TDengine 的建模规则,对应 4 个子表,其名称分别是 d1001, d1002, d1003, d1004。 \ No newline at end of file +数据集包含 4 个智能电表的数据,按照 TDengine 的建模规则,对应 4 个子表,其名称分别是 d1001, d1002, d1003, d1004。 + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-cn/13-operation/_category_.yml b/docs-cn/13-operation/_category_.yml index 930e441defdc80215ce5d90375a9cbd2d4bad947..315839970c47e4ac76f6f19f65331a44fd93229e 100644 --- a/docs-cn/13-operation/_category_.yml +++ b/docs-cn/13-operation/_category_.yml @@ -1,4 +1 @@ label: 运维指南 -link: - slug: /operation/ - type: generated-index diff --git a/docs-cn/13-operation/index.md b/docs-cn/13-operation/index.md new file mode 100644 index 0000000000000000000000000000000000000000..d265ea8ef3f1d18a8ab743fc66cd6dbc05dc60c6 --- /dev/null +++ b/docs-cn/13-operation/index.md @@ -0,0 +1,10 @@ +--- +title: 运维指南 +--- + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-cn/14-reference/03-connector/_linux_install.mdx b/docs-cn/14-reference/03-connector/_linux_install.mdx index 6437583b43d905272a9676703d318b9fdb74d941..eb7f68328809fdf75ce11a3bddb324b59bfe8dcb 100644 --- a/docs-cn/14-reference/03-connector/_linux_install.mdx +++ b/docs-cn/14-reference/03-connector/_linux_install.mdx @@ -20,11 +20,11 @@ import PkgList from "/components/PkgList"; 运行 install_client.sh 进行安装。 4. 配置 taos.cfg - 编辑 taos.cfg 文件(默认路径/etc/taos/taos.cfg),将 firstEP 修改为 TDengine 服务器的 End Point,例如:`h1.tdengine.com:6030` + 编辑 `taos.cfg` 文件(默认路径/etc/taos/taos.cfg),将 `firstEP` 修改为 TDengine 服务器的 End Point,例如:`h1.tdengine.com:6030` :::tip -1. 如本机没有部署 TDengine 服务,仅安装了应用驱动,则 taos.cfg 中仅需配置 firstEP,无需在本机配置 FQDN。 -2. 为防止与服务器端连接时出现“Unable to resolve FQDN”错误,建议确认本机的 hosts 文件已经配置了服务器正确的 FQDN 值,或配置好了 DNS 服务。 +1. 如本机没有部署 TDengine 服务,仅安装了应用驱动,则 `taos.cfg` 中仅需配置 `firstEP`,无需在本机配置 `FQDN`。 +2. 为防止与服务器端连接时出现“Unable to resolve FQDN”错误,建议确认本机的 `/etc/hosts` 文件已经配置了服务器正确的 FQDN 值,或配置好了 DNS 服务。 ::: diff --git a/docs-cn/14-reference/03-connector/go.mdx b/docs-cn/14-reference/03-connector/go.mdx index c5f448916a39acdf7f0ffff01bf431d93f2143b4..694dfc2510ca668391dc735bbe99812645c2d7b0 100644 --- a/docs-cn/14-reference/03-connector/go.mdx +++ b/docs-cn/14-reference/03-connector/go.mdx @@ -136,7 +136,7 @@ import ( ) func main() { - var taosUri = "root:taosdata/tcp(localhost:6030)/" + var taosUri = "root:taosdata@tcp(localhost:6030)/" taos, err := sql.Open("taosSql", taosUri) if err != nil { fmt.Println("failed to connect TDengine, err:", err) @@ -168,7 +168,7 @@ import ( ) func main() { - var taosUri = "root:taosdata/http(localhost:6041)/" + var taosUri = "root:taosdata@http(localhost:6041)/" taos, err := sql.Open("taosRestful", taosUri) if err != nil { fmt.Println("failed to connect TDengine, err:", err) diff --git a/docs-cn/14-reference/03-connector/java.mdx b/docs-cn/14-reference/03-connector/java.mdx index 970f8aeb7f1095544361f07ef758eb35de709a19..f80a019a4ab433cc66944c0ff6b6110d34571baf 100644 --- a/docs-cn/14-reference/03-connector/java.mdx +++ b/docs-cn/14-reference/03-connector/java.mdx @@ -211,7 +211,7 @@ url 中的配置参数如下: INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES(now, 24.6); ``` -- 从 taos-jdbcdriver-2.0.36 和 TDengine 2.2.0.0 版本开始,如果在 url 中指定了 dbname,那么,JDBC REST 连接会默认使用/rest/sql/dbname 作为 resful 请求的 url,在 SQL 中不需要指定 dbname。例如:url 为 jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行 sql:insert into t1 using weather(ts, temperatrue) tags('beijing') values(now, 24.6); +- 从 taos-jdbcdriver-2.0.36 和 TDengine 2.2.0.0 版本开始,如果在 url 中指定了 dbname,那么,JDBC REST 连接会默认使用/rest/sql/dbname 作为 restful 请求的 url,在 SQL 中不需要指定 dbname。例如:url 为 jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行 sql:insert into t1 using weather(ts, temperature) tags('beijing') values(now, 24.6); ::: @@ -348,8 +348,8 @@ JDBC 连接器可能报错的错误码包括 3 种:JDBC driver 本身的报错 具体的错误码请参考: -- https://github.com/taosdata/TDengine/blob/develop/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java -- https://github.com/taosdata/TDengine/blob/develop/src/inc/taoserror.h +- [TDengine Java Connector](https://github.com/taosdata/TDengine/blob/develop/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java) +- [TDengine_ERROR_CODE](https://github.com/taosdata/TDengine/blob/develop/src/inc/taoserror.h) ### 通过参数绑定写入数据 @@ -816,21 +816,21 @@ Query OK, 1 row(s) in set (0.000141s) 1. 使用 Statement 的 `addBatch` 和 `executeBatch` 来执行“批量写入/更行”,为什么没有带来性能上的提升? - **原因**:TDengine 的 JDBC 实现中,通过 `addBatch` 方法提交的 SQL 语句,会按照添加的顺序,依次执行,这种方式没有减少与服务端的交互次数,不会带来性能上的提升。 + **原因**:TDengine 的 JDBC 实现中,通过 `addBatch` 方法提交的 SQL 语句,会按照添加的顺序,依次执行,这种方式没有减少与服务端的交互次数,不会带来性能上的提升。 - **解决方法**:1. 在一条 insert 语句中拼接多个 values 值;2. 使用多线程的方式并发插入;3. 使用参数绑定的写入方式 + **解决方法**:1. 在一条 insert 语句中拼接多个 values 值;2. 使用多线程的方式并发插入;3. 使用参数绑定的写入方式 2. java.lang.UnsatisfiedLinkError: no taos in java.library.path - **原因**:程序没有找到依赖的本地函数库 taos。 + **原因**:程序没有找到依赖的本地函数库 taos。 - **解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 + **解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform - **原因**:目前 TDengine 只支持 64 位 JDK。 + **原因**:目前 TDengine 只支持 64 位 JDK。 - **解决方法**:重新安装 64 位 JDK。 + **解决方法**:重新安装 64 位 JDK。 4. 其它问题请参考 [FAQ](/train-faq/faq) diff --git a/docs-cn/14-reference/05-taosbenchmark.md b/docs-cn/14-reference/05-taosbenchmark.md index dbf6847d514d70852204963c289d2bf901d7cbf0..d438dce9fe02e43dc919f9684be1c6524a164320 100644 --- a/docs-cn/14-reference/05-taosbenchmark.md +++ b/docs-cn/14-reference/05-taosbenchmark.md @@ -361,7 +361,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\) ### 查询场景配置参数 -查询场景下 `filetype` 必须设置为 `qeury`,该参数及其它通用参数详见[通用配置参数](#通用配置参数) +查询场景下 `filetype` 必须设置为 `query`,该参数及其它通用参数详见[通用配置参数](#通用配置参数) #### 执行指定查询语句的配置参数 @@ -400,7 +400,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\) - **threads** : 执行 SQL 的线程数,默认为 1。 -- **interva** : 执行订阅的时间间隔,单位为秒,默认为 0。 +- **interval** : 执行订阅的时间间隔,单位为秒,默认为 0。 - **restart** : "yes" 表示开始新的订阅,"no" 表示继续之前的订阅,默认值为 "no"。 @@ -420,7 +420,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\) - **threads** : 执行 SQL 的线程数,默认为 1。 -- **interva** : 执行订阅的时间间隔,单位为秒,默认为 0。 +- **interval** : 执行订阅的时间间隔,单位为秒,默认为 0。 - **restart** : "yes" 表示开始新的订阅,"no" 表示继续之前的订阅,默认值为 "no"。 diff --git a/docs-cn/14-reference/08-taos-shell.md b/docs-cn/14-reference/08-taos-shell.md index c9167fcf2643954981925fb5ef67a60cbad97a6d..a75e64e0c11e092633f3bdf026b93dcf606ba3bc 100644 --- a/docs-cn/14-reference/08-taos-shell.md +++ b/docs-cn/14-reference/08-taos-shell.md @@ -12,7 +12,7 @@ TDengine 命令行程序(以下简称 TDengine CLI)是用户操作 TDengine ## 执行 -要进入 TDengine CLI,您只要在 Linux 终端或Windos 终端执行 `taos` 即可。 +要进入 TDengine CLI,您只要在 Linux 终端或Windows 终端执行 `taos` 即可。 ```bash taos diff --git a/docs-cn/14-reference/12-config/index.md b/docs-cn/14-reference/12-config/index.md index 9fff685ee6bfe9ef77b3a83d8b49ccc13216e0ce..e153f82a21360266460347d82dfbdadc774760df 100644 --- a/docs-cn/14-reference/12-config/index.md +++ b/docs-cn/14-reference/12-config/index.md @@ -38,7 +38,6 @@ taos --dump-config ::: - :::note 配置文件参数修改后,需要重启*taosd*服务,或客户端应用才能生效。 @@ -48,54 +47,54 @@ taos --dump-config ### firstEp -| 属性 | 说明 | -| -------- | ----------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | +| 属性 | 说明 | +| -------- | --------------------------------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | | 含义 | taosd 或者 taos 启动时,主动连接的集群中首个 dnode 的 end point | -| 缺省值 | localhost:6030 | +| 缺省值 | localhost:6030 | ### secondEp -| 属性 | 说明 | -| -------- | ---------------------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | +| 属性 | 说明 | +| -------- | -------------------------------------------------------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | | 含义 | taosd 或者 taos 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 end point | -| 缺省值 | 无 | +| 缺省值 | 无 | ### fqdn | 属性 | 说明 | | -------- | ----------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | +| 适用范围 | 仅服务端适用 | | 含义 | 数据节点的 FQDN。如果习惯 IP 地址访问,可设置为该节点的 IP 地址。 | | 缺省值 | 缺省为操作系统配置的第一个 hostname。 | | 补充说明 | 这个参数值的长度需要控制在 96 个字符以内。 | ### serverPort -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | taosd 启动后,对外服务的端口号 | -| 缺省值 | 6030 | -| 补充说明 | RESTful 服务在2.4.0.0之前(不含)由taosd提供,默认端口为 6041; 在2.4.0.0 及后续版本由 taosAdapter,默认端口为6041 | +| 属性 | 说明 | +| -------- | ----------------------------------------------------------------------------------------------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | taosd 启动后,对外服务的端口号 | +| 缺省值 | 6030 | +| 补充说明 | RESTful 服务在 2.4.0.0 之前(不含)由 taosd 提供,默认端口为 6041; 在 2.4.0.0 及后续版本由 taosAdapter,默认端口为 6041 | :::note 对于端口,TDengine 会使用从 serverPort 起 13 个连续的 TCP 和 UDP 端口号,请务必在防火墙打开。因此如果是缺省配置,需要打开从 6030 到 6042 共 13 个端口,而且必须 TCP 和 UDP 都打开。(详细的端口情况请参见下表) ::: -| 协议 | 默认端口 | 用途说明 | 修改方法 | +| 协议 | 默认端口 | 用途说明 | 修改方法 | | :--- | :-------- | :---------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- | -| TCP | 6030 | 客户端与服务端之间通讯。 | 由配置文件设置 serverPort 决定。 | -| TCP | 6035 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | -| TCP | 6040 | 多节点集群的节点间数据同步。 | 随 serverPort 端口变化。 | -| TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | -| TCP | 6042 | Arbitrator 的服务端口。 | 随 Arbitrator 启动参数设置变化。 | -| TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 | -| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | -| UDP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | -| TCP | 6060 | 企业版内 Monitor 服务的网络端口。 | | -| UDP | 6030-6034 | 客户端与服务端之间通讯。 | 随 serverPort 端口变化。 | -| UDP | 6035-6039 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 +| TCP | 6030 | 客户端与服务端之间通讯。 | 由配置文件设置 serverPort 决定。 | +| TCP | 6035 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | +| TCP | 6040 | 多节点集群的节点间数据同步。 | 随 serverPort 端口变化。 | +| TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | +| TCP | 6042 | Arbitrator 的服务端口。 | 随 Arbitrator 启动参数设置变化。 | +| TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 | +| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | +| UDP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | +| TCP | 6060 | 企业版内 Monitor 服务的网络端口。 | | +| UDP | 6030-6034 | 客户端与服务端之间通讯。 | 随 serverPort 端口变化。 | +| UDP | 6035-6039 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 ### maxShellConns @@ -147,14 +146,13 @@ taos --dump-config | 取值范围 | 1-600 | | 缺省值 | 30 | - ### telemetryReporting | 属性 | 说明 | | -------- | ---------------------------------------- | | 适用范围 | 仅服务端适用 | | 含义 | 是否允许 TDengine 采集和上报基本使用信息 | -| 取值范围 | 0:不允许 1:允许 | +| 取值范围 | 0:不允许 1:允许 | | 缺省值 | 1 | ## 查询相关 @@ -166,27 +164,27 @@ taos --dump-config | 适用范围 | 仅服务端适用 | | 含义 | 为所有并发查询占用保留的内存大小。 | | 单位 | MB | -| 缺省值 | 无 | +| 缺省值 | 无 | | 补充说明 | 计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。
(2.0.15 以前的版本中,此参数的单位是字节) | ### ratioOfQueryCores | 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | +| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 适用范围 | 仅服务端适用 | | 含义 | 设置查询线程的最大数量。 | -| 缺省值 | 1 | -| 补充说明 | 最小值 0 表示只有 1 个查询线程
最大值 2 表示最大建立 2 倍 CPU 核数的查询线程。
默认为 1,表示最大和 CPU 核数相等的查询线程。
该值可以为小数,即 0.5 表示最大建立 CPU 核数一半的查询线程。 | +| 缺省值 | 1 | +| 补充说明 | 最小值 0 表示只有 1 个查询线程
最大值 2 表示最大建立 2 倍 CPU 核数的查询线程。
默认为 1,表示最大和 CPU 核数相等的查询线程。
该值可以为小数,即 0.5 表示最大建立 CPU 核数一半的查询线程。 | ### maxNumOfDistinctRes | 属性 | 说明 | -| -------- | -------------------------------- | +| -------- | -------------------------------- | --- | | 适用范围 | 仅服务端适用 | | 含义 | 允许返回的 distinct 结果最大行数 | | 取值范围 | 默认值为 10 万,最大值 1 亿 | | 缺省值 | 10 万 | -| 补充说明 | 2.3 版本新增。 | | +| 补充说明 | 2.3 版本新增。 | | ## 区域相关 @@ -201,35 +199,35 @@ taos --dump-config :::info 为应对多时区的数据写入和查询问题,TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区,产生的时间戳均一致。需要注意的是,Unix 时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。 - 在 Linux 系统中,客户端会自动读取系统设置的时区信息。用户也可以采用多种方式在配置文件设置时区。例如: +在 Linux 系统中,客户端会自动读取系统设置的时区信息。用户也可以采用多种方式在配置文件设置时区。例如: - ``` - timezone UTC-8 - timezone GMT-8 - timezone Asia/Shanghai - ``` +``` +timezone UTC-8 +timezone GMT-8 +timezone Asia/Shanghai +``` - 均是合法的设置东八区时区的格式。但需注意,Windows 下并不支持 `timezone Asia/Shanghai` 这样的写法,而必须写成 `timezone UTC-8`。 +均是合法的设置东八区时区的格式。但需注意,Windows 下并不支持 `timezone Asia/Shanghai` 这样的写法,而必须写成 `timezone UTC-8`。 - 时区的设置对于查询和写入 SQL 语句中非 Unix 时间戳的内容(时间戳字符串、关键词 now 的解析)产生影响。例如: +时区的设置对于查询和写入 SQL 语句中非 Unix 时间戳的内容(时间戳字符串、关键词 now 的解析)产生影响。例如: - ```sql - SELECT count(*) FROM table_name WHERE TS<'2019-04-11 12:01:08'; - ``` +```sql +SELECT count(*) FROM table_name WHERE TS<'2019-04-11 12:01:08'; +``` - 在东八区,SQL 语句等效于 +在东八区,SQL 语句等效于 - ```sql - SELECT count(*) FROM table_name WHERE TS<1554955268000; - ``` +```sql +SELECT count(*) FROM table_name WHERE TS<1554955268000; +``` - 在 UTC 时区,SQL 语句等效于 +在 UTC 时区,SQL 语句等效于 - ```sql - SELECT count(*) FROM table_name WHERE TS<1554984068000; - ``` +```sql +SELECT count(*) FROM table_name WHERE TS<1554984068000; +``` - 为了避免使用字符串时间格式带来的不确定性,也可以直接使用 Unix 时间戳。此外,还可以在 SQL 语句中使用带有时区的时间戳字符串,例如:RFC3339 格式的时间戳字符串,2013-04-12T15:52:01.123+08:00 或者 ISO-8601 格式时间戳字符串 2013-04-12T15:52:01.123+0800。上述两个字符串转化为 Unix 时间戳不受系统所在时区的影响。 +为了避免使用字符串时间格式带来的不确定性,也可以直接使用 Unix 时间戳。此外,还可以在 SQL 语句中使用带有时区的时间戳字符串,例如:RFC3339 格式的时间戳字符串,2013-04-12T15:52:01.123+08:00 或者 ISO-8601 格式时间戳字符串 2013-04-12T15:52:01.123+0800。上述两个字符串转化为 Unix 时间戳不受系统所在时区的影响。 ::: @@ -242,11 +240,11 @@ taos --dump-config | 缺省值 | 系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置 | :::info - TDengine 为存储中文、日文、韩文等非 ASCII 编码的宽字符,提供一种专门的字段类型 nchar。写入 nchar 字段的数据将统一采用 UCS4-LE 格式进行编码并发送到服务器。需要注意的是,编码正确性是客户端来保证。因此,如果用户想要正常使用 nchar 字段来存储诸如中文、日文、韩文等非 ASCII 字符,需要正确设置客户端的编码格式。 +TDengine 为存储中文、日文、韩文等非 ASCII 编码的宽字符,提供一种专门的字段类型 nchar。写入 nchar 字段的数据将统一采用 UCS4-LE 格式进行编码并发送到服务器。需要注意的是,编码正确性是客户端来保证。因此,如果用户想要正常使用 nchar 字段来存储诸如中文、日文、韩文等非 ASCII 字符,需要正确设置客户端的编码格式。 - 客户端的输入的字符均采用操作系统当前默认的编码格式,在 Linux 系统上多为 UTF-8,部分中文系统编码则可能是 GB18030 或 GBK 等。在 docker 环境中默认的编码是 POSIX。在中文版 Windows 系统中,编码则是 CP936。客户端需要确保正确设置自己所使用的字符集,即客户端运行的操作系统当前编码字符集,才能保证 nchar 中的数据正确转换为 UCS4-LE 编码格式。 +客户端的输入的字符均采用操作系统当前默认的编码格式,在 Linux 系统上多为 UTF-8,部分中文系统编码则可能是 GB18030 或 GBK 等。在 docker 环境中默认的编码是 POSIX。在中文版 Windows 系统中,编码则是 CP936。客户端需要确保正确设置自己所使用的字符集,即客户端运行的操作系统当前编码字符集,才能保证 nchar 中的数据正确转换为 UCS4-LE 编码格式。 - 在 Linux 中 locale 的命名规则为: <语言>\_<地区>.<字符集编码> 如:zh_CN.UTF-8,zh 代表中文,CN 代表大陆地区,UTF-8 表示字符集。字符集编码为客户端正确解析本地字符串提供编码转换的说明。Linux 系统与 Mac OSX 系统可以通过设置 locale 来确定系统的字符编码,由于 Windows 使用的 locale 中不是 POSIX 标准的 locale 格式,因此在 Windows 下需要采用另一个配置参数 charset 来指定字符编码。在 Linux 系统中也可以使用 charset 来指定字符编码。 +在 Linux 中 locale 的命名规则为: <语言>\_<地区>.<字符集编码> 如:zh_CN.UTF-8,zh 代表中文,CN 代表大陆地区,UTF-8 表示字符集。字符集编码为客户端正确解析本地字符串提供编码转换的说明。Linux 系统与 Mac OSX 系统可以通过设置 locale 来确定系统的字符编码,由于 Windows 使用的 locale 中不是 POSIX 标准的 locale 格式,因此在 Windows 下需要采用另一个配置参数 charset 来指定字符编码。在 Linux 系统中也可以使用 charset 来指定字符编码。 ::: @@ -261,35 +259,35 @@ taos --dump-config :::info 如果配置文件中不设置 charset,在 Linux 系统中,taos 在启动时候,自动读取系统当前的 locale 信息,并从 locale 信息中解析提取 charset 编码格式。如果自动读取 locale 信息失败,则尝试读取 charset 配置,如果读取 charset 配置也失败,则中断启动过程。 - 在 Linux 系统中,locale 信息包含了字符编码信息,因此正确设置了 Linux 系统 locale 以后可以不用再单独设置 charset。例如: +在 Linux 系统中,locale 信息包含了字符编码信息,因此正确设置了 Linux 系统 locale 以后可以不用再单独设置 charset。例如: - ``` - locale zh_CN.UTF-8 - ``` +``` +locale zh_CN.UTF-8 +``` - 在 Windows 系统中,无法从 locale 获取系统当前编码。如果无法从配置文件中读取字符串编码信息,taos 默认设置为字符编码为 CP936。其等效在配置文件中添加如下配置: +在 Windows 系统中,无法从 locale 获取系统当前编码。如果无法从配置文件中读取字符串编码信息,taos 默认设置为字符编码为 CP936。其等效在配置文件中添加如下配置: - ``` - charset CP936 - ``` +``` +charset CP936 +``` - 如果需要调整字符编码,请查阅当前操作系统使用的编码,并在配置文件中正确设置。 +如果需要调整字符编码,请查阅当前操作系统使用的编码,并在配置文件中正确设置。 - 在 Linux 系统中,如果用户同时设置了 locale 和字符集编码 charset,并且 locale 和 charset 的不一致,后设置的值将覆盖前面设置的值。 +在 Linux 系统中,如果用户同时设置了 locale 和字符集编码 charset,并且 locale 和 charset 的不一致,后设置的值将覆盖前面设置的值。 - ``` - locale zh_CN.UTF-8 - charset GBK - ``` +``` +locale zh_CN.UTF-8 +charset GBK +``` - 则 charset 的有效值是 GBK。 +则 charset 的有效值是 GBK。 - ``` - charset GBK - locale zh_CN.UTF-8 - ``` +``` +charset GBK +locale zh_CN.UTF-8 +``` - charset 的有效值是 UTF-8。 +charset 的有效值是 UTF-8。 ::: @@ -391,7 +389,7 @@ taos --dump-config | 含义 | 是否在内存中缓存子表的最近数据 | | 取值范围 | 0:关闭
1:缓存子表最近一行数据
2:缓存子表每一列的最近的非 NULL 值
3:同时打开缓存最近行和列功能。(2.1.2.0 版本开始此参数支持 0 ~ 3 的取值范围,在此之前取值只能是 [0, 1]) | | 缺省值 | 0 | -| 补充说明 | 2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。 +| 补充说明 | 2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。 | ### minimalTmpDirGB @@ -400,7 +398,7 @@ taos --dump-config | 适用范围 | 服务端和客户端均适用 | | 含义 | 当日志文件夹的磁盘大小小于该值时,停止写临时文件 | | 单位 | GB | -| 缺省值 | 1.0 | +| 缺省值 | 1.0 | ### minimalDataDirGB @@ -456,6 +454,7 @@ taos --dump-config | 含义 | dnode 的可选角色 | | 取值范围 | 0:any(既可作为 mnode,也可分配 vnode)
1:mgmt(只能作为 mnode,不能分配 vnode)
2:dnode(不能作为 mnode,只能分配 vnode) | | 缺省值 | 0 | + ### balance | 属性 | 说明 | @@ -477,14 +476,23 @@ taos --dump-config ### arbitrator -| 属性 | 说明 | -| -------- | ------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 系统中裁决器的 end point,其格式如firstEp | -| 缺省值 | 空 | +| 属性 | 说明 | +| -------- | ------------------------------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | 系统中裁决器的 end point,其格式如 firstEp | +| 缺省值 | 空 | ## 时间相关 +### precision + +| 属性 | 说明 | +| -------- | ------------------------------------------------- | +| 适用范围 | 仅服务端 | +| 含义 | 创建数据库时使用的时间精度 | +| 取值范围 | ms: millisecond; us: microsecond ; ns: nanosecond | +| 缺省值 | ms | + ### rpcTimer | 属性 | 说明 | @@ -555,7 +563,6 @@ taos --dump-config | 取值范围 | 5-7200000 | | 缺省值 | 86400\*10(10 天) | - ## 性能调优 ### numOfThreadsPerCore @@ -603,11 +610,11 @@ taos --dump-config ### tableIncStepPerVnode -| 属性 | 说明 | -| -------- | ----------------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | ------------------------------------------------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | 每个 vnode 中超过最小表数,i.e. minTablesPerVnode, 后递增步长 | -| 缺省值 | 1000 | +| 缺省值 | 1000 | ### maxNumOfOrderedRes @@ -617,14 +624,13 @@ taos --dump-config | 含义 | 支持超级表时间排序允许的最多记录数限制 | | 缺省值 | 10 万 | - ### mnodeEqualVnodeNum -| 属性 | 说明 | -| -------- | ---------------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | ------------------------------------ | +| 适用范围 | 仅服务端适用 | | 含义 | 将一个 mnode 等同于 vnode 消耗的个数 | -| 缺省值 | 4 | +| 缺省值 | 4 | ### numOfCommitThreads @@ -681,7 +687,7 @@ taos --dump-config | 适用范围 | 服务器端 | | 含义 | 配置要进行有损压缩的浮点数据类型 | | 取值范围 | 空字符串:关闭有损压缩
float:只对 float 类型进行有损压缩
double:只对 double 类型进行有损压缩
float \| double:float double 都进行有损压缩 | -| 缺省值 | 空字符串 | +| 缺省值 | 空字符串 | | 补充说明 | 有损压缩默认为关闭状态,只有配置后才生效 | ### fPrecision @@ -738,13 +744,13 @@ taos --dump-config ### maxStreamCompDelay -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 连续查询启动最大延迟 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000000 | -| 缺省值 | 20000 | +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 连续查询启动最大延迟 | +| 单位 | 毫秒 | +| 取值范围 | 10-1000000000 | +| 缺省值 | 20000 | ### maxFirstStreamCompDelay @@ -768,12 +774,12 @@ taos --dump-config ### streamCompDelayRatio -| 属性 | 说明 | -| -------- | -------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | ---------------------------------------------------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | 连续查询的延迟时间计算系数,实际延迟时间为本参数乘以计算时间窗口 | -| 取值范围 | 0.1-0.9 | -| 缺省值 | 0.1 | +| 取值范围 | 0.1-0.9 | +| 缺省值 | 0.1 | :::info 为避免多个 stream 同时执行占用太多系统资源,程序中对 stream 的执行时间人为增加了一些随机的延时。
maxFirstStreamCompDelay 是 stream 第一次执行前最少要等待的时间。
streamCompDelayRatio 是延迟时间的计算系数,它乘以查询的 interval 后为延迟时间基准。
maxStreamCompDelay 是延迟时间基准的上限。
实际延迟时间为一个不超过延迟时间基准的随机值。
stream 某次计算失败后需要重试,retryStreamCompDelay 是重试的等待时间基准。
实际重试等待时间为不超过等待时间基准的随机值。 @@ -783,8 +789,8 @@ taos --dump-config ## HTTP 相关 :::note -HTTP服务在2.4.0.0(不含)以前的版本中由taosd提供,在2.4.0.0以后(含)由taosAdapter提供。 -本节的配置参数仅在2.4.0.0(不含)以前的版本中生效。如果您使用的是2.4.0.0(含)及以后的版本请参考[文档](/reference/taosadapter/)。 +HTTP 服务在 2.4.0.0(不含)以前的版本中由 taosd 提供,在 2.4.0.0 以后(含)由 taosAdapter 提供。 +本节的配置参数仅在 2.4.0.0(不含)以前的版本中生效。如果您使用的是 2.4.0.0(含)及以后的版本请参考[文档](/reference/taosadapter/)。 ::: @@ -799,29 +805,29 @@ HTTP服务在2.4.0.0(不含)以前的版本中由taosd提供,在2.4.0.0以 ### httpEnableRecordSql -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 记录通过 RESTFul 接口,产生的 SQL 调用。 | -| 缺省值 | 0 | -| 补充说明 | 生成的文件(httpnote.0/httpnote.1),与服务端日志所在目录相同。 | +| 属性 | 说明 | +| -------- | --------------------------------------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 记录通过 RESTFul 接口,产生的 SQL 调用。 | +| 缺省值 | 0 | +| 补充说明 | 生成的文件(httpnote.0/httpnote.1),与服务端日志所在目录相同。 | ### httpMaxThreads -| 属性 | 说明 | -| -------- | --------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | ------------------------------------------------------------------------------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | RESTFul 接口的线程数。taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | -| 缺省值 | 2 | +| 缺省值 | 2 | ### restfulRowLimit -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | ----------------------------------------------------------------------------------------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | RESTFul 接口单次返回的记录条数。taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | -| 缺省值 | 10240 | -| 补充说明 | 最大 10,000,000 | +| 缺省值 | 10240 | +| 补充说明 | 最大 10,000,000 | ### httpDBNameMandatory @@ -850,8 +856,7 @@ HTTP服务在2.4.0.0(不含)以前的版本中由taosd提供,在2.4.0.0以 | 适用范围 | 服务端和客户端均适用 | | 含义 | 当日志文件夹的磁盘大小小于该值时,停止写日志 | | 单位 | GB | -| 缺省值 | 1.0 | - +| 缺省值 | 1.0 | ### numOfLogLines @@ -1074,11 +1079,11 @@ HTTP服务在2.4.0.0(不含)以前的版本中由taosd提供,在2.4.0.0以 ### maxBinaryDisplayWidth -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 含义 | Taos shell 中 binary 和 nchar 字段的显示宽度上限,超过此限制的部分将被隐藏 | -| 取值范围 | 5 - | -| 缺省值 | 30 | +| 属性 | 说明 | +| -------- | -------------------------------------------------------------------------- | +| 含义 | Taos shell 中 binary 和 nchar 字段的显示宽度上限,超过此限制的部分将被隐藏 | +| 取值范围 | 5 - | +| 缺省值 | 30 | :::info 实际上限按以下规则计算:如果字段值的长度大于 maxBinaryDisplayWidth,则显示上限为 **字段名长度** 和 **maxBinaryDisplayWidth** 的较大者。
否则,上限为 **字段名长度** 和 **字段值长度** 的较大者。
可在 shell 中通过命令 set max_binary_display_width nn 动态修改此选项 diff --git a/docs-cn/14-reference/_category_.yml b/docs-cn/14-reference/_category_.yml index 079c784e6512109661afe08c12b398e8c4fab720..ae861a15ff626b1e0424a28838830702262aa377 100644 --- a/docs-cn/14-reference/_category_.yml +++ b/docs-cn/14-reference/_category_.yml @@ -1,5 +1 @@ -label: 参考指南 -link: - slug: /reference/ - type: generated-index - description: "参考指南是对 TDengine 本身、 TDengine 各语言连接器及自带的工具最详细的介绍。" +label: 参考指南 \ No newline at end of file diff --git a/docs-cn/14-reference/_collectd.mdx b/docs-cn/14-reference/_collectd.mdx index 1853769bf926a081a80cdf72b8e822e58cefb1e9..af3388f680228cacee3ea1081e3c01faec54e670 100644 --- a/docs-cn/14-reference/_collectd.mdx +++ b/docs-cn/14-reference/_collectd.mdx @@ -38,7 +38,7 @@ LoadPlugin network 其中 填写运行 taosAdapter 的服务器域名或 IP 地址。 填写 taosAdapter 用于接收 collectd 数据的端口(默认为 6045)。 -实例如下: +示例如下: ```text LoadPlugin network diff --git a/docs-cn/14-reference/_icinga2.mdx b/docs-cn/14-reference/_icinga2.mdx index 0ed5023f953a6d879cc553def3aa0eaa9098afd5..fdb341e264df8f9315ccd51abbc638adef65c06a 100644 --- a/docs-cn/14-reference/_icinga2.mdx +++ b/docs-cn/14-reference/_icinga2.mdx @@ -33,7 +33,7 @@ object OpenTsdbWriter "opentsdb" { } ``` -实例文件: +示例文件: ``` object OpenTsdbWriter "opentsdb" { diff --git a/docs-cn/14-reference/index.md b/docs-cn/14-reference/index.md new file mode 100644 index 0000000000000000000000000000000000000000..f48ce31fcefd2f0d875aee64e7d92490f4e92fcb --- /dev/null +++ b/docs-cn/14-reference/index.md @@ -0,0 +1,12 @@ +--- +title: 参考指南 +--- + +参考指南是对 TDengine 本身、 TDengine 各语言连接器及自带的工具最详细的介绍。 + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-cn/20-third-party/01-grafana.mdx b/docs-cn/20-third-party/01-grafana.mdx index 569cd750475447c9c6d107949c99b9405867916e..39420a01a308d41924d189fce75e8a372e294eba 100644 --- a/docs-cn/20-third-party/01-grafana.mdx +++ b/docs-cn/20-third-party/01-grafana.mdx @@ -5,6 +5,12 @@ title: Grafana TDengine 能够与开源数据可视化系统 [Grafana](https://www.grafana.com/) 快速集成搭建数据监测报警系统,整个过程无需任何代码开发,TDengine 中数据表的内容可以在仪表盘(DashBoard)上进行可视化展现。关于 TDengine 插件的使用您可以在[GitHub](https://github.com/taosdata/grafanaplugin/blob/master/README.md)中了解更多。 +## 前置条件 + +要让 Grafana 能正常添加 TDengine 数据源,需要以下几方面的准备工作。 +- TDengine 集群已经部署并正常运行 +- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) + ## 安装 Grafana 目前 TDengine 支持 Grafana 7.0 以上的版本。用户可以根据当前的操作系统,到 Grafana 官网下载安装包,并执行安装。下载地址如下:。 @@ -78,7 +84,7 @@ GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=tdengine-datasource ![img](/img/connections/create_dashboard1.jpg) -如上图所示,在 Query 中选中 `TDengine` 数据源,在下方查询框可输入相应 sql 进行查询,具体说明如下: +如上图所示,在 Query 中选中 `TDengine` 数据源,在下方查询框可输入相应 SQL 进行查询,具体说明如下: - INPUT SQL:输入要查询的语句(该 SQL 语句的结果集应为两列多行),例如:`select avg(mem_system) from log.dn where ts >= $from and ts < $to interval($interval)` ,其中,from、to 和 interval 为 TDengine 插件的内置变量,表示从 Grafana 插件面板获取的查询范围和时间间隔。除了内置变量外,`也支持可以使用自定义模板变量`。 - ALIAS BY:可设置当前查询别名。 diff --git a/docs-cn/20-third-party/09-emq-broder.md b/docs-cn/20-third-party/09-emq-broder.md deleted file mode 100644 index a661943088e2b478ff9940b6679a47c1bbb039ed..0000000000000000000000000000000000000000 --- a/docs-cn/20-third-party/09-emq-broder.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -sidebar_label: EMQ Broker -title: EMQ Broker 写入 ---- - -MQTT 是流行的物联网数据传输协议,[EMQ](https://github.com/emqx/emqx)是一开源的 MQTT Broker 软件,无需任何代码,只需要在 EMQ Dashboard 里使用“规则”做简单配置,即可将 MQTT 的数据直接写入 TDengine。EMQ X 支持通过 发送到 Web 服务的方式保存数据到 TDEngine,也在企业版上提供原生的 TDEngine 驱动实现直接保存。详细使用方法请参考 [EMQ 官方文档](https://docs.emqx.io/broker/latest/cn/rule/rule-example.html#%E4%BF%9D%E5%AD%98%E6%95%B0%E6%8D%AE%E5%88%B0-tdengine)。 diff --git a/docs-cn/20-third-party/09-emq-broker.md b/docs-cn/20-third-party/09-emq-broker.md new file mode 100644 index 0000000000000000000000000000000000000000..52a6e79dfc6e562b7a11be525c65efc40cfc91cc --- /dev/null +++ b/docs-cn/20-third-party/09-emq-broker.md @@ -0,0 +1,192 @@ +--- +sidebar_label: EMQX Broker +title: EMQX Broker 写入 +--- + +MQTT 是流行的物联网数据传输协议,[EMQX](https://github.com/emqx/emqx)是一开源的 MQTT Broker 软件,无需任何代码,只需要在 EMQX Dashboard 里使用“规则”做简单配置,即可将 MQTT 的数据直接写入 TDengine。EMQX 支持通过 发送到 Web 服务的方式保存数据到 TDengine,也在企业版上提供原生的 TDengine 驱动实现直接保存。 + +## 前置条件 + +要让 EMQX 能正常添加 TDengine 数据源,需要以下几方面的准备工作。 +- TDengine 集群已经部署并正常运行 +- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) +- 如果使用后文介绍的模拟写入程序,需要安装合适版本的 Node.js,推荐安装 v12。 + +## 安装并启动 EMQX + +用户可以根据当前的操作系统,到 EMQX 官网下载安装包,并执行安装。下载地址如下:。安装后使用 `sudo emqx start` 或 `sudo systemctl start emqx` 启动 EMQX 服务。 + +## 在 TDengine 中为接收 MQTT 数据创建相应数据库和表结构 + +### 以 Docker 安装 TDengine 为例 + +```bash + docker exec -it tdengine bash + taos +``` + +### 创建数据库和表 + +```sql + create database test; + use test; + create table: + + CREATE TABLE sensor_data (ts timestamp, temperature float, humidity float, volume float, PM10 float, pm25 float, SO2 float, NO2 float, CO float, sensor_id NCHAR(255), area TINYINT, coll_time timestamp); +``` + +注:表结构以博客[数据传输、存储、展现,EMQ X + TDengine 搭建 MQTT 物联网数据可视化平台](https://www.taosdata.com/blog/2020/08/04/1722.html)为例。后续操作均以此博客场景为例进行,请你根据实际应用场景进行修改。 + +## 配置 EMQX 规则 + +由于 EMQX 不同版本配置界面所有不同,这里仅以 v4.4.3 为例,其他版本请参考相应官网文档。 + +### 登录 EMQX Dashboard + +使用浏览器打开网址 http://IP:18083 并登录 EMQX Dashboard。初次安装用户名为 `admin` 密码为:`public` + +![img](./emqx/login-dashboard.png) + +### 创建规则(Rule) + +选择左侧“规则引擎(Rule Engine)”中的“规则(Rule)”并点击“创建(Create)”按钮: + +![img](./emqx/rule-engine.png) + +### 编辑 SQL 字段 + +![img](./emqx/create-rule.png) + +### 新增“动作(action handler)” + +![img](./emqx/add-action-handler.png) + +### 新增“资源(Resource)” + +![img](./emqx/create-resource.png) + +选择“发送数据到 Web 服务“并点击“新建资源”按钮: + +### 编辑“资源(Resource)” + +选择“发送数据到 Web 服务“并填写 请求 URL 为 运行 taosAdapter 的服务器地址和端口(默认为 6041)。其他属性请保持默认值。 + +![img](./emqx/edit-resource.png) + +### 编辑“动作(action)” + +编辑资源配置,增加 Authorization 认证的键/值配对项,相关文档请参考[ TDengine REST API 文档](https://docs.taosdata.com/reference/rest-api/)。在消息体中输入规则引擎替换模板。 + +![img](./emqx/edit-action.png) + +## 编写模拟测试程序 + +```javascript + // mock.js + const mqtt = require('mqtt') + const Mock = require('mockjs') + const EMQX_SERVER = 'mqtt://localhost:1883' + const CLIENT_NUM = 10 + const STEP = 5000 // 模拟采集时间间隔 ms + const AWAIT = 5000 // 每次发送完后休眠时间,防止消息速率过快 ms + const CLIENT_POOL = [] + startMock() + function sleep(timer = 100) { + return new Promise(resolve => { + setTimeout(resolve, timer) + }) + } + async function startMock() { + const now = Date.now() + for (let i = 0; i < CLIENT_NUM; i++) { + const client = await createClient(`mock_client_${i}`) + CLIENT_POOL.push(client) + } + // last 24h every 5s + const last = 24 * 3600 * 1000 + for (let ts = now - last; ts <= now; ts += STEP) { + for (const client of CLIENT_POOL) { + const mockData = generateMockData() + const data = { + ...mockData, + id: client.clientId, + area: 0, + ts, + } + client.publish('sensor/data', JSON.stringify(data)) + } + const dateStr = new Date(ts).toLocaleTimeString() + console.log(`${dateStr} send success.`) + await sleep(AWAIT) + } + console.log(`Done, use ${(Date.now() - now) / 1000}s`) + } + /** + * Init a virtual mqtt client + * @param {string} clientId ClientID + */ + function createClient(clientId) { + return new Promise((resolve, reject) => { + const client = mqtt.connect(EMQX_SERVER, { + clientId, + }) + client.on('connect', () => { + console.log(`client ${clientId} connected`) + resolve(client) + }) + client.on('reconnect', () => { + console.log('reconnect') + }) + client.on('error', (e) => { + console.error(e) + reject(e) + }) + }) + } + /** + * Generate mock data + */ + function generateMockData() { + return { + "temperature": parseFloat(Mock.Random.float(22, 100).toFixed(2)), + "humidity": parseFloat(Mock.Random.float(12, 86).toFixed(2)), + "volume": parseFloat(Mock.Random.float(20, 200).toFixed(2)), + "PM10": parseFloat(Mock.Random.float(0, 300).toFixed(2)), + "pm25": parseFloat(Mock.Random.float(0, 300).toFixed(2)), + "SO2": parseFloat(Mock.Random.float(0, 50).toFixed(2)), + "NO2": parseFloat(Mock.Random.float(0, 50).toFixed(2)), + "CO": parseFloat(Mock.Random.float(0, 50).toFixed(2)), + "area": Mock.Random.integer(0, 20), + "ts": 1596157444170, + } + } +``` + +注意:代码中 CLIENT_NUM 在开始测试中可以先设置一个较小的值,避免硬件性能不能完全处理较大并发客户端数量。 + +![img](./emqx/client-num.png) + +## 执行测试模拟发送 MQTT 数据 + +``` +npm install mqtt mockjs --save --registry=https://registry.npm.taobao.org +node mock.js +``` + +![img](./emqx/run-mock.png) + +## 验证 EMQX 接收到数据 + +在 EMQX Dashboard 规则引擎界面进行刷新,可以看到有多少条记录被正确接收到: + +![img](./emqx/check-rule-matched.png) + +## 验证数据写入到 TDengine + +使用 TDengine CLI 程序登录并查询相应数据库和表,验证数据是否被正确写入到 TDengine 中: + +![img](./emqx/check-result-in-taos.png) + +TDengine 详细使用方法请参考 [TDengine 官方文档](https://docs.taosdata.com/)。 +EMQX 详细使用方法请参考 [EMQ 官方文档](https://www.emqx.io/docs/zh/v4.4/rule/rule-engine.html)。 + diff --git a/docs-cn/20-third-party/_category_.yml b/docs-cn/20-third-party/_category_.yml index cf9d95e5f9e0941f64159ffa17619839fdafbf05..514d8c19a878d9700bf11cd7f25208278dfa902e 100644 --- a/docs-cn/20-third-party/_category_.yml +++ b/docs-cn/20-third-party/_category_.yml @@ -1,6 +1 @@ -label: 第三方工具 -link: - type: generated-index - slug: /third-party/ - description: TDengine 通过对标准 SQL 命令、常用数据库连接器标准(例如 JDBC)、ORM 以及其他流行时序数据库写入协议(例如 InfluxDB Line Protocol、OpenTSDB JSON、OpenTSDB Telnet 等)的支持可以使 TDengine 非常容易和第三方工具共同使用。 - +label: 第三方工具 \ No newline at end of file diff --git a/docs-cn/20-third-party/emqx/add-action-handler.png b/docs-cn/20-third-party/emqx/add-action-handler.png new file mode 100644 index 0000000000000000000000000000000000000000..97a1f933ecfadfcab399938806d73c5a5ecc6427 Binary files /dev/null and b/docs-cn/20-third-party/emqx/add-action-handler.png differ diff --git a/docs-cn/20-third-party/emqx/check-result-in-taos.png b/docs-cn/20-third-party/emqx/check-result-in-taos.png new file mode 100644 index 0000000000000000000000000000000000000000..c17a5c1ea2b9bbd49263056c8bf09c9aabab07d5 Binary files /dev/null and b/docs-cn/20-third-party/emqx/check-result-in-taos.png differ diff --git a/docs-cn/20-third-party/emqx/check-rule-matched.png b/docs-cn/20-third-party/emqx/check-rule-matched.png new file mode 100644 index 0000000000000000000000000000000000000000..9e9a466946a1afa857e2bbc07b14956dd0f984b6 Binary files /dev/null and b/docs-cn/20-third-party/emqx/check-rule-matched.png differ diff --git a/docs-cn/20-third-party/emqx/client-num.png b/docs-cn/20-third-party/emqx/client-num.png new file mode 100644 index 0000000000000000000000000000000000000000..fff48cbf3b271c367079ddde425b3f9b014062f7 Binary files /dev/null and b/docs-cn/20-third-party/emqx/client-num.png differ diff --git a/docs-cn/20-third-party/emqx/create-resource.png b/docs-cn/20-third-party/emqx/create-resource.png new file mode 100644 index 0000000000000000000000000000000000000000..58da4c391a3692b9f5fa348d952701eab8bcb746 Binary files /dev/null and b/docs-cn/20-third-party/emqx/create-resource.png differ diff --git a/docs-cn/20-third-party/emqx/create-rule.png b/docs-cn/20-third-party/emqx/create-rule.png new file mode 100644 index 0000000000000000000000000000000000000000..73b0b6ee3e6065a142df98abe8c0dbb32b34f89d Binary files /dev/null and b/docs-cn/20-third-party/emqx/create-rule.png differ diff --git a/docs-cn/20-third-party/emqx/edit-action.png b/docs-cn/20-third-party/emqx/edit-action.png new file mode 100644 index 0000000000000000000000000000000000000000..2a43ee369a439cf11cee23c11f25d6a84b26d7dc Binary files /dev/null and b/docs-cn/20-third-party/emqx/edit-action.png differ diff --git a/docs-cn/20-third-party/emqx/edit-resource.png b/docs-cn/20-third-party/emqx/edit-resource.png new file mode 100644 index 0000000000000000000000000000000000000000..0a0b3560044f4ed6e0a8f040b74085a7e8948b1f Binary files /dev/null and b/docs-cn/20-third-party/emqx/edit-resource.png differ diff --git a/docs-cn/20-third-party/emqx/login-dashboard.png b/docs-cn/20-third-party/emqx/login-dashboard.png new file mode 100644 index 0000000000000000000000000000000000000000..d6c5035c98d860faf639ef6611c6719adf80c47b Binary files /dev/null and b/docs-cn/20-third-party/emqx/login-dashboard.png differ diff --git a/docs-cn/20-third-party/emqx/rule-engine.png b/docs-cn/20-third-party/emqx/rule-engine.png new file mode 100644 index 0000000000000000000000000000000000000000..db110a837b024c82ee9d22f02dcd3a9d06abdd55 Binary files /dev/null and b/docs-cn/20-third-party/emqx/rule-engine.png differ diff --git a/docs-cn/20-third-party/emqx/rule-header-key-value.png b/docs-cn/20-third-party/emqx/rule-header-key-value.png new file mode 100644 index 0000000000000000000000000000000000000000..b81b9a9684aa2f98d00b7ec21e5de411fb450312 Binary files /dev/null and b/docs-cn/20-third-party/emqx/rule-header-key-value.png differ diff --git a/docs-cn/20-third-party/emqx/run-mock.png b/docs-cn/20-third-party/emqx/run-mock.png new file mode 100644 index 0000000000000000000000000000000000000000..0da25818575247732d5d3a783aa52cf7ce24662c Binary files /dev/null and b/docs-cn/20-third-party/emqx/run-mock.png differ diff --git a/docs-cn/20-third-party/index.md b/docs-cn/20-third-party/index.md new file mode 100644 index 0000000000000000000000000000000000000000..2d21d1d74276ee12ad857367217273eda184a7b9 --- /dev/null +++ b/docs-cn/20-third-party/index.md @@ -0,0 +1,12 @@ +--- +title: 第三方工具 +--- + +TDengine 通过对标准 SQL 命令、常用数据库连接器标准(例如 JDBC)、ORM 以及其他流行时序数据库写入协议(例如 InfluxDB Line Protocol、OpenTSDB JSON、OpenTSDB Telnet 等)的支持可以使 TDengine 非常容易和第三方工具共同使用。 + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-cn/21-tdinternal/_category_.yml b/docs-cn/21-tdinternal/_category_.yml index 73c78f68a520fefecc145daaa24fe7e28c7c78e2..c7509bf66224fa94759de9a2ae82955e2a7eb82f 100644 --- a/docs-cn/21-tdinternal/_category_.yml +++ b/docs-cn/21-tdinternal/_category_.yml @@ -1,4 +1 @@ -label: 技术内幕 -link: - slug: /tdinternal/ - type: generated-index \ No newline at end of file +label: 技术内幕 \ No newline at end of file diff --git a/docs-cn/21-tdinternal/index.md b/docs-cn/21-tdinternal/index.md new file mode 100644 index 0000000000000000000000000000000000000000..63a746623e0dd955f61ba887a76f8ecf7eb16972 --- /dev/null +++ b/docs-cn/21-tdinternal/index.md @@ -0,0 +1,10 @@ +--- +title: 技术内幕 +--- + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-cn/25-application/01-telegraf.md b/docs-cn/25-application/01-telegraf.md index 87f74fa67fbdbc3e4c5631b9cd393c4a78d3e25e..f63a6701eed2b4c5b98f577d5b2867ae6dada387 100644 --- a/docs-cn/25-application/01-telegraf.md +++ b/docs-cn/25-application/01-telegraf.md @@ -34,11 +34,11 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ### TDengine -从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.3.0.0 或以上版本安装。 +从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.4.0.x 或以上版本安装。 ## 数据链路设置 -### 下载 TDengine 插件到 grafana 插件目录 +### 下载 TDengine 插件到 Grafana 插件目录 ```bash 1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip @@ -50,7 +50,7 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ### 修改 /etc/telegraf/telegraf.conf -配置方法,在 /etc/telegraf/telegraf.conf 增加如下文字,其中 database name 请填写希望在 TDengine 保存 Telegraf 数据的数据库名,TDengine server/cluster host、username 和 password 填写 TDengine 实际值: +配置方法,在 `/etc/telegraf/telegraf.conf` 增加如下文字,其中 `database name` 请填写希望在 TDengine 保存 Telegraf 数据的数据库名,`TDengine server/cluster host`、`username` 和 `password` 填写 TDengine 实际值: ``` [[outputs.http]] @@ -63,7 +63,7 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 influx_max_line_bytes = 250 ``` -然后重启 telegraf: +然后重启 Telegraf: ```bash sudo systemctl start telegraf @@ -71,12 +71,12 @@ sudo systemctl start telegraf ### 导入 Dashboard -使用 Web 浏览器访问 IP:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。 -点击左侧齿轮图标并选择 Plugins,应该可以找到 TDengine data source 插件图标。 -点击左侧加号图标并选择 Import,从 `https://github.com/taosdata/grafanaplugin/blob/master/examples/telegraf/grafana/dashboards/telegraf-dashboard-v0.1.0.json` 下载 dashboard JSON 文件后导入。之后可以看到如下界面的仪表盘: +使用 Web 浏览器访问 `IP:3000` 登录 Grafana 界面,系统初始用户名密码为 admin/admin。 +点击左侧齿轮图标并选择 `Plugins`,应该可以找到 TDengine data source 插件图标。 +点击左侧加号图标并选择 `Import`,从 `https://github.com/taosdata/grafanaplugin/blob/master/examples/telegraf/grafana/dashboards/telegraf-dashboard-v0.1.0.json` 下载 dashboard JSON 文件后导入。之后可以看到如下界面的仪表盘: ![IT-DevOps-Solutions-telegraf-dashboard.png](/img/IT-DevOps-Solutions-telegraf-dashboard.png) ## 总结 -以上演示如何快速搭建一个完整的 IT 运维展示系统。得力于 TDengine 2.3.0.0 版本中新增的 schemaless 协议解析功能,以及强大的生态软件适配能力,用户可以短短数分钟就可以搭建一个高效易用的 IT 运维系统。TDengine 强大的数据写入查询性能和其他丰富功能请参考官方文档和产品落地案例。 +以上演示如何快速搭建一个完整的 IT 运维展示系统。得力于 TDengine 2.4.0.0 版本中新增的 schemaless 协议解析功能,以及强大的生态软件适配能力,用户可以短短数分钟就可以搭建一个高效易用的 IT 运维系统。TDengine 强大的数据写入查询性能和其他丰富功能请参考官方文档和产品落地案例。 diff --git a/docs-cn/25-application/02-collectd.md b/docs-cn/25-application/02-collectd.md index da055632837e74f4d863148843f1001cc3aa3e8b..5e6bc6577b2f4c8564e4533ced745d0b214ec748 100644 --- a/docs-cn/25-application/02-collectd.md +++ b/docs-cn/25-application/02-collectd.md @@ -36,7 +36,7 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ### 安装 TDengine -从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.3.0.0 或以上版本安装。 +从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.4.0.x 或以上版本安装。 ## 数据链路设置 @@ -52,7 +52,7 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ### 配置 collectd -在 `/etc/collectd/collectd.conf` 文件中增加如下内容,其中 host 和 port 请填写 TDengine 和 taosAdapter 配置的实际值: +在 `/etc/collectd/collectd.conf` 文件中增加如下内容,其中 `host` 和 `port` 请填写 TDengine 和 taosAdapter 配置的实际值: ``` LoadPlugin network @@ -65,7 +65,7 @@ sudo systemctl start collectd ### 配置 StatsD -在 `config.js` 文件中增加如下内容后启动 StatsD,其中 host 和 port 请填写 TDengine 和 taosAdapter 配置的实际值: +在 `config.js` 文件中增加如下内容后启动 StatsD,其中 `host` 和 `port` 请填写 TDengine 和 taosAdapter 配置的实际值: ``` backends 部分添加 "./backends/repeater" @@ -74,22 +74,22 @@ repeater 部分添加 { host:'', port: ``` -即可让 collectd 将数据使用推送到 OpenTSDB 的插件方式推送到 taosAdapter, taosAdapter 将调用 API 将数据写入到 taosd 中,从而完成数据的写入工作。如果你使用的是 StatsD 相应地调整配置文件信息。 +即可让 collectd 将数据使用推送到 OpenTSDB 的插件方式推送到 taosAdapter, taosAdapter 将调用 API 将数据写入到 TDengine 中,从而完成数据的写入工作。如果你使用的是 StatsD 相应地调整配置文件信息。 -- **调整看板(Dashborad)系统** +- **调整看板(Dashboard)系统** 在数据能够正常写入 TDengine 后,可以调整适配 Grafana 将写入 TDengine 的数据可视化呈现出来。获取和使用 TDengine 提供的 Grafana 插件请参考[与其他工具的连接](/third-party/grafana)。 @@ -93,11 +93,11 @@ TDengine 提供了默认的两套 Dashboard 模板,用户只需要将 Grafana TDengine 当前只支持 Grafana 的可视化看板呈现,所以如果你的应用中使用了 Grafana 以外的前端看板(例如[TSDash](https://github.com/facebook/tsdash)、[Status Wolf](https://github.com/box/StatusWolf)等),那么前端看板将无法直接迁移到 TDengine,需要将前端看板重新适配到 Grafana 才可以正常运行。 -截止到 2.3.0.x 版本,TDengine 只能够支持 collectd 和 StatsD 作为数据收集汇聚软件,当然后面会陆续提供更多的数据收集聚合软件的接入支持。如果您的收集端使用了其他类型的数据汇聚器,您的应用需要适配到这两个数据汇聚端系统,才能够将数据正常写入。除了上述两个数据汇聚端软件协议以外,TDengine 还支持通过 InfluxDB 的行协议和 OpenTSDB 的数据写入协议、JSON 格式将数据直接写入,您可以重写数据推送端的逻辑,使用 TDengine 支持的行协议来写入数据。 +在 2.3.0.x 版本中,TDengine 只能够支持 collectd 和 StatsD 作为数据收集汇聚软件,当然后面会陆续提供更多的数据收集聚合软件的接入支持。如果您的收集端使用了其他类型的数据汇聚器,您的应用需要适配到这两个数据汇聚端系统,才能够将数据正常写入。除了上述两个数据汇聚端软件协议以外,TDengine 还支持通过 InfluxDB 的行协议和 OpenTSDB 的数据写入协议、JSON 格式将数据直接写入,您可以重写数据推送端的逻辑,使用 TDengine 支持的行协议来写入数据。 此外,如果你的应用中使用了 OpenTSDB 以下特性,在将应用迁移到 TDengine 之前你还需要了解以下注意事项: -1. ` /api/stats`:如果你的应用中使用了该项特性来监控 OpenTSDB 的服务状态,并在应用中建立了相关的逻辑来联动处理,那么这部分状态读取和获取的逻辑需要重新适配到 TDengine。TDengine 提供了全新的处理集群状态监控机制,来满足你的应用对其进行的监控和维护的需求。 +1. `/api/stats`:如果你的应用中使用了该项特性来监控 OpenTSDB 的服务状态,并在应用中建立了相关的逻辑来联动处理,那么这部分状态读取和获取的逻辑需要重新适配到 TDengine。TDengine 提供了全新的处理集群状态监控机制,来满足你的应用对其进行的监控和维护的需求。 2. `/api/tree`:如果你依赖于 OpenTSDB 的该项特性来进行时间线的层级化组织和维护,那么便无法将其直接迁移至 TDengine。TDengine 采用了数据库->超级表->子表这样的层级来组织和维护时间线,归属于同一个超级表的所有的时间线在系统中同一个层级,但是可以通过不同标签值的特殊构造来模拟应用逻辑上的多级结构。 3. `Rollup And PreAggregates`:采用了 Rollup 和 PreAggregates 需要应用来决定在合适的地方访问 Rollup 的结果,在某些场景下又要访问原始的结果,这种结构的不透明性让应用处理逻辑变得极为复杂而且完全不具有移植性。我们认为这种策略是时序数据库无法提供高性能聚合情况下的妥协与折中。TDengine 暂不支持多个时间线的自动降采样和(时间段范围的)预聚合,由于 其拥有的高性能查询处理逻辑,即使不依赖于 Rollup 和 (时间段)预聚合计算结果,也能够提供很高性能的查询响应,而且让你的应用查询处理逻辑更加简单。 4. `Rate`: TDengine 提供了两个计算数值变化率的函数,分别是 Derivative(其计算结果与 InfluxDB 的 Derivative 行为一致)和 IRate(其计算结果与 Prometheus 中的 IRate 函数计算结果一致)。但是这两个函数的计算结果与 Rate 有细微的差别,但整体上功能更强大。此外,**OpenTSDB 提供的所有计算函数,TDengine 均有对应的查询函数支持,并且 TDengine 的查询函数功能远超过 OpenTSDB 支持的查询函数,**可以极大地简化你的应用处理逻辑。 @@ -122,13 +122,13 @@ TDengine 当前只支持 Grafana 的可视化看板呈现,所以如果你的 TDengine 要求存储的数据具有数据模式,即写入数据之前需创建超级表并指定超级表的模式。对于数据模式的建立,你有两种方式来完成此项工作:1)充分利用 TDengine 对 OpenTSDB 的数据原生写入的支持,调用 TDengine 提供的 API 将(文本行或 JSON 格式)数据写入,并自动化地建立单值模型。采用这种方式不需要对数据写入应用进行较大的调整,也不需要对写入的数据格式进行转换。 -在 C 语言层面,TDengine 提供了 taos_insert_lines() 函数来直接写入 OpenTSDB 格式的数据(在 2.3.x 版本中该函数对应的是 taos_schemaless_insert())。其代码参考示例请参见安装包目录下示例代码 schemaless.c。 +在 C 语言层面,TDengine 提供了 `taos_schemaless_insert()` 函数来直接写入 OpenTSDB 格式的数据(在更早版本中该函数名称是 `taos_insert_lines()`)。其代码参考示例请参见安装包目录下示例代码 schemaless.c。 2)在充分理解 TDengine 的数据模型基础上,结合生成数据的特点,手动方式建立 OpenTSDB 到 TDengine 的数据模型调整的映射关系。TDengine 能够支持多值模型和单值模型,考虑到 OpenTSDB 均为单值映射模型,这里推荐使用单值模型在 TDengine 中进行建模。 - **单值模型**。 -具体步骤如下:将度量(metrics)的名称作为 TDengine 超级表的名称,该超级表建成后具有两个基础的数据列—时间戳(timestamp)和值(value),超级表的标签等效于 度量 的标签信息,标签数量等同于度量 的标签的数量。子表的表名采用具有固定规则的方式进行命名:`metric + '_' + tags1_value + '_' + tag2_value + '_' + tag3_value ... `作为子表名称。 +具体步骤如下:将度量(metrics)的名称作为 TDengine 超级表的名称,该超级表建成后具有两个基础的数据列—时间戳(timestamp)和值(value),超级表的标签等效于 度量 的标签信息,标签数量等同于度量 的标签的数量。子表的表名采用具有固定规则的方式进行命名:`metric + '_' + tags1_value + '_' + tag2_value + '_' + tag3_value ...`作为子表名称。 在 TDengine 中建立 3 个超级表: @@ -141,7 +141,7 @@ create stable disk(ts timestamp, val double) tags(host binary(12), disk_point bi 对于子表使用动态建表的方式创建如下所示: ```sql -insert into memory_vm130_memory_bufferred_collectd using memory tags(‘vm130’, ‘memory’, 'buffer', 'collectd') values(1632979445, 3.0656); +insert into memory_vm130_memory_buffered_collectd using memory tags(‘vm130’, ‘memory’, 'buffer', 'collectd') values(1632979445, 3.0656); ``` 最终系统中会建立 340 个左右的子表,3 个超级表。需要注意的是,如果采用串联标签值的方式导致子表名称超过系统限制(191 字节),那么需要采用一定的编码方式(例如 MD5)将其转化为可接受长度。 @@ -172,7 +172,7 @@ TDengine 支持标准的 JDBC 3.0 接口操纵数据库,你也可以使用其 为了方便历史数据的迁移工作,我们为数据同步工具 DataX 提供了插件,能够将数据自动写入到 TDengine 中,需要注意的是 DataX 的自动化数据迁移只能够支持单值模型的数据迁移过程。 -DataX 具体的使用方式及如何使用 DataX 将数据写入 TDengine 请参见[基于 DataX 的 TDeninge 数据迁移工具](https://www.taosdata.com/blog/2021/10/26/3156.html)。 +DataX 具体的使用方式及如何使用 DataX 将数据写入 TDengine 请参见[基于 DataX 的 TDengine 数据迁移工具](https://www.taosdata.com/blog/2021/10/26/3156.html)。 在对 DataX 进行迁移实践后,我们发现通过启动多个进程,同时迁移多个 metric 的方式,可以大幅度的提高迁移历史数据的效率,下面是迁移过程中的部分记录,希望这些能为应用迁移工作带来参考。 @@ -202,13 +202,15 @@ DataX 具体的使用方式及如何使用 DataX 将数据写入 TDengine 请参 ## 附录 1: OpenTSDB 查询函数对应表 -**Avg** +### Avg 等效函数:avg 示例: +```sql SELECT avg(val) FROM (SELECT first(val) FROM super_table WHERE ts >= startTime and ts <= endTime INTERVAL(20s) Fill(linear)) INTERVAL(20s) +``` 备注: @@ -217,103 +219,124 @@ SELECT avg(val) FROM (SELECT first(val) FROM super_table WHERE ts >= startTime a 3. Interval 中参数 20s 表示将内层查询按照 20 秒一个时间窗口生成结果。在真实的查询中,需要调整为不同的记录之间的时间间隔。这样可确保等效于原始数据生成了插值结果。 4. 由于 OpenTSDB 特殊的插值策略和机制,聚合查询(Aggregate)中先插值再计算的方式导致其计算结果与 TDengine 不可能完全一致。但是在降采样(Downsample)的情况下,TDengine 和 OpenTSDB 能够获得一致的结果(由于 OpenTSDB 在聚合查询和降采样查询中采用了完全不同的插值策略)。 -**Count** +### Count 等效函数:count 示例: +```sql select count(\*) from super_table_name; +``` -**Dev** +### Dev 等效函数:stddev 示例: +```sql Select stddev(val) from table_name +``` -**Estimated percentiles** +### Estimated percentiles 等效函数:apercentile 示例: +```sql Select apercentile(col1, 50, “t-digest”) from table_name +``` 备注: 1. 近似查询处理过程中,OpenTSDB 默认采用 t-digest 算法,所以为了获得相同的计算结果,需要在 apercentile 函数中指明使用的算法。TDengine 能够支持两种不同的近似处理算法,分别通过“default”和“t-digest”来声明。 - -**First** +### First 等效函数:first 示例: +```sql Select first(col1) from table_name +``` -**Last** +### Last 等效函数:last 示例: +```sql Select last(col1) from table_name +``` -**Max** +### Max 等效函数:max 示例: +```sql Select max(value) from (select first(val) value from table_name interval(10s) fill(linear)) interval(10s) +``` 备注:Max 函数需要插值,原因见上。 -**Min** +### Min 等效函数:min 示例: +```sql Select min(value) from (select first(val) value from table_name interval(10s) fill(linear)) interval(10s); +``` -**MinMax** +### MinMax 等效函数:max +```sql Select max(val) from table_name +``` 备注:该函数无插值需求,因此可用直接计算。 -**MimMin** +### MimMin 等效函数:min +```sql Select min(val) from table_name +``` 备注:该函数无插值需求,因此可用直接计算。 -**Percentile** +### Percentile 等效函数:percentile 备注: -**Sum** +### Sum 等效函数:sum +```sql Select max(value) from (select first(val) value from table_name interval(10s) fill(linear)) interval(10s) +``` 备注:该函数无插值需求,因此可用直接计算。 -**Zimsum** +### Zimsum 等效函数:sum +```sql Select sum(val) from table_name +``` 备注:该函数无插值需求,因此可用直接计算。 @@ -354,7 +377,7 @@ WHERE ts>=1510560000 AND ts<=1515000009 ### 存储设备选型考虑 -硬盘应该选用具有较好随机读性能的硬盘设备,如果能够有 SSD,尽可能考虑使用 SSD。较好的随机读性能的磁盘对于提升系统查询性能具有极大的帮助,能够整体上提升系统的查询响应性能。为了获得较好的查询性能,硬盘设备的单线程随机读 IOPS 的性能指标不应该低于 1000,能够达到 5000 IOPS 以上为佳。为了获得当前的设备随机读取的 IO 性能的评估,建议使用 fio 软件对其进行运行性能评估(具体的使用方式请参阅附录 1),确认其是否能够满足大文件随机读性能要求。 +硬盘应该选用具有较好随机读性能的硬盘设备,如果能够有 SSD,尽可能考虑使用 SSD。较好的随机读性能的磁盘对于提升系统查询性能具有极大的帮助,能够整体上提升系统的查询响应性能。为了获得较好的查询性能,硬盘设备的单线程随机读 IOPS 的性能指标不应该低于 1000,能够达到 5000 IOPS 以上为佳。为了获得当前的设备随机读取的 IO 性能的评估,建议使用 `fio` 软件对其进行运行性能评估(具体的使用方式请参阅附录 1),确认其是否能够满足大文件随机读性能要求。 硬盘写性能对于 TDengine 的影响不大。TDengine 写入过程采用了追加写的模式,所以只要有较好的顺序写性能即可,一般意义上的 SAS 硬盘和 SSD 均能够很好地满足 TDengine 对于磁盘写入性能的要求。 @@ -372,13 +395,13 @@ WHERE ts>=1510560000 AND ts<=1515000009 ## 附录 3: 集群部署及启动 -TDengine 提供了丰富的帮助文档说明集群安装、部署的诸多方面的内容,这里提供响应的文档索引,供你参考。 +TDengine 提供了丰富的帮助文档说明集群安装、部署的诸多方面的内容,这里提供相应的文档列表,供你参考。 ### 集群部署 首先是安装 TDengine,从官网上下载 TDengine 最新稳定版,解压缩后运行 install.sh 进行安装。各种安装包的使用帮助请参见博客[《TDengine 多种安装包的安装和卸载》](https://www.taosdata.com/blog/2019/08/09/566.html)。 -注意安装完成以后,不要立即启动 taosd 服务,在正确配置完成参数以后才启动 taosd 服务。 +注意安装完成以后,不要立即启动 `taosd` 服务,在正确配置完成参数以后才启动 `taosd` 服务。 ### 设置运行参数并启动服务 @@ -386,13 +409,13 @@ TDengine 提供了丰富的帮助文档说明集群安装、部署的诸多方 FQDN、firstEp、secondEP、dataDir、logDir、tmpDir、serverPort。各参数的具体含义及设置的要求,可参见文档《[TDengine 集群安装、管理](/cluster/)》 -按照相同的步骤,在需要运行的节点上设置参数,并启动 taosd 服务,然后添加 Dnode 到集群中。 +按照相同的步骤,在需要运行的节点上设置参数,并启动 `taosd` 服务,然后添加 Dnode 到集群中。 -最后启动 taos,执行命令 show dnodes,如果能看到所有的加入集群的节点,那么集群顺利搭建完成。具体的操作流程及注意事项,请参阅文档《[TDengine 集群安装、管理](/cluster/)》 +最后启动 `taos` 命令行程序,执行命令 `show dnodes`,如果能看到所有的加入集群的节点,那么集群顺利搭建完成。具体的操作流程及注意事项,请参阅文档《[TDengine 集群安装、管理](/cluster/)》 ## 附录 4: 超级表名称 -由于 OpenTSDB 的 metric 名称中带有点号(“.“),例如“cpu.usage_user”这种名称的 metric。但是点号在 TDengine 中具有特殊含义,是用来分隔数据库和表名称的分隔符。TDengine 也提供转义符,以允许用户在(超级)表名称中使用关键词或特殊分隔符(如:点号)。为了使用特殊字符,需要采用转义字符将表的名称括起来,例如:`cpu.usage_user`这样就是合法的(超级)表名称。 +由于 OpenTSDB 的 metric 名称中带有点号(“.”),例如“cpu.usage_user”这种名称的 metric。但是点号在 TDengine 中具有特殊含义,是用来分隔数据库和表名称的分隔符。TDengine 也提供转义符,以允许用户在(超级)表名称中使用关键词或特殊分隔符(如:点号)。为了使用特殊字符,需要采用转义字符将表的名称括起来,例如:`cpu.usage_user`这样就是合法的(超级)表名称。 ## 附录 5:参考文章 diff --git a/docs-cn/25-application/_category_.yml b/docs-cn/25-application/_category_.yml index 141c9269b50a2155391543ecea1dfe5c918e113c..f43a4601b6c269822cbc0de1b7ed99dfdc70cfe5 100644 --- a/docs-cn/25-application/_category_.yml +++ b/docs-cn/25-application/_category_.yml @@ -1,4 +1 @@ label: 应用实践 -link: - slug: /application/ - type: generated-index diff --git a/docs-cn/25-application/index.md b/docs-cn/25-application/index.md new file mode 100644 index 0000000000000000000000000000000000000000..1305cf230f78b68f988918921540a1df05f0931f --- /dev/null +++ b/docs-cn/25-application/index.md @@ -0,0 +1,10 @@ +--- +title: 应用实践 +--- + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-cn/27-train-faq/01-faq.md b/docs-cn/27-train-faq/01-faq.md index fac12cb44eaff68ec74d3019e537aecb0291410f..80f66226b2171b1fcdf58ba18334f87868154ac6 100644 --- a/docs-cn/27-train-faq/01-faq.md +++ b/docs-cn/27-train-faq/01-faq.md @@ -177,40 +177,9 @@ title: 常见问题及反馈 -**18. 时间戳的时区信息是怎样处理的?** +**18. go 语言编写组件编译失败怎样解决?** - TDengine 中时间戳的时区总是由客户端进行处理,而与服务端无关。具体来说,客户端会对 SQL 语句中的时间戳进行时区转换,转为 UTC 时区(即 Unix 时间戳——Unix Timestamp)再交由服务端进行写入和查询;在读取数据时,服务端也是采用 UTC 时区提供原始数据,客户端收到后再根据本地设置,把时间戳转换为本地系统所要求的时区进行显示。 - - 客户端在处理时间戳字符串时,会采取如下逻辑: - - 1. 在未做特殊设置的情况下,客户端默认使用所在操作系统的时区设置。 - 2. 如果在 taos.cfg 中设置了 timezone 参数,则客户端会以这个配置文件中的设置为准。 - 3. 如果在 C/C++/Java/Python 等各种编程语言的 Connector Driver 中,在建立数据库连接时显式指定了 timezone,那么会以这个指定的时区设置为准。例如 Java Connector 的 JDBC URL 中就有 timezone 参数。 - 4. 在书写 SQL 语句时,也可以直接使用 Unix 时间戳(例如 `1554984068000`)或带有时区的时间戳字符串,也即以 RFC 3339 格式(例如 `2013-04-12T15:52:01.123+08:00`)或 ISO-8601 格式(例如 `2013-04-12T15:52:01.123+0800`)来书写时间戳,此时这些时间戳的取值将不再受其他时区设置的影响。 - - - -**19. TDengine 都会用到哪些网络端口?** - - 在 TDengine 2.0 版本中,会用到以下这些网络端口(以默认端口 6030 为前提进行说明,如果修改了配置文件中的设置,那么这里列举的端口都会出现变化),管理员可以参考这里的信息调整防火墙设置: - -| 协议 | 默认端口 | 用途说明 | 修改方法 | -| :--- | :-------- | :---------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- | -| TCP | 6030 | 客户端与服务端之间通讯。 | 由配置文件设置 serverPort 决定。 | -| TCP | 6035 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | -| TCP | 6040 | 多节点集群的节点间数据同步。 | 随 serverPort 端口变化。 | -| TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | -| TCP | 6042 | Arbitrator 的服务端口。 | 随 Arbitrator 启动参数设置变化。 | -| TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 | -| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | -| TCP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | -| TCP | 6060 | 企业版内 Monitor 服务的网络端口。 | | -| UDP | 6030-6034 | 客户端与服务端之间通讯。 | 随 serverPort 端口变化。 | -| UDP | 6035-6039 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | - -**20. go 语言编写组件编译失败怎样解决?** - - 新版本 TDengine 2.3.0.0 包含一个使用 go 语言开发的 taosAdapter 独立组件,需要单独运行,取代之前 taosd 内置的 httpd ,提供包含原 httpd 功能以及支持多种其他软件(Prometheus、Telegraf、collectd、StatsD 等)的数据接入功能。 + TDengine 2.3.0.0 及之后的版本包含一个使用 go 语言开发的 taosAdapter 独立组件,需要单独运行,取代之前 taosd 内置的 httpd ,提供包含原 httpd 功能以及支持多种其他软件(Prometheus、Telegraf、collectd、StatsD 等)的数据接入功能。 使用最新 develop 分支代码编译需要先 `git submodule update --init --recursive` 下载 taosAdapter 仓库代码后再编译。 目前编译方式默认自动编译 taosAdapter。go 语言版本要求 1.14 以上,如果发生 go 编译错误,往往是国内访问 go mod 问题,可以通过设置 go 环境变量来解决: @@ -222,3 +191,14 @@ title: 常见问题及反馈 如果希望继续使用之前的内置 httpd,可以关闭 taosAdapter 编译,使用 `cmake .. -DBUILD_HTTP=true` 使用原来内置的 httpd。 + + +**19. 如何查询数据占用的存储空间大小?** + + 默认情况下,TDengine 的数据文件存储在 /var/lib/taos ,日志文件存储在 /var/log/taos 。 + + 若想查看所有数据文件占用的具体大小,可以执行 Shell 指令:`du -sh /var/lib/taos/vnode --exclude='wal'` 来查看。此处排除了 wal 目录,因为在持续写入的情况下,这里大小几乎是固定的,并且每当正常关闭 TDengine 让数据落盘后, wal 目录都会清空。 + + 若想查看单个数据库占用的大小,可在命令行程序 taos 内指定要查看的数据库后执行 `show vgroups;` ,通过得到的 VGroup id 去 /var/lib/taos/vnode 下查看包含的文件夹大小。 + + 若仅仅想查看指定(超级)表的数据块分布及大小,可查看[_block_dist 函数](https://docs.taosdata.com/taos-sql/select/#_block_dist-%E5%87%BD%E6%95%B0) diff --git a/docs-cn/27-train-faq/_category_.yml b/docs-cn/27-train-faq/_category_.yml index 034d5894b9aea00e43caf4df21cb39487d8baf7b..16b32bc38fd3ef88313150cf89e32b15696fe7ff 100644 --- a/docs-cn/27-train-faq/_category_.yml +++ b/docs-cn/27-train-faq/_category_.yml @@ -1,4 +1 @@ -label: FAQ、教程及其它 -link: - slug: /train-faq/ - type: generated-index +label: FAQ 及其他 diff --git a/docs-cn/27-train-faq/index.md b/docs-cn/27-train-faq/index.md new file mode 100644 index 0000000000000000000000000000000000000000..b42bff0288fc8ab59810a7d7121be28ddf781551 --- /dev/null +++ b/docs-cn/27-train-faq/index.md @@ -0,0 +1,10 @@ +--- +title: FAQ 及其他 +--- + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-en/01-intro/01-intro.md b/docs-en/01-intro/01-intro.md index 7d807be15eefb5acb1350330d557f91805bd1898..3fffcfb7da118a767b6736d1e32a3dad2f850c61 100644 --- a/docs-en/01-intro/01-intro.md +++ b/docs-en/01-intro/01-intro.md @@ -1,87 +1,111 @@ --- -sidebar_label: 产品简介 -title: 产品简介 +title: Introduction toc_max_heading_level: 2 --- -## TDengine 简介 +## TDengine Major Features -TDengine 是一款高性能、分布式、支持 SQL 的时序数据库。而且除时序数据库功能外,它还提供[缓存](/develop/cache/)、数据订阅、流式计算等功能,最大程度减少研发和运维的复杂度,且核心代码,包括集群功能全部开源(开源协议,AGPL v3.0)。与其他时序数据数据库相比,TDengine 有以下特点: +TDengine is a high-performance, scalable time-series database with SQL support. Its code, including its cluster feature is open source under GNU AGPL v3.0. Besides the database engine, it provides [caching](/develop/cache), [stream processing](/develop/continuous-query), [data subscription](/develop/subscribe) and other functionalities to reduce the complexity and cost of development and operation. The major features are listed below: -- **高性能**:通过创新的存储引擎设计,无论是数据写入还是查询,TDengine 的性能比通用数据库快 10 倍以上,也远超其他时序数据库,而且存储空间也大为节省。 +1. Besides [using SQL to insert](/develop/insert-data/sql-writing),supports [Schemaless writing](/reference/schemaless/),and supports [InfluxDB LINE](/develop/insert-data/influxdb-line),[OpenTSDB Telnet](/develop/insert-data/opentsdb-telnet), [OpenTSDB JSON ](/develop/insert-data/opentsdb-json) and other protocols. +2. Support seamless integration with third-party data collection agent like [Telegraf](/third-party/telegraf),[Prometheus](/third-party/prometheus),[StatsD](/third-party/statsd),[collectd](/third-party/collectd),[icinga2](/third-party/icinga2), [Tcollector](/third-party/tcollector), [EMQ](/third-party/emq-broker), [HiveMQ](/third-party/hive-mq-broker). Without a line of code, those agents can write data points into TDengine just by configuration. +3. Support [all kinds of queries](/query-data), including aggregation, nested query, downsampling, interpolation, etc. +4. Support [user defined functions](/develop/udf) +5. Support [caching](/develop/cache). TDengine always save the last data point in cache, so Redis is not needed in some scenarios. +6. Support [continuous query](/develop/continuous-query). +7. Support [data subscription](/develop/subscribe),and the filter condition can be specified. +8. Support [cluster](/cluster/), so it can gain more processing power by adding more nodes. The high availability is supported by replication. +9. Provide interactive [command line intrerface](/reference/taos-shell) for management, maintainence and ad-hoc query. +10. Provide many ways to [import](/operation/import), [export](/operation/export) data. +11. Provide [monitoring](/operation/monitor) on TDengine running instances. +12. Provide [connectors](/reference/connector/) for [C/C++](/reference/connector/cpp), [Java](/reference/connector/java), [Python](/reference/connector/python), [Go](/reference/connector/go), [Rust](/reference/connector/rust), [Node.js](/reference/connector/node) and other programming languages. +13. Provide [REST API](/reference/rest-api/). +14. Support the seamless integration with [Grafana](/third-party/grafana) for visualization. +15. Support seamless integration with Google Data Studio. -- **分布式**:通过原生分布式的设计,TDengine 提供了水平扩展的能力,只需要增加节点就能获得更强的数据处理能力,同时通过多副本机制保证了系统的高可用。 +For more detailed features, please read through the whole document. -- **支持 SQL**:TDengine 采用 SQL 作为数据查询语言,减少学习和迁移成本,同时提供 SQL 扩展来处理时序数据特有的分析,而且支持方便灵活的 schemaless 数据写入。 +## TDenginge Highlights -- **All in One**:将数据库、消息队列、缓存、流式计算等功能融合一起,应用无需再集成 Kafka/Redis/HBase/Spark 等软件,大幅降低应用开发和维护成本。 +TDengine makes full use of [the characteristics of time series data](https://tdengine.com/2019/07/09/86.html), such as structured, no transaction, rarely delete or update, etc., and builds its own innovative storage engine and computing engine to differentiate itself from other TSDBs with the following advantages. -- **零管理**:安装、集群几秒搞定,无任何依赖,不用分库分表,系统运行状态监测能与 Grafana 或其他运维工具无缝集成。 +- **High Performance**: TDengine outperforms other time series databases in data ingestion and querying while significantly reducing storage cost and compute costs, with an innovatively designed and purpose-built storage engine. -- **零学习成本**:采用 SQL 查询语言,支持 Python, Java, C/C++, Go, Rust, Node.js 等多种编程语言,与 MySQL 相似,零学习成本。 +- **Scalable**: TDengine provides out-of-box scalability and high-availability through its native distributed design. Nodes can be added through simple configuration to achieve greater data processing power. In addition, this feature is open source. -- **无缝集成**:不用一行代码,即可与 Telegraf, Grafana, EMQX, Prometheus, StatsD, collectd, Matlab, R 等第三方工具无缝集成。 +- **SQL Support**: TDengine uses SQL as the query language, thereby reducing learning and migration costs, while adding SQL extensions to handle time-series data better, and supporting convenient and flexible schemaless data ingestion. -- **互动 Console**: 通过命令行 console,不用编程,执行 SQL 语句就能做即席查询、各种数据库的操作、管理以及集群的维护. +- **All in One**: TDengine has built-in caching, stream processing and data subscription functions. It is no longer necessary to integrate Kafka/Redis/HBase/Spark or other software in some scenarios. It makes the system architecture much simpler, cost-effective and easier to maintain. -采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。表现在几个方面,1:由于其超强性能,它能将系统需要的计算资源和存储资源大幅降低;2:因为采用SQL接口,能与众多第三放软件无缝集成,学习迁移成本大幅下降;3:因为其All In One的特性,系统复杂度降低,能降研发成本;4:因为运维维护简单,运营维护成本能大幅降低。 +- **Seamless Integration**: Without a single line of code, TDengine provide seamless, configurable integration with third-party tools such as Telegraf, Grafana, EMQX, Prometheus, StatsD, collectd, etc. More third-party tools are being integrated. -在整个时序大数据平台中,TDengine在其中扮演的角色如下: -![TDengine技术生态图](eco_system.png) +- **Zero Management**: Installation and cluster setup can be done in seconds. Data partitioning and sharding are executed automatically. TDengine’s running status can be monitored via Grafana or other DevOps tools. -
图 1. TDengine技术生态图
+- **Zero Learning Cost**: With SQL as the query language, support for ubiquitous tools like Python, Java, C/C++, Go, Rust, Node.js connectors, there is zero learning cost. -## TDengine 总体适用场景 +- **Interactive Console**: TDengine provides convenient console access to the database to run ad hoc queries, maintain the database, or manage the cluster without any programming. -作为一个高性能、分布式、支持 SQL 的时序数据库,TDengine 的典型适用场景包括但不限于 IoT、工业互联网、车联网、IT运维、能源、金融证券等领域。需要指出的是,TDengine是针对时序数据场景设计的专用数据库和专用大数据处理工具,因充分利用了时序大数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。本文对适用场景做更多详细的分析。 +With TDengine, the total cost of ownership of time-seriess data platform can be greatly reduced. Because 1: with its superior performance, the computing and storage resources are reduced significantly; 2:with SQL support, it can be seamlessly integrated with many third party tools, and learning cost/migration cost is reduced significantly; 3: with its simple architecture and zero management, the operation and maintainence cost is reduced. -### 数据源特点和需求 +## TDengine Technical Ecosystem +In the time-series data processing platform, TDengine stands in a role like this diagram below: -从数据源角度,设计人员可以从下面几个角度分析 TDengine 在目标应用系统里面的适用性。 +![TDengine Technical Ecosystem ](eco_system.png) -| 数据源特点和需求 | 不适用 | 可能适用 | 非常适用 | 简单说明 | -| ---------------------------- | ------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------- | -| 总体数据量巨大 | | | √ | TDengine 在容量方面提供出色的水平扩展功能,并且具备匹配高压缩的存储结构,达到业界最优的存储效率。 | -| 数据输入速度偶尔或者持续巨大 | | | √ | TDengine 的性能大大超过同类产品,可以在同样的硬件环境下持续处理大量的输入数据,并且提供很容易在用户环境里面运行的性能评估工具。 | -| 数据源数目巨大 | | | √ | TDengine 设计中包含专门针对大量数据源的优化,包括数据的写入和查询,尤其适合高效处理海量(千万或者更多量级)的数据源。 | +
Figure 1. TDengine Technical Ecosystem
-### 系统架构要求 +On the left side, there are data collection agents like OPC-UA, MQTT, Telegraf and Kafka. On the right side, visualization/BI tools, HMI, Python/R, IoT App can be connected. TDengine itself provides interactive command line interface and web interface for management and maintainence. -| 系统架构要求 | 不适用 | 可能适用 | 非常适用 | 简单说明 | -| ---------------------- | ------ | -------- | -------- | ----------------------------------------------------------------------------------------------------- | -| 要求简单可靠的系统架构 | | | √ | TDengine 的系统架构非常简单可靠,自带消息队列,缓存,流式计算,监控等功能,无需集成额外的第三方产品。 | -| 要求容错和高可靠 | | | √ | TDengine 的集群功能,自动提供容错灾备等高可靠功能。 | -| 标准化规范 | | | √ | TDengine 使用标准的 SQL 语言提供主要功能,遵守标准化规范。 | +## Suited Scenarios for TDengine -### 系统功能需求 +As a high-performance, scalable and SQL supported time-series database, TDengine's typical application scenarios include but are not limited to IoT, Industrial Internet, Connected Vehicles, IT operation and maintenance, energy, financial market and other fields. But you shall note that TDengine is a purpose-built database and does tons of optimization based on the characteristics of time series data, it cannot be used to process data from web crawlers, social media, e-commerce, ERP, CRM, etc. This section makes a more detailed analysis of the applicable scenarios. -| 系统功能需求 | 不适用 | 可能适用 | 非常适用 | 简单说明 | -| -------------------------- | ------ | -------- | -------- | --------------------------------------------------------------------------------------------------------------------- | -| 要求完整的内置数据处理算法 | | √ | | TDengine 的实现了通用的数据处理算法,但是还没有做到妥善处理各行各业的所有要求,因此特殊类型的处理还需要应用层面处理。 | -| 需要大量的交叉查询处理 | | √ | | 这种类型的处理更多应该用关系型数据系统处理,或者应该考虑 TDengine 和关系型数据系统配合实现系统功能。 | +### Characteristics and Requirements of Data Sources -### 系统性能需求 +From the perspective of data sources, designers can analyze the applicability of TDengine in target application systems as follows. -| 系统性能需求 | 不适用 | 可能适用 | 非常适用 | 简单说明 | -| ---------------------- | ------ | -------- | -------- | ------------------------------------------------------------------------------------------------------ | -| 要求较大的总体处理能力 | | | √ | TDengine 的集群功能可以轻松地让多服务器配合达成处理能力的提升。 | -| 要求高速处理数据 | | | √ | TDengine 的专门为 IoT 优化的存储和数据处理的设计,一般可以让系统得到超出同类产品多倍数的处理速度提升。 | -| 要求快速处理小粒度数据 | | | √ | 这方面 TDengine 性能可以完全对标关系型和 NoSQL 型数据处理系统。 | +| **Data Source Characteristics and Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | +| -------------------------------------------------------- | ------------------ | ----------------------- | ------------------- | :----------------------------------------------------------- | +| A massive amount of total data | | | √ | TDengine provides excellent scale-out functions in terms of capacity, and has a storage structure with matching high compression ratio to achieve the best storage efficiency in the industry.| +| Data input velocity is extremely high | | | √ | TDengine's performance is much higher than that of other similar products. It can continuously process larger amounts of input data in the same hardware environment, and provides a performance evaluation tool that can easily run in the user environment. | +| A huge number of data sources | | | √ | TDengine is optimized specifically for a huge number of data sources. It is especially suitable for efficiently ingesting, writing and querying data from billions of data sources. | -### 系统维护需求 +### System Architecture Requirements -| 系统维护需求 | 不适用 | 可能适用 | 非常适用 | 简单说明 | -| ---------------------- | ------ | -------- | -------- | --------------------------------------------------------------------------------------------------------------------- | -| 要求系统可靠运行 | | | √ | TDengine 的系统架构非常稳定可靠,日常维护也简单便捷,对维护人员的要求简洁明了,最大程度上杜绝人为错误和事故。 | -| 要求运维学习成本可控 | | | √ | 同上。 | -| 要求市场有大量人才储备 | √ | | | TDengine 作为新一代产品,目前人才市场里面有经验的人员还有限。但是学习成本低,我们作为厂家也提供运维的培训和辅助服务。 | +| **System Architecture Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | +| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ | +| A simple and reliable system architecture | | | √ | TDengine's system architecture is very simple and reliable, with its own message queue, cache, stream computing, monitoring and other functions. There is no need to integrate any additional third-party products. | +| Fault-tolerance and high-reliability | | | √ | TDengine has cluster functions to automatically provide high-reliability and high-availability functions such as fault tolerance and disaster recovery. | +| Standardization support | | | √ | TDengine supports standard SQL and also provides extensions specifically to analyze time-series data. | -## TDengine 与其他数据库的对比测试 +### System Function Requirements -- [用 InfluxDB 开源的性能测试工具对比 InfluxDB 和 TDengine](https://www.taosdata.com/blog/2020/01/13/1105.html) -- [TDengine 与 OpenTSDB 对比测试](https://www.taosdata.com/blog/2019/08/21/621.html) -- [TDengine 与 Cassandra 对比测试](https://www.taosdata.com/blog/2019/08/14/573.html) -- [TDengine 与 InfluxDB 对比测试](https://www.taosdata.com/blog/2019/07/19/419.html) -- [TDengine VS InfluxDB ,写入性能大 PK !](https://www.taosdata.com/2021/11/05/3248.html) -- [TDengine 和 InfluxDB 查询性能对比测试报告](https://www.taosdata.com/2022/02/22/5969.html) -- [TDengine 与 InfluxDB、OpenTSDB、Cassandra、MySQL、ClickHouse 等数据库的对比测试报告](https://www.taosdata.com/downloads/TDengine_Testing_Report_cn.pdf) +| **System Function Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | +| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ | +| Complete data processing algorithms built-in | | √ | | While TDengine implements various general data processing algorithms, industry specific algorithms and special types of processing will need to be implemented at the application level.| +| A large number of crosstab queries | | √ | | This type of processing is better handled by general purpose relational database systems but TDengine can work in concert with relational database systems to provide more complete solutions. | + +### System Performance Requirements + +| **System Performance Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | +| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ | +| Very large total processing capacity | | | √ | TDengine’s cluster functions can easily improve processing capacity via multi-server coordination. | +| Extremely high-speed data processing | | | √ | TDengine’s storage and data processing are optimized for IoT, and can process data many times faster than similar products.| +| Extremely fast processing of fine-grained data | | | √ | TDengine has achieved the same or better performance than other relational and NoSQL data processing systems. | + +### System Maintenance Requirements + +| **System Maintenance Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | +| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ | +| Native high-reliability | | | √ | TDengine has a very robust, reliable and easily configurable system architecture to simplify routine operation. Human errors and accidents are eliminated to the greatest extent, with a streamlined experience for operators. | +| Minimize learning and maintenance costs | | | √ | In addition to being easily configurable, standard SQL support and the Taos shell for ad hoc queries makes maintenance simpler, allows reuse and reduces learning costs.| +| Abundant talent supply | √ | | | Given the above, and given the extensive training and professional services provided by TDengine, it is easy to migrate from existing solutions or create a new and lasting solution based on TDengine.| + +## Benchmark comparision between TDengine and other databases + +- [Writing Performance Comparison of TDengine and InfluxDB ](https://tdengine.com/2022/02/23/4975.html) +- [Query Performance Comparison of TDengine and InfluxDB](https://tdengine.com/2022/02/24/5120.html) +- [TDengine vs InfluxDB、OpenTSDB、Cassandra、MySQL、ClickHouse](https://www.tdengine.com/downloads/TDengine_Testing_Report_en.pdf) +- [TDengine vs OpenTSDB](https://tdengine.com/2019/09/12/710.html) +- [TDengine vs Cassandra](https://tdengine.com/2019/09/12/708.html) +- [TDengine vs InfluxDB](https://tdengine.com/2019/09/12/706.html) diff --git a/docs-en/01-intro/_category_.yml b/docs-en/01-intro/_category_.yml index 1fdaed6b943d4a0877325bf00005307fb2f19880..a3d691e87b15eaf6a62030a130179ffe2e8e5fa6 100644 --- a/docs-en/01-intro/_category_.yml +++ b/docs-en/01-intro/_category_.yml @@ -1 +1 @@ -label: TDengine 介绍 +label: Introduction diff --git a/docs-en/02-concept/02-concept.md b/docs-en/02-concept/02-concept.md index b1638e838d9b2da35018b4d24640b98d5e476e47..01b308a193f1342349712fe79552eb0fc8e7c1c1 100644 --- a/docs-en/02-concept/02-concept.md +++ b/docs-en/02-concept/02-concept.md @@ -1,176 +1,170 @@ --- -title: 数据模型和基本概念 +title: Concepts --- -## 物联网典型场景 - -在典型的物联网、车联网、运维监测场景中,往往有多种不同类型的数据采集设备或采集点,采集一个到多个不同的物理量。而同一种采集设备类型,往往又有多个具体的采集设备分布在不同的地点。采集的物理量都带有时间标签,而且数据量随时间不断增长,但每个数据采集设备或采集点还有自身的静态属性。对于同一类设备,其采集的数据以及静态属性都是很规则的。以智能电表为例,假设每个智能电表采集电流、电压、相位三个量,其采集的数据类似如下的表格: +In order to explain the basic concepts and show sample code easily, the entire TDengine document takes smart meters as a typical time series data scenario. Assuming that each smart meter collects three metrics of current, voltage, and phase, there are multiple smart meters, and each meter has static attributes like location and group ID, the collected data shall be similar to the following table: +
- - - - + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + +
设备ID时间戳采集量标签Device IDTime StampCollected MetricsTags
Device IDTime StampcurrentvoltagephaselocationgroupIdDevice IDTime StampcurrentvoltagephaselocationgroupId
d1001153854868500010.32190.31Beijing.Chaoyang2d1001153854868500010.32190.31Beijing.Chaoyang2
d1002153854868400010.22200.23Beijing.Chaoyang3d1002153854868400010.22200.23Beijing.Chaoyang3
d1003153854868650011.52210.35Beijing.Haidian3d1003153854868650011.52210.35Beijing.Haidian3
d1004153854868550013.42230.29Beijing.Haidian2d1004153854868550013.42230.29Beijing.Haidian2
d1001153854869500012.62180.33Beijing.Chaoyang2d1001153854869500012.62180.33Beijing.Chaoyang2
d1004153854869660011.82210.28Beijing.Haidian2d1004153854869660011.82210.28Beijing.Haidian2
d1002153854869665010.32180.25Beijing.Chaoyang3d1002153854869665010.32180.25Beijing.Chaoyang3
d1001153854869680012.32210.31Beijing.Chaoyang2d1001153854869680012.32210.31Beijing.Chaoyang2
+Table 1: Smart meter example data +
-
表 1:智能电表数据示例
- -每一条记录都有设备 ID,时间戳,采集的物理量(如上图中的电流、电压、相位),还有与每个设备相关的静态标签(如上述表 1 中的位置 location 和分组 groupId)。每个设备是受外界的触发,或按照设定的周期采集数据。采集的数据点是时序的,是一个数据流。 +Each row contains the device ID, timestamp, collected metrics (current, voltage, phase as above), and static tags (Location and groupId in Table 1) associated with the devices. Each smart meter generates a row (data point) in a pre-defined timer or triggered by an external event. It is a sequence of data points like a stream. -## 数据特征 +## Metric -除时序特征外,仔细研究发现,物联网、车联网、运维监测类数据及其应用还具有很多其他明显的特征。 +Metric refers to the physical quantity collected by sensors, equipment or other types of data collection devices, such as current, voltage, temperature, pressure, GPS position, etc., which changes with time, and the data type can be integer, float, Boolean, or strings. As time goes by, the amount of collected metric data stored increases. -1. 数据是结构化的; -2. 数据极少有更新或删除操作; -3. 无需传统数据库的事务处理; -4. 相对互联网应用,写多读少; -5. 流量平稳,根据设备数量和采集频次,可以预测出来; -6. 用户关注的是一段时间的趋势,而不是某一特点时间点的值; -7. 数据是有保留期限的; -8. 数据的查询分析一定是基于时间段和地理区域的; -9. 系统需要各种实时计算和统计操作,包括降采样、插值等特种操作; -10. 数据量巨大,一天采集的数据就可以超过 100 亿条。 +## Label/Tag -充分利用上述特征,TDengine 采取了一特殊的优化的存储和计算设计来处理时序数据,能将系统处理能力显著提高。 +Label/Tag refers to the static properties of sensors, devices or other types of data collection devices, which do not change with time, such as device model, color, fixed location of the device, etc. The data type can be any type. Although static, TDengine allows users to add, delete or update tag values. Unlike the collected metric data, the amount of tag data stored does not change over time. -## 采集量(Metric) +## Data Collection Point -采集量是指传感器、设备或其他类型采集点采集的物理量,比如电流、电压、温度、压力、GPS位置等,是随时间变化的,数据类型可以是整型、浮点型、布尔型,也可是字符串。随着时间的推移,存储的采集量的数据量越来越大。 +Data Collection Point(DCP) refers to hardware or software that collects metrics based on preset time periods or triggered by events. A data collection point can collect one or multiple metrics, but these metrics are collected at the same time and have the same time stamp. For some complex equipments, there are often multiple data collection points, and the sampling rate of each collection point may be different, and fully independent. For example, for a car, there is a data collection point to collect GPS position metrics, a data collection point to collect engine status metrics, and a data collection point to collect the environment metrics inside the car, so a car has three data collection points. -## 标签(Label/Tag) +## Table -标签是指传感器、设备或其他类型采集点的静态属性,不是随时间变化的,比如设备型号、颜色、设备的所在地等,数据类型可以是任何类型。虽然是静态的,但TDengine容许用户修改、删除或增加标签值。与采集量不一样的是,随时间的推移,存储的标签的数据量不会有什么变化。 +Since time-series data is most likely to be structured data, TDengine adopts the traditional relational database model to process them with a short learning curve. You need to create a database, create tables, then insert data points and execute queries to explore the data. -## 数据采集点(Data Colletion Point) +To make full use of time-series data characteristics, TDengine adopts a strategy "**One Table for One Data Collection Point**". TDengine requires the user to create a table for each data collection point (DCP) to store collected time-series data. For example, if there are over 10 million smart meters, it means 10 million tables shall be created. For the table above, 4 tables shall be created for devices D1001, D1002, D1003, and D1004 to store the data collected. This design has several benefits: -数据采集点是指按照预设时间周期或受事件触发采集物理量的硬件或软件。一个数据采集点可以采集一个或多个物理量,**但这些物理量都是同一时刻采集的,具有相同的时间戳**。对于复杂的设备,往往有多个数据采集点,每个采集点采集的周期都可能不一样,而且完全独立,不同步。比如对于一台汽车,有数据采集点专门采集GPS位置,有数据采集点专门采集发动机状态,有数据采集点专门采集车内的环境,这样一台汽车就有三个数据采集点。 +1. Since the metric data from different DCP is fully independent, the data source of each DCP is unique, and a table has only one writer. In this way, data points can be written in a lock-free manner, and the writing speed can be greatly improved. +2. For a DCP, the metric data generated by DCP is ordered by timestamp, so the write operation can be implemented by simple appending, which further greatly improves the data writing speed. +3. The metric data from a DCP is continuously stored in block by block. If you read data for a period of time, it can greatly reduce random read operations and improve read and query performance by orders of magnitude. +4. Inside a data block for a DCP, columnar storage is used, and different compression algorithms are used for different data types. Because the change of the metrics from a DCP is not big in a time range, the compression rate is higher. -## 关系型数据库模型 +If the metric data of multiple DPCs are traditionally written into a single table, due to the uncontrollable network delay, the timing of the data from different DCPs arriving at the server cannot be guaranteed, the writing operation must be protected by locks, and the metric data from one DCP cannot be guaranteed to be continuously stored together. **One table for one data collection point can ensure the best performance of insert and query of a single data collection point to the greatest extent.** -因为采集的数据一般是结构化数据,同时为降低学习门槛,TDengine 采用传统的关系型数据库模型管理数据。用户需要先创建库,然后创建表,之后才能插入或查询数据。TDengine 采用的是结构化存储,而不是 NoSQL 的 key-value 存储。 +TDengine suggests using DCP ID as the table name (like D1001 in the above table). Each DCP may collect one or multiple metrics (like the current, voltage, phase as above). Each metric has a corresponding column in the table. The data type for a column can be int, float, string and others. In addition, the first column in the table must be a timestamp. TDengine uses the time stamp as the index, and won’t build the index on any metrics stored. Column wise storage is used. -与通用数据库相比,TDengine通过一个数据采集点一张表,来大幅提高单个数据采集点的插入和查询速度。同时TDengine引入了超级表的概念,让每个表都带有标签,解决多个数据采集点之间的聚合分析问题。 +## Super Table (STable) -## 一个数据采集点一张表 +The design of one table for one data collection point will require a huge number of tables, which is difficult to manage. Furthermore, applications often need to take aggregation operations among DCPs, thus aggregation operations will become complicated. To support aggregation over multiple tables efficiently, the STable(Super Table) concept is introduced by TDengine. -为充分利用其数据的时序性和其他数据特点,TDengine 要求**对每个数据采集点单独建表**(比如有一千万个智能电表,就需创建一千万张表,上述表格中的 d1001,d1002,d1003,d1004 都需单独建表),用来存储这个采集点所采集的时序数据。这种设计有几大优点: +STable is an set for a type of data collection point. A STable contains a set of data collection points (tables) that have the same schema or data structure, but with different static attributes(tags). To describe a STable, in addition to defining the table structure of the metrics, it is also necessary to define the schema of its tags. The data type of tags can be int, float, string, and there can be multiple tags, which can be added, deleted, or modified afterward. If the whole system has N different types of data collection points, N STables need to be established. -1. 由于不同采集设备产生数据的过程完全独立,每个设备的数据源是唯一的,一张表也就只有一个写入者,这样就可采用无锁方式来写,写入速度就能大幅提升。 -2. 对于一个数据采集点而言,其产生的数据是按照时间排序的,因此写的操作可用追加的方式实现,进一步大幅提高数据写入速度。 -3. 一个数据采集点的数据是以块为单位连续存储的。如果读取一个时间段的数据,它能大幅减少随机读取操作,成数量级的提升读取和查询速度。 -4. 一个数据块内部,采用列式存储,对于不同数据类型,采用不同压缩算法,而且由于一个数据采集点的采集量的变化是缓慢的,压缩率更高。 +In the design of TDengine, **a table is used to represent a specific data collection point, and STable is used to represent a set of data collection points of the same type**. -如果采用传统的方式,将多个设备的数据写入一张表,由于网络延时不可控,不同设备的数据到达服务器的时序是无法保证的,写入操作是要有锁保护的,而且一个设备的数据是难以保证连续存储在一起的。**采用一个数据采集点一张表的方式,能最大程度的保证单个数据采集点的插入和查询的性能是最优的。** +## Subtable -TDengine 建议用数据采集点的名字(如上表中的 D1001)来做表名。每个数据采集点可能同时采集多个物理量(如上表中的 curent,voltage,phase),每个物理量对应一张表中的一列,数据类型可以是整型、浮点型、字符串等。除此之外,表的第一列必须是时间戳,即数据类型为 timestamp。对采集的数据,TDengine 将自动按照时间戳建立索引,但对采集的物理量不建任何索引。数据用列式存储方式保存。 +When creating a table for a specific data collection point, the user can use a STable as a template and specifies the tag value of this specific DCP to create it. **The table created by using a STable as the template is called subtable** in TDengine system. The difference between regular table and subtable is: +1. Subtable is a table, all SQL commands applied on a regular table can be applied on subtable. +2. Subtable is a table with extension, it has static tags(labels), and these tags can be added, deleted, and updated afterward. But regular table does not have tags. +3. A subtable belongs to only one STable, but a STable may have many subtables. Regular table does not belong to any STable. +4. A regular table could not converted into a subtable, and vice versa. -对于复杂的设备,比如汽车,它有多个数据采集点,那么就需要为一台汽车建立多张表。 +The relationship between a STable and the subtables created based on this STable is as follows: -## 超级表:同一类型数据采集点的集合 +1. A STable contains multiple subtables with the same metric schema but with different tag values. +2. The schema of metrics or labels cannot be adjusted through subtables, and it can only be changed via STable. Changes to the schema of a STable takes effect immediately for all belonged subtables. +3. STable defines only one template and does not store any data or label information by itself. Therefore, data cannot be written to a STable, only to subtables. -由于一个数据采集点一张表,导致表的数量巨增,难以管理,而且应用经常需要做采集点之间的聚合操作,聚合的操作也变得复杂起来。为解决这个问题,TDengine 引入超级表(Super Table,简称为 STable)的概念。 +Query can be executed on both table(subtable) and STable. For a query on a STable, TDengine will treat the data in all its subtables as a whole data set for processing. TDengine will first find out the subtables that meet the tag filter conditions, then scan the time-series data of these subtables to perform aggregation operation, which can greatly reduce the data sets to be scanned, thus greatly improving the performance of data aggregation across multiple DCPs. -超级表是指某一特定类型的数据采集点的集合。同一类型的数据采集点,其表的结构是完全一样的,但每个表(数据采集点)的静态属性(标签)是不一样的。描述一个超级表(某一特定类型的数据采集点的集合),除需要定义采集量的表结构之外,还需要定义其标签的 schema,标签的数据类型可以是整数、浮点数、字符串,标签可以有多个,可以事后增加、删除或修改。如果整个系统有 N 个不同类型的数据采集点,就需要建立 N 个超级表。 +In TDengine system, it is recommend to use a substable instead of a regular table for a DCP. -在 TDengine 的设计里,**表用来代表一个具体的数据采集点,超级表用来代表一组相同类型的数据采集点集合**。当为某个具体数据采集点创建表时,用户使用超级表的定义做模板,同时指定该具体采集点(表)的标签值。与传统的关系型数据库相比,表(一个数据采集点)是带有静态标签的,而且这些标签可以事后增加、删除、修改。超级表与与基于超级表建立的子表之间的关系表现在: +## Database -1. 一张超级表包含有多张子表,这些子表具有相同的采集量 schema,但带有不同的标签值。 -2. 不能通过子表调整数据或标签的模式,对于超级表的数据模式修改立即对所有的子表生效。 -3. 超级表只定义一个模板,自身不存储任何数据或标签信息。因此,不能向一个超级表写入数据,只能将数据写入子表中。 +A database is a collection of tables. TDengine allows a running instance to have multiple databases, and each database can be configured with different storage policies. Different types of DCPs often have different data characteristics, including the frequency of data collection, data retention time, the number of replications, the size of data blocks, whether data is allowed to be updated, and so on. In order for TDengine to work with maximum efficiency in various scenarios, TDengine recommends that STables with different data characteristics be created in different databases. -针对超级表的查询,TDengine将把所有子表中的数据视为一个整体数据集进行处理,会先把满足标签过滤条件的表从超级表中找出来,然后再扫描这些表的时序数据,进行聚合操作,这样需要扫描的数据集会大幅减少,从而显著提高查询的性能。本质上,TDengine通过对超级表查询的支持,实现了多个同类数据采集点的高效聚合。 +In a database, there can be one or more STables, but a STable belongs to only one database. All tables owned by a STable are stored in only one database. ## FQDN & End Point -FQDN (fully qualified domain name, 完全限定域名)是 Internet 上特定计算机或主机的完整域名。FQDN由两部分组成:主机名和域名。例如,假设邮件服务器的FQDN可能是mail.tdengine.com。主机名是mail,主机位于域名tdengine.com中。DNS(Domain Name System),负责将FQDN翻译成IP,是互联网应用的寻址方式。对于没有DNS的系统,可以通过配置hosts文件来解决。 +FQDN (Fully Qualified Domain Name) is the full domain name of a specific computer or host on the Internet. FQDN consists of two parts: hostname and domain name. For example, the FQDN of a mail server might be mail.tdengine.com. The hostname is mail, and the host is located in the domain name tdengine.com. DNS (Domain Name System) is responsible for translating FQDN into IP. For systems without DNS, it can be solved by configuring the hosts file. -TDengine集群的每个节点是由End Point来唯一标识的,End Point是由 FQDN 外加 Port 组成,比如 h1.tdengine.com:6030。这样当IP发生变化的时候,我们依然可以使用 FQDN 来动态找到节点,不需要更改集群的任何配置。而且采用 FQDN,便于内网和外网对同一个集群的统一访问。 +Each node of a TDengine cluster is uniquely identified by an End Point, which consists of an FQDN and a Port, such as h1.tdengine.com:6030. In this way, when the IP changes, we can still use the FQDN to dynamically find the node without changing any configuration of the cluster. In addition, FQDN is used to facilitate unified access to the same cluster from the Intranet and the Internet. -TDengine 不建议采用直接的IP地址访问集群,不利于管理。不了解 FQDN 概念,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。 +TDengine does not recommend using IP address to access the cluster, which is not good for cluster management. diff --git a/docs-en/02-concept/_category_.yml b/docs-en/02-concept/_category_.yml index aad75dce21f63a6510bc0b8da4c93952767adfdf..12c659a9265e86d0e74d88a751c19d5d715e9fe0 100644 --- a/docs-en/02-concept/_category_.yml +++ b/docs-en/02-concept/_category_.yml @@ -1 +1 @@ -label: 基本概念 \ No newline at end of file +label: Concepts \ No newline at end of file diff --git a/docs-en/03-get-started/03-get-started.md b/docs-en/03-get-started/03-get-started.md index 6776455c9dc3ab68d291488b7b3b0353967f0ac1..d0b6165c909e506fd4ac7452e824b00824c8bfda 100644 --- a/docs-en/03-get-started/03-get-started.md +++ b/docs-en/03-get-started/03-get-started.md @@ -1,6 +1,6 @@ --- -title: 立即开始 -description: "从 Docker,安装包或使用 apt-get 快速安装 TDengine, 通过命令行程序TAOS CLI和工具 taosdemo 快速体验 TDengine 功能" +title: Get Started +description: "Install TDengine from Docker image, apt-get or package, and run TAOS CLI and taosBenchmark to experience the features" --- import Tabs from "@theme/Tabs"; @@ -8,38 +8,38 @@ import TabItem from "@theme/TabItem"; import PkgInstall from "./\_pkg_install.mdx"; import AptGetInstall from "./\_apt_get_install.mdx"; -## 安装 +## Quick Install -TDengine 完整的软件包包括服务端(taosd)、用于与第三方系统对接并提供RESTful接口的taosAdapter、应用驱动(taosc)、命令行程序 (CLI,taos) 和一些工具软件,目前 2.X 版服务端taosd、taosAdapter 仅在 Linux 系统上安装和运行,后续将支持 Windows、macOS 等系统。应用驱动 taosc 与 TDengine CLI 可以在 Windows 或 Linux 上安装和运行。TDengine 除 RESTful接口外,还提供一些列编程语言的连接器。2.4 之前的版本中,无 taosAdapter,RESTfule 接口均由 taosd 内置的 http 服务提供。 +The full package of TDengine includes server(taosd), taosAdapter for connecting with third-party systems and providing RESTful interface, application driver(taosc), command line program(CLI, taos) and some tools. For current version, the server taosd and taosAdapter can only be installed and run on Linux systems, and will support Windows, macOS and other systems in the future. The application driver taosc and TDengine CLI can be installed and run on Windows or Linux. In addition to the RESTful interface, TDengine also provides connectors for a number of programming languages. In versions before 2.4, there is no taosAdapter, and the RESTfule interface is provided by the built-in http service of taosd. -TDengine 支持 X64/ARM64/MIPS64/Alpha64 硬件平台,后续将支持 ARM32、RISC-V 等 CPU 架构。 +TDengine supports X64/ARM64/MIPS64/Alpha64 hardware platforms, and will support ARM32, RISC-V and other CPU architectures in the future. -如果已经安装了 docker, 只需执行下面的命令。 +If docker is already installed on your computer, execute the following command: ```shell docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine ``` -确定该容器已经启动并且在正常运行 +Make sure the container is running ```shell docker ps ``` -进入该容器并执行 bash +Enter into container and execute bash ```shell docker exec -it bash ``` -然后就可以执行相关的 Linux 命令操作和访问 TDengine +Then you can execute the Linux commands and access TDengine. -详细操作方法请参照 [通过 Docker 快速体验 TDengine](/train-faq/docker)。 +For detailed steps, please visit [Experience TDengine via Docker](/train-faq/docker)。 :::info -从 2.4.0.10 开始,除 taosd 以外,Docker 镜像还包含:taos、taosAdapter、taosdump、taosBenchmark、TDinsight 安装脚本和示例代码。启动 Docker 容器时,将同时启动 taosAdapter 和 taosd,实现对 RESTful 的支持。 +Starting from 2.4.0.10,besides taosd,TDengine docker image includes: taos,taosAdapter,taosdump,taosBenchmark,TDinsight, scripts and sample code. Once the TDengine container is started,it will start both taosAdapter and taosd automatically to support RESTful interface. ::: @@ -47,66 +47,64 @@ docker exec -it bash - + - + -如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装. - -下载其他组件、最新 Beta 版及之前版本的安装包,请点击[这里](https://www.taosdata.com/cn/all-downloads/)。 +If you like to check the source code, build the package by youself or contribute to the project, please check [TDengine GitHub Repository](https://github.com/taosdata/TDengine) -## 启动 +## Quick Launch -安装后,请使用 `systemctl` 命令来启动 TDengine 的服务进程。 +After installation, you can launch the TDengine service by the 'systemctl' command to start 'taosd'. ```bash systemctl start taosd ``` -检查服务是否正常工作: +Check if taosd is running: ```bash systemctl status taosd ``` -如果 TDengine 服务正常工作,那么您可以通过 TDengine 的命令行程序 `taos` 来访问并体验 TDengine。 +If everything is fine,you can run TDengine command line interface `taos` to access TDengine and play around it. :::info -- systemctl 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 sudo 。 -- 为更好的获得产品反馈,改善产品,TDengine 会采集基本的使用信息,但您可以修改系统配置文件 taos.cfg 里的配置参数 telemetryReporting,将其设为 0,就可将其关闭。 -- TDengine 采用 FQDN(一般就是 hostname)作为节点的 ID,为保证正常运行,需要给运行 taosd 的服务器配置好 FQDN,在 TDengine CLI 或应用运行的机器配置好 DNS 服务或 hosts 文件,保证 FQDN 能够解析。 -- `systemctl stop taosd` 指令在执行后并不会马上停止 TDengine 服务,而是会等待系统中必要的落盘工作正常完成。在数据量很大的情况下,这可能会消耗较长时间。 +- systemctl requires _root_ privileges,if you are not _root_ ,please add sudo before the command. +- To get feedback and keep polishing the prodcut, TDengine is colleting some basic usage information, but you can turn it off by setting telemetryReporting to 0 in configuration file taos.cfg. +- TDengine uses FQDN (usually hostname)as the ID for a node. To make system work, you need to configure the FQDN for the server running taosd, and configure the DNS service or hosts file on the the machine where the application or TDengine CLI runs to ensure that the FQDN can be resolved. +- `systemctl stop taosd` won't stop the server right away, it will wait until all the data in memory are flushed to disk. It may takes time depending on the cache size. -TDengine 支持在使用 [`systemd`](https://en.wikipedia.org/wiki/Systemd) 做进程服务管理的 Linux 系统上安装,用 `which systemctl` 命令来检测系统中是否存在 `systemd` 包: +TDengine supports the installation on system which runs [`systemd`](https://en.wikipedia.org/wiki/Systemd) for process management,use `which systemctl` to check if the system has `systemd` installed: ```bash which systemctl ``` -如果系统中不支持 `systemd`,也可以用手动运行 `/usr/local/taos/bin/taosd` 方式启动 TDengine 服务。 +If the system does not have `systemd`,you can start TDengine manually by executing `/usr/local/taos/bin/taosd` :::note -## TDengine 命令行 (CLI) - -为便于检查 TDengine 的状态,执行各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI) taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux 终端执行 `taos` 即可。 +## Command Line Interface + +To manage the TDengine running instance,or execute ad-hoc queries, TDengine provides a Command Line Interface(hereinafter referred to as TDengine CLI) taos. To enter into the interactive CLI,execute `taos` on a Linux terminal where TDengine is installed. ```bash taos ``` -如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-faq/faq) 来解决终端连接服务端失败的问题)。 TDengine CLI 的提示符号如下: +If it connects to the TDengine server successfully, it will print out the version and welcome message. If it fails, it will print out the error message, please check [FAQ](/train-faq/faq) for trouble shooting connection issue. TDengine CLI's prompt is: ```cmd taos> ``` -在 TDengine CLI中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行插入查询操作。在终端中运行的 SQL 语句需要以分号结束来运行。示例: +Inside TDengine CLI,you can execute SQL commands to create/drop database/table, and run queries. The SQL command must be eneded with a semicolon. For example: ```sql create database demo; @@ -121,52 +119,50 @@ select * from t; 2019-07-15 01:00:00.000 | 20 | Query OK, 2 row(s) in set (0.003128s) ``` +Besides executing SQL commands, system administrator can check running status, add/drop user accounts and manage the running instances. TAOS CLI with application driver can be installed and run on either Linux or windows machine. For more details on CLI, please [check here](../reference/taos-shell/). -除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TAOS CLI 连同应用驱动也可以独立安装在 Linux 或 windows 机器上运行,更多细节请参考 [这里](../reference/taos-shell/) - -## 使用 taosBenchmark 体验写入速度 +## Experience the blazing fast speed -启动 TDengine 的服务,在 Linux 终端执行 `taosBenchmark` (曾命名为 `taosdemo`): +After TDengine server is running,execute `taosBenchmark`(named as taosdemo before) from a Linux terminal: ```bash taosBenchmark ``` +This command will create a super table "meters" under database "test". Unde "meters", 10000 tables are created with name from "d0" to "d9999". Each table has 10000 rows and each row has four columns (ts, current, voltage, phase). Time stamp is starting from "2017-07-14 10:40:00 000" to "2017-07-14 10:40:09 999". Each table has tags "location" and "groupId". groupId is set 1 to 10 randomly, and location is set to "beijing" or "shanghai". -该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "beijing" 或者 "shanghai"。 - -这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能,即使在一台普通的 PC 服务器往往也仅需十几秒。 - -taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [如何使用 taosBenchmark 对 TDengine 进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)。 +This command will insert 100 million rows into database quickly. Depends on the hardware configuration, it only takes a dozen seconds for a regular PC server. -## 使用 TDengine CLI 体验查询速度 +taosBenchmark provides you command line options and confuguration file to customize the scenarios, like number of tables, number of rows per table, number of columns and more. Please execute `taosBenchmark --help` to list them. For details on running taosBenchmark, please check [reference for taosBenchmark](/reference/taosbenchmark) -使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。 +## Experience query speed + +After using taosBenchmark to insert a number of rows data, you can execute queries from TDengine CLI to experience the lightning query speed. -查询超级表下记录总条数: +query the total number of rows under super table "meters": ```sql taos> select count(*) from test.meters; ``` -查询 1 亿条记录的平均值、最大值、最小值等: +query the average, maximum, minimum of 100 million rows: ```sql taos> select avg(current), max(voltage), min(phase) from test.meters; ``` -查询 location="beijing" 的记录总条数: +query the total number of rows with location="beijing": ```sql taos> select count(*) from test.meters where location="beijing"; ``` -查询 groupId=10 的所有记录的平均值、最大值、最小值等: +query the average, maximum, minimum of all rows with groupId=10: ```sql taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10; ``` -对表 d10 按 10s 进行平均值、最大值和最小值聚合统计: +query the average, maximum, minimum for table d10 in 10 seconds time interal: ```sql taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s); diff --git a/docs-en/03-get-started/_apt_get_install.mdx b/docs-en/03-get-started/_apt_get_install.mdx index b1bc4a13517bbfdc9eda86a58b89aee8e41fa470..40f6cad1f672a97fd28e6d4b5795d32b2ff0d26c 100644 --- a/docs-en/03-get-started/_apt_get_install.mdx +++ b/docs-en/03-get-started/_apt_get_install.mdx @@ -1,19 +1,19 @@ -可以使用 apt-get 工具从官方仓库安装。 +`apt-get` can be used to install TDengine from official package repository. -**安装包仓库** +**Package Repository** ``` wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add - echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-stable stable main" | sudo tee /etc/apt/sources.list.d/tdengine-stable.list ``` -如果安装 Beta 版需要安装包仓库 +The repository required for installing beta versions can be configured as below: ``` echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-beta beta main" | sudo tee /etc/apt/sources.list.d/tdengine-beta.list ``` -**使用 apt-get 命令安装** +**Install With apt-get** ``` sudo apt-get update @@ -22,5 +22,5 @@ sudo apt-get install tdengine ``` :::tip -apt-get 方式只适用于 Debian 或 Ubuntu 系统 +`apt-get` can only be used on Debian or Ubuntu Linux. :::: diff --git a/docs-en/03-get-started/_category_.yml b/docs-en/03-get-started/_category_.yml index b2348fade63c7bb717eac3e6e6b8dfda3c73b17a..043ae21554ffd8f274c6afe41c5ae5e7da742b26 100644 --- a/docs-en/03-get-started/_category_.yml +++ b/docs-en/03-get-started/_category_.yml @@ -1 +1 @@ -label: 立即开始 +label: Get Started diff --git a/docs-en/04-develop/01-connect/_category_.yml b/docs-en/04-develop/01-connect/_category_.yml index f75d563ac9e061f8b8d66392031413f4051e351e..83f9754f582f541ca62c7ff8701698dd949c3f99 100644 --- a/docs-en/04-develop/01-connect/_category_.yml +++ b/docs-en/04-develop/01-connect/_category_.yml @@ -1 +1 @@ -label: 建立连接 +label: Connect diff --git a/docs-en/04-develop/01-connect/_connect_c.mdx b/docs-en/04-develop/01-connect/_connect_c.mdx index 9cd8669561195b49e8428ed490ad97bb5653ae6a..174bf45c4e2f26bab8f57c098f9f8f00d2f5064d 100644 --- a/docs-en/04-develop/01-connect/_connect_c.mdx +++ b/docs-en/04-develop/01-connect/_connect_c.mdx @@ -1,3 +1,3 @@ -```c title="原生连接" +```c title="Native Connection" {{#include docs-examples/c/connect_example.c}} ``` diff --git a/docs-en/04-develop/01-connect/_connect_cs.mdx b/docs-en/04-develop/01-connect/_connect_cs.mdx index 204173dd329f6f214a9ea44c2f360be2cdbfdab8..52ea2d437123a26bd87e6f3fdc05a17141f9f835 100644 --- a/docs-en/04-develop/01-connect/_connect_cs.mdx +++ b/docs-en/04-develop/01-connect/_connect_cs.mdx @@ -1,7 +1,8 @@ -```csharp title="原生连接" +```csharp title="Native Connection" {{#include docs-examples/csharp/ConnectExample.cs}} ``` + :::info -C# 连接器目前只支持原生连接。 +C# connector supports only native connection for now. -::: \ No newline at end of file +::: diff --git a/docs-en/04-develop/01-connect/_connect_go.mdx b/docs-en/04-develop/01-connect/_connect_go.mdx index 4e4f189672f2fda4b807fe628d4455a41ac4cb69..1dd5d67e3533bba21960269e49e3d843b026efc8 100644 --- a/docs-en/04-develop/01-connect/_connect_go.mdx +++ b/docs-en/04-develop/01-connect/_connect_go.mdx @@ -1,15 +1,17 @@ -#### 使用数据库访问统一接口 -```go title="原生连接" +#### Unified Database Access Interface + +```go title="Native Connection" {{#include docs-examples/go/connect/cgoexample/main.go}} ``` -```go title="REST 连接" + +```go title="REST Connection" {{#include docs-examples/go/connect/restexample/main.go}} ``` -#### 使用高级封装 -也可以使用 driver-go 的 af 包建立连接。这个模块封装了 TDengine 的高级功能, 如:参数绑定、订阅等。 -```go title="使用 af 包建立原生连接" -{{#include docs-examples/go/connect/afconn/main.go}} -``` +#### Advanced Features +The af package of driver-go can also be used to establish connection, with this way some advanced features of TDengine, like parameter binding and subscription, can be used. +```go title="Establish native connection using af package" +{{#include docs-examples/go/connect/afconn/main.go}} +``` diff --git a/docs-en/04-develop/01-connect/_connect_java.mdx b/docs-en/04-develop/01-connect/_connect_java.mdx index cd6d7c4cab9a84abb22895c704debd260884081f..1c3e9326bf2ae597ffba683250dd43986e670469 100644 --- a/docs-en/04-develop/01-connect/_connect_java.mdx +++ b/docs-en/04-develop/01-connect/_connect_java.mdx @@ -1,11 +1,15 @@ -```java title="原生连接" +```java title="Native Connection" {{#include docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java}} ``` -```java title="REST 连接" + +```java title="REST Connection" {{#include docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}} ``` -使用REST 连接时,如果查询数据量比较大,还可开启批量拉取功能。 -```java title="开启批量拉取功能" {4} + +When using REST connection, the feature of bulk pulling can be enabled if the size of resulting data set is huge. + +```java title="Enable Bulk Pulling" {4} {{#include docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}} ``` -更多连接参数配置,参考[Java 连接器](/reference/connector/java) \ No newline at end of file + +More configuration about connection,please refer to [Java Connector](/reference/connector/java) diff --git a/docs-en/04-develop/01-connect/_connect_node.mdx b/docs-en/04-develop/01-connect/_connect_node.mdx index 8a259888f87d4d441c58b9a8a9008b19273c1a58..489b0386e991ee1e8ddd173205637b75ae5a0c95 100644 --- a/docs-en/04-develop/01-connect/_connect_node.mdx +++ b/docs-en/04-develop/01-connect/_connect_node.mdx @@ -1,6 +1,7 @@ -```js title="原生连接" +```js title="Native Connection" {{#include docs-examples/node/nativeexample/connect.js}} ``` -```js title="REST 连接" + +```js title="REST Connection" {{#include docs-examples/node/restexample/connect.js}} -``` \ No newline at end of file +``` diff --git a/docs-en/04-develop/01-connect/_connect_python.mdx b/docs-en/04-develop/01-connect/_connect_python.mdx index 331ec0f693601baeb28ede7b0278e67f1471c187..f6c8bcfee1d92fae2d1ad320002b805dd9951228 100644 --- a/docs-en/04-develop/01-connect/_connect_python.mdx +++ b/docs-en/04-develop/01-connect/_connect_python.mdx @@ -1,3 +1,3 @@ -```python title="原生连接" +```python title="Native Connection" {{#include docs-examples/python/connect_exmaple.py}} -``` \ No newline at end of file +``` diff --git a/docs-en/04-develop/01-connect/_connect_r.mdx b/docs-en/04-develop/01-connect/_connect_r.mdx index a69a57f66be3672d61cb0f84f43aba123cfbd5aa..09c3d71ac35b1134d3089247daea9a13db4129e2 100644 --- a/docs-en/04-develop/01-connect/_connect_r.mdx +++ b/docs-en/04-develop/01-connect/_connect_r.mdx @@ -1,3 +1,3 @@ -```r title="原生连接" +```r title="Native Connection" {{#include docs-examples/R/connect_native.r:demo}} -``` \ No newline at end of file +``` diff --git a/docs-en/04-develop/01-connect/_connect_rust.mdx b/docs-en/04-develop/01-connect/_connect_rust.mdx index b051108452d16f207ce10b128f5de2e5f507200f..aa19f58de6c9bab69df0663e5369402ab1a8f899 100644 --- a/docs-en/04-develop/01-connect/_connect_rust.mdx +++ b/docs-en/04-develop/01-connect/_connect_rust.mdx @@ -1,7 +1,8 @@ -```rust title="原生连接/REST 连接" +```rust title="Native Connection/REST Connection" {{#include docs-examples/rust/nativeexample/examples/connect.rs}} ``` + :::note -对于 Rust 连接器, 连接方式的不同只体现在使用的特性不同。如果启用了 "rest" 特性,那么只有 RESTful 的实现会被编译进来。 +For Rust connector, the connection depends on the feature being used. If "rest" feature is enabled, then only the implementation for "rest" is compiled and packaged. ::: diff --git a/docs-en/04-develop/01-connect/index.md b/docs-en/04-develop/01-connect/index.md index 07bcc8ea125a0e4bc8f40a1bd2fab3a568b3402d..e319969ad4abb7842c337e3b1e7cc56eeb4b9a85 100644 --- a/docs-en/04-develop/01-connect/index.md +++ b/docs-en/04-develop/01-connect/index.md @@ -1,44 +1,45 @@ --- -title: 建立连接 -description: "本节介绍如何使用连接器建立与 TDengine 的连接,给出连接器安装、连接的简单说明。" +sidebar_label: Connection +title: Connect to TDengine +description: "This document explains how to establish connection to TDengine, and briefly introduce how to install and use TDengine connectors." --- import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; -import ConnJava from "./_connect_java.mdx"; -import ConnGo from "./_connect_go.mdx"; -import ConnRust from "./_connect_rust.mdx"; -import ConnNode from "./_connect_node.mdx"; -import ConnPythonNative from "./_connect_python.mdx"; -import ConnCSNative from "./_connect_cs.mdx"; -import ConnC from "./_connect_c.mdx"; -import ConnR from "./_connect_r.mdx"; -import InstallOnWindows from "../../14-reference/03-connector/_linux_install.mdx"; -import InstallOnLinux from "../../14-reference/03-connector/_windows_install.mdx"; -import VerifyLinux from "../../14-reference/03-connector/_verify_linux.mdx"; -import VerifyWindows from "../../14-reference/03-connector/_verify_windows.mdx"; +import ConnJava from "./\_connect_java.mdx"; +import ConnGo from "./\_connect_go.mdx"; +import ConnRust from "./\_connect_rust.mdx"; +import ConnNode from "./\_connect_node.mdx"; +import ConnPythonNative from "./\_connect_python.mdx"; +import ConnCSNative from "./\_connect_cs.mdx"; +import ConnC from "./\_connect_c.mdx"; +import ConnR from "./\_connect_r.mdx"; +import InstallOnWindows from "../../14-reference/03-connector/\_linux_install.mdx"; +import InstallOnLinux from "../../14-reference/03-connector/\_windows_install.mdx"; +import VerifyLinux from "../../14-reference/03-connector/\_verify_linux.mdx"; +import VerifyWindows from "../../14-reference/03-connector/\_verify_windows.mdx"; -TDengine 提供 REST API,容许在任何平台的任何应用程序通过它访问 TDengine 运行实例,详细介绍请看 [REST API](/reference/rest-api/)。除 REST API 之外,TDengine 还提供多种编程语言的连接器方便用户开发应用程序,其中包括 C/C++、Java、Python、Go、Node.js、C# 等。 本节介绍如何使用连接器建立与 TDengine 的连接,给出连接器安装、连接的简单说明。关于各连接器的详细功能说明,请查看[连接器](https://docs.taosdata.com/reference/connector/) +Any application programs running on any kind of platforms can access TDengine through the REST API provided by TDengine. For the details, please refer to [REST API](/reference/rest-api/). Besides, application programs can use the connectors of multiple programming languages to access TDengine, including C/C++, Java, Python, Go, Node.js, C#, and Rust. This chapter describes how to establish connection to TDengine and briefly introduce how to install and use connectors. For details about the connectors, please refer to [Connectors](/reference/connector/) -## 连接器建立连接的方式 +## Establish Connection -连接器建立连接的方式,TDengine 提供两种: +There are two ways for a connector to establish connections to TDengine: -1. 通过 taosAdapter 组件提供的 REST API 建立与 taosd 的连接,这种连接方式下文中简称"REST 连接“ -2. 通过客户端驱动程序 taosc 直接与服务端程序 taosd 建立连接,这种连接方式下文中简称“原生连接”。 +1. Connection through the REST API provided by taosAdapter component, this way is called "REST connection" hereinafter. +2. Connection through the TDengine application driver taosc, this way is called "Native connection" hereinafter. -无论使用何种方式建立连接,连接器都提供了相同或相似的 API 操作数据库,都可以执行 SQL 语句,只是初始化连接的方式稍有不同,用户在使用上不会感到什么差别。 +Either way, same or similar APIs are provided by connectors to access database or execute SQL statements, no obvious difference can be observed. -关键不同点在于: +Key differences: -1. 使用 REST 连接,用户无需安装客户端驱动程序 taosc,具有跨平台易用的优势,但性能要下降 30%左右。 -2. 使用原生连接可以体验 TDengine 的全部功能,如[参数绑定接口](/reference/connector/cpp#参数绑定-api)、[订阅](reference/connector/cpp#数据订阅接口)等等。 +1. With REST connection, it's not necessary to install TDengine application driver taosc, it's more friendly for cross-platform with the cost of 30% performance downgrade. When taosc has an upgrade, application does not need to make changes. +2. With native connection, full compatibility of TDengine can be utilized, like [Parameter Binding](/reference/connector/cpp#Parameter Binding-api), [Subscription](reference/connector/cpp#Subscription), etc. But taosc has to be installed, some platforms may not be supported. -## 安装客户端驱动 taosc +## Install Client Driver taosc -如果选择原生连接,而且应用程序不在 TDengine 同一台服务器上运行,你需要先安装客户端驱动,否则可以跳过此一步。为避免客户端驱动和服务端不兼容,请使用一致的版本。 +If choosing to use native connection and the application is not on the same host as TDengine server, TDengine application driver taosc needs to be installed on the host where the application is. If choosing to use REST connection or the application is on the same host as server side, this step can be skipped. It's better to use same version of taosc as the server. -### 安装步骤 +### Install @@ -49,9 +50,9 @@ TDengine 提供 REST API,容许在任何平台的任何应用程序通过它 -### 安装验证 +### Verify -以上安装和配置完成后,并确认 TDengine 服务已经正常启动运行,此时可以执行安装包里带有的 TDengine 命令行程序 taos 进行登录。 +After the above installation and configuration are done and making sure TDengine service is already started and in service, the TDengine command line interface `taos` can be launched to access TDengine.以 @@ -62,12 +63,12 @@ TDengine 提供 REST API,容许在任何平台的任何应用程序通过它 -## 安装连接器 +## Install Connectors -如果使用 maven 管理项目,只需在 pom.xml 中加入以下依赖。 +If `maven` is used to manage the projects, what needs to be done is only adding below dependency in `pom.xml`. ```xml @@ -80,13 +81,13 @@ TDengine 提供 REST API,容许在任何平台的任何应用程序通过它 -使用 `pip` 从 PyPI 安装: +Install from PyPI using `pip`: ``` pip install taospy ``` -从 Git URL 安装: +Install from Git URL: ``` pip install git+https://github.com/taosdata/taos-connector-python.git @@ -95,7 +96,7 @@ pip install git+https://github.com/taosdata/taos-connector-python.git -编辑 `go.mod` 添加 `driver-go` 依赖即可。 +Just need to add `driver-go` dependency in `go.mod` . ```go-mod title=go.mod module goexample @@ -106,14 +107,14 @@ require github.com/taosdata/driver-go/v2 develop ``` :::note -driver-go 使用 cgo 封装了 taosc 的 API。cgo 需要使用 gcc 编译 C 的源码。因此需要确保你的系统上有 gcc。 +`driver-go` uses `cgo` to wrap the APIs provided by taosc, while `cgo` needs `gcc` to compile source code in C language, so please make sure you have proper `gcc` on your system. ::: -编辑 `Cargo.toml` 添加 `libtaos` 依赖即可。 +Just need to add `libtaos` dependency in `Cargo.toml`. ```toml title=Cargo.toml [dependencies] @@ -121,7 +122,7 @@ libtaos = { version = "0.4.2"} ``` :::info -Rust 连接器通过不同的特性区分不同的连接方式。如果要建立 REST 连接,需要开启 `rest` 特性: +Rust connector uses different features to distinguish the way to establish connection. To establish REST connection, please enable `rest` feature. ```toml libtaos = { version = "*", features = ["rest"] } @@ -132,28 +133,28 @@ libtaos = { version = "*", features = ["rest"] } -Node.js 连接器通过不同的包提供不同的连接方式。 +Node.js connector provides different ways of establishing connections by providing different packages. -1. 安装 Node.js 原生连接器 +1. Install Node.js Native Connector - ``` - npm i td2.0-connector - ``` +``` +npm i td2.0-connector +``` :::note -推荐 Node 版本大于等于 `node-v12.8.0` 小于 `node-v13.0.0` -::: - -2. 安装 Node.js REST 连接器 +It's recommend to use Node whose version is between `node-v12.8.0` and `node-v13.0.0`. +::: - ``` - npm i td2.0-rest-connector - ``` +2. Install Node.js REST Connector + +``` +npm i td2.0-rest-connector +``` -编辑项目配置文件中添加 [TDengine.Connector](https://www.nuget.org/packages/TDengine.Connector/) 的引用即可: +Just need to add the reference to [TDengine.Connector](https://www.nuget.org/packages/TDengine.Connector/) in the project configuration file. ```xml title=csharp.csproj {12} @@ -173,22 +174,22 @@ Node.js 连接器通过不同的包提供不同的连接方式。 ``` -也可通过 dotnet 命令添加: +Or add by `dotnet` command. ``` dotnet add package TDengine.Connector ``` :::note -以下示例代码,均基于 dotnet6.0,如果使用其它版本,可能需要做适当调整。 +The sample code below are based on dotnet6.0, they may need to be adjusted if your dotnet version is not exactly same. ::: -1. 下载 [taos-jdbcdriver-version-dist.jar](https://repo1.maven.org/maven2/com/taosdata/jdbc/taos-jdbcdriver/2.0.38/)。 -2. 安装 R 的依赖包`RJDBC`: +1. Download [taos-jdbcdriver-version-dist.jar](https://repo1.maven.org/maven2/com/taosdata/jdbc/taos-jdbcdriver/2.0.38/). +2. Install the dependency package `RJDBC`: ```R install.packages("RJDBC") @@ -197,15 +198,15 @@ install.packages("RJDBC") -如果已经安装了 TDengine 服务端软件或 TDengine 客户端驱动 taosc, 那么已经安装了 C 连接器,无需额外操作。 +If the client driver taosc is already installed, then the C connector is already available.
-## 建立连接 +## Establish Connection -在执行这一步之前,请确保有一个正在运行的,且可以访问到的 TDengine,而且服务端的 FQDN 配置正确。以下示例代码,都假设 TDengine 安装在本机,且 FQDN(默认 localhost) 和 serverPort(默认 6030) 都使用默认配置。 +Prior to establishing connection, please make sure TDengine is already running and accessible. The following sample code assumes TDengine is running on the same host as the client program, with FQDN configured to "localhost" and serverPort configured to "6030". @@ -235,6 +236,6 @@ install.packages("RJDBC") :::tip -如果建立连接失败,大部分情况下是 FQDN 或防火墙的配置不正确,详细的排查方法请看[《常见问题及反馈》](https://docs.taosdata.com/train-faq/faq)中的“遇到错误 Unable to establish connection, 我怎么办?” +If the connection fails, in most cases it's caused by improper configuration for FQDN or firewall. Please refer to the section "Unable to establish connection" in [FAQ](https://docs.taosdata.com/train-faq/faq). ::: diff --git a/docs-en/04-develop/02-model/_category_.yml b/docs-en/04-develop/02-model/_category_.yml index e5dae7c27cf17ff737aa8301bc79aad468c28791..a2b49eb879c593b29cba1b1bfab3f5b2b615c1e6 100644 --- a/docs-en/04-develop/02-model/_category_.yml +++ b/docs-en/04-develop/02-model/_category_.yml @@ -1,2 +1,2 @@ -label: 数据建模 +label: Data Model diff --git a/docs-en/04-develop/02-model/index.mdx b/docs-en/04-develop/02-model/index.mdx index 7cf03cee37a5ac681181b0982e98e48d139ddb83..5ff92eddb17fc5eede430574a15c8ac345d9dc69 100644 --- a/docs-en/04-develop/02-model/index.mdx +++ b/docs-en/04-develop/02-model/index.mdx @@ -1,87 +1,85 @@ --- slug: /model -title: TDengine 数据建模 +title: Data Model --- -TDengine 采用类关系型数据模型,需要建库、建表。因此对于一个具体的应用场景,需要考虑库、超级表和普通表的设计。本节不讨论细致的语法规则,只介绍概念。 +The data model employed by TDengine is similar to relational database, you need to create databases and tables. For a specific application, the design of databases, STables (abbreviated for super table), and tables need to be considered. This chapter will explain the big picture without syntax details. -关于数据建模请参考[视频教程](https://www.taosdata.com/blog/2020/11/11/1945.html)。 +## Create Database -## 创建库 - -不同类型的数据采集点往往具有不同的数据特征,包括数据采集频率的高低,数据保留时间的长短,副本的数目,数据块的大小,是否允许更新数据等等。为了在各种场景下 TDengine 都能最大效率的工作,TDengine 建议将不同数据特征的表创建在不同的库里,因为每个库可以配置不同的存储策略。创建一个库时,除 SQL 标准的选项外,还可以指定保留时长、副本数、内存块个数、时间精度、文件块里最大最小记录条数、是否压缩、一个数据文件覆盖的天数等多种参数。比如: +The characteristics of data from different data collection points may be different, such as collection frequency, days to keep, number of replicas, data block size, whether it's allowed to update data, etc. For TDengine to operate with the best performance, it's strongly suggested to put the data with different characteristics into different databases because different storage policy can be set for each database. When creating a database, there are a lot of parameters that can be configured, such as the days to keep data, the number of replicas, the number of memory blocks, time precision, the minimum and maximum number of rows in each data block, compress or not, the time range of the data in single data file, etc. Below is an example of the SQL statement for creating a database. ```sql CREATE DATABASE power KEEP 365 DAYS 10 BLOCKS 6 UPDATE 1; ``` -上述语句将创建一个名为 power 的库,这个库的数据将保留 365 天(超过 365 天将被自动删除),每 10 天一个数据文件,内存块数为 6,允许更新数据。详细的语法及参数请见 [数据库管理](/taos-sql/database) 章节。 +In the above SQL statement, a database named "power" will be created, the data in it will be kept for 365 days, which means the data older than 365 days will be deleted automatically, a new data file will be created every 10 days, the number of memory blocks is 6, data is allowed to be updated. For more details please refer to [Database](/taos-sql/database). -创建库之后,需要使用 SQL 命令 `USE` 将当前库切换过来,例如: +After creating a database, the current database in use can be switched using SQL command `USE`, for example below SQL statement switches the current database to `power`. Without current database specified, table name must be preceded with the corresponding database name. ```sql USE power; ``` -将当前连接里操作的库换为 power,否则对具体表操作前,需要使用“库名.表名”来指定库的名字。 - :::note -- 任何一张表或超级表必须属于某个库,在创建表之前,必须先创建库。 -- 处于两个不同库的表是不能进行 JOIN 操作的。 -- 创建并插入记录、查询历史记录的时候,均需要指定时间戳。 +- Any table or STable must belong to a database. To create a table or STable, the database it belongs to must be ready. +- JOIN operation can't be performed tables from two different databases. +- Timestamp needs to be specified when inserting rows or querying historical rows. ::: -## 创建超级表 +## Create STable -一个物联网系统,往往存在多种类型的设备,比如对于电网,存在智能电表、变压器、母线、开关等等。为便于多表之间的聚合,使用 TDengine, 需要对每个类型的数据采集点创建一个超级表。以[表 1](/tdinternal/arch#model_table1) 中的智能电表为例,可以使用如下的 SQL 命令创建超级表: +In a time-series application, there may be multiple kinds of data collection points. For example, in the electrical power system there are meters, transformers, bus bars, switches, etc. For easy and efficient aggregation of multiple tables, one STable needs to be created for each kind of data collection point. For example, for the meters in [table 1](/tdinternal/arch#model_table1), below SQL statement can be used to create the super table. ```sql -CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int); +CREATE STable meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int); ``` :::note -这一指令中的 STABLE 关键字,在 2.0.15 之前的版本中需写作 TABLE 。 +If you are using versions prior to 2.0.15, the `STable` keyword needs to be replaced with `TABLE`. + ::: -与创建普通表一样,创建超级表时,需要提供表名(示例中为 meters),表结构 Schema,即数据列的定义。第一列必须为时间戳(示例中为 ts),其他列为采集的物理量(示例中为 current, voltage, phase),数据类型可以为整型、浮点型、字符串等。除此之外,还需要提供标签的 schema (示例中为 location, groupId),标签的数据类型可以为整型、浮点型、字符串等。采集点的静态属性往往可以作为标签,比如采集点的地理位置、设备型号、设备组 ID、管理员 ID 等等。标签的 schema 可以事后增加、删除、修改。具体定义以及细节请见 [TAOS SQL 的超级表管理](/taos-sql/stable) 章节。 +Similar to creating a regular table, when creating a STable, name and schema need to be provided too. In the STable schema, the first column must be timestamp (like ts in the example), and other columns (like current, voltage and phase in the example) are the data collected. The type of a column can be integer, float, double, string ,etc. Besides, the schema for tags need to be provided, like location and groupId in the example. The type of a tag can be integer, float, string, etc. The static properties of a data collection point can be defined as tags, like the location, device type, device group ID, manager ID, etc. Tags in the schema can be added, removed or updated. Please refer to [STable](/taos-sql/stable) for more details. -每一种类型的数据采集点需要建立一个超级表,因此一个物联网系统,往往会有多个超级表。对于电网,我们就需要对智能电表、变压器、母线、开关等都建立一个超级表。在物联网中,一个设备就可能有多个数据采集点(比如一台风力发电的风机,有的采集点采集电流、电压等电参数,有的采集点采集温度、湿度、风向等环境参数),这个时候,对这一类型的设备,需要建立多张超级表。 +For each kind of data collection points, a corresponding STable must be created. There may be man y STables in an application. For electrical power system, we need to create a STable respectively for meters, transformers, busbars, switches. There may be multiple kinds of data collection points on a single device, for example there may be one data collection point for electrical data like current and voltage and another point for environmental data like temperature, humidity and wind direction, multiple STables are required for such kind of device. -一张超级表最多容许 4096 列 (在 2.1.7.0 版本之前,列数限制为 1024 列),如果一个采集点采集的物理量个数超过 4096,需要建多张超级表来处理。一个系统可以有多个 DB,一个 DB 里可以有一到多个超级表。 +At most 4096 (or 1024 prior to version 2.1.7.0) columns are allowed in a STable. If there are more than 4096 of metrics to bo collected for a data collection point, multiple STables are required for such kind of data collection point. There can be multiple databases in system, while one or more STables can exist in a database. -## 创建表 +## Create Table -TDengine 对每个数据采集点需要独立建表。与标准的关系型数据库一样,一张表有表名,Schema,但除此之外,还可以带有一到多个标签。创建时,需要使用超级表做模板,同时指定标签的具体值。以[表 1](/tdinternal/arch#model_table1)中的智能电表为例,可以使用如下的 SQL 命令建表: +A specific table needs to be created for each data collection point. Similar to RDBMS, table name and schema are required to create a table. Beside, one or more tags can be created for each table. To create a table, a STable needs to be used as template and the values need to be specified for the tags. For example, for the meters in [Table 1](/tdinternal/arch#model_table1), the table can be created using below SQL statement. ```sql CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2); ``` -其中 d1001 是表名,meters 是超级表的表名,后面紧跟标签 Location 的具体标签值 ”Beijing.Chaoyang",标签 groupId 的具体标签值 2。虽然在创建表时,需要指定标签值,但可以事后修改。详细细则请见 [TAOS SQL 的表管理](/taos-sql/table) 章节。 +In the above SQL statement, "d1001" is the table name, "meters" is the STable name, followed by the value of tag "Location" and the value of tag "groupId", which are "Beijing.Chaoyang" and "2" respectively in the example. The tag values can be updated after the table is created. Please refer to [Tables](/taos-sql/table) for details. -:::warning -目前 TDengine 没有从技术层面限制使用一个 database (db1) 的超级表作为模板建立另一个 database (db2) 的子表,后续会禁止这种用法,不建议使用这种方法建表。 +In TDengine system, it's recommended to create a table for a data collection point via STable. Table created via STable is called subtable in some parts of TDengine document. All SQL commands applied on regular table can be applied on subtable. -::: +:::warning +It's not recommended to create a table in a database while using a STable from another database as template. -TDengine 建议将数据采集点的全局唯一 ID 作为表名(比如设备序列号)。但对于有的场景,并没有唯一的 ID,可以将多个 ID 组合成一个唯一的 ID。不建议将具有唯一性的 ID 作为标签值。 +:::tip +It's suggested to use the global unique ID of a data collection point as the table name, for example the device serial number. If there isn't such a unique ID, multiple IDs that are not global unique can be combined to form a global unique ID. It's not recommended to use a global unique ID as tag value. -### 自动建表 +## Create Table Automatically -在某些特殊场景中,用户在写数据时并不确定某个数据采集点的表是否存在,此时可在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表且后面的 USING 语句被忽略。比如: +In some circumstances, it's not sure whether the table already exists when inserting rows. The table can be created automatically using the SQL statement below, and nothing will happen if the table already exist. ```sql INSERT INTO d1001 USING meters TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219, 0.32); ``` -上述 SQL 语句将记录`(now, 10.2, 219, 0.32)`插入表 d1001。如果表 d1001 还未创建,则使用超级表 meters 做模板自动创建,同时打上标签值 `"Beijing.Chaoyang", 2`。 +In the above SQL statement, a row with value `(now, 10.2, 219, 0.32)` will be inserted into table "d1001". If table "d1001" doesn't exist, it will be created automatically using STable "meters" as template with tag value `"Beijing.Chaoyang", 2`. -关于自动建表的详细语法请参见 [插入记录时自动建表](/taos-sql/insert#插入记录时自动建表) 章节。 +For more details please refer to [Create Table Automatically](/taos-sql/insert#automatically-create-table-when-inserting). -## 多列模型 vs 单列模型 +## Single Column vs Multiple Column -TDengine 支持多列模型,只要物理量是一个数据采集点同时采集的(时间戳一致),这些量就可以作为不同列放在一张超级表里。但还有一种极限的设计,单列模型,每个采集的物理量都单独建表,因此每种类型的物理量都单独建立一超级表。比如电流、电压、相位,就建三张超级表。 +Multiple columns data model is supported in TDengine. As long as multiple metrics are collected by same data collection point at same time, i.e. the timestamp are identical, these metrics can be put in single stable as columns. However, there is another kind of design, i.e. single column data model, a table is created for each metric, which means a STable is required for each kind of metric. For example, 3 STables are required for current, voltage and phase. -TDengine 建议尽可能采用多列模型,因为插入效率以及存储效率更高。但对于有些场景,一个采集点的采集量的种类经常变化,这个时候,如果采用多列模型,就需要频繁修改超级表的结构定义,让应用变的复杂,这个时候,采用单列模型会显得更简单。 +It's recommended to use multiple column data model as much as possible because it's better in the performance of inserting or querying rows. In some cases, however, the metrics to be collected vary frequently and correspondingly the STable schema needs to be changed frequently too. In such case, it's more convenient to use single column data model. diff --git a/docs-en/04-develop/03-insert-data/01-sql-writing.mdx b/docs-en/04-develop/03-insert-data/01-sql-writing.mdx index 7a4ab3eb72f6bf41e863ba26aa7ef97b503349d8..9f66992d3de755389c3a0722ebb09097177742f1 100644 --- a/docs-en/04-develop/03-insert-data/01-sql-writing.mdx +++ b/docs-en/04-develop/03-insert-data/01-sql-writing.mdx @@ -1,5 +1,6 @@ --- -title: SQL 写入 +sidebar_label: SQL +title: Insert Using SQL --- import Tabs from "@theme/Tabs"; @@ -19,52 +20,53 @@ import CsStmt from "./_cs_stmt.mdx"; import CSQL from "./_c_sql.mdx"; import CStmt from "./_c_stmt.mdx"; -## SQL 写入简介 +## Introduction -应用通过连接器执行 INSERT 语句来插入数据,用户还可以通过 TAOS Shell,手动输入 INSERT 语句插入数据。 +Application program can execute `INSERT` statement through connectors to insert rows. TAOS CLI can be launched manually to insert data too. -### 一次写入一条 -下面这条 INSERT 就将一条记录写入到表 d1001 中: +### Insert Single Row + +Below SQL statement is used to insert one row into table "d1001". ```sql INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31); ``` -### 一次写入多条 +### Insert Multiple Rows -TDengine 支持一次写入多条记录,比如下面这条命令就将两条记录写入到表 d1001 中: +Multiple rows can be inserted in single SQL statement. Below example inserts 2 rows into table "d1001". ```sql INSERT INTO d1001 VALUES (1538548684000, 10.2, 220, 0.23) (1538548696650, 10.3, 218, 0.25); ``` -### 一次写入多表 +### Insert into Multiple Tables -TDengine 也支持一次向多个表写入数据,比如下面这条命令就向 d1001 写入两条记录,向 d1002 写入一条记录: +Data can be inserted into multiple tables in same SQL statement. Below example inserts 2 rows into table "d1001" and 1 row into table "d1002". ```sql INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, 218, 0.33) d1002 VALUES (1538548696800, 12.3, 221, 0.31); ``` -详细的 SQL INSERT 语法规则参考 [TAOS SQL 的数据写入](/taos-sql/insert)。 +For more details about `INSERT` please refer to [INSERT](/taos-sql/insert). :::info -- 要提高写入效率,需要批量写入。一批写入的记录条数越多,插入效率就越高。但一条记录不能超过 16K,一条 SQL 语句总长度不能超过 1M 。 -- TDengine 支持多线程同时写入,要进一步提高写入速度,一个客户端需要打开 20 个以上的线程同时写。但线程数达到一定数量后,无法再提高,甚至还会下降,因为线程频繁切换,带来额外开销。 +- Inserting in batch can gain better performance. Normally, the higher the batch size, the better the performance. Please be noted each single row can't exceed 16K bytes and each single SQL statement can't exceed 1M bytes. +- Inserting with multiple threads can gain better performance too. However, depending on the system resources on the application side and the server side, with the number of inserting threads grows to a specific point, the performance may drop instead of growing. The proper number of threads need to be tested in a specific environment to find the best number. ::: :::warning -- 对同一张表,如果新插入记录的时间戳已经存在,默认情形下(UPDATE=0)新记录将被直接抛弃,也就是说,在一张表里,时间戳必须是唯一的。如果应用自动生成记录,很有可能生成的时间戳是一样的,这样,成功插入的记录条数会小于应用插入的记录条数。如果在创建数据库时使用了 UPDATE 1 选项,插入相同时间戳的新记录将覆盖原有记录。 -- 写入的数据的时间戳必须大于当前时间减去配置参数 keep 的时间。如果 keep 配置为 3650 天,那么无法写入比 3650 天还早的数据。写入数据的时间戳也不能大于当前时间加配置参数 days。如果 days 为 2,那么无法写入比当前时间还晚 2 天的数据。 +- If the timestamp for the row to be inserted already exists in the table, the behavior depends on the value of parameter `UPDATE`. If it's set to 0 (also the default value), the row will be discarded. If it's set to 1, the new values will override the old values for the same row. +- The timestamp to be inserted must be newer than the timestamp of subtracting current time by the parameter `KEEP`. If `KEEP` is set to 3650 days, then the data older than 3650 days ago can't be inserted. The timestamp to be inserted can't be newer than the timestamp of current time plus parameter `DAYS`. If `DAYS` is set to 2, the data newer than 2 days later can't be inserted. ::: -## 示例程序 +## Examples -### 普通 SQL 写入 +### Insert Using SQL @@ -92,16 +94,16 @@ INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, :::note -1. 无论 RESTful 方式建立连接还是本地驱动方式建立连接,以上示例代码都能正常工作。 -2. 唯一需要注意的是:由于 RESTful 接口无状态, 不能使用 `use db` 语句来切换数据库, 所以在上面示例中使用了`dbName.tbName`指定表名。 +1. With either native connection or REST connection, the above samples can work well. +2. Please be noted that `use db` can't be used with REST connection because REST connection is stateless, so in the samples `dbName.tbName` is used to specify the table name. ::: -### 参数绑定写入 +### Insert with Parameter Binding -TDengine 也提供了支持参数绑定的 Prepare API,与 MySQL 类似,这些 API 目前也仅支持用问号 `?` 来代表待绑定的参数。从 2.1.1.0 和 2.1.2.0 版本开始,TDengine 大幅改进了参数绑定接口对数据写入(INSERT)场景的支持。这样在通过参数绑定接口写入数据时,就避免了 SQL 语法解析的资源消耗,从而在绝大多数情况下显著提升写入性能。 +TDengine also provides Prepare API that support parameter binding. Similar to MySQL, only `?` can be used in these APIs to represent the parameters to bind. From version 2.1.1.0 and 2.1.2.0, parameter binding support for inserting data has been improved significantly to improve the insert performance by avoiding the cost of parsing SQL statements. -需要注意的是,只有使用原生连接的连接器,才能使用参数绑定功能。 +Parameter binding is available only with native connection. @@ -126,4 +128,3 @@ TDengine 也提供了支持参数绑定的 Prepare API,与 MySQL 类似,这 - diff --git a/docs-en/04-develop/03-insert-data/02-influxdb-line.mdx b/docs-en/04-develop/03-insert-data/02-influxdb-line.mdx index dedd7f0e70834e21257bda78dd184f5ddc520160..172003d203fa309ce51b3ecae9a7490a59f513d7 100644 --- a/docs-en/04-develop/03-insert-data/02-influxdb-line.mdx +++ b/docs-en/04-develop/03-insert-data/02-influxdb-line.mdx @@ -1,6 +1,6 @@ --- -sidebar_label: InfluxDB 行协议 -title: InfluxDB 行协议 +sidebar_label: InfluxDB Line Protocol +title: InfluxDB Line Protocol --- import Tabs from "@theme/Tabs"; @@ -13,20 +13,20 @@ import NodeLine from "./_js_line.mdx"; import CsLine from "./_cs_line.mdx"; import CLine from "./_c_line.mdx"; -## 协议介绍 +## Introduction -InfluxDB Line 协议采用一行字符串来表示一行数据。分为四部分: +A single line of text is used in InfluxDB Line protocol format represents one row of data, each line contains 4 parts as shown below. ``` measurement,tag_set field_set timestamp ``` -- measurement 将作为超级表名。它与 tag_set 之间使用一个英文逗号来分隔。 -- tag_set 将作为标签数据,其格式形如 `=,=`,也即可以使用英文逗号来分隔多个标签数据。它与 field_set 之间使用一个半角空格来分隔。 -- field_set 将作为普通列数据,其格式形如 `=,=`,同样是使用英文逗号来分隔多个普通列的数据。它与 timestamp 之间使用一个半角空格来分隔。 -- timestamp 即本行数据对应的主键时间戳。 +- `measurement` will be used as the STable name +- `tag_set` will be used as tags, with format like `=,=` +- `field_set`will be used as data columns, with format like `=,=` +- `timestamp` is the primary key timestamp corresponding to this row of data -例如: +For example: ``` meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611249500 @@ -34,16 +34,16 @@ meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 16 :::note -- tag_set 中的所有的数据自动转化为 nchar 数据类型; -- field_set 中的每个数据项都需要对自身的数据类型进行描述, 比如 1.2f32 代表 float 类型的数值 1.2, 如果不带类型后缀会被当作 double 处理; -- timestamp 支持多种时间精度。写入数据的时候需要用参数指定时间精度,支持从小时到纳秒的 6 种时间精度。 +- All the data in `tag_set` will be converted to ncahr type automatically . +- Each data in `field_set` must be self-description for its data type. For example 1.2f32 means a value 1.2 of float type, it will be treated as double without the "f" type suffix. +- Multiple kinds of precision can be used for the `timestamp` field. Time precision can be from nanosecond (ns) to hour (h). ::: -要了解更多可参考:[InfluxDB Line 协议官方文档](https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/) 和 [TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) +For more details please refer to [InfluxDB Line Protocol](https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/) and [TDengine Schemaless](/reference/schemaless/#Schemaless-Line-Protocol) -## 示例代码 +## Examples diff --git a/docs-en/04-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs-en/04-develop/03-insert-data/03-opentsdb-telnet.mdx index dfbe6efda67b6928999287900637e0a251b86562..66bb67c25669b906183526377f60b969ea3d1e85 100644 --- a/docs-en/04-develop/03-insert-data/03-opentsdb-telnet.mdx +++ b/docs-en/04-develop/03-insert-data/03-opentsdb-telnet.mdx @@ -1,6 +1,6 @@ --- -sidebar_label: OpenTSDB 行协议 -title: OpenTSDB 行协议 +sidebar_label: OpenTSDB Line Protocol +title: OpenTSDB Line Protocol --- import Tabs from "@theme/Tabs"; @@ -13,28 +13,28 @@ import NodeTelnet from "./_js_opts_telnet.mdx"; import CsTelnet from "./_cs_opts_telnet.mdx"; import CTelnet from "./_c_opts_telnet.mdx"; -## 协议介绍 +## Introduction -OpenTSDB 行协议同样采用一行字符串来表示一行数据。OpenTSDB 采用的是单列模型,因此一行只能包含一个普通数据列。标签列依然可以有多个。分为四部分,具体格式约定如下: +A single line of text is used in OpenTSDB line protocol to represent one row of data. OpenTSDB employs single column data model, so one line can only contains single data column. There can be multiple tags. Each line contains 4 parts as below: -```txt +``` =[ =] ``` -- metric 将作为超级表名。 -- timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度 -- value 度量值,必须为一个数值。对应的列名也是 “value”。 -- 最后一部分是标签集, 用空格分隔不同标签, 所有标签自动转化为 nchar 数据类型; +- `metric` will be used as STable name. +- `timestamp` is the timestamp of current row of data. The time precision will be determined automatically based on the length of the timestamp. second and millisecond time precision are supported.\ +- `value` is a metric which must be a numeric value, the corresponding column name is "value". +- The last part is tag sets separated by space, all tags will be converted to nchar type automatically. -例如: +For example: ```txt meters.current 1648432611250 11.3 location=Beijing.Haidian groupid=3 ``` -参考[OpenTSDB Telnet API文档](http://opentsdb.net/docs/build/html/api_telnet/put.html)。 +Please refer to [OpenTSDB Telnet API](http://opentsdb.net/docs/build/html/api_telnet/put.html) for more details. -## 示例代码 +## Examples @@ -60,13 +60,13 @@ meters.current 1648432611250 11.3 location=Beijing.Haidian groupid=3 -以上示例代码会自动创建 2 个超级表, 每个超级表有 4 条数据。 +2 STables will be crated automatically while each STable has 4 rows of data in the above sample code. ```cmd taos> use test; Database changed. -taos> show stables; +taos> show STables; name | created_time | columns | tags | tables | ============================================================================================ meters.current | 2022-03-30 17:04:10.877 | 2 | 2 | 2 | diff --git a/docs-en/04-develop/03-insert-data/04-opentsdb-json.mdx b/docs-en/04-develop/03-insert-data/04-opentsdb-json.mdx index 5d445997d061ca052e4f3673b8e881ea4acf0ade..fb938d26961f86cefd3b5b9d31e4eb3481e10873 100644 --- a/docs-en/04-develop/03-insert-data/04-opentsdb-json.mdx +++ b/docs-en/04-develop/03-insert-data/04-opentsdb-json.mdx @@ -1,6 +1,6 @@ --- -sidebar_label: OpenTSDB JSON 格式协议 -title: OpenTSDB JSON 格式协议 +sidebar_label: OpenTSDB JSON Protocol +title: OpenTSDB JSON Protocol --- import Tabs from "@theme/Tabs"; @@ -13,9 +13,9 @@ import NodeJson from "./_js_opts_json.mdx"; import CsJson from "./_cs_opts_json.mdx"; import CJson from "./_c_opts_json.mdx"; -## 协议介绍 +## Introduction -OpenTSDB JSON 格式协议采用一个 JSON 字符串表示一行或多行数据。例如: +A JSON string is used in OpenTSDB JSON to represent one or more rows of data, for exmaple: ```json [ @@ -40,18 +40,18 @@ OpenTSDB JSON 格式协议采用一个 JSON 字符串表示一行或多行数据 ] ``` -与 OpenTSDB 行协议类似, metric 将作为超级表名, timestamp 表示时间戳,value 表示度量值, tags 表示标签集。 +Similar to OpenTSDB line protocol, `metric` will be used as the STable name, `timestamp` is the timestamp to be used, `value` represents the metric collected, `tags` are the tag sets. -参考[OpenTSDB HTTP API文档](http://opentsdb.net/docs/build/html/api_http/put.html)。 +Please refer to [OpenTSDB HTTP API](http://opentsdb.net/docs/build/html/api_http/put.html) for more details. :::note -- 对于 JSON 格式协议,TDengine 并不会自动把所有标签转成 nchar 类型, 字符串将将转为 nchar 类型, 数值将同样转换为 double 类型。 -- TDengine 只接收 JSON **数组格式**的字符串,即使一行数据也需要转换成数组形式。 +- In JSON protocol, strings will be converted to nchar type and numeric values will be converted to double type. +- Only data in array format is accepted, array must be used even there is only one row. ::: -## 示例代码 +## Examples @@ -77,13 +77,13 @@ OpenTSDB JSON 格式协议采用一个 JSON 字符串表示一行或多行数据 -以上示例代码会自动创建 2 个超级表, 每个超级表有 2 条数据。 +The above sample code will created 2 STables automatically while each STable has 2 rows of data. ```cmd taos> use test; Database changed. -taos> show stables; +taos> show STables; name | created_time | columns | tags | tables | ============================================================================================ meters.current | 2022-03-29 16:05:25.193 | 2 | 2 | 1 | diff --git a/docs-en/04-develop/03-insert-data/_c_stmt.mdx b/docs-en/04-develop/03-insert-data/_c_stmt.mdx index 01ac067519a2bd224e313fd70169722ba5f20413..7f5ef23a849689c36e732b6fd374a131695c9090 100644 --- a/docs-en/04-develop/03-insert-data/_c_stmt.mdx +++ b/docs-en/04-develop/03-insert-data/_c_stmt.mdx @@ -1,6 +1,6 @@ -```c title=一次绑定一行 +```c title=Single Row Binding {{#include docs-examples/c/stmt_example.c}} ``` -```c title=一次绑定多行 72:117 +```c title=Multiple Row Binding 72:117 {{#include docs-examples/c/multi_bind_example.c}} ``` \ No newline at end of file diff --git a/docs-en/04-develop/03-insert-data/_category_.yml b/docs-en/04-develop/03-insert-data/_category_.yml index 9e76a57abd132b528bbd692f03439649ab83425d..e515d60e09ec44894e2c42f38fee74fe4286e17f 100644 --- a/docs-en/04-develop/03-insert-data/_category_.yml +++ b/docs-en/04-develop/03-insert-data/_category_.yml @@ -1,5 +1 @@ -label: 写入数据 -link: - type: generated-index - slug: /insert-data/ - description: "TDengine 支持多种写入协议,包括 SQL,InfluxDB Line 协议, OpenTSDB Telnet 协议,OpenTSDB JSON 格式协议。数据可以单条插入,也可以批量插入,可以插入一个数据采集点的数据,也可以同时插入多个数据采集点的数据。同时,TDengine 支持多线程插入,支持时间乱序数据插入,也支持历史数据插入。InfluxDB Line 协议、OpenTSDB Telnet 协议和 OpenTSDB JSON 格式协议是 TDengine 支持的三种无模式写入协议。使用无模式方式写入无需提前创建超级表和子表,并且引擎能自适用数据对表结构做调整。" +label: Insert Data diff --git a/docs-en/04-develop/03-insert-data/_go_stmt.mdx b/docs-en/04-develop/03-insert-data/_go_stmt.mdx index 7bb6792d6df5b250850bd0a0021ecceba994aa09..c32bc21fb9bcaf45059e4f47df73fb57f047ed1c 100644 --- a/docs-en/04-develop/03-insert-data/_go_stmt.mdx +++ b/docs-en/04-develop/03-insert-data/_go_stmt.mdx @@ -3,6 +3,6 @@ ``` :::tip -driver-go 的模块 `github.com/taosdata/driver-go/v2/wrapper` 是 C 接口的底层封装。使用这个模块也可以实现参数绑定写入。 +`github.com/taosdata/driver-go/v2/wrapper` module in driver-go is the wrapper for C API, it can be used to insert data with parameter binding. ::: diff --git a/docs-en/04-develop/03-insert-data/_js_stmt.mdx b/docs-en/04-develop/03-insert-data/_js_stmt.mdx index 17a6c9785c7dc1e3c3fa6a59982913f1f139f9c2..964d7ddc11b90031b70936efb85fbaabe873ddbb 100644 --- a/docs-en/04-develop/03-insert-data/_js_stmt.mdx +++ b/docs-en/04-develop/03-insert-data/_js_stmt.mdx @@ -1,12 +1,12 @@ -```js title=一次绑定一行 +```js title=Single Row Binding {{#include docs-examples/node/nativeexample/param_bind_example.js}} ``` -```js title=一次绑定多行 +```js title=Multiple Row Binding {{#include docs-examples/node/nativeexample/multi_bind_example.js:insertData}} ``` :::info -一次绑定一行效率不如一次绑定多行,但支持非 INSERT 语句。一次绑定多行效率更高,但仅支持 INSERT 语句。 +Multiple row binding is better in performance than single row binding, but it can only be used with `INSERT` statement while single row binding can be used for other SQL statements besides `INSERT`. ::: diff --git a/docs-en/04-develop/03-insert-data/_py_stmt.mdx b/docs-en/04-develop/03-insert-data/_py_stmt.mdx index 8241ea86bc64ac64d842dc0a6cddc0eae0399503..16d98f54329ad0d3dfb463392f5c1d41c9aab25b 100644 --- a/docs-en/04-develop/03-insert-data/_py_stmt.mdx +++ b/docs-en/04-develop/03-insert-data/_py_stmt.mdx @@ -1,12 +1,12 @@ -```py title=一次绑定一行 +```py title=Single Row Binding {{#include docs-examples/python/bind_param_example.py}} ``` -```py title=一次绑定多行 +```py title=Multiple Row Binding {{#include docs-examples/python/multi_bind_example.py:bind_batch}} ``` :::info -一次绑定一行效率不如一次绑定多行,但支持非 INSERT 语句。一次绑定多行效率更高,但仅支持 INSERT 语句。 +Multiple row binding is better in performance than single row binding, but it can only be used with `INSERT` statement while single row binding can be used for other SQL statements besides `INSERT`. ::: \ No newline at end of file diff --git a/docs-en/04-develop/03-insert-data/index.md b/docs-en/04-develop/03-insert-data/index.md new file mode 100644 index 0000000000000000000000000000000000000000..ee80d436f11f19b422df261845f1c209620251f2 --- /dev/null +++ b/docs-en/04-develop/03-insert-data/index.md @@ -0,0 +1,12 @@ +--- +title: Insert +--- + +TDengine supports multiple protocols of inserting data, including SQL, InfluxDB Line protocol, OpenTSDB Telnet protocol, OpenTSDB JSON protocol. Data can be inserted row by row, or in batch. Data from one or more collecting points can be inserted simultaneously. In the meantime, data can be inserted with multiple threads, out of order data and historical data can be inserted too. InfluxDB Line protocol, OpenTSDB Telnet protocol and OpenTSDB JSON protocol are the 3 kinds of schemaless insert protocols supported by TDengine. It's not necessary to create stable and table in advance if using schemaless protocols, and the schemas can be adjusted automatically according to the data to be inserted. + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-en/04-develop/04-query-data/_category_.yml b/docs-en/04-develop/04-query-data/_category_.yml index 69273cb31cc54fd438bf82b408e529f8d3d9ccb4..5912a48fc31ed36235c0d34d8b0909bf3b518aaa 100644 --- a/docs-en/04-develop/04-query-data/_category_.yml +++ b/docs-en/04-develop/04-query-data/_category_.yml @@ -1 +1 @@ -label: 查询数据 +label: Select Data diff --git a/docs-en/04-develop/04-query-data/_py.mdx b/docs-en/04-develop/04-query-data/_py.mdx index 6a1bacdd3ef91e9484c1d87d6a22de8b128e2144..aeae42a15e5c39b7e9d227afc424e77658109705 100644 --- a/docs-en/04-develop/04-query-data/_py.mdx +++ b/docs-en/04-develop/04-query-data/_py.mdx @@ -1,11 +1,11 @@ -通过迭代逐行获取查询结果。 +Result set is iterated row by row. ```py {{#include docs-examples/python/query_example.py:iter}} ``` -一次获取所有查询结果,并把每一行转化为一个字典返回。 +Result set is retrieved as a whole, each row is converted to a dict and returned. ```py {{#include docs-examples/python/query_example.py:fetch_all}} -``` +``` \ No newline at end of file diff --git a/docs-en/04-develop/04-query-data/_py_async.mdx b/docs-en/04-develop/04-query-data/_py_async.mdx index 2399a50df645804788036e17bf223c53482d4eaf..ed6880ae64e59a860e7dc75a5d3c1ad5d2614d01 100644 --- a/docs-en/04-develop/04-query-data/_py_async.mdx +++ b/docs-en/04-develop/04-query-data/_py_async.mdx @@ -3,6 +3,6 @@ ``` :::note -这个示例程序,目前在 Windows 系统上还无法运行 +This sample code can't be run on Windows system for now. ::: diff --git a/docs-en/04-develop/04-query-data/index.mdx b/docs-en/04-develop/04-query-data/index.mdx index 829280fba5b1e5a956b79699df39f9bb2c1cb177..3105a174ba51d23e90b067efd2b5c21376a66a70 100644 --- a/docs-en/04-develop/04-query-data/index.mdx +++ b/docs-en/04-develop/04-query-data/index.mdx @@ -1,7 +1,8 @@ --- slug: /query-data -title: 查询数据 -description: "主要查询功能,通过连接器执行同步查询和异步查询" +Sidebar_label: Select +title: Select +description: "This chapter introduces major query functionalities and how to perform sync and async query using connectors." --- import Tabs from "@theme/Tabs"; @@ -18,20 +19,26 @@ import NodeAsync from "./_js_async.mdx"; import CsAsync from "./_cs_async.mdx"; import CAsync from "./_c_async.mdx"; -## 主要查询功能 +## Introduction -TDengine 采用 SQL 作为查询语言。应用程序可以通过 REST API 或连接器发送 SQL 语句,用户还可以通过 TDengine 命令行工具 taos 手动执行 SQL 即席查询(Ad-Hoc Query)。TDengine 支持如下查询功能: +SQL is used by TDengine as the query language. Application programs can send SQL statements to TDengine through REST API or connectors. TDengine CLI `taos` can also be used to execute SQL Ad-Hoc query. Here is the list of major query functionalities supported by TDengine: -- 单列、多列数据查询 -- 标签和数值的多种过滤条件:>, <, =, <\>, like 等 -- 聚合结果的分组(Group by)、排序(Order by)、约束输出(Limit/Offset) -- 数值列及聚合结果的四则运算 -- 时间戳对齐的连接查询(Join Query: 隐式连接)操作 -- 多种聚合/计算函数: count, max, min, avg, sum, twa, stddev, leastsquares, top, bottom, first, last, percentile, apercentile, last_row, spread, diff 等 +- Query on single column or multiple columns +- Filter on tags or data columns:>, <, =, <\>, like +- Grouping of results: `Group By` +- Sorting of results: `Order By` +- Limit the number of results: `Limit/Offset` +- Arithmetic on columns of numeric types or aggregate results +- Join query with timestamp alignment +- Aggregate functions: count, max, min, avg, sum, twa, stddev, leastsquares, top, bottom, first, last, percentile, apercentile, last_row, spread, diff -例如:在命令行工具 taos 中,从表 d1001 中查询出 voltage > 215 的记录,按时间降序排列,仅仅输出 2 条。 +For example, below SQL statement can be executed in TDengine CLI `taos` to select the rows whose voltage column is bigger than 215 and limit the output to only 2 rows. ```sql +select * from d1001 where voltage > 215 order by ts desc limit 2; +``` + +```title=Output taos> select * from d1001 where voltage > 215 order by ts desc limit 2; ts | current | voltage | phase | ====================================================================================== @@ -40,17 +47,19 @@ taos> select * from d1001 where voltage > 215 order by ts desc limit 2; Query OK, 2 row(s) in set (0.001100s) ``` -为满足物联网场景的需求,TDengine 支持几个特殊的函数,比如 twa(时间加权平均),spread (最大值与最小值的差),last_row(最后一条记录)等,更多与物联网场景相关的函数将添加进来。TDengine 还支持连续查询。 +To meet the requirements in many use cases, some special functions have been added in TDengine, for example `twa` (Time Weighted Average), `spared` (The difference between the maximum and the minimum), `last_row` (the last row), more and more functions will be added to better perform in many use cases. Furthermore, continuous query is also supported in TDengine. + +For detailed query syntax please refer to [Select](/taos-sql/select). -具体的查询语法请看 [TAOS SQL 的数据查询](/taos-sql/select) 章节。 +## Aggregation among Tables -## 多表聚合查询 +In many use cases, there are always multiple kinds of data collection points. A new concept, called STable (abbreviated for super table), is used in TDengine to represent a kind of data collection points, and a table is used to represent a specific data collection point. Tags are used by TDengine to represent the static properties of data collection points. A specific data collection point has its own values for static properties. By specifying filter conditions on tags, aggregation can be performed efficiently among all the subtables created via the same STable, i.e. same kind of data collection points, can be. Aggregate functions applicable for tables can be used directly on STables, syntax is exactly same. -物联网场景中,往往同一个类型的数据采集点有多个。TDengine 采用超级表(STable)的概念来描述某一个类型的数据采集点,一张普通的表来描述一个具体的数据采集点。同时 TDengine 使用标签来描述数据采集点的静态属性,一个具体的数据采集点有具体的标签值。通过指定标签的过滤条件,TDengine 提供了一高效的方法将超级表(某一类型的数据采集点)所属的子表进行聚合查询。对普通表的聚合函数以及绝大部分操作都适用于超级表,语法完全一样。 +In summary, for a STable, its subtables can be aggregated by a simple query on STable, it's kind of join operation. But tables belong to different STables could not be aggregated. -### 示例一 +### Example 1 -在 TAOS Shell,查找北京所有智能电表采集的电压平均值,并按照 location 分组。 +In TDengine CLI `taos`, use below SQL to get the average voltage of all the meters in BeiJing grouped by location. ``` taos> SELECT AVG(voltage) FROM meters GROUP BY location; @@ -61,9 +70,9 @@ taos> SELECT AVG(voltage) FROM meters GROUP BY location; Query OK, 2 row(s) in set (0.002136s) ``` -### 示例二 +### Example 2 -在 TAOS shell, 查找 groupId 为 2 的所有智能电表过去 24 小时的记录条数,电流的最大值。 +In TDengine CLI `taos`, use below SQL to get the number of rows and the maximum current in the past 24 hours from meters whose groupId is 2. ``` taos> SELECT count(*), max(current) FROM meters where groupId = 2 and ts > now - 24h; @@ -73,11 +82,11 @@ taos> SELECT count(*), max(current) FROM meters where groupId = 2 and ts > now - Query OK, 1 row(s) in set (0.002136s) ``` -TDengine 仅容许对属于同一个超级表的表之间进行聚合查询,不同超级表之间的聚合查询不支持。在 [TAOS SQL 的数据查询](/taos-sql/select) 一章,查询类操作都会注明是否支持超级表。 +Join query is allowed between only the tables of same STable. In [Select](/taos-sql/select), all query operations are marked as whether it supports STable or not. -## 降采样查询、插值 +## Down Sampling and Interpolation -物联网场景里,经常需要通过降采样(down sampling)将采集的数据按时间段进行聚合。TDengine 提供了一个简便的关键词 interval 让按照时间窗口的查询操作变得极为简单。比如,将智能电表 d1001 采集的电流值每 10 秒钟求和 +In IoT use cases, down sampling is widely used to aggregate the data by time range. `INTERVAL` keyword in TDengine can be used to simplify the query by time window. For example, below SQL statement can be used to get the sum of current every 10 seconds from meters table d1001. ``` taos> SELECT sum(current) FROM d1001 INTERVAL(10s); @@ -88,7 +97,7 @@ taos> SELECT sum(current) FROM d1001 INTERVAL(10s); Query OK, 2 row(s) in set (0.000883s) ``` -降采样操作也适用于超级表,比如:将北京所有智能电表采集的电流值每秒钟求和 +Down sampling can also be used for STable. For example, below SQL statement can be used to get the sum of current from all meters in BeiJing. ``` taos> SELECT SUM(current) FROM meters where location like "Beijing%" INTERVAL(1s); @@ -102,7 +111,7 @@ taos> SELECT SUM(current) FROM meters where location like "Beijing%" INTERVAL(1s Query OK, 5 row(s) in set (0.001538s) ``` -降采样操作也支持时间偏移,比如:将所有智能电表采集的电流值每秒钟求和,但要求每个时间窗口从 500 毫秒开始 +Down sampling also supports time offset. For example, below SQL statement can be used to get the sum of current from all meters but each time window must start at the boundary of 500 milliseconds. ``` taos> SELECT SUM(current) FROM meters INTERVAL(1s, 500a); @@ -116,17 +125,17 @@ taos> SELECT SUM(current) FROM meters INTERVAL(1s, 500a); Query OK, 5 row(s) in set (0.001521s) ``` -物联网场景里,每个数据采集点采集数据的时间是难同步的,但很多分析算法(比如 FFT)需要把采集的数据严格按照时间等间隔的对齐,在很多系统里,需要应用自己写程序来处理,但使用 TDengine 的降采样操作就轻松解决。 +In many use cases, it's hard to align the timestamp of the data collected by each collection point. However, a lot of algorithms like FFT require the data to be aligned with same time interval and application programs have to handle by themselves in many systems. In TDengine, it's easy to achieve the alignment using down sampling. -如果一个时间间隔里,没有采集的数据,TDengine 还提供插值计算的功能。 +Interpolation can be performed in TDengine if there is no data in a time range. -语法规则细节请见 [TAOS SQL 的按时间窗口切分聚合](/taos-sql/interval) 章节。 +For more details please refer to [Aggregate by Window](/taos-sql/interval). -## 示例代码 +## Examples -### 查询数据 +### Query -在 [SQL 写入](/develop/insert-data/sql-writing) 一章,我们创建了 power 数据库,并向 meters 表写入了一些数据,以下示例代码展示如何查询这个表的数据。 +In the section describing [Insert](/develop/insert-data/sql-writing), a database named `power` is created and some data are inserted into STable `meters`. Below sample code demonstrates how to query the data in this STable. @@ -154,16 +163,16 @@ Query OK, 5 row(s) in set (0.001521s) :::note -1. 无论是使用 REST 连接还是原生连接的连接器,以上示例代码都能正常工作。 -2. 唯一需要注意的是:由于 RESTful 接口无状态, 不能使用 `use db` 语句来切换数据库。 +1. With either REST connection or native connection, the above sample code work well. +2. Please be noted that `use db` can't be used in case of REST connection because it's stateless. ::: -### 异步查询 +### Asynchronous Query -除同步查询 API 之外,TDengine 还提供性能更高的异步调用 API 处理数据插入、查询操作。在软硬件环境相同的情况下,异步 API 处理数据插入的速度比同步 API 快 2-4 倍。异步 API 采用非阻塞式的调用方式,在系统真正完成某个具体数据库操作前,立即返回。调用的线程可以去处理其他工作,从而可以提升整个应用的性能。异步 API 在网络延迟严重的情况下,优点尤为突出。 +Besides synchronous query, asynchronous query API is also provided by TDengine to insert or query data more efficiently. With similar hardware and software environment, async API is 2~4 times faster than sync APIs. Async API works in non-blocking mode, which means an operation can be returned without finishing so that the calling thread can switch to other works to improve the performance of the whole application system. Async APIs perform especially better in case of poor network. -需要注意的是,只有使用原生连接的连接器,才能使用异步查询功能。 +Please be noted that async query can only be used with native connection. diff --git a/docs-en/04-develop/05-continuous-query.mdx b/docs-en/04-develop/05-continuous-query.mdx index 2fd1b3cc755188f513fe511541a84efa3558d3ea..97e32a17ff325a9f67ac0a732be3dd72ccca8888 100644 --- a/docs-en/04-develop/05-continuous-query.mdx +++ b/docs-en/04-develop/05-continuous-query.mdx @@ -1,20 +1,20 @@ --- -sidebar_label: 连续查询 -description: "连续查询是一个按照预设频率自动执行的查询功能,提供按照时间窗口的聚合查询能力,是一种简化的时间驱动流式计算。" -title: "连续查询(Continuous Query)" +sidebar_label: Continuous Query +description: "Continuous query is a query that's executed automatically according to predefined frequency to provide aggregate query capability by time window, it's actually a simplified time driven stream computing." +title: "Continuous Query" --- -连续查询是 TDengine 定期自动执行的查询,采用滑动窗口的方式进行计算,是一种简化的时间驱动的流式计算。针对库中的表或超级表,TDengine 可提供定期自动执行的连续查询,用户可让 TDengine 推送查询的结果,也可以将结果再写回到 TDengine 中。每次执行的查询是一个时间窗口,时间窗口随着时间流动向前滑动。在定义连续查询的时候需要指定时间窗口(time window, 参数 interval)大小和每次前向增量时间(forward sliding times, 参数 sliding)。 +Continuous query is a query that's executed automatically according to predefined frequency to provide aggregate query capability by time window, it's actually a simplified time driven stream computing. Continuous query can be performed on a table or STable in TDengine. The result of continuous query can be pushed to client or written back to TDengine. Each query is executed on a time window, which moves forward with time. The size of time window and the forward sliding time need to be specified with parameter `INTERVAL` and `SLIDING` respectively. -TDengine 的连续查询采用时间驱动模式,可以直接使用 TAOS SQL 进行定义,不需要额外的操作。使用连续查询,可以方便快捷地按照时间窗口生成结果,从而对原始采集数据进行降采样(down sampling)。用户通过 TAOS SQL 定义连续查询以后,TDengine 自动在最后的一个完整的时间周期末端拉起查询,并将计算获得的结果推送给用户或者写回 TDengine。 +Continuous query in TDengine is time driven, and can be defined using TAOS SQL directly without any extra operations. With continuous query, the result can be generated according to time window to achieve down sampling of original data. Once a continuous query is defined using TAOS SQL, the query is automatically executed at the end of each time window and the result is pushed back to client or written to TDengine. -TDengine 提供的连续查询与普通流计算中的时间窗口计算具有以下区别: +There are some differences between continuous query in TDengine and time window computation in stream computing: -- 不同于流计算的实时反馈计算结果,连续查询只在时间窗口关闭以后才开始计算。例如时间周期是 1 天,那么当天的结果只会在 23:59:59 以后才会生成。 -- 如果有历史记录写入到已经计算完成的时间区间,连续查询并不会重新进行计算,也不会重新将结果推送给用户。对于写回 TDengine 的模式,也不会更新已经存在的计算结果。 -- 使用连续查询推送结果的模式,服务端并不缓存客户端计算状态,也不提供 Exactly-Once 的语义保证。如果用户的应用端崩溃,再次拉起的连续查询将只会从再次拉起的时间开始重新计算最近的一个完整的时间窗口。如果使用写回模式,TDengine 可确保数据写回的有效性和连续性。 +- The computation is performed and the result is returned in real time in stream computing, but the computation in continuous query is only started when a time window closes. For example, if the time window is 1 day, then the result will only be generated at 23:59:59. +- If a historical data row is written in to a time widow for which the computation has been finished, the computation will not be performed again and the result will not be pushed to client again either. If the result has been written into TDengine, there will be no update for the result. +- In continuous query, if the result is pushed to client, the client status is not cached on the server side and Exactly-once is not guaranteed by the server either. If the client program crashes, a new time window will be generated from the time where the continuous query is restarted. If the result is written into TDengine, the data written into TDengine can be guaranteed as valid and continuous. -## 连续查询语法 +## Syntax ```sql [CREATE TABLE AS] SELECT select_expr [, select_expr ...] @@ -24,40 +24,39 @@ TDengine 提供的连续查询与普通流计算中的时间窗口计算具有 ``` -INTERVAL: 连续查询作用的时间窗口 +INTERVAL: The time window for which continuous query is performed -SLIDING: 连续查询的时间窗口向前滑动的时间间隔 +SLIDING: The time step for which the time window moves forward each time -## 使用连续查询 +## How to Use -下面以智能电表场景为例介绍连续查询的具体使用方法。假设我们通过下列 SQL 语句创建了超级表和子表: +In this section the use case of meters will be used to introduce how to use continuous query. Assume the STable and sub tables have been created using below SQL statement. ```sql create table meters (ts timestamp, current float, voltage int, phase float) tags (location binary(64), groupId int); create table D1001 using meters tags ("Beijing.Chaoyang", 2); create table D1002 using meters tags ("Beijing.Haidian", 2); -... ``` -可以通过下面这条 SQL 语句以一分钟为时间窗口、30 秒为前向增量统计这些电表的平均电压。 +The average voltage for each time window of one minute with 30 seconds as the length of moving forward can be retrieved using below SQL statement. ```sql select avg(voltage) from meters interval(1m) sliding(30s); ``` -每次执行这条语句,都会重新计算所有数据。 如果需要每隔 30 秒执行一次来增量计算最近一分钟的数据,可以把上面的语句改进成下面的样子,每次使用不同的 `startTime` 并定期执行: +Whenever the above SQL statement is executed, all the existing data will be computed again. If the computation needs to be performed every 30 seconds automatically to compute on the data in the past one minute, the above SQL statement needs to be revised as below, in which `{startTime}` stands for the beginning timestamp in the latest time window. ```sql select avg(voltage) from meters where ts > {startTime} interval(1m) sliding(30s); ``` -这样做没有问题,但 TDengine 提供了更简单的方法,只要在最初的查询语句前面加上 `create table {tableName} as` 就可以了,例如: +Another easier way for same purpose is prepend `create table {tableName} as` before the `select`. ```sql create table avg_vol as select avg(voltage) from meters interval(1m) sliding(30s); ``` -会自动创建一个名为 `avg_vol` 的新表,然后每隔 30 秒,TDengine 会增量执行 `as` 后面的 SQL 语句,并将查询结果写入这个表中,用户程序后续只要从 `avg_vol` 中查询数据即可。例如: +A table named as `avg_vol` will be created automatically, then every 30 seconds the `select` statement will be executed automatically on the data in the past 1 minutes, i.e. the latest time window, and the result is written into table `avg_vol`. The client program just needs to query from table `avg_vol`. For example: ```sql taos> select * from avg_vol; @@ -69,16 +68,16 @@ taos> select * from avg_vol; 2020-07-29 13:39:00.000 | 223.0800000 | ``` -需要注意,查询时间窗口的最小值是 10 毫秒,没有时间窗口范围的上限。 +Please be noted that the minimum allowed time window is 10 milliseconds, and no upper limit. -此外,TDengine 还支持用户指定连续查询的起止时间。如果不输入开始时间,连续查询将从第一条原始数据所在的时间窗口开始;如果没有输入结束时间,连续查询将永久运行;如果用户指定了结束时间,连续查询在系统时间达到指定的时间以后停止运行。比如使用下面的 SQL 创建的连续查询将运行一小时,之后会自动停止。 +Besides, it's allowed to specify the start and end time of continuous query. If the start time is not specified, the timestamp of the first original row will be considered as the start time; if the end time is not specified, the continuous will be performed infinitely, otherwise it will be terminated once the end time is reached. For example, the continuous query in below SQL statement will be started from now and terminated one hour later. ```sql create table avg_vol as select avg(voltage) from meters where ts > now and ts <= now + 1h interval(1m) sliding(30s); ``` -需要说明的是,上面例子中的 `now` 是指创建连续查询的时间,而不是查询执行的时间,否则,查询就无法自动停止了。另外,为了尽量避免原始数据延迟写入导致的问题,TDengine 中连续查询的计算有一定的延迟。也就是说,一个时间窗口过去后,TDengine 并不会立即计算这个窗口的数据,所以要稍等一会(一般不会超过 1 分钟)才能查到计算结果。 +`now` in above SQL statement stands for the time when the continuous query is created, not the time when the computation is actually performed. Besides, to avoid the trouble caused by the delay of original data as much as possible, the actual computation in continuous query is also started with a little delay. That means, once a time window closes, the computation is not started immediately. Normally, the result can only be available a little time later, normally within one minute, after the time window closes. -## 管理连续查询 +## How to Manage -用户可在控制台中通过 `show streams` 命令来查看系统中全部运行的连续查询,并可以通过 `kill stream` 命令杀掉对应的连续查询。后续版本会提供更细粒度和便捷的连续查询管理命令。 +`show streams` command can be used in TDengine CLI `taos` to show all the continuous queries in the system, and `kill stream` can be used to terminate a continuous query. diff --git a/docs-en/04-develop/06-subscribe.mdx b/docs-en/04-develop/06-subscribe.mdx index d471c114e827d7c4b40195c2c1b3c8f6a9d26ed4..45b13d94c45e62ea8efb6e45e798a71e8cb16cba 100644 --- a/docs-en/04-develop/06-subscribe.mdx +++ b/docs-en/04-develop/06-subscribe.mdx @@ -1,7 +1,7 @@ --- -sidebar_label: 数据订阅 -description: "轻量级的数据订阅与推送服务。连续写入到 TDengine 中的时序数据能够被自动推送到订阅客户端。" -title: 数据订阅 +sidebar_label: Subscription +description: "Lightweight service for data subscription and pushing, the time series data inserted into TDengine continuously can be pushed automatically to the subscribing clients." +title: Data Subscription --- import Tabs from "@theme/Tabs"; @@ -14,13 +14,13 @@ import Node from "./_sub_node.mdx"; import CSharp from "./_sub_cs.mdx"; import CDemo from "./_sub_c.mdx"; -基于数据天然的时间序列特性,TDengine 的数据写入(insert)与消息系统的数据发布(pub)逻辑上一致,均可视为系统中插入一条带时间戳的新记录。同时,TDengine 在内部严格按照数据时间序列单调递增的方式保存数据。本质上来说,TDengine 中每一张表均可视为一个标准的消息队列。 +## Introduction -TDengine 内嵌支持轻量级的消息订阅与推送服务。使用系统提供的 API,用户可使用普通查询语句订阅数据库中的一张或多张表。订阅的逻辑和操作状态的维护均是由客户端完成,客户端定时轮询服务器是否有新的记录到达,有新的记录到达就会将结果反馈到客户。 +According to the time series nature of the data, data inserting in TDengine is similar to data publishing in message queues, they both can be considered as a new data record with timestamp is inserted into the system. Data is stored in ascending order of timestamp inside TDengine, so essentially each table in TDengine can be considered as a message queue. -TDengine 的订阅与推送服务的状态是由客户端维持,TDengine 服务端并不维持。因此如果应用重启,从哪个时间点开始获取最新数据,由应用决定。 +Lightweight service for data subscription and pushing is built in TDengine. With the API provided by TDengine, client programs can used `select` statement to subscribe the data from one or more tables. The subscription and and state maintenance is performed on the client side, the client programs polls the server to check whether there is new data, and if so the new data will be pushed back to the client side. If the client program is restarted, where to start for retrieving new data is up to the client side. -TDengine 的 API 中,与订阅相关的主要有以下三个: +There are 3 major APIs related to subscription provided in the TDengine client driver. ```c taos_subscribe @@ -28,9 +28,11 @@ taos_consume taos_unsubscribe ``` -这些 API 的文档请见 [C/C++ Connector](/reference/connector/cpp),下面仍以智能电表场景为例介绍一下它们的具体用法(超级表和子表结构请参考上一节“连续查询”),完整的示例代码可以在 [这里](https://github.com/taosdata/TDengine/blob/master/examples/c/subscribe.c) 找到。 +For more details about these API please refer to [C/C++ Connector](/reference/connector/cpp). Their usage will be introduced below using the use case of meters, in which the schema of STable and sub tables please refer to the previous section "continuous query". Full sample code can be found [here](https://github.com/taosdata/TDengine/blob/master/examples/c/subscribe.c). -如果我们希望当某个电表的电流超过一定限制(比如 10A)后能得到通知并进行一些处理, 有两种方法:一是分别对每张子表进行查询,每次查询后记录最后一条数据的时间戳,后续只查询这个时间戳之后的数据: +If we want to get notification and take some actions if the current exceeds a threshold, like 10A, from some meters, there are two ways: + +The first way is to query on each sub table and record the last timestamp matching the criteria, then after some time query on the data later than recorded timestamp and repeat this process. The SQL statements for this way are as below. ```sql select * from D1001 where ts > {last_timestamp1} and current > 10; @@ -38,19 +40,19 @@ select * from D1002 where ts > {last_timestamp2} and current > 10; ... ``` -这确实可行,但随着电表数量的增加,查询数量也会增加,客户端和服务端的性能都会受到影响,当电表数增长到一定的程度,系统就无法承受了。 +The above way works, but the problem is that the number of `select` statements increases with the number of meters grows. Finally the performance of both client side and server side will be unacceptable once the number of meters grows to a big enough number. -另一种方法是对超级表进行查询。这样,无论有多少电表,都只需一次查询: +A better way is to query on the STable, only one `select` is enough regardless of the number of meters, like below: ```sql select * from meters where ts > {last_timestamp} and current > 10; ``` -但是,如何选择 `last_timestamp` 就成了一个新的问题。因为,一方面数据的产生时间(也就是数据时间戳)和数据入库的时间一般并不相同,有时偏差还很大;另一方面,不同电表的数据到达 TDengine 的时间也会有差异。所以,如果我们在查询中使用最慢的那台电表的数据的时间戳作为 `last_timestamp`,就可能重复读入其它电表的数据;如果使用最快的电表的时间戳,其它电表的数据就可能被漏掉。 +However, how to choose `last_timestamp` becomes a new problem if using this way. Firstly, the timestamp when the data is generated is different from the timestamp when the data is inserted into the database, sometimes the difference between them may be very big. Secondly, the time when the data from different meters may arrives at the database may be different too. If the timestamp of the "slowest" meter is used as `last_timestamp` in the query, the data from other meters may be selected repeatedly; but if the timestamp of the "fasted" meters is used as `last_timestamp`, some data from other meters may be missed. -TDengine 的订阅功能为上面这个问题提供了一个彻底的解决方案。 +All the problems mentioned above can be resolved thoroughly using subscription provided by TDengine. -首先是使用 `taos_subscribe` 创建订阅: +The first step is to create subscription using `taos_subscribe`. ```c TAOS_SUB* tsub = NULL; @@ -63,31 +65,31 @@ if (async) { } ``` -TDengine 中的订阅既可以是同步的,也可以是异步的,上面的代码会根据从命令行获取的参数 `async` 的值来决定使用哪种方式。这里,同步的意思是用户程序要直接调用 `taos_consume` 来拉取数据,而异步则由 API 在内部的另一个线程中调用 `taos_consume`,然后把拉取到的数据交给回调函数 `subscribe_callback`去处理。(注意,`subscribe_callback` 中不宜做较为耗时的操作,否则有可能导致客户端阻塞等不可控的问题。) +The subscription in TDengine can be either synchronous or asynchronous. In the above sample code, the value of variable `async` is determined from the CLI input, then it's used to create either an async or sync subscription. Sync subscription means the client program needs to invoke `taos_consume` to retrieve data, and async subscription means another thread created by `taos_subscribe` internally invokes `taos_consume` to retrieve data and pass the data to `subscribe_callback` for processing, `subscribe_callback` is a call back function provided by the client program and it's suggested not to do time consuming operation in the call back function. -参数 `taos` 是一个已经建立好的数据库连接,在同步模式下无特殊要求。但在异步模式下,需要注意它不会被其它线程使用,否则可能导致不可预计的错误,因为回调函数在 API 的内部线程中被调用,而 TDengine 的部分 API 不是线程安全的。 +The parameter `taos` is an established connection. There is nothing special in sync subscription mode. In async subscription, it should be exclusively by current thread, otherwise unpredictable error may occur. -参数 `sql` 是查询语句,可以在其中使用 where 子句指定过滤条件。在我们的例子中,如果只想订阅电流超过 10A 时的数据,可以这样写: +The parameter `sql` is a `select` statement in which `where` clause can be used to specify filter conditions. In our example, the data whose current exceeds 10A needs to be subscribed like below SQL statement: ```sql select * from meters where current > 10; ``` -注意,这里没有指定起始时间,所以会读到所有时间的数据。如果只想从一天前的数据开始订阅,而不需要更早的历史数据,可以再加上一个时间条件: +Please be noted that, all the data will be processed because no start time is specified. If only the data from one day ago needs to be processed, a time related condition can be added: ```sql select * from meters where ts > now - 1d and current > 10; ``` -订阅的 `topic` 实际上是它的名字,因为订阅功能是在客户端 API 中实现的,所以没必要保证它全局唯一,但需要它在一台客户端机器上唯一。 +The parameter `topic` is the name of the subscription, it needs to be guaranteed unique in the client program, but it's not necessary to be globally unique because subscription is implemented in the APIs on client side. -如果名为 `topic` 的订阅不存在,参数 `restart` 没有意义;但如果用户程序创建这个订阅后退出,当它再次启动并重新使用这个 `topic` 时,`restart` 就会被用于决定是从头开始读取数据,还是接续上次的位置进行读取。本例中,如果 `restart` 是 **true**(非零值),用户程序肯定会读到所有数据。但如果这个订阅之前就存在了,并且已经读取了一部分数据,且 `restart` 是 **false**(**0**),用户程序就不会读到之前已经读取的数据了。 +If the subscription named as `topic` doesn't exist, parameter `restart` would be ignored. If the subscription named as `topic` has been created before by the client program which then exited, when the client program is restarted to use this `topic`, parameter `restart` is used to determine retrieving data from beginning or from the last point where the subscription was broken. If the value of `restart` is **true** (i.e. a non-zero value), the data will be retrieved from beginning, or if it is **false** (i.e. zero), the data already consumed before will not be processed again. -`taos_subscribe`的最后一个参数是以毫秒为单位的轮询周期。在同步模式下,如果前后两次调用 `taos_consume` 的时间间隔小于此时间,`taos_consume` 会阻塞,直到间隔超过此时间。异步模式下,这个时间是两次调用回调函数的最小时间间隔。 +The last parameter of `taos_subscribe` is the polling interval in unit of millisecond. In sync mode, if the time difference between two continuous invocations to `taos_consume` is smaller than the interval specified by `taos_subscribe`, `taos_consume` would be blocked until the interval is reached. In async mode, this interval is the minimum interval between two invocations to the call back function. -`taos_subscribe` 的倒数第二个参数用于用户程序向回调函数传递附加参数,订阅 API 不对其做任何处理,只原样传递给回调函数。此参数在同步模式下无意义。 +The last second parameter of `taos_subscribe` is used to pass arguments to the call back function. `taos_subscribe` doesn't process this parameter and simply passes it to the call back function. This parameter is simply ignored in sync mode. -订阅创建以后,就可以消费其数据了,同步模式下,示例代码是下面的 else 部分: +After a subscription is created, its data can be consumed and processed, below is the sample code of how to consume data in sync mode, in the else part if `if (async)`. ```c if (async) { @@ -104,7 +106,7 @@ if (async) { } ``` -这里是一个 **while** 循环,用户每按一次回车键就调用一次 `taos_consume`,而 `taos_consume` 的返回值是查询到的结果集,与 `taos_use_result` 完全相同,例子中使用这个结果集的代码是函数 `print_result`: +In the above sample code, there is an infinite loop, each time carriage return is entered `taos_consume` is invoked, the return value of `taos_consume` is the selected result set, exactly as the input of `taos_use_result`, in the above sample `print_result` is used instead to simplify the sample. Below is the implementation of `print_result`. ```c void print_result(TAOS_RES* res, int blockFetch) { @@ -131,7 +133,9 @@ void print_result(TAOS_RES* res, int blockFetch) { } ``` -其中的 `taos_print_row` 用于处理订阅到数据,在我们的例子中,它会打印出所有符合条件的记录。而异步模式下,消费订阅到的数据则显得更为简单: +In the above code `taos_print_row` is used to process the data consumed. All the matching rows will be printed. + +In async mode, the data consuming is simpler as below. ```c void subscribe_callback(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code) { @@ -139,44 +143,43 @@ void subscribe_callback(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code) { } ``` -当要结束一次数据订阅时,需要调用 `taos_unsubscribe`: +`taos_unsubscribe` can be invoked to terminate a subscription. ```c taos_unsubscribe(tsub, keep); ``` -其第二个参数,用于决定是否在客户端保留订阅的进度信息。如果这个参数是**false**(**0**),那无论下次调用 `taos_subscribe` 时的 `restart` 参数是什么,订阅都只能重新开始。另外,进度信息的保存位置是 _{DataDir}/subscribe/_ 这个目录下,每个订阅有一个与其 `topic` 同名的文件,删掉某个文件,同样会导致下次创建其对应的订阅时只能重新开始。 +The second parameter `keep` is used to specify whether to keep the subscription progress on the client sde. If it is **false**, i.e. **0**, then subscription will be restarted from beginning regardless of the `restart` parameter's value in when `taos_subscribe` is invoked again. The subscription progress information is stored in _{DataDir}/subscribe/_ , under which there is a file with same name as `topic` for each subscription, the subscription will be restarted from beginning if the corresponding progress file is removed. -代码介绍完毕,我们来看一下实际的运行效果。假设: +Now let's see the effect of the above sample code, assuming below prerequisites have been done. -- 示例代码已经下载到本地 -- TDengine 也已经在同一台机器上安装好 -- 示例所需的数据库、超级表、子表已经全部创建好 +- The sample code has been downloaded to local system 示 +- TDengine has been installed and launched properly on same system +- The database, STable, sub tables required in the sample code have been ready -则可以在示例代码所在目录执行以下命令来编译并启动示例程序: +It's ready to launch below command in the directory where the sample code resides to compile and start the program. ```bash make ./subscribe -sql='select * from meters where current > 10;' ``` -示例程序启动后,打开另一个终端窗口,启动 TDengine CLI 向 **D1001** 插入一条电流为 12A 的数据: +After the program is started, open another terminal and launch TDengine CLI `taos`, then use below SQL commands to insert a row whose current is 12A into table **D1001**. ```sql -$ taos -> use test; -> insert into D1001 values(now, 12, 220, 1); +use test; +insert into D1001 values(now, 12, 220, 1); ``` -这时,因为电流超过了 10A,您应该可以看到示例程序将它输出到了屏幕上。您可以继续插入一些数据观察示例程序的输出。 +Then, this row of data will be shown by the example program on the first terminal because its current exceeds 10A. More data can be inserted for you to observe the output of the example program. -## 示例程序 +## Examples -下面的示例程序展示是如何使用连接器订阅所有电流超过 10A 的记录。 +Below example program demonstrates how to subscribe the data rows whose current exceeds 10A using connectors. -### 准备数据 +### Prepare Data -``` +```bash # create database "power" taos> create database power; # use "power" as the database in following operations @@ -200,20 +203,21 @@ taos> select * from meters where current > 10; 2020-08-15 12:20:00.000 | 12.20000 | 220 | 1 | Beijing.Chaoyang | 2 | Query OK, 5 row(s) in set (0.004896s) ``` -### 示例代码 + +### Example Programs - + - + {/* */} - + {/* @@ -222,13 +226,13 @@ Query OK, 5 row(s) in set (0.004896s) */} - - + + -### 运行示例程序 - -示例程序会先消费符合查询条件的所有历史数据: +### Run the Examples + +The example programs firstly consume all historical data matching the criteria. ```bash ts: 1597464000000 current: 12.0 voltage: 220 phase: 1 location: Beijing.Chaoyang groupid : 2 @@ -238,7 +242,7 @@ ts: 1597464600000 current: 10.3 voltage: 220 phase: 1 location: Beijing.Haidian ts: 1597465200000 current: 11.2 voltage: 220 phase: 1 location: Beijing.Haidian groupid : 2 ``` -接着,使用 TDengine CLI 向表中新增一条数据: +Next, use TDengine CLI to insert a new row. ``` # taos @@ -246,7 +250,7 @@ taos> use power; taos> insert into d1001 values(now, 12.4, 220, 1); ``` -因为这条数据的电流大于 10A,示例程序会将其消费: +Because the current in inserted row exceeds 10A, it will be consumed by the example program. ``` ts: 1651146662805 current: 12.4 voltage: 220 phase: 1 location: Beijing.Chaoyang groupid: 2 diff --git a/docs-en/04-develop/07-cache.md b/docs-en/04-develop/07-cache.md index fd31335310d62d792e5173e38a9aa778ee6c6c60..13db6c363802abed290cfc4d4466d40e48852f3d 100644 --- a/docs-en/04-develop/07-cache.md +++ b/docs-en/04-develop/07-cache.md @@ -1,21 +1,19 @@ --- -sidebar_label: 缓存 -title: 缓存 -description: "提供写驱动的缓存管理机制,将每个表最近写入的一条记录持续保存在缓存中,可以提供高性能的最近状态查询。" +sidebar_label: Cache +title: Cache +description: "The latest row of each table is kept in cache to provide high performance query of latest state." --- -TDengine 采用时间驱动缓存管理策略(First-In-First-Out,FIFO),又称为写驱动的缓存管理机制。这种策略有别于读驱动的数据缓存模式(Least-Recent-Used,LRU),直接将最近写入的数据保存在系统的缓存中。当缓存达到临界值的时候,将最早的数据批量写入磁盘。一般意义上来说,对于物联网数据的使用,用户最为关心最近产生的数据,即当前状态。TDengine 充分利用了这一特性,将最近到达的(当前状态)数据保存在缓存中。 +The cache management policy in TDengine is First-In-First-Out (FIFO), which is also known as insert driven cache management policy and different from read driven cache management, i.e. Least-Recent-Used (LRU). It simply stores the latest data in cache and flushes the oldest data in cache to disk when the cache usage reaches a threshold. In IoT use cases, the most cared about data is the latest data, i.e. current state. The cache policy in TDengine is based the nature of IoT data. -TDengine 通过查询函数向用户提供毫秒级的数据获取能力。直接将最近到达的数据保存在缓存中,可以更加快速地响应用户针对最近一条或一批数据的查询分析,整体上提供更快的数据库查询响应能力。从这个意义上来说,可通过设置合适的配置参数将 TDengine 作为数据缓存来使用,而不需要再部署额外的缓存系统,可有效地简化系统架构,降低运维的成本。需要注意的是,TDengine 重启以后系统的缓存将被清空,之前缓存的数据均会被批量写入磁盘,缓存的数据将不会像专门的 key-value 缓存系统再将之前缓存的数据重新加载到缓存中。 +Caching the latest data provides the capability of retrieving data in milliseconds. With this capability, TDengine can be configured properly to be used as caching system without deploying another separate caching system to simplify the system architecture and minimize the operation cost. The cache will be emptied after TDengine is restarted, TDengine doesn't reload data from disk into cache like a real key-value caching system. -TDengine 分配固定大小的内存空间作为缓存空间,缓存空间可根据应用的需求和硬件资源配置。通过适当的设置缓存空间,TDengine 可以提供极高性能的写入和查询的支持。TDengine 中每个虚拟节点(virtual node)创建时分配独立的缓存池。每个虚拟节点管理自己的缓存池,不同虚拟节点间不共享缓存池。每个虚拟节点内部所属的全部表共享该虚拟节点的缓存池。 +The memory space used by TDengine cache is fixed in size, according to the configuration based on application requirement and system resources. Independent memory pool is allocated for and managed by each vnode (virtual node) in TDengine, there is no sharing of memory pools between vnodes. All the tables belonging to a vnode share all the cache memory of the vnode. -TDengine 将内存池按块划分进行管理,数据在内存块里是以行(row)的形式存储。一个 vnode 的内存池是在 vnode 创建时按块分配好,而且每个内存块按照先进先出的原则进行管理。在创建内存池时,块的大小由系统配置参数 cache 决定;每个 vnode 中内存块的数目则由配置参数 blocks 决定。因此对于一个 vnode,总的内存大小为:`cache * blocks`。一个 cache block 需要保证每张表能存储至少几十条以上记录,才会有效率。 +Memory pool is divided into blocks and data is stored in row format in memory and each block follows FIFO policy. The size of each block is determined by configuration parameter `cache`, the number of blocks for each vnode is determined by `blocks`. For each vnode, the total cache size is `cache * blocks`. It's better to set the size of each block to hold at least tends of rows. -你可以通过函数 last_row() 快速获取一张表或一张超级表的最后一条记录,这样很便于在大屏显示各设备的实时状态或采集值。例如: +`last_row` function can be used to retrieve the last row of a table or a STable to quickly show the current state of devices on monitoring screen. For example below SQL statement retrieves the latest voltage of all meters in Chaoyang district of Beijing. ```sql select last_row(voltage) from meters where location='Beijing.Chaoyang'; ``` - -该 SQL 语句将获取所有位于北京朝阳区的电表最后记录的电压值。 diff --git a/docs-en/04-develop/08-udf.md b/docs-en/04-develop/08-udf.md index 09681650db32200e60c0fdb787d3e455dd339d85..e344e4024ca629607ff6c1a7be13186d548838c5 100644 --- a/docs-en/04-develop/08-udf.md +++ b/docs-en/04-develop/08-udf.md @@ -1,180 +1,190 @@ --- -sidebar_label: 用户定义函数 -title: UDF(用户定义函数) -description: "支持用户编码的聚合函数和标量函数,在查询中嵌入并使用用户定义函数,拓展查询的能力和功能。" +sidebar_label: UDF +title: User Defined Functions +description: "Scalar functions and aggregate functions developed by users can be utilized by the query framework to expand the query capability" --- -在有些应用场景中,应用逻辑需要的查询无法直接使用系统内置的函数来表示。利用 UDF 功能,TDengine 可以插入用户编写的处理代码并在查询中使用它们,就能够很方便地解决特殊应用场景中的使用需求。 UDF 通常以数据表中的一列数据做为输入,同时支持以嵌套子查询的结果作为输入。 +In some use cases, the query capability required by application programs can't be achieved directly by builtin functions. With UDF, the functions developed by users can be utilized by query framework to meet some special requirements. UDF normally takes one column of data as input, but can also support the result of sub query as input. -从 2.2.0.0 版本开始,TDengine 支持通过 C/C++ 语言进行 UDF 定义。接下来结合示例讲解 UDF 的使用方法。 +From version 2.2.0.0, UDF programmed in C/C++ language can be supported by TDengine. -用户可以通过 UDF 实现两类函数: 标量函数 和 聚合函数。 +Two kinds of functions can be implemented by UDF: scalar function and aggregate function. -## 用 C/C++ 语言来定义 UDF +## Define UDF -### 标量函数 +### Scalar Function -用户可以按照下列函数模板定义自己的标量计算函数 +Below function template can be used to define your own scalar function. - `void udfNormalFunc(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, int* numOfOutput, short otype, short obytes, SUdfInit* buf)` - - 其中 udfNormalFunc 是函数名的占位符,以上述模板实现的函数对行数据块进行标量计算,其参数项是固定的,用于按照约束完成与引擎之间的数据交换。 +`void udfNormalFunc(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, int* numOfOutput, short otype, short obytes, SUdfInit* buf)` -- udfNormalFunc 中各参数的具体含义是: - - data:输入数据。 - - itype:输入数据的类型。这里采用的是短整型表示法,与各种数据类型对应的值可以参见 [column_meta 中的列类型说明](/reference/rest-api/)。例如 4 用于表示 INT 型。 - - iBytes:输入数据中每个值会占用的字节数。 - - numOfRows:输入数据的总行数。 - - ts:主键时间戳在输入中的列数据(只读)。 - - dataOutput:输出数据的缓冲区,缓冲区大小为用户指定的输出类型大小 \* numOfRows。 - - interBuf:中间计算结果的缓冲区,大小为用户在创建 UDF 时指定的 BUFSIZE 大小。通常用于计算中间结果与最终结果不一致时使用,由引擎负责分配与释放。 - - tsOutput:主键时间戳在输出时的列数据,如果非空可用于输出结果对应的时间戳。 - - numOfOutput:输出结果的个数(行数)。 - - oType:输出数据的类型。取值含义与 itype 参数一致。 - - oBytes:输出数据中每个值占用的字节数。 - - buf:用于在 UDF 与引擎间的状态控制信息传递块。 +`udfNormalFunc` is the place holder of function name, a function implemented based on the above template can be used to perform scalar computation on data rows. The parameters are fixed to control the data exchange between UDF and TDengine. - [add_one.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c) 是结构最简单的 UDF 实现,也即上面定义的 udfNormalFunc 函数的一个具体实现。其功能为:对传入的一个数据列(可能因 WHERE 子句进行了筛选)中的每一项,都输出 +1 之后的值,并且要求输入的列数据类型为 INT。 +- Defintions of the parameters: -### 聚合函数 + - data:input data + - itype:the type of input data, for details please refer to [type definition in column_meta](/reference/rest-api/), for example 4 represents INT + - iBytes:the number of bytes consumed by each value in the input data + - oType:the type of output data, similar to iType + - oBytes:the number of bytes consumed by each value in the output data + - numOfRows:the number of rows in the input data + - ts: the column of timestamp corresponding to the input data + - dataOutput:the buffer for output data, total size is `oBytes * numberOfRows` + - interBuf:the buffer for intermediate result, its size is specified by `BUFSIZE` parameter when creating a UDF. It's normally used when the intermediate result is not same as the final result, it's allocated and freed by TDengine. + - tsOutput:the column of timestamps corresponding to the output data; it can be used to output timestamp together with the output data if it's not NULL + - numOfOutput:the number of rows in output data + - buf:for the state exchange between UDF and TDengine -用户可以按照如下函数模板定义自己的聚合函数。 + [add_one.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c) is one example of the simplest UDF implementations, i.e. one instance of the above `udfNormalFunc` template. It adds one to each value of a column passed in which can be filtered using `where` clause and outputs the result. + +### Aggregate Function + +Below function template can be used to define your own aggregate function. `void abs_max_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf)` -其中 udfMergeFunc 是函数名的占位符,以上述模板实现的函数用于对计算中间结果进行聚合,只有针对超级表的聚合查询才需要调用该函数。其中各参数的具体含义是: +`udfMergeFunc` is the place holder of function name, the function implemented with the above template is used to aggregate the intermediate result, only can be used in the aggregate query for STable. - - data:udfNormalFunc 的输出数据数组,如果使用了 interBuf 那么 data 就是 interBuf 的数组。 - - numOfRows:data 中数据的行数。 - - dataOutput:输出数据的缓冲区,大小等于一条最终结果的大小。如果此时输出还不是最终结果,可以选择输出到 interBuf 中即 data 中。 - - numOfOutput:输出结果的个数(行数)。 - - buf:用于在 UDF 与引擎间的状态控制信息传递块。 +Definitions of the parameters: -[abs_max.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c) 实现的是一个聚合函数,功能是对一组数据按绝对值取最大值。 +- data:array of output data, if interBuf is used it's an array of interBuf +- numOfRows:number of rows in `data` +- dataOutput:the buffer for output data, the size is same as that of the final result; If the result is not final, it can be put in the interBuf, i.e. `data`. +- numOfOutput:number of rows in the output data +- buf:for the state exchange between UDF and TDengine -其计算过程为:与所在查询语句相关的数据会被分为多个行数据块,对每个行数据块调用 udfNormalFunc(在本例的实现代码中,实际函数名是 `abs_max`)来生成每个子表的中间结果,再将子表的中间结果调用 udfMergeFunc(本例中,其实际的函数名是 `abs_max_merge`)进行聚合,生成超级表的最终聚合结果或中间结果。聚合查询最后还会通过 udfFinalizeFunc(本例中,其实际的函数名是 `abs_max_finalize`)再把超级表的中间结果处理为最终结果,最终结果只能含 0 或 1 条结果数据。 +[abs_max.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c) is an user defined aggregate function to get the maximum from the absolute value of a column. -其他典型场景,如协方差的计算,也可通过定义聚合 UDF 的方式实现。 +The internal processing is that the data affected by the select statement will be divided into multiple row blocks and `udfNormalFunc`, i.e. `abs_max` in this case, is performed on each row block to generate the intermediate of each sub table, then `udfMergeFunc`, i.e. `abs_max_merge` in this case, is performed on the intermediate result of sub tables to aggregate to generate the final or intermediate result of STable. The intermediate result of STable is finally processed by `udfFinalizeFunc` to generate the final result, which contain either 0 or 1 row. -### 最终计算 +Other typical scenarios, like covariance, can also be achieved by aggregate UDF. -用户可以按下面的函数模板实现自己的函数对计算结果进行最终计算,通常用于有 interBuf 使用的场景。 +### Finalize + +Below function template can be used to finalize the result of your own UDF, normally used when interBuf is used. `void abs_max_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf)` -其中 udfFinalizeFunc 是函数名的占位符 ,其中各参数的具体含义是: - - dataOutput:输出数据的缓冲区。 - - interBuf:中间结算结果缓冲区,可作为输入。 - - numOfOutput:输出数据的个数,对聚合函数来说只能是 0 或者 1。 - - buf:用于在 UDF 与引擎间的状态控制信息传递块。 +`udfFinalizeFunc` is the place holder of function name, definitions of the parameter are as below: -## UDF 实现方式的规则总结 +- dataOutput:buffer for output data +- interBuf:buffer for intermediate result, can be used as input for next processing step +- numOfOutput:number of output data, can only be 0 or 1 for aggregate function +- buf:for state exchange between UDF and TDengine -三类 UDF 函数: udfNormalFunc、udfMergeFunc、udfFinalizeFunc ,其函数名约定使用相同的前缀,此前缀即 udfNormalFunc 的实际函数名,也即 udfNormalFunc 函数不需要在实际函数名后添加后缀;而udfMergeFunc 的函数名要加上后缀 `_merge`、udfFinalizeFunc 的函数名要加上后缀 `_finalize`,这是 UDF 实现规则的一部分,系统会按照这些函数名后缀来调用相应功能。 +## UDF Conventions -根据 UDF 函数类型的不同,用户所要实现的功能函数也不同: +The naming of 3 kinds of UDF, i.e. udfNormalFunc, udfMergeFunc, and udfFinalizeFunc is required to have same prefix, i.e. the actual name of udfNormalFunc, which means udfNormalFunc doesn't need a suffix following the function name. While udfMergeFunc should be udfNormalFunc followed by `_merge`, udfFinalizeFunc should be udfNormalFunc followed by `_finalize`. The naming convention is part of UDF framework, TDengine follows this convention to invoke corresponding actual functions.\ -- 标量函数:UDF 中需实现 udfNormalFunc。 -- 聚合函数:UDF 中需实现 udfNormalFunc、udfMergeFunc(对超级表查询)、udfFinalizeFunc。 +According to the kind of UDF to implement, the functions that need to be implemented are different. -:::note -如果对应的函数不需要具体的功能,也需要实现一个空函数。 +- Scalar function:udfNormalFunc is required +- Aggregate function:udfNormalFunc, udfMergeFunc (if query on STable) and udfFinalizeFunc are required -::: +To be more accurate, assuming we want to implement a UDF named "foo". If the function is a scalar function, what we really need to implement is `foo`; if the function is aggregate function, we need to implement `foo`, `foo_merge`, and `foo_finalize`. For aggregate UDF, even though one of the three functions is not necessary, there must be an empty implementation. -## 编译 UDF +## Compile UDF -用户定义函数的 C 语言源代码无法直接被 TDengine 系统使用,而是需要先编译为 动态链接库,之后才能载入 TDengine 系统。 +The source code of UDF in C can't be utilized by TDengine directly. UDF can only be loaded into TDengine after compiling to dynamically linked library. -例如,按照上一章节描述的规则准备好了用户定义函数的源代码 add_one.c,以 Linux 为例可以执行如下指令编译得到动态链接库文件: +For example, the example UDF `add_one.c` mentioned in previous sections need to be compiled into DLL using below command on Linux Shell. ```bash gcc -g -O0 -fPIC -shared add_one.c -o add_one.so ``` -这样就准备好了动态链接库 add_one.so 文件,可以供后文创建 UDF 时使用了。为了保证可靠的系统运行,编译器 GCC 推荐使用 7.5 及以上版本。 +The generated DLL file `dd_one.so` can be used later when creating UDF. It's recommended to use GCC not older than 7.5. + +## Create and Use UDF -## 在系统中管理和使用 UDF +### Create UDF -### 创建 UDF +SQL command can be executed on the same hos where the generated UDF DLL resides to load the UDF DLL into TDengine, this operation can't be done through REST interface or web console. Once created, all the clients of the current TDengine can use these UDF functions in their SQL commands. UDF are stored in the management node of TDengine. The UDFs loaded in TDengine would be still available after TDengine is restarted. -用户可以通过 SQL 指令在系统中加载客户端所在主机上的 UDF 函数库(不能通过 RESTful 接口或 HTTP 管理界面来进行这一过程)。一旦创建成功,则当前 TDengine 集群的所有用户都可以在 SQL 指令中使用这些函数。UDF 存储在系统的 MNode 节点上,因此即使重启 TDengine 系统,已经创建的 UDF 也仍然可用。 +When creating UDF, it needs to be clarified as either scalar function or aggregate function. If the specified type is wrong, the SQL statements using the function would fail with error. Besides, the input type and output type don't need to be same in UDF, but the input data type and output data type need to be consistent with the UDF definition. -在创建 UDF 时,需要区分标量函数和聚合函数。如果创建时声明了错误的函数类别,则可能导致通过 SQL 指令调用函数时出错。此外, UDF 支持输入与输出类型不一致,用户需要保证输入数据类型与 UDF 程序匹配,UDF 输出数据类型与 OUTPUTTYPE 匹配。 +- Create Scalar Function -- 创建标量函数 ```sql CREATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) [ BUFSIZE B ]; ``` - - ids(X):标量函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致; - - ids(Y):包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来; - - typename(Z):此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可; - - B:中间计算结果的缓冲区大小,单位是字节,最小 0,最大 512,如果不使用可以不设置。 +- ids(X):the function name to be sued in SQL statement, must be consistent with the function name defined by `udfNormalFunc` +- ids(Y):the absolute path of the DLL file including the implementation of the UDF, the path needs to be quoted by single or double quotes +- typename(Z):the output data type, the value is the literal string of the type +- B:the size of intermediate buffer, in bytes; it's an optional parameter and the range is [0,512] - 例如,如下语句可以把 add_one.so 创建为系统中可用的 UDF: +For example, below SQL statement can be used to create a UDF from `add_one.so`. + +```sql +CREATE FUNCTION add_one AS "/home/taos/udf_example/add_one.so" OUTPUTTYPE INT; +``` - ```sql - CREATE FUNCTION add_one AS "/home/taos/udf_example/add_one.so" OUTPUTTYPE INT; - ``` +- Create Aggregate Function -- 创建聚合函数: ```sql CREATE AGGREGATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) [ BUFSIZE B ]; ``` - - ids(X):聚合函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致; - - ids(Y):包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来; - - typename(Z):此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可; - - B:中间计算结果的缓冲区大小,单位是字节,最小 0,最大 512,如果不使用可以不设置。 +- ids(X):the function name to be sued in SQL statement, must be consistent with the function name defined by `udfNormalFunc` +- ids(Y):the absolute path of the DLL file including the implementation of the UDF, the path needs to be quoted by single or double quotes +- typename(Z):the output data type, the value is the literal string of the type 此 +- B:the size of intermediate buffer, in bytes; it's an optional parameter and the range is [0,512] - 关于中间计算结果的使用,可以参考示例程序[demo.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c) +For details about how to use intermediate result, please refer to example program [demo.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c). - 例如,如下语句可以把 demo.so 创建为系统中可用的 UDF: +For example, below SQL statement can be used to create a UDF rom `demo.so`. - ```sql - CREATE AGGREGATE FUNCTION demo AS "/home/taos/udf_example/demo.so" OUTPUTTYPE DOUBLE bufsize 14; - ``` +```sql +CREATE AGGREGATE FUNCTION demo AS "/home/taos/udf_example/demo.so" OUTPUTTYPE DOUBLE bufsize 14; +``` -### 管理 UDF +### Manage UDF + +- Delete UDF -- 删除指定名称的用户定义函数: ``` DROP FUNCTION ids(X); ``` -- ids(X):此参数的含义与 CREATE 指令中的 ids(X) 参数一致,也即要删除的函数的名字,例如 +- ids(X):same as that in `CREATE FUNCTION` statement + ```sql DROP FUNCTION add_one; ``` -- 显示系统中当前可用的所有 UDF: + +- Show Available UDF + ```sql SHOW FUNCTIONS; ``` -### 调用 UDF +### Use UDF + +The function name specified when creating UDF can be used directly in SQL statements, just like builtin functions. -在 SQL 指令中,可以直接以在系统中创建 UDF 时赋予的函数名来调用用户定义函数。例如: ```sql -SELECT X(c) FROM table/stable; +SELECT X(c) FROM table/STable; ``` -表示对名为 c 的数据列调用名为 X 的用户定义函数。SQL 指令中用户定义函数可以配合 WHERE 等查询特性来使用。 +The above SQL statement invokes function X for column c. -## UDF 的一些使用限制 +## Restrictions for UDF -在当前版本下,使用 UDF 存在如下这些限制: +In current version there are some restrictions for UDF -1. 在创建和调用 UDF 时,服务端和客户端都只支持 Linux 操作系统; -2. UDF 不能与系统内建的 SQL 函数混合使用,暂不支持在一条 SQL 语句中使用多个不同名的 UDF ; -3. UDF 只支持以单个数据列作为输入; -4. UDF 只要创建成功,就会被持久化存储到 MNode 节点中; -5. 无法通过 RESTful 接口来创建 UDF; -6. UDF 在 SQL 中定义的函数名,必须与 .so 库文件实现中的接口函数名前缀保持一致,也即必须是 udfNormalFunc 的名称,而且不可与 TDengine 中已有的内建 SQL 函数重名。 +1. Only Linux is supported when creating and invoking UDF for both client side and server side +2. UDF can't be mixed with builtin functions +3. Only one UDF can be used in a SQL statement +4. Single column is supported as input for UDF +5. Once created successfully, UDF is persisted in MNode of TDengineUDF +6. UDF can't be created through REST interface +7. The function name used when creating UDF in SQL must be consistent with the function name defined in the DLL, i.e. the name defined by `udfNormalFunc` +8. The name name of UDF name should not conflict with any of builtin functions -## 示例代码 +## Examples -### 标量函数示例 [add_one](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c) +### Scalar function example [add_one](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c)
add_one.c @@ -185,7 +195,7 @@ SELECT X(c) FROM table/stable;
-### 向量函数示例 [abs_max](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c) +### Aggregate function example [abs_max](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c)
abs_max.c @@ -196,7 +206,7 @@ SELECT X(c) FROM table/stable;
-### 使用中间计算结果示例 [demo](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c) +### Example for using intermediate result [demo](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c)
demo.c diff --git a/docs-en/04-develop/_category_.yml b/docs-en/04-develop/_category_.yml index b17f078b9a42143b8eb42a04909d5c881dcaad9d..9267c5657c39f1915b89b67a5884bd66e0bd9ed4 100644 --- a/docs-en/04-develop/_category_.yml +++ b/docs-en/04-develop/_category_.yml @@ -1,5 +1 @@ -label: 开发指南 -link: - type: generated-index - slug: /develop - description: "开始指南是对开发者友好的使用教程,既包括数据建模、写入、查询等基础功能的使用,也包括数据订阅、连续查询等高级功能的使用。对于每个主题,都配有各编程语言的连接器的示例代码,方便开发者快速上手。如果想更深入地了解各连接器的使用,请阅读连接器参考指南。" +label: Develop \ No newline at end of file diff --git a/docs-en/04-develop/_sub_java.mdx b/docs-en/04-develop/_sub_java.mdx index 1ee0cb1a21e35f6760f8680e2ba6dedee92201cd..e65bc576ebed030d935ced6a4572289cd367ffac 100644 --- a/docs-en/04-develop/_sub_java.mdx +++ b/docs-en/04-develop/_sub_java.mdx @@ -2,6 +2,6 @@ {{#include docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java}} ``` :::note -目前 Java 接口没有提供异步订阅模式,但用户程序可以通过创建 `TimerTask` 等方式达到同样的效果。 +For now Java connector doesn't provide asynchronous subscription, but `TimerTask` can be used to achieve similar purpose. ::: \ No newline at end of file diff --git a/docs-en/04-develop/index.md b/docs-en/04-develop/index.md new file mode 100644 index 0000000000000000000000000000000000000000..d9ec62ad63e2f122680c3a096508c69832df7b49 --- /dev/null +++ b/docs-en/04-develop/index.md @@ -0,0 +1,12 @@ +--- +title: Develop +--- + +The guide is for developers to quickly learn about the functionalities of TDengine, including fundamentals like data model, inserting data, query and advanced features like data subscription, continuous query. For each functionality, sample code of multiple programming languages are provided for developers to get started quickly. + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-en/10-cluster/01-deploy.md b/docs-en/10-cluster/01-deploy.md index cee140c0ec13bc9c8052a599a2147acc1aa15a8d..a81ea0e316bba88b1fec7548a9d143cd44da2a14 100644 --- a/docs-en/10-cluster/01-deploy.md +++ b/docs-en/10-cluster/01-deploy.md @@ -1,89 +1,75 @@ --- -title: 集群部署 +title: Deployment --- -## 准备工作 +## Prerequisites -### 第零步 +### Step 1 -规划集群所有物理节点的 FQDN,将规划好的 FQDN 分别添加到每个物理节点的 /etc/hosts;修改每个物理节点的 /etc/hosts,将所有集群物理节点的 IP 与 FQDN 的对应添加好。【如部署了 DNS,请联系网络管理员在 DNS 上做好相关配置】 +The FQDN of all hosts need to be setup properly, all the FQDNs need to be configured in the /etc/hosts of each host. It must be guaranteed that each FQDN can be accessed (by ping, for example) from any other hosts. -### 第一步 - -如果搭建集群的物理节点中,存有之前的测试数据、装过 1.X 的版本,或者装过其他版本的 TDengine,请先将其删除,并清空所有数据(如果需要保留原有数据,请联系涛思交付团队进行旧版本升级、数据迁移),具体步骤请参考博客[《TDengine 多种安装包的安装和卸载》](https://www.taosdata.com/blog/2019/08/09/566.html)。 - -:::note -因为 FQDN 的信息会写进文件,如果之前没有配置或者更改 FQDN,且启动了 TDengine。请一定在确保数据无用或者备份的前提下,清理一下之前的数据(rm -rf /var/lib/taos/\*); -::: +On each host command `hostname -f` can be executed to get the hostname. `ping` command can be executed on each host to check whether any other host is accessible from it. If any host is not accessible, the network configuration, like /etc/hosts or DNS configuration, need to be checked and revised to make any two hosts accessible to each other. :::note -客户端所在服务器也需要配置,确保它可以正确解析每个节点的 FQDN 配置,不管是通过 DNS 服务,还是修改 hosts 文件。 -::: - -### 第二步 - -建议关闭所有物理节点的防火墙,至少保证端口:6030 - 6042 的 TCP 和 UDP 端口都是开放的。强烈建议先关闭防火墙,集群搭建完毕之后,再来配置端口; -### 第三步 +- The host where the client program runs also needs to configured properly for FQDN, to make sure all hosts for client or server can be accessed from any other. In other words, the hosts where the client is running are also considered as a part of the cluster. -在所有物理节点安装 TDengine,且版本必须是一致的,但不要启动 taosd。安装时,提示输入是否要加入一个已经存在的 TDengine 集群时,第一个物理节点直接回车创建新集群,后续物理节点则输入该集群任何一个在线的物理节点的 FQDN:端口号(默认 6030); +- It's suggested to disable the firewall for all hosts in the cluster. At least TCP/UDP for port 6030~6042 need to be open if firewall is enabled. -### 第四步 - -检查所有数据节点,以及应用程序所在物理节点的网络设置: +::: -每个物理节点上执行命令 `hostname -f`,查看和确认所有节点的 hostname 是不相同的(应用驱动所在节点无需做此项检查); +### Step 2 -每个物理节点上执行 ping host,其中 host 是其他物理节点的 hostname,看能否 ping 通其它物理节点;如果不能 ping 通,需要检查网络设置,或 /etc/hosts 文件(Windows 系统默认路径为 C:\Windows\system32\drivers\etc\hosts),或 DNS 的配置。如果无法 ping 通,是无法组成集群的; +If any previous version of TDengine has been installed and configured on any host, the installation needs to be removed and the data needs to be cleaned up. For details about uninstalling please refer to [Install and Uninstall](/operation/pkg-install). To clean up the data, please use `rm -rf /var/lib/taos/\*` assuming the `dataDir` is configured as `/var/lib/taos`. -从应用运行的物理节点,ping taosd 运行的数据节点,如果无法 ping 通,应用是无法连接 taosd 的,请检查应用所在物理节点的 DNS 设置或 hosts 文件; +### Step 3 -每个数据节点的 End Point 就是输出的 hostname 外加端口号,比如 h1.taosdata.com:6030。 +Now it's time to install TDengine on all hosts without starting `taosd`, the versions on all hosts should be same. If it's prompted to input the existing TDengine cluster, simply press carriage return to ignore it. `install.sh -e no` can also be used to disable this prompt. For details please refer to [Install and Uninstall](/operation/pkg-install). -### 第五步 +### Step 4 -修改 TDengine 的配置文件(所有节点的文件 /etc/taos/taos.cfg 都需要修改)。假设准备启动的第一个数据节点 End Point 为 h1.taosdata.com:6030,其与集群配置相关参数如下: +Now each physical node (referred to as `dnode` hereinafter, it's abbreviation for "data node") of TDengine need to be configured properly. Please be noted that one dnode doesn't stand for one host, multiple TDengine nodes can be started on single host as long as they are configured properly without conflicting. More specifically each instance of the configuration file `taos.cfg` stands for a dnode. Assuming the first dnode of TDengine cluster is "h1.taosdata.com:6030", its `taos.cfg` is configured as following. ```c -// firstEp 是每个数据节点首次启动后连接的第一个数据节点 +// firstEp is the end point to connect to when any dnode starts firstEp h1.taosdata.com:6030 -// 必须配置为本数据节点的 FQDN,如果本机只有一个 hostname,可注释掉本项 +// must be configured to the FQDN of the host where the dnode is launched fqdn h1.taosdata.com -// 配置本数据节点的端口号,缺省是 6030 +// the port used by the dnode, default is 6030 serverPort 6030 -// 副本数为偶数的时候,需要配置,请参考《Arbitrator 的使用》的部分 -arbitrator ha.taosdata.com:6042 +// only necessary when replica is configured to an even number +#arbitrator ha.taosdata.com:6042 ``` -一定要修改的参数是 firstEp 和 fqdn。在每个数据节点,firstEp 需全部配置成一样,但 fqdn 一定要配置成其所在数据节点的值。其他参数可不做任何修改,除非你很清楚为什么要修改。 +`firstEp` and `fqdn` must be configured properly. In `taos.cfg` of all dnodes in TDengine cluster, `firstEp` must be configured to point to same address, i.e. the first dnode of the cluster. `fqdn` and `serverPort` compose the address of each node itself. If you want to start multiple TDengine dnodes on a single host, please also make sure all other configurations like `dataDir`, `logDir`, and other resources related parameters are not conflicting. -加入到集群中的数据节点 dnode,涉及集群相关的下表 9 项参数必须完全相同,否则不能成功加入到集群中。 +For all the dnodes in a TDengine cluster, below parameters must be configured as exactly same, any node whose configuration is different from dnodes already in the cluster can't join the cluster. -| **#** | **配置参数名称** | **含义** | -| ----- | ------------------ | ------------------------------------------- | -| 1 | numOfMnodes | 系统中管理节点个数 | -| 2 | mnodeEqualVnodeNum | 一个 mnode 等同于 vnode 消耗的个数 | -| 3 | offlineThreshold | dnode 离线阈值,超过该时间将导致 Dnode 离线 | -| 4 | statusInterval | dnode 向 mnode 报告状态时长 | -| 5 | arbitrator | 系统中裁决器的 End Point | -| 6 | timezone | 时区 | -| 7 | balance | 是否启动负载均衡 | -| 8 | maxTablesPerVnode | 每个 vnode 中能够创建的最大表个数 | -| 9 | maxVgroupsPerDb | 每个 DB 中能够使用的最大 vgroup 个数 | +| **#** | **Parameter** | **Definition** | +| ----- | ------------------ | --------------------------------------------------------------------------------- | +| 1 | numOfMnodes | The number of management nodes in the cluster | +| 2 | mnodeEqualVnodeNum | The ratio of resource consuming of mnode to vnode | +| 3 | offlineThreshold | The threshold of dnode offline, once it's reached the dnode is considered as down | +| 4 | statusInterval | The interval by which dnode reports its status to mnode | +| 5 | arbitrator | End point of the arbitrator component in the cluster | +| 6 | timezone | Timezone | +| 7 | balance | Enable load balance automatically | +| 8 | maxTablesPerVnode | Maximum number of tables that can be created in each vnode | +| 9 | maxVgroupsPerDb | Maximum number vgroups that can be used by each DB | :::note -在 2.0.19.0 及更早的版本中,除以上 9 项参数外,dnode 加入集群时,还会要求 locale 和 charset 参数的取值也一致。 +Prior to version 2.0.19.0, besides the above parameters, `locale` and `charset` must be configured as same too for each dnode. ::: -## 启动集群 +## Start Cluster -### 启动第一个数据节点 +### Start The First DNODE -按照《立即开始》里的步骤,启动第一个数据节点,例如 h1.taosdata.com,然后执行 taos,启动 taos shell,从 shell 里执行命令“SHOW DNODES”,如下所示: +The first dnode can be started following the instructions in [Get Started](/get-started/), for example h1.taosdata.com. Then TDengine CLI `taos` can be launched to execute command `show dnodes`, the output is as following for example: ``` Welcome to the TDengine shell from Linux, Client Version:2.0.0.0 @@ -100,39 +86,29 @@ Query OK, 1 row(s) in set (0.006385s) taos> ``` -上述命令里,可以看到刚启动的数据节点的 End Point 是:h1.taos.com:6030,就是这个新集群的 firstEp。 +From the above output, it is shown that the end point of the started dnode is "h1.taos.com:6030", which is the `firstEp` of the cluster. -### 启动后续数据节点 +### Start Other DNODEs -将后续的数据节点添加到现有集群,具体有以下几步: +There are a few steps necessary to add other dnodes in the cluster. -按照《立即开始》一章的方法在每个物理节点启动 taosd;(注意:每个物理节点都需要在 taos.cfg 文件中将 firstEp 参数配置为新集群首个节点的 End Point——在本例中是 h1.taos.com:6030) +Firstly, start `taosd` as instructed in [Get Started](/get-started/), assuming it's for the second dnode. Before starting `taosd`, please making sure the configuration is correct, especially `firstEp`, `FQDN` and `serverPort`, `firstEp` must be same as the dnode shown in the section "Start First DNODE", i.e. "h1.taosdata.com" in this example. -在第一个数据节点,使用 CLI 程序 taos,登录进 TDengine 系统,执行命令: +Then, on the first dnode, use TDengine CLI `taos` to execute below command to add the end point of the dnode in the cluster. In the command "fqdn:port" should be quoted using double quotes. ```sql CREATE DNODE "h2.taos.com:6030"; ``` -将新数据节点的 End Point(准备工作中第四步获知的)添加进集群的 EP 列表。“fqdn:port”需要用双引号引起来,否则出错。请注意将示例的“h2.taos.com:6030” 替换为这个新数据节点的 End Point。 - -然后执行命令 +Then on the first dnode, execute `show dnodes` in `taos` to show whether the second dnode has been added in the cluster successfully or not. ```sql SHOW DNODES; ``` -查看新节点是否被成功加入。如果该被加入的数据节点处于离线状态,请做两个检查: +If the status of the newly added dnode is offlie, please check: -查看该数据节点的 taosd 是否正常工作,如果没有正常运行,需要先检查为什么? -查看该数据节点 taosd 日志文件 taosdlog.0 里前面几行日志(一般在 /var/log/taos 目录),看日志里输出的该数据节点 fqdn 以及端口号是否为刚添加的 End Point。如果不一致,需要将正确的 End Point 添加进去。 -按照上述步骤可以源源不断的将新的数据节点加入到集群。 +- Whether the `taosd` process is running properly or not +- In the log file `taosdlog.0` to see whether the fqdn and port are correct or not 查 -:::tip - -任何已经加入集群在线的数据节点,都可以作为后续待加入节点的 firstEp。 -firstEp 这个参数仅仅在该数据节点首次加入集群时有作用,加入集群后,该数据节点会保存最新的 mnode 的 End Point 列表,不再依赖这个参数。 -接下来,配置文件中的 firstEp 参数就主要在客户端连接的时候使用了,例如 taos shell 如果不加参数,会默认连接由 firstEp 指定的节点。 -两个没有配置 firstEp 参数的数据节点 dnode 启动后,会独立运行起来。这个时候,无法将其中一个数据节点加入到另外一个数据节点,形成集群。无法将两个独立的集群合并成为新的集群。 - -::: +The above process can be repeated to add more dnodes in the cluster. diff --git a/docs-en/10-cluster/02-cluster-mgmt.md b/docs-en/10-cluster/02-cluster-mgmt.md index 6ab8ec091b898e8f441d75ef898dc0ff06fce6be..c2c3caeebd3dcb70813caffc14bb52a5221f4650 100644 --- a/docs-en/10-cluster/02-cluster-mgmt.md +++ b/docs-en/10-cluster/02-cluster-mgmt.md @@ -1,26 +1,24 @@ --- -title: 数据节点管理 +sidebar_label: Operation +title: Manage DNODEs --- -上面已经介绍如何从零开始搭建集群。集群组建完成后,可以随时查看集群中当前的数据节点的状态,还可以添加新的数据节点进行扩容,删除数据节点,甚至手动进行数据节点之间的负载均衡操作。 +It has been introduced that how to deploy and start a cluster from scratch. Once a cluster is ready, the dnode status in the cluster can be shown at any time, new dnode can be added to scale out the cluster, an existing dnode can be removed, even load balance can be performed manually.\ :::note - -以下所有执行命令的操作需要先登陆进 TDengine 系统,必要时请使用 root 权限。 +All the commands to be introduced in this chapter need to be run through TDengine CLI, sometimes it's necessary to use root privilege. ::: -## 查看数据节点 +## Show DNODEs -启动 TDengine CLI 程序 taos,然后执行: +below command can be executed in TDengine CLI `taos` to list all dnodes in the cluster, including ID, end point (fqdn:port), status (ready, offline), number of vnodes, number of free vnodes, etc. It's suggested to execute this command to check after adding or removing a dnode. ```sql SHOW DNODES; ``` -它将列出集群中所有的 dnode,每个 dnode 的 ID,end_point(fqdn:port),状态(ready,offline 等),vnode 数目,还未使用的 vnode 数目等信息。在添加或删除一个数据节点后,可以使用该命令查看。 - -输出如下(具体内容仅供参考,取决于实际的集群配置) +Below is the example output of this command. ``` taos> show dnodes; @@ -30,18 +28,18 @@ taos> show dnodes; Query OK, 1 row(s) in set (0.008298s) ``` -## 查看虚拟节点组 +## Show VGROUPs -为充分利用多核技术,并提供 scalability,数据需要分片处理。因此 TDengine 会将一个 DB 的数据切分成多份,存放在多个 vnode 里。这些 vnode 可能分布在多个数据节点 dnode 里,这样就实现了水平扩展。一个 vnode 仅仅属于一个 DB,但一个 DB 可以有多个 vnode。vnode 所在的数据节点是 mnode 根据当前系统资源的情况,自动进行分配的,无需任何人工干预。 +To utilize system resources efficiently and provide scalability, data sharding is required. The data of each database is divided into multiple shards and stored in multiple vnodes. These vnodes may be located in different dnodes, scaling out can be achieved by adding more vnodes from more dnodes. Each vnode can only be used for a single DB, but one DB can have multiple vnodes. The allocation of vnode is scheduled automatically by mnode according to system resources of the dnodes. -启动 CLI 程序 taos,然后执行: +Launch TDengine CLI `taos` and execute below command: ```sql USE SOME_DATABASE; SHOW VGROUPS; ``` -输出如下(具体内容仅供参考,取决于实际的集群配置) +The example output is as below: ``` taos> show dnodes; @@ -67,17 +65,16 @@ taos> show vgroups; Query OK, 8 row(s) in set (0.001154s) ``` -## 添加数据节点 +## Add DNODE -启动 CLI 程序 taos,然后执行: +Launch TDengine CLI `taos` and execute the command below to add the end point of a new dnode into the EPI (end point) list of the cluster. "fqdn:port" must be quoted using double quotes. ```sql CREATE DNODE "fqdn:port"; ``` -将新数据节点的 End Point 添加进集群的 EP 列表。“fqdn:port“需要用双引号引起来,否则出错。一个数据节点对外服务的 fqdn 和 port 可以通过配置文件 taos.cfg 进行配置,缺省是自动获取。【强烈不建议用自动获取方式来配置 FQDN,可能导致生成的数据节点的 End Point 不是所期望的】 +The example output is as below: -示例如下: ``` taos> create dnode "localhost:7030"; Query OK, 0 of 0 row(s) in database (0.008203s) @@ -90,7 +87,7 @@ taos> show dnodes; Query OK, 2 row(s) in set (0.001017s) ``` -在上面的示例中可以看到新创建的 dnode 的状态为 offline,待该 dnode 被启动并连接上配置文件中指定的 firstEp后再次查看,得到如下结果(示例) +It can be seen that the status of the new dnode is "offline", once the dnode is started and connects the firstEp of the cluster, execute the command again and get below example output, from which it can be seen that two dnodes are both in "ready" status. ``` taos> show dnodes; @@ -100,24 +97,23 @@ taos> show dnodes; 2 | localhost:7030 | 6 | 8 | ready | any | 2022-04-19 08:14:59.165 | | Query OK, 2 row(s) in set (0.001316s) ``` -从中可以看到两个 dnode 状态都为 ready - -## 删除数据节点 +## Drop DNODE -启动 CLI 程序 taos,然后执行: +Launch TDengine CLI `taos` and execute the command below to drop or remove a dndoe from the cluster. In the command, `dnodeId` can be gotten from `show dnodes`. ```sql DROP DNODE "fqdn:port"; ``` -或者 + +or + ```sql DROP DNODE dnodeId; ``` -通过 “fqdn:port” 或 dnodeID 来指定一个具体的节点都是可以的。其中 fqdn 是被删除的节点的 FQDN,port 是其对外服务器的端口号;dnodeID 可以通过 SHOW DNODES 获得。 +The example output is as below: -示例如下: ``` taos> show dnodes; id | end_point | vnodes | cores | status | role | create_time | offline reason | @@ -136,30 +132,31 @@ taos> show dnodes; Query OK, 1 row(s) in set (0.001137s) ``` -上面的示例中,初次执行 `show dnodes` 列出了两个 dnode, 执行 `drop dnode 2` 删除其中 ID 为 2 的 dnode 之后再次执行 `show dnodes`,可以看到只剩下 ID 为 1 的 dnode 。 +In the above example, when `show dnodes` is executed the first time, two dnodes are shown. Then `drop dnode 2` is executed, after that from the output of executing `show dnodes` again it can be seen that only the dnode with ID 1 is still in the cluster. -:::warning +:::note -数据节点一旦被 drop 之后,不能重新加入集群。需要将此节点重新部署(清空数据文件夹)。集群在完成 `drop dnode` 操作之前,会将该 dnode 的数据迁移走。 -请注意 `drop dnode` 和 停止 taosd 进程是两个不同的概念,不要混淆:因为删除 dnode 之前要执行迁移数据的操作,因此被删除的 dnode 必须保持在线状态。待删除操作结束之后,才能停止 taosd 进程。 -一个数据节点被 drop 之后,其他节点都会感知到这个 dnodeID 的删除操作,任何集群中的节点都不会再接收此 dnodeID 的请求。 -dnodeID 是集群自动分配的,不得人工指定。它在生成时是递增的,不会重复。 +- Once a dnode is dropped, it can't rejoin the cluster. To rejoin, the dnode needs to deployed again after cleaning up the data directory. Normally, before dropping a dnode, the data belonging to the dnode needs to be migrated to other place. +- Please be noted that `drop dnode` is different from stopping `taosd` process. `drop dnode` just removes the dnode out of TDengine cluster. Only after a dnode is dropped, can the corresponding `taosd` process be stopped. +- Once a dnode is dropped, other dnodes in the cluster will be notified of the drop and will not accept the request from the dropped dnode. +- dnodeID is allocated automatically and can't be interfered manually. dnodeID is generated in ascending order without duplication. ::: -## 手动迁移数据节点 +## Move VNODE -手动将某个 vnode 迁移到指定的 dnode。 +A vnode can be manually moved from one dnode to another. -启动 CLI 程序 taos,然后执行: +Launch TDengine CLI `taos` and execute below command: ```sql ALTER DNODE BALANCE "VNODE:-DNODE:"; ``` -其中:source-dnodeId 是源 dnodeId,也就是待迁移的 vnode 所在的 dnodeID;vgId 可以通过 SHOW VGROUPS 获得,列表的第一列;dest-dnodeId 是目标 dnodeId。 +In the above command, `source-dnodeId` is the original dnodeId where the vnode resides, `dest-dnodeId` specifies the target dnode. vgId (vgroup ID) can be shown by `SHOW VGROUPS `. + +Firstly `show vgroups` is executed to show the vgrup distribution. -首先执行 `show vgroups` 查看 vgroup 的分布情况 ``` taos> show vgroups; vgId | tables | status | onlines | v1_dnode | v1_status | compacting | @@ -175,7 +172,7 @@ taos> show vgroups; Query OK, 8 row(s) in set (0.001314s) ``` -从中可以看到在 dnode 3 中有5个 vgroup,而 dnode 1 有 3 个 vgroup,假定我们想将其中 vgId 为18 的 vgroup 从 dnode 3 迁移到 dnode 1 +It can be seen that there are 5 vgroups in dnode 3 and 3 vgroups in node 1, now we want to move vgId 18 from dnode 3 to dnode 1. Execute below command in `taos` ``` taos> alter dnode 3 balance "vnode:18-dnode:1"; @@ -183,9 +180,10 @@ taos> alter dnode 3 balance "vnode:18-dnode:1"; DB error: Balance already enabled (0.00755 ``` -上面的结果表明目前所在数据库已经启动了 balance 选项,所以无法进行手动迁移。 +However, the operation fails with error message show above, which means automatic load balancing has been enabled in the current database so manual load balance can't be performed. + +Shutdown the cluster, configure `balance` parameter in all the dnodes to 0, then restart the cluster, and execute `alter dnode` and `show vgroups` as below. -停止整个集群,将两个 dnode 的配置文件中的 balance 都设置为 0 (默认为1)之后,重新启动集群,再次执行 ` alter dnode` 和 `show vgroups` 命令如下 ``` taos> alter dnode 3 balance "vnode:18-dnode:1"; Query OK, 0 row(s) in set (0.000575s) @@ -204,13 +202,12 @@ taos> show vgroups; Query OK, 8 row(s) in set (0.001242s) ``` -从上面的输出可以看到 vgId 为 18 的 vnode 被从 dnode 3 迁移到了 dnode 1。 +It can be seen from above output that vgId 18 has been moved from dndoe 3 to dnode 1. -:::warning +:::note -只有在集群的自动负载均衡选项关闭时(balance 设置为 0),才允许手动迁移。 -只有处于正常工作状态的 vnode 才能被迁移:master/slave;当处于 offline/unsynced/syncing 状态时,是不能迁移的。 -迁移前,务必核实目标 dnode 的资源足够:CPU、内存、硬盘。 +- Manual load balancing can only be performed when the automatic load balancing is disabled, i.e. `balance` is set to 0 只. +- Only vnode in normal state, i.e. master or slave, can be moved. vnode can't moved when its in status offline, unsynced or syncing. +- Before moving a vnode, it's necessary to make sure the target dnode has enough resources: CPU, memory and disk. ::: - diff --git a/docs-en/10-cluster/03-ha-and-lb.md b/docs-en/10-cluster/03-ha-and-lb.md index 3d15feb11c47fe821fa4689de2665a65ea17cbe9..53c95be9e995a728b2b4053e4f204df58271716e 100644 --- a/docs-en/10-cluster/03-ha-and-lb.md +++ b/docs-en/10-cluster/03-ha-and-lb.md @@ -1,86 +1,79 @@ --- -title: 高可用与负载均衡 +sidebar_label: HA & LB +title: High Availability and Load Balancing --- -## Vnode 的高可用性 +## High Availability of Vnode -TDengine 通过多副本的机制来提供系统的高可用性,包括 vnode 和 mnode 的高可用性。 +High availability of vnode and mnode can be achieved through replicas in TDengine. -vnode 的副本数是与 DB 关联的,一个集群里可以有多个 DB,根据运营的需求,每个 DB 可以配置不同的副本数。创建数据库时,通过参数 replica 指定副本数(缺省为 1)。如果副本数为 1,系统的可靠性无法保证,只要数据所在的节点宕机,就将无法提供服务。集群的节点数必须大于等于副本数,否则创建表时将返回错误“more dnodes are needed”。比如下面的命令将创建副本数为 3 的数据库 demo: +The number of vnodes is associated with each DB, there can be multiple DBs in a TDengine cluster. For the purpose of operation, different number of replicas can be configured properly for each DB. When creating a database, the parameter `replica` is used to specify the number of replicas, the default value is 1. With single replica, the high availability of the system can't be guaranteed. Whenever one node is down, data service would be unavailable. The number of dnodes in the cluster must NOT be lower than the number of replicas set for any DB, otherwise the `create table` operation would fail with error "more dnodes are needed". Below SQL statement is used to create a database named as "demo" with 3 replicas. ```sql CREATE DATABASE demo replica 3; ``` -一个 DB 里的数据会被切片分到多个 vnode group,vnode group 里的 vnode 数目就是 DB 的副本数,同一个 vnode group 里各 vnode 的数据是完全一致的。为保证高可用性,vnode group 里的 vnode 一定要分布在不同的数据节点 dnode 里(实际部署时,需要在不同的物理机上),只要一个 vnode group 里超过半数的 vnode 处于工作状态,这个 vnode group 就能正常的对外服务。 +The data in a DB is divided into multiple shards and stored in multiple vgroups. The number of vnodes in each group is determined by the number of replicas set for the DB. The vnodes in each vgroups store exactly same data. For the purpose of high availability, the vnodes in a vgroup must be located in different dnodes on different hosts. As long as over half of the vnodes in a vgroup are in online state, the vgroup is able to serve data access. Otherwise the vgroup can't handle any data access for reading or inserting data. -一个数据节点 dnode 里可能有多个 DB 的数据,因此一个 dnode 离线时,可能会影响到多个 DB。如果一个 vnode group 里的一半或一半以上的 vnode 不工作,那么该 vnode group 就无法对外服务,无法插入或读取数据,这样会影响到它所属的 DB 的一部分表的读写操作。 +There may be data for multiple DBs in a dnode. Once a dnode is down, multiple DBs may be affected. However, it's hard to say the cluster is guaranteed to work properly as long as over half of dnodes are online because vnodes are introduced and there may be complex mapping between vnodes and dnodes. -因为 vnode 的引入,无法简单地给出结论:“集群中过半数据节点 dnode 工作,集群就应该工作”。但是对于简单的情形,很好下结论。比如副本数为 3,只有三个 dnode,那如果仅有一个节点不工作,整个集群还是可以正常工作的,但如果有两个数据节点不工作,那整个集群就无法正常工作了。 +## High Availability of Mnode -## Mnode 的高可用性 +Each TDengine cluster is managed by `mnode`, which is a module of `taosd`. For the high availability of mnode, multiple mnodes can be configured using system parameter `numOfMNodes`, the valid time range is [1,3]. To make sure the data consistency between mnodes, the data replication between mnodes is performed in synchronous way. -TDengine 集群是由 mnode(taosd 的一个模块,管理节点)负责管理的,为保证 mnode 的高可用,可以配置多个 mnode 副本,副本数由系统配置参数 numOfMnodes 决定,有效范围为 1-3。为保证元数据的强一致性,mnode 副本之间是通过同步的方式进行数据复制的。 - -一个集群有多个数据节点 dnode,但一个 dnode 至多运行一个 mnode 实例。多个 dnode 情况下,哪个 dnode 可以作为 mnode 呢?这是完全由系统根据整个系统资源情况,自动指定的。用户可通过 CLI 程序 taos,在 TDengine 的 console 里,执行如下命令: +There may be multiple dnodes in a cluster, but only one mnode can be started in each dnode. Which one or ones of the dnodes will be designated as mnodes is automatically determined by TDengine according to the cluster configuration and system resources. Command `show mnodes` can be executed in TDengine `taos` to show the mnodes in the cluster. ```sql SHOW MNODES; ``` -来查看 mnode 列表,该列表将列出 mnode 所处的 dnode 的 End Point 和角色(master,slave,unsynced 或 offline)。当集群中第一个数据节点启动时,该数据节点一定会运行一个 mnode 实例,否则该数据节点 dnode 无法正常工作,因为一个系统是必须有至少一个 mnode 的。如果 numOfMnodes 配置为 2,启动第二个 dnode 时,该 dnode 也将运行一个 mnode 实例。 +The end point and role/status (master, slave, unsynced, or offline) of all mnodes can be shown by the above command. When the first dnode is started in a cluster, there must be one mnode in this dnode, because there must be at least one mnode otherwise the cluster doesn't work. If `numOfMNodes` is configured to 2, another mnode will be started when the second dnode is launched. -为保证 mnode 服务的高可用性,numOfMnodes 必须设置为 2 或更大。因为 mnode 保存的元数据必须是强一致的,如果 numOfMnodes 大于 2,复制参数 quorum 自动设为 2,也就是说,至少要保证有两个副本写入数据成功,才通知客户端应用写入成功。 +For the high availability of mnode, `numOfMnodes` needs to be configured to 2 or a higher value. Because the data consistency between mnodes must be guaranteed, the replica confirmation parameter `quorum` is set to 2 automatically if `numOfMNodes` is set to 2 or higher. :::note -一个 TDengine 高可用系统,无论是 vnode 还是 mnode,都必须配置多个副本。 +If high availability is important for your system, both vnode and mnode must be configured to have multiple replicas. How to configure for them are different and have been described. ::: -## 负载均衡 - -有三种情况,将触发负载均衡,而且都无需人工干预。 +## Load Balance -当一个新数据节点添加进集群时,系统将自动触发负载均衡,一些节点上的数据将被自动转移到新数据节点上,无需任何人工干预。 -当一个数据节点从集群中移除时,系统将自动把该数据节点上的数据转移到其他数据节点,无需任何人工干预。 -如果一个数据节点过热(数据量过大),系统将自动进行负载均衡,将该数据节点的一些 vnode 自动挪到其他节点。 -当上述三种情况发生时,系统将启动各个数据节点的负载计算,从而决定如何挪动。 +Load balance will be triggered in 3 cades without manual intervention. -:::tip -负载均衡由参数 balance 控制,它决定是否启动自动负载均衡,0 表示禁用,1 表示启用自动负载均衡。 +- When a new dnode is joined in the cluster, automatic load balancing may be triggered, some data from some dnodes may be transferred to the new dnode automatically. +- When a dnode is removed from the cluster, the data from this dnode will be transferred to other dnodes automatically. +- When a dnode is too hot, i.e. too much data has been stored in it, automatic load balancing may be triggered to migrate some vnodes from this dnode to other dnodes. +- :::tip + Automatic load balancing is controlled by parameter `balance`, 0 means disabled and 1 means enabled. ::: -## 数据节点离线处理 +## Dnode Offline -如果一个数据节点离线,TDengine 集群将自动检测到。有如下两种情况: +When a dnode is offline, it can be detected by the TDengine cluster. There are two cases: -该数据节点离线超过一定时间(taos.cfg 里配置参数 offlineThreshold 控制时长),系统将自动把该数据节点删除,产生系统报警信息,触发负载均衡流程。如果该被删除的数据节点重新上线时,它将无法加入集群,需要系统管理员重新将其添加进集群才会开始工作。 +- The dnode becomes online again before the threshold configured in `offlineThreshold` is reached, it is still in the cluster and data replication is started automatically. The dnode can work properly after the data syncup is finished. -离线后,在 offlineThreshold 的时长内重新上线,系统将自动启动数据恢复流程,等数据完全恢复后,该节点将开始正常工作。 +- If the dnode has been offline over the threshold configured in `offlineThreshold` in `taos.cfg`, the dnode will be removed from the cluster automatically. System alert will be generated and automatic load balancing will be triggered too if `balance` is set to 1. When the removed dnode is restarted and becomes online, it will not be joined in the cluster automatically, it can only be joined manually by the system operator. :::note -如果一个虚拟节点组(包括 mnode 组)里所归属的每个数据节点都处于离线或 unsynced 状态,必须等该虚拟节点组里的所有数据节点都上线、都能交换状态信息后,才能选出 Master,该虚拟节点组才能对外提供服务。比如整个集群有 3 个数据节点,副本数为 3,如果 3 个数据节点都宕机,然后 2 个数据节点重启,是无法工作的,只有等 3 个数据节点都重启成功,才能对外服务。 +If all the vnodes in a vgroup (or mnodes in mnode group) are in offline or unsynced status, the master node can only be voted after all the vnodes or mnodes in the group become online and can exchange status, then the vgroup (or mnode group) is able to provide service. ::: -## Arbitrator 的使用 - -如果副本数为偶数,当一个 vnode group 里一半或超过一半的 vnode 不工作时,是无法从中选出 master 的。同理,一半或超过一半的 mnode 不工作时,是无法选出 mnode 的 master 的,因为存在“split brain”问题。 +## Arbitrator -为解决这个问题,TDengine 引入了 Arbitrator 的概念。Arbitrator 模拟一个 vnode 或 mnode 在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含 Arbitrator 在内,超过半数的 vnode 或 mnode 工作,那么该 vnode group 或 mnode 组就可以正常的提供数据插入或查询服务。比如对于副本数为 2 的情形,如果一个节点 A 离线,但另外一个节点 B 正常,而且能连接到 Arbitrator,那么节点 B 就能正常工作。 +If the number of replicas is set to an even number like 2, when half of the vnodes in a vgroup don't work master node can't be voted. Similar case is also applicable to mnode if the number of mnodes is set to an even number like 2. -总之,在目前版本下,TDengine 建议在双副本环境要配置 Arbitrator,以提升系统的可用性。 +To resolve this problem, a new arbitrator component named `tarbitrator`, abbreviated for TDengine Arbitrator, was introduced. Arbitrator simulates a vnode or mnode but it's only responsible for network communication and doesn't handle any actual data access. With Arbitrator, any vgroup or mnode group can be considered as having number of member nodes and master node can be selected. -Arbitrator 的执行程序名为 tarbitrator。该程序对系统资源几乎没有要求,只需要保证有网络连接,找任何一台 Linux 服务器运行它即可。以下简要描述安装配置的步骤: +Normally, it's suggested to configure replica number of each DB or system parameter `numOfMNodes` to an odd number. However, if a user is very sensitive to storage space, replica number of 2 plus arbitrator component can be used to achieve both lower cost of storage space and high availability. -请点击 安装包下载,在 TDengine Arbitrator Linux 一节中,选择合适的版本下载并安装。 -该应用的命令行参数 -p 可以指定其对外服务的端口号,缺省是 6042。 +Arbitrator component is installed with the server package. For details about how to install, please refer to [Install](/operation/pkg-install). The `-p` parameter of `tarbitrator` can be used to specify the port on which it provides service. -修改每个 taosd 实例的配置文件,在 taos.cfg 里将参数 arbitrator 设置为 tarbitrator 程序所对应的 End Point。(如果该参数配置了,当副本数为偶数时,系统将自动连接配置的 Arbitrator。如果副本数为奇数,即使配置了 Arbitrator,系统也不会去建立连接。) +In the configuration file `taos.cfg` of each dnode, parameter `arbitrator` needs to be configured to the end point of the `tarbitrator` process. arbitrator component will be used automatically if the replica is configured to an even number and will be ignored if the replica is configured to an odd number. -在配置文件中配置了的 Arbitrator,会出现在 SHOW DNODES 指令的返回结果中,对应的 role 列的值会是“arb”。 -查看集群 Arbitrator 的状态【2.0.14.0 以后支持】 +Arbitrator can be shown by executing command in TDengine CLI `taos` with its role shown as "arb". ```sql SHOW DNODES; diff --git a/docs-en/10-cluster/_category_.yml b/docs-en/10-cluster/_category_.yml index df953cb6dd297c91f1e6d1e2d30690afab293982..141fd7832631d69efed214293c69cee336bc854d 100644 --- a/docs-en/10-cluster/_category_.yml +++ b/docs-en/10-cluster/_category_.yml @@ -1,12 +1 @@ -label: 集群管理 -link: - type: generated-index - slug: /cluster/ - description: "TDengine支持以集群方式部署,以提升系统的处理能力和高可用性。TDengine集群支持任意数据的多副本从而提升高可用性,并自动实现负载均衡。同时TDengine集群具有很好的横向扩展能力以处理更多的数据采集点和更大的数据量。" - keywords: - [ - 集群, - 高可用, - 负载均衡, - 横向扩展 - ] +label: Cluster diff --git a/docs-en/10-cluster/index.md b/docs-en/10-cluster/index.md new file mode 100644 index 0000000000000000000000000000000000000000..7f8d87965754c1f529d806ad59f54ea935fe31ce --- /dev/null +++ b/docs-en/10-cluster/index.md @@ -0,0 +1,13 @@ +--- +title: Cluster +keywords: ["cluster", "high availability", "load balance", "scale out"] +--- + +TDengine can be deployed in cluster mode to increase the processing capability and high availability. In cluster mode, any data can have multiple replications for the purpose of high availability and load balance. TDengine cluster can be scaled out easily to support more data collecting points and more data. + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-en/12-taos-sql/01-data-type.md b/docs-en/12-taos-sql/01-data-type.md index be5c9a8cb4ed7f4ed9f9c7e11faf1b0f8f6e51b8..77e95109c7dff1b01b9fd0680fab0fb123445413 100644 --- a/docs-en/12-taos-sql/01-data-type.md +++ b/docs-en/12-taos-sql/01-data-type.md @@ -1,50 +1,49 @@ --- -sidebar_label: 支持的数据类型 -title: 支持的数据类型 -description: "TDengine 支持的数据类型: 时间戳、浮点型、JSON 类型等" +title: Data Types +description: "The data types supported by TDengine include timestamp, float, JSON, etc" --- -使用 TDengine,最重要的是时间戳。创建并插入记录、查询历史记录的时候,均需要指定时间戳。时间戳有如下规则: +When using TDengine to store and query data, the most important part of the data is timestamp. Timestamp must be specified when creating and inserting data rows or querying data, timestamp must follow below rules: -- 时间格式为 `YYYY-MM-DD HH:mm:ss.MS`,默认时间分辨率为毫秒。比如:`2017-08-12 18:25:58.128` -- 内部函数 now 是客户端的当前时间 -- 插入记录时,如果时间戳为 now,插入数据时使用提交这条记录的客户端的当前时间 -- Epoch Time:时间戳也可以是一个长整数,表示从格林威治时间 1970-01-01 00:00:00.000 (UTC/GMT) 开始的毫秒数(相应地,如果所在 Database 的时间精度设置为“微秒”,则长整型格式的时间戳含义也就对应于从格林威治时间 1970-01-01 00:00:00.000 (UTC/GMT) 开始的微秒数;纳秒精度逻辑类似。) -- 时间可以加减,比如 now-2h,表明查询时刻向前推 2 个小时(最近 2 小时)。数字后面的时间单位可以是 b(纳秒)、u(微秒)、a(毫秒)、s(秒)、m(分)、h(小时)、d(天)、w(周)。 比如 `select * from t1 where ts > now-2w and ts <= now-1w`,表示查询两周前整整一周的数据。在指定降采样操作(down sampling)的时间窗口(interval)时,时间单位还可以使用 n (自然月) 和 y (自然年)。 +- the format must be `YYYY-MM-DD HH:mm:ss.MS`, the default time precision is millisecond (ms), for example `2017-08-12 18:25:58.128` +- internal function `now` can be used to get the current timestamp of the client side +- the current timestamp of the client side is applied when `now` is used to insert data +- Epoch Time:timestamp can also be a long integer number, which means the number of seconds, milliseconds or nanoseconds, depending on the time precision, from 1970-01-01 00:00:00.000 (UTC/GMT) +- timestamp can be applied with add/substract operation, for example `now-2h` means 2 hours back from the time at which query is executed,the unit can be b(nanosecond), u(microsecond), a(millisecond), s(second), m(minute), h(hour), d(day), w(week.。 So `select * from t1 where ts > now-2w and ts <= now-1w` means the data between two weeks ago and one week ago. The time unit can also be n (calendar month) or y (calendar year) when specifying the time window for down sampling operation. -TDengine 缺省的时间戳精度是毫秒,但通过在 `CREATE DATABASE` 时传递的 PRECISION 参数也可以支持微秒和纳秒。(从 2.1.5.0 版本开始支持纳秒精度) +Time precision in TDengine can be set by the `PRECISION` parameter when executing `CREATE DATABASE`, like below, the default time precision is millisecond. ```sql CREATE DATABASE db_name PRECISION 'ns'; ``` -在 TDengine 中,普通表的数据模型中可使用以下 10 种数据类型。 - -| # | **类型** | **Bytes** | **说明** | -| --- | :-------: | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 1 | TIMESTAMP | 8 | 时间戳。缺省精度毫秒,可支持微秒和纳秒。从格林威治时间 1970-01-01 00:00:00.000 (UTC/GMT) 开始,计时不能早于该时间。(从 2.0.18.0 版本开始,已经去除了这一时间范围限制)(从 2.1.5.0 版本开始支持纳秒精度) | -| 2 | INT | 4 | 整型,范围 [-2^31+1, 2^31-1], -2^31 用作 NULL | -| 3 | BIGINT | 8 | 长整型,范围 [-2^63+1, 2^63-1], -2^63 用作 NULL | -| 4 | FLOAT | 4 | 浮点型,有效位数 6-7,范围 [-3.4E38, 3.4E38] | -| 5 | DOUBLE | 8 | 双精度浮点型,有效位数 15-16,范围 [-1.7E308, 1.7E308] | -| 6 | BINARY | 自定义 | 记录单字节字符串,建议只用于处理 ASCII 可见字符,中文等多字节字符需使用 nchar。理论上,最长可以有 16374 字节。binary 仅支持字符串输入,字符串两端需使用单引号引用。使用时须指定大小,如 binary(20) 定义了最长为 20 个单字节字符的字符串,每个字符占 1 byte 的存储空间,总共固定占用 20 bytes 的空间,此时如果用户字符串超出 20 字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示,即 `\’`。 | -| 7 | SMALLINT | 2 | 短整型, 范围 [-32767, 32767], -32768 用作 NULL | -| 8 | TINYINT | 1 | 单字节整型,范围 [-127, 127], -128 用作 NULL | -| 9 | BOOL | 1 | 布尔型,{true, false} | -| 10 | NCHAR | 自定义 | 记录包含多字节字符在内的字符串,如中文字符。每个 nchar 字符占用 4 bytes 的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 `\’`。nchar 使用时须指定字符串大小,类型为 nchar(10) 的列表示此列的字符串最多存储 10 个 nchar 字符,会固定占用 40 bytes 的空间。如果用户字符串长度超出声明长度,将会报错。 | -| 11 | JSON | | json 数据类型, 只有 tag 可以是 json 格式 | +In TDengine, below data types can be used when specifying a column or tag. + +| # | **类型** | **Bytes** | **说明** | +| --- | :-------: | --------- | ------------------------- | +| 1 | TIMESTAMP | 8 | Default precision is millisecond, microsecond and nanosecond are also supported | +| 2 | INT | 4 | Integer, the value range is [-2^31+1, 2^31-1], while -2^31 is treated as NULL | +| 3 | BIGINT | 8 | Long integer, the value range is [-2^63+1, 2^63-1], while -2^63 is treated as NULL | +| 4 | FLOAT | 4 | Floating point number, the effective number of digits is 6-7, the value range is [-3.4E38, 3.4E38] | +| 5 | DOUBLE | 8 | double precision floating point number, the effective number of digits is 15-16, the value range is [-1.7E308, 1.7E308] | +| 6 | BINARY | User Defined | Single-byte string for ASCII visible characters. Length must be specified when defining a column or tag of binary type. The string length can be up to 16374 bytes. The string value must be quoted with single quotes. The literal single quote inside the string must be preceded with back slash like `\'` | +| 7 | SMALLINT | 2 | Short integer, the value range is [-32767, 32767], while -32768 is treated as NULL | +| 8 | TINYINT | 1 | Single-byte integer, the value range is [-127, 127], while -128 is treated as NLLL | +| 9 | BOOL | 1 | Bool, the value range is {true, false} | +| 10 | NCHAR | User Defined| Multiple-Byte string that can include like Chinese characters. Each character of NCHAR type consumes 4 bytes storage. The string value should be quoted with single quotes. Literal single quote inside the string must be preceded with backslash, like `\’`. The length must be specified when defining a column or tag of NCHAR type, for example nchar(10) means it can store at most 10 characters of nchar type and will consume fixed storage of 40 bytes. Error will be reported the string value exceeds the length defined. | +| 11 | JSON | | json type can only be used on tag, a tag of json type is excluded with any other tags of any other type | :::tip -TDengine 对 SQL 语句中的英文字符不区分大小写,自动转化为小写执行。因此用户大小写敏感的字符串及密码,需要使用单引号将字符串引起来。 +TDengine is case insensitive and treats any characters in the sql command as lower case by default, case sensitive strings must be quoted with single quotes. ::: :::note -虽然 BINARY 类型在底层存储上支持字节型的二进制字符,但不同编程语言对二进制数据的处理方式并不保证一致,因此建议在 BINARY 类型中只存储 ASCII 可见字符,而避免存储不可见字符。多字节的数据,例如中文字符,则需要使用 NCHAR 类型进行保存。如果强行使用 BINARY 类型保存中文字符,虽然有时也能正常读写,但并不带有字符集信息,很容易出现数据乱码甚至数据损坏等情况。 +Only ASCII visible characters are suggested to be used in a column or tag of BINARY type. Multiple-byte characters must be stored in NCHAR type. ::: :::note -SQL 语句中的数值类型将依据是否存在小数点,或使用科学计数法表示,来判断数值类型是否为整型或者浮点型,因此在使用时要注意相应类型越界的情况。例如,9999999999999999999 会认为超过长整型的上边界而溢出,而 9999999999999999999.0 会被认为是有效的浮点数。 +Numeric values in SQL statements will be determined as integer or float type according to whether there is decimal point or whether scientific notation is used, so attention must be paid to avoid overflow. For example, 9999999999999999999 will be considered as overflow because it exceeds the upper limit of long integer, but 9999999999999999999.0 will be considered as a legal float number. ::: diff --git a/docs-en/12-taos-sql/02-database.md b/docs-en/12-taos-sql/02-database.md index 5d358193f96b9c3258d1236f8d11341f8889b8e5..c9d2ba8713c152473684da1102e052a0043dee62 100644 --- a/docs-en/12-taos-sql/02-database.md +++ b/docs-en/12-taos-sql/02-database.md @@ -1,104 +1,127 @@ --- -sidebar_label: 数据库管理 -title: 数据库管理 -description: "创建、删除数据库,查看、修改数据库参数" +sidebar_label: Database +title: Database +description: "create and drop database, show or change database parameters" --- -## 创建数据库 +## Create Datable ``` CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep] [DAYS days] [UPDATE 1]; ``` :::info -1. KEEP 是该数据库的数据保留多长天数,缺省是 3650 天(10 年),数据库会自动删除超过时限的数据; -2. UPDATE 标志数据库支持更新相同时间戳数据;(从 2.1.7.0 版本开始此参数支持设为 2,表示允许部分列更新,也即更新数据行时未被设置的列会保留原值。)(从 2.0.8.0 版本开始支持此参数。注意此参数不能通过 `ALTER DATABASE` 指令进行修改。) - 1. UPDATE 设为 0 时,表示不允许更新数据,后发送的相同时间戳的数据会被直接丢弃; - 2. UPDATE 设为 1 时,表示更新全部列数据,即如果更新一个数据行,其中某些列没有提供取值,那么这些列会被设为 NULL; - 3. UPDATE 设为 2 时,表示支持更新部分列数据,即如果更新一个数据行,其中某些列没有提供取值,那么这些列会保持原有数据行中的对应值; - 4. 更多关于 UPDATE 参数的用法,请参考[FAQ](/train-faq/faq)。 -3. 数据库名最大长度为 33; -4. 一条 SQL 语句的最大长度为 65480 个字符; -5. 数据库还有更多与数据库相关的配置参数,如 cache, blocks, days, keep, minRows, maxRows, wal, fsync, update, cacheLast, replica, quorum, maxVgroupsPerDb, ctime, comp, prec, 具体细节请参见 [配置参数](/reference/config/) 章节。 +1. KEEP specifies the number of days for which the data in the database to be created will be kept, the default value is 3650 days, i.e. 10 years. The data will be deleted automatically once its age exceeds this threshold. +2. UPDATE specifies whether the data can be updated and how the data can be updated. + 1. UPDATE set to 0 means update operation is not allowed, the data with an existing timestamp will be dropped silently. + 2. UPDATE set to 1 means the whole row will be updated, the columns for which no value is specified will be set to NULL + 3. UPDATE set to 2 means updating a part of columns for a row is allowed, the columns for which no value is specified will be kept as no change +3. The maximum length of database name is 33 bytes. +4. The maximum length of a SQL statement is 65,480 bytes. +5. Below are the parameters that can be used when creating a database + - cache: [Description](/reference/config/#cache) + - blocks: [Description](/reference/config/#blocks) + - days: [Description](/reference/config/#days) + - keep: [Description](/reference/config/#keep) + - minRows: [Description](/reference/config/#minrows) + - maxRows: [Description](/reference/config/#maxrows) + - wal: [Description](/reference/config/#wallevel) + - fsync: [Description](/reference/config/#fsync) + - update: [Description](/reference/config/#update) + - cacheLast: [Description](/reference/config/#cachelast) + - replica: [Description](/reference/config/#replica) + - quorum: [Description](/reference/config/#quorum) + - maxVgroupsPerDb: [Description](/reference/config/#maxvgroupsperdb) + - comp: [Description](/reference/config/#comp) + - precision: [Description](reference/config/#precision) +6. Please be noted that all of the parameters mentioned in this section can be configured in configuration file `taosd.cfg` at server side and used by default, can be override if they are specifically in `create database` statement. + ::: -## 显示系统当前参数 +## Show Current Configuration ``` SHOW VARIABLES; ``` -## 使用数据库 +## Specify The Database In Use ``` USE db_name; ``` -使用/切换数据库(在 REST 连接方式下无效)。 +:::note +This way is not applicable when using a REST connection -## 删除数据库 +::: + +## Drop Database ``` DROP DATABASE [IF EXISTS] db_name; ``` -删除数据库。指定 Database 所包含的全部数据表将被删除,谨慎使用! +:::note +All data in the database will be deleted too. This command must be used with caution. + +::: + +## Change Database Configuration -## 修改数据库参数 +Some examples are shown below to demonstrate how to change the configuration of a database. Please be noted that some configuration parameters can be changed after the database is created, but some others can't, for details of the configuration parameters of database please refer to [Configuration Parameters](/reference/config/). ``` ALTER DATABASE db_name COMP 2; ``` -COMP 参数是指修改数据库文件压缩标志位,缺省值为 2,取值范围为 [0, 2]。0 表示不压缩,1 表示一阶段压缩,2 表示两阶段压缩。 +COMP parameter specifies whether the data is compressed and how the data is compressed. ``` ALTER DATABASE db_name REPLICA 2; ``` -REPLICA 参数是指修改数据库副本数,取值范围 [1, 3]。在集群中使用,副本数必须小于或等于 DNODE 的数目。 +REPLICA parameter specifies the number of replications of the database. ``` ALTER DATABASE db_name KEEP 365; ``` -KEEP 参数是指修改数据文件保存的天数,缺省值为 3650,取值范围 [days, 365000],必须大于或等于 days 参数值。 +KEEP parameter specifies the number of days for which the data will be kept. ``` ALTER DATABASE db_name QUORUM 2; ``` -QUORUM 参数是指数据写入成功所需要的确认数,取值范围 [1, 2]。对于异步复制,quorum 设为 1,具有 master 角色的虚拟节点自己确认即可。对于同步复制,quorum 设为 2。原则上,Quorum >= 1 并且 Quorum <= replica(副本数),这个参数在启动一个同步模块实例时需要提供。 +QUORUM parameter specifies the necessary number of confirmations to determine whether the data is written successfully. ``` ALTER DATABASE db_name BLOCKS 100; ``` -BLOCKS 参数是每个 VNODE (TSDB) 中有多少 cache 大小的内存块,因此一个 VNODE 的用的内存大小粗略为(cache \* blocks)。取值范围 [3, 1000]。 +BLOCKS parameter specifies the number of memory blocks used by each VNODE. ``` ALTER DATABASE db_name CACHELAST 0; ``` -CACHELAST 参数控制是否在内存中缓存子表的最近数据。缺省值为 0,取值范围 [0, 1, 2, 3]。其中 0 表示不缓存,1 表示缓存子表最近一行数据,2 表示缓存子表每一列的最近的非 NULL 值,3 表示同时打开缓存最近行和列功能。(从 2.0.11.0 版本开始支持参数值 [0, 1],从 2.1.2.0 版本开始支持参数值 [0, 1, 2, 3]。) -说明:缓存最近行,将显著改善 LAST_ROW 函数的性能表现;缓存每列的最近非 NULL 值,将显著改善无特殊影响(WHERE、ORDER BY、GROUP BY、INTERVAL)下的 LAST 函数的性能表现。 +CACHELAST parameter specifies whether and how the latest data of a sub table is cached. :::tip -以上所有参数修改后都可以用 show databases 来确认是否修改成功。另外,从 2.1.3.0 版本开始,修改这些参数后无需重启服务器即可生效。 -:::tip +The above parameters can be changed using `ALTER DATABASE` command without restarting. For more details of all configuration parameters please refer to [Configuration Parameters](/reference/config/). + +::: -## 显示系统所有数据库 +## Show All Databases ``` SHOW DATABASES; ``` -## 显示一个数据库的创建语句 +## Show The Create Statement of A Database ``` SHOW CREATE DATABASE db_name; ``` -常用于数据库迁移。对一个已经存在的数据库,返回其创建语句;在另一个集群中执行该语句,就能得到一个设置完全相同的 Database。 - +This command is useful when migrating the data from one TDengine cluster to another one. Firstly this command can be used to get the CREATE statement, which in turn can be used in another TDengine to create an exactly same database. diff --git a/docs-en/12-taos-sql/03-table.md b/docs-en/12-taos-sql/03-table.md index 330734f9bc46ffb09fc338997f37c0e05560a2d5..3ec429f9dfe72e59d28df0581d8f118f324e8771 100644 --- a/docs-en/12-taos-sql/03-table.md +++ b/docs-en/12-taos-sql/03-table.md @@ -1,91 +1,87 @@ --- -title: 表管理 +sidebar_label: Table +title: Table +description: create super table, normal table and sub table, drop tables and change tables --- -## 创建数据表 +## Create Table ``` CREATE TABLE [IF NOT EXISTS] tb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]); ``` -:::info 说明 +:::info -1. 表的第一个字段必须是 TIMESTAMP,并且系统自动将其设为主键; -2. 表名最大长度为 192; -3. 表的每行长度不能超过 16k 个字符;(注意:每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置) -4. 子表名只能由字母、数字和下划线组成,且不能以数字开头,不区分大小写 -5. 使用数据类型 binary 或 nchar,需指定其最长的字节数,如 binary(20),表示 20 字节; -6. 为了兼容支持更多形式的表名,TDengine 引入新的转义符 "\`",可以让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。但是同样具有长度限制要求。使用转义字符以后,不再对转义字符中的内容进行大小写统一。 - 例如:\`aBc\` 和 \`abc\` 是不同的表名,但是 abc 和 aBc 是相同的表名。 - 需要注意的是转义字符中的内容必须是可打印字符。 - 上述的操作逻辑和约束要求与 MySQL 数据的操作一致。 - 从 2.3.0.0 版本开始支持这种方式。 +1. The first column of a table must be in TIMESTAMP type, and it will be set as primary key automatically +2. The maximum length of table name is 192 bytes. +3. The maximum length of each row is 16k bytes, please be notes that the extra 2 bytes used by each BINARY/NCHAR column are also counted in. +4. The name of sub-table can only be consisted of English characters, digits and underscore, and can't be started with digit. Table names are case insensitive. +5. The maximum length in bytes must be specified when using BINARY or NCHAR type. +6. Escape character "\`" can be used to avoid the conflict between table names and reserved keywords, above rules will be bypassed when using escape character on table names, but the upper limit for name length is still valid. The table names specified using escape character are case sensitive. Only ASCII visible characters can be used with escape character. + For example \`aBc\` and \`abc\` are different table names but `abc` and `aBc` are same table names because they are both converted to `abc` internally. ::: -### 以超级表为模板创建数据表 +### Create Subtable Using STable As Template ``` CREATE TABLE [IF NOT EXISTS] tb_name USING stb_name TAGS (tag_value1, ...); ``` -以指定的超级表为模板,指定 TAGS 的值来创建数据表。 +The above command creates a subtable using the specified super table as template and the specified tab values. -### 以超级表为模板创建数据表,并指定具体的 TAGS 列 +### Create Subtable Using STable As Template With A Part of Tags ``` CREATE TABLE [IF NOT EXISTS] tb_name USING stb_name (tag_name1, ...) TAGS (tag_value1, ...); ``` -以指定的超级表为模板,指定一部分 TAGS 列的值来创建数据表(没被指定的 TAGS 列会设为空值)。 - 说明:从 2.0.17.0 版本开始支持这种方式。在之前的版本中,不允许指定 TAGS 列,而必须显式给出所有 TAGS 列的取值。 +The tags for which no value is specified will be set to NULL. -### 批量创建数据表 +### Create Tables in Batch ``` CREATE TABLE [IF NOT EXISTS] tb_name1 USING stb_name TAGS (tag_value1, ...) [IF NOT EXISTS] tb_name2 USING stb_name TAGS (tag_value2, ...) ...; ``` -以更快的速度批量创建大量数据表(服务器端 2.0.14 及以上版本)。 +This way can be used to create a lot of tables in a single SQL statement to accelerate the speed of the creating tables. :::info -1.批量建表方式要求数据表必须以超级表为模板。 2.在不超出 SQL 语句长度限制的前提下,单条语句中的建表数量建议控制在 1000 ~ 3000 之间,将会获得比较理想的建表速度。 +- Creating tables in batch must use super table as template. +- The length of single statement is suggested to be between 1,000 and 3,000 bytes for best performance. ::: -## 删除数据表 +## Drop Tables ``` DROP TABLE [IF EXISTS] tb_name; ``` -## 显示当前数据库下的所有数据表信息 +## Show All Tables In Current Database ``` SHOW TABLES [LIKE tb_name_wildcar]; ``` -显示当前数据库下的所有数据表信息。 - -## 显示一个数据表的创建语句 +## Show Create Statement of A Table ``` SHOW CREATE TABLE tb_name; ``` -常用于数据库迁移。对一个已经存在的数据表,返回其创建语句;在另一个集群中执行该语句,就能得到一个结构完全相同的数据表。 - +This way is useful when migrating the data in one TDengine cluster to another one because it can be used to create exactly same tables in the target database. -## 获取表的结构信息 +## Show Table Definition ``` DESCRIBE tb_name; ``` -## 修改表定义 +## Change Table Definition -### 表增加列 +### Add A Column ``` ALTER TABLE tb_name ADD COLUMN field_name data_type; @@ -93,31 +89,39 @@ ALTER TABLE tb_name ADD COLUMN field_name data_type; :::info -1. 列的最大个数为 1024,最小个数为 2;(从 2.1.7.0 版本开始,改为最多允许 4096 列) -2. 列名最大长度为 64。 +1. The maximum number of columns is 4096, the minimum number of columns is 2. +2. The maximum length of column name is 64 bytes. ::: -### 表删除列 +### Remove A Column ``` ALTER TABLE tb_name DROP COLUMN field_name; ``` -如果表是通过超级表创建,更改表结构的操作只能对超级表进行。同时针对超级表的结构更改对所有通过该结构创建的表生效。对于不是通过超级表创建的表,可以直接修改表结构。 +:::note +If a table is created using a super table as template, the table definition can only be changed on the corresponding super table, but the change will be automatically applied to all the sub tables created using this super table as template. For tables created in normal way, the table definition can be changed directly on the table. + +::: -### 表修改列宽 +### Change Column Length ``` ALTER TABLE tb_name MODIFY COLUMN field_name data_type(length); ``` -如果数据列的类型是可变长格式(BINARY 或 NCHAR),那么可以使用此指令修改其宽度(只能改大,不能改小)。(2.1.3.0 版本新增) - 如果表是通过超级表创建,更改表结构的操作只能对超级表进行。同时针对超级表的结构更改对所有通过该结构创建的表生效。对于不是通过超级表创建的表,可以直接修改表结构。 +The the type of a column is variable length, like BINARY or NCHAR, this way can be used to change (or increase) the length of the column. - ### 修改子表标签值 +:::note +If a table is created using a super table as template, the table definition can only be changed on the corresponding super table, but the change will be automatically applied to all the sub tables created using this super table as template. For tables created in normal way, the table definition can be changed directly on the table. + +::: + +### Change Tag Value Of Sub Table ``` ALTER TABLE tb_name SET TAG tag_name=new_tag_value; ``` -如果表是通过超级表创建,可以使用此指令修改其标签值 + +This command can be used to change the tag value if the table is created using a super table as template. diff --git a/docs-en/12-taos-sql/04-stable.md b/docs-en/12-taos-sql/04-stable.md index 52ec7fa6983abc63bcb839f28f8d9a56d6863cb8..8d763ac22f0c64ff898036653c1fd58c6df00298 100644 --- a/docs-en/12-taos-sql/04-stable.md +++ b/docs-en/12-taos-sql/04-stable.md @@ -1,118 +1,118 @@ --- -sidebar_label: 超级表管理 -title: 超级表 STable 管理 +sidebar_label: STable +title: Super Table --- :::note -在 2.0.15.0 及以后的版本中开始支持 STABLE 保留字。也即,在本节后文的指令说明中,CREATE、DROP、ALTER 三个指令在 2.0.15.0 之前的版本中 STABLE 保留字需写作 TABLE。 +Keyword `STable`, abbreviated for super table, is supported since version 2.0.15. ::: -## 创建超级表 +## Crate STable ``` -CREATE STABLE [IF NOT EXISTS] stb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]) TAGS (tag1_name tag_type1, tag2_name tag_type2 [, tag3_name tag_type3]); +CREATE STable [IF NOT EXISTS] stb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]) TAGS (tag1_name tag_type1, tag2_name tag_type2 [, tag3_name tag_type3]); ``` -创建 STable,与创建表的 SQL 语法相似,但需要指定 TAGS 字段的名称和类型。 +The SQL statement of creating STable is similar to that of creating table, but a special column named as `TAGS` must be specified with the names and types of the tags. :::info -1. TAGS 列的数据类型不能是 timestamp 类型;(从 2.1.3.0 版本开始,TAGS 列中支持使用 timestamp 类型,但需注意在 TAGS 中的 timestamp 列写入数据时需要提供给定值,而暂不支持四则运算,例如 `NOW + 10s` 这类表达式) -2. TAGS 列名不能与其他列名相同; -3. TAGS 列名不能为预留关键字(参见:[参数限制与保留关键字](/taos-sql/keywords/) 章节); -4. TAGS 最多允许 128 个,至少 1 个,总长度不超过 16 KB。 +1. The tag types specified in TAGS should NOT be timestamp. Since 2.1.3.0 timestamp type can be used in TAGS column, but its value must be fixed and arithmetic operation can't be applied on it. +2. The tag names specified in TAGS should NOT be same as other columns. +3. The tag names specified in TAGS should NOT be same as any reserved keywords.(Please refer to [keywords](/taos-sql/keywords/) +4. The maximum number of tags specified in TAGS is 128, but there must be at least one tag, and the total length of all tag columns should NOT exceed 16KB. ::: -## 删除超级表 +## Drop STable ``` -DROP STABLE [IF EXISTS] stb_name; +DROP STable [IF EXISTS] stb_name; ``` -删除 STable 会自动删除通过 STable 创建的子表。 +All the sub-tables created using the deleted STable will be deleted automatically. -## 显示当前数据库下的所有超级表信息 +## Show All STables ``` -SHOW STABLES [LIKE tb_name_wildcard]; +SHOW STableS [LIKE tb_name_wildcard]; ``` -查看数据库内全部 STable,及其相关信息,包括 STable 的名称、创建时间、列数量、标签(TAG)数量、通过该 STable 建表的数量。 +This command can be used to display the information of all STables in the current database, including name, creation time, number of columns, number of tags, number of tables created using this STable. -## 显示一个超级表的创建语句 +## Show The Create Statement of A STable ``` -SHOW CREATE STABLE stb_name; +SHOW CREATE STable stb_name; ``` -常用于数据库迁移。对一个已经存在的超级表,返回其创建语句;在另一个集群中执行该语句,就能得到一个结构完全相同的超级表。 +This command is useful in migrating data from one TDengine cluster to another one because it can be used to create an exactly same STable in the target database. -## 获取超级表的结构信息 +## Get STable Definition ``` DESCRIBE stb_name; ``` -## 修改超级表普通列 +## Change Columns Of STable -### 超级表增加列 +### Add A Column ``` -ALTER STABLE stb_name ADD COLUMN field_name data_type; +ALTER STable stb_name ADD COLUMN field_name data_type; ``` -### 超级表删除列 +### Remove A Column ``` -ALTER STABLE stb_name DROP COLUMN field_name; +ALTER STable stb_name DROP COLUMN field_name; ``` -### 超级表修改列宽 +### Change Column Length ``` -ALTER STABLE stb_name MODIFY COLUMN field_name data_type(length); +ALTER STable stb_name MODIFY COLUMN field_name data_type(length); ``` -如果数据列的类型是可变长格式(BINARY 或 NCHAR),那么可以使用此指令修改其宽度(只能改大,不能改小)。(2.1.3.0 版本新增) +This command can be used to change (or incerase, more specifically) the length of a column of variable length types, like BINARY or NCHAR. -## 修改超级表标签列 +## Change Tags of A STable -### 添加标签 +### Add A Tag ``` -ALTER STABLE stb_name ADD TAG new_tag_name tag_type; +ALTER STable stb_name ADD TAG new_tag_name tag_type; ``` -为 STable 增加一个新的标签,并指定新标签的类型。标签总数不能超过 128 个,总长度不超过 16k 个字符。 +This command is used to add a new tag for a STable and specify the tag type. -### 删除标签 +### Remove A Tag ``` -ALTER STABLE stb_name DROP TAG tag_name; +ALTER STable stb_name DROP TAG tag_name; ``` -删除超级表的一个标签,从超级表删除某个标签后,该超级表下的所有子表也会自动删除该标签。 +The tag will be removed automatically from all the sub tables crated using the super table as template once a tag is removed from a super table. -### 修改标签名 +### Change A Tag ``` -ALTER STABLE stb_name CHANGE TAG old_tag_name new_tag_name; +ALTER STable stb_name CHANGE TAG old_tag_name new_tag_name; ``` -修改超级表的标签名,从超级表修改某个标签名后,该超级表下的所有子表也会自动更新该标签名。 +The tag name will be changed automatically from all the sub tables crated using the super table as template once a tag name is changed for a super table. -### 修改标签列宽度 +### Change Tag Length ``` -ALTER STABLE stb_name MODIFY TAG tag_name data_type(length); +ALTER STable stb_name MODIFY TAG tag_name data_type(length); ``` -如果标签的类型是可变长格式(BINARY 或 NCHAR),那么可以使用此指令修改其宽度(只能改大,不能改小)。(2.1.3.0 版本新增) +This command can be used to change (or incerase, more specifically) the length of a tag of variable length types, like BINARY or NCHAR. :::note -除了更新标签的值的操作是针对子表进行,其他所有的标签操作(添加标签、删除标签等)均只能作用于 STable,不能对单个子表操作。对 STable 添加标签以后,依托于该 STable 建立的所有表将自动增加了一个标签,所有新增标签的默认值都是 NULL。 +Changing tag value can be applied to only sub tables. All other tag operations, like add tag, remove tag, however, can be applied to only STable. If a new tag is added for a STable, the tag will be added with NULL value for all its sub tables. -::: \ No newline at end of file +::: diff --git a/docs-en/12-taos-sql/05-insert.md b/docs-en/12-taos-sql/05-insert.md index e542e442b78c9033ae37196f4913a7c67fb19d8b..47900a44fde85574d7c7cf361c8eaa08c72b1ad2 100644 --- a/docs-en/12-taos-sql/05-insert.md +++ b/docs-en/12-taos-sql/05-insert.md @@ -1,11 +1,10 @@ --- -sidebar_label: 数据写入 -title: 数据写入 +title: Insert --- -## 写入语法 +## Syntax -``` +```sql INSERT INTO tb_name [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)] @@ -18,117 +17,123 @@ INSERT INTO ...]; ``` -## 插入一条或多条记录 +## Insert Single or Multiple Rows -指定已经创建好的数据子表的表名,并通过 VALUES 关键字提供一行或多行数据,即可向数据库写入这些数据。例如,执行如下语句可以写入一行记录: +Single row or multiple rows specified with VALUES can be inserted into a specific table. For example -``` +Single row is inserted using below statement. + +```sq; INSERT INTO d1001 VALUES (NOW, 10.2, 219, 0.32); ``` -或者,可以通过如下语句写入两行记录: +Double rows can be inserted using below statement. -``` +```sql INSERT INTO d1001 VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32) (1626164208000, 10.15, 217, 0.33); ``` :::note -1. 在第二个例子中,两行记录的首列时间戳使用了不同格式的写法。其中字符串格式的时间戳写法不受所在 DATABASE 的时间精度设置影响;而长整形格式的时间戳写法会受到所在 DATABASE 的时间精度设置影响——例子中的时间戳在毫秒精度下可以写作 1626164208000,而如果是在微秒精度设置下就需要写为 1626164208000000,纳秒精度设置下需要写为 1626164208000000000。 -2. 在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为 NOW,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。其原因在于,NOW 函数在执行中会被解析为所在 SQL 语句的实际执行时间,出现在同一语句中的多个 NOW 标记也就会被替换为完全相同的时间戳取值。 -3. 允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的 keep 值(数据保留的天数);允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的 days 值(数据文件存储数据的时间跨度,单位为天)。keep 和 days 都是可以在创建数据库时指定的,缺省值分别是 3650 天和 10 天。 +1. In the second example above, different formats are used in the two rows to be inserted. In the first row, the timestamp format is a date and time string, which is interpreted from the string value only. In the second row, the timestamp format is a long integer, which will be interpreted based on the database time precision. +2. When trying to insert multiple rows in single statement, only the timestamp of one row can be set as NOW, otherwise there will be duplicate timestamps among the rows and the result may be out of expectation because NOW will be interpreted as the time when the statement is executed. +3. The oldest timestamp that is allowed is subtracting the KEEP parameter from current time. +4. The newest timestamp that is allowed is adding the DAYS parameter to current time. ::: -## 插入记录,数据对应到指定的列 +## Insert Into Specific Columns -向数据子表中插入记录时,无论插入一行还是多行,都可以让数据对应到指定的列。对于 SQL 语句中没有出现的列,数据库将自动填充为 NULL。主键(时间戳)不能为 NULL。例如: +Data can be inserted into specific columns, either single row or multiple row, while other columns will be inserted as NULL value. ``` INSERT INTO d1001 (ts, current, phase) VALUES ('2021-07-13 14:06:33.196', 10.27, 0.31); ``` :::info -如果不指定列,也即使用全列模式——那么在 VALUES 部分提供的数据,必须为数据表的每个列都显式地提供数据。全列模式写入速度会远快于指定列,因此建议尽可能采用全列写入方式,此时空列可以填入 NULL。 +If no columns are explicitly specified, all the columns must be provided with values, this is called "all column mode". The insert performance of all column mode is much better than specifying a part of columns, so it's encouraged to use "all column mode" while providing NULL value explicitly for the columns for which no actual value can be provided. ::: -## 向多个表插入记录 +## Insert Into Multiple Tables -可以在一条语句中,分别向多个表插入一条或多条记录,并且也可以在插入过程中指定列。例如: +One or multiple rows can be inserted into multiple tables in single SQL statement, with or without specifying specific columns. -``` +```sql INSERT INTO d1001 VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33) d1002 (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31); ``` -## 插入记录时自动建表 +## Automatically Create Table When Inserting -如果用户在写数据时并不确定某个表是否存在,此时可以在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。自动建表时,要求必须以超级表为模板,并写明数据表的 TAGS 取值。例如: +If it's not sure whether the table already exists, the table can be created automatically while inserting using below SQL statement. To use this functionality, a STable must be used as template and tag values must be provided. -``` +```sql INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32); ``` -也可以在自动建表时,只是指定部分 TAGS 列的取值,未被指定的 TAGS 列将置为 NULL。例如: +It's not necessary to provide values for all tag when creating tables automatically, the tags without values provided will be set to NULL. -``` +```sql INSERT INTO d21001 USING meters (groupId) TAGS (2) VALUES ('2021-07-13 14:06:33.196', 10.15, 217, 0.33); ``` -自动建表语法也支持在一条语句中向多个表插入记录。例如: +Multiple rows can also be inserted into same table in single SQL statement using this way.自 -``` +```sql INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33) d21002 USING meters (groupId) TAGS (2) VALUES ('2021-07-13 14:06:34.255', 10.15, 217, 0.33) d21003 USING meters (groupId) TAGS (2) (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31); ``` :::info -在 2.0.20.5 版本之前,在使用自动建表语法并指定列时,子表的列名必须紧跟在子表名称后面,而不能如例子里那样放在 TAGS 和 VALUES 之间。从 2.0.20.5 版本开始,两种写法都可以,但不能在一条 SQL 语句中混用,否则会报语法错误。 +Prior to version 2.0.20.5, when using `INSERT` to create table automatically and specify the columns, the column names must follow the table name immediately. From version 2.0.20.5, the column names can follow the table name immediately, also can be put between `TAGS` and `VALUES`. In same SQL statement, however, these two ways of specifying column names can't be mixed. ::: -## 插入来自文件的数据记录 +## Insert Rows From A File -除了使用 VALUES 关键字插入一行或多行数据外,也可以把要写入的数据放在 CSV 文件中(英文逗号分隔、英文单引号括住每个值)供 SQL 指令读取。其中 CSV 文件无需表头。例如,如果 /tmp/csvfile.csv 文件的内容为: +Besides using `VALUES` to insert one or multiple rows, the data to be inserted can also be prepared in a CSV file with comma as separator and each field value quoted by single quotes. Table definition is not required in the CSV file. For example, if file "/tmp/csvfile.csv" contains below data: ``` '2021-07-13 14:07:34.630', '10.2', '219', '0.32' '2021-07-13 14:07:35.779', '10.15', '217', '0.33' ``` -那么通过如下指令可以把这个文件中的数据写入子表中: +Then data in this file can be inserted by below SQL statement: -``` +```sql INSERT INTO d1001 FILE '/tmp/csvfile.csv'; ``` -## 插入来自文件的数据记录,并自动建表 +## Create Tables Automatically and Insert Rows From File -从 2.1.5.0 版本开始,支持在插入来自 CSV 文件的数据时,以超级表为模板来自动创建不存在的数据表。例如: +From version 2.1.5.0, tables can be automatically created using a super table as template when inserting data from a CSV file, Like below: -``` +```sql INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) FILE '/tmp/csvfile.csv'; ``` -也可以在一条语句中向多个表以自动建表的方式插入记录。例如: +Multiple tables can be automatically created and inserted in single SQL statement, like below:也 -``` +```sql INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) FILE '/tmp/csvfile_21001.csv' d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv'; ``` -## 历史记录写入 +## More About Insert -可使用 IMPORT 或者 INSERT 命令,IMPORT 的语法,功能与 INSERT 完全一样。 +For SQL statement like `insert`, stream parsing strategy is applied. That means before an error is found and the execution is aborted, the part prior to the error point has already been executed. Below is an experiment to help understand the behavior. -针对 insert 类型的 SQL 语句,我们采用的流式解析策略,在发现后面的错误之前,前面正确的部分 SQL 仍会执行。下面的 SQL 中,INSERT 语句是无效的,但是 d1001 仍会被创建。 +Firstly, a super table is created. +```sql +CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT); ``` -taos> CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT); -Query OK, 0 row(s) affected (0.008245s) -taos> SHOW STABLES; +It can be proved that the super table has been created by `SHOW STableS`, but no table exists by `SHOW TABLES`. + +``` +taos> SHOW STableS; name | created_time | columns | tags | tables | ============================================================================================ meters | 2020-08-06 17:50:27.831 | 4 | 2 | 0 | @@ -136,14 +141,24 @@ Query OK, 1 row(s) in set (0.001029s) taos> SHOW TABLES; Query OK, 0 row(s) in set (0.000946s) +``` -taos> INSERT INTO d1001 USING meters TAGS('Beijing.Chaoyang', 2) VALUES('a'); +Then, try to create table d1001 automatically when inserting data into it. +```sql +INSERT INTO d1001 USING meters TAGS('Beijing.Chaoyang', 2) VALUES('a'); +``` + +The output shows the value to be inserted is invalid. But `SHOW TABLES` proves that the table has been created automatically by the `INSERT` statement. + +``` DB error: invalid SQL: 'a' (invalid timestamp) (0.039494s) taos> SHOW TABLES; - table_name | created_time | columns | stable_name | + table_name | created_time | columns | STable_name | ====================================================================================================== d1001 | 2020-08-06 17:52:02.097 | 4 | meters | Query OK, 1 row(s) in set (0.001091s) ``` + +From the above experiment, we can see that even though the value to be inserted is invalid but the table is still created. diff --git a/docs-en/12-taos-sql/06-select.md b/docs-en/12-taos-sql/06-select.md index 6f0a0735135738c9502632387022cc94e9495375..22c2ee5e288a8fd388dbb6fba200caae69daacd1 100644 --- a/docs-en/12-taos-sql/06-select.md +++ b/docs-en/12-taos-sql/06-select.md @@ -1,11 +1,10 @@ --- -sidebar_label: 数据查询 -title: 数据查询 +title: Select --- -## 查询语法 +## Syntax -``` +```SQL SELECT select_expr [, select_expr ...] FROM {tb_name_list} [WHERE where_condition] @@ -20,9 +19,9 @@ SELECT select_expr [, select_expr ...] [>> export_file]; ``` -## 通配符 +## Wildcard -通配符 \* 可以用于代指全部列。对于普通表,结果中只有普通列。 +Wilcard \* can be used to specify all columns. The result includes only data columns for normal tables. ``` taos> SELECT * FROM d1001; @@ -34,7 +33,7 @@ taos> SELECT * FROM d1001; Query OK, 3 row(s) in set (0.001165s) ``` -在针对超级表,通配符包含 _标签列_ 。 +The result includes both data columns and tag columns for super table. ``` taos> SELECT * FROM meters; @@ -52,14 +51,14 @@ taos> SELECT * FROM meters; Query OK, 9 row(s) in set (0.002022s) ``` -通配符支持表名前缀,以下两个 SQL 语句均为返回全部的列: +Wildcard can be used with table name as prefix, both below SQL statements have same effects and return all columns. -``` +```SQL SELECT * FROM d1001; SELECT d1001.* FROM d1001; ``` -在 JOIN 查询中,带前缀的\*和不带前缀\*返回的结果有差别, \*返回全部表的所有列数据(不包含标签),带前缀的通配符,则只返回该表的列数据。 +In JOIN query, however, with or without table name prefix will return different results. \* without table prefix will return all the columns of both tables, but \* with table name as prefix will return only the columns of that table. ``` taos> SELECT * FROM d1001, d1003 WHERE d1001.ts=d1003.ts; @@ -77,8 +76,7 @@ taos> SELECT d1001.* FROM d1001,d1003 WHERE d1001.ts = d1003.ts; Query OK, 1 row(s) in set (0.020443s) ``` -在使用 SQL 函数来进行查询的过程中,部分 SQL 函数支持通配符操作。其中的区别在于: -`count(*)`函数只返回一列。`first`、`last`、`last_row`函数则是返回全部列。 +Wilcard \* can be used with some functions, but the result may be different depending on the function being used. For example, `count(*)` returns only one column, i.e. the number of rows; `first`, `last` and `last_row` return all columns of the selected row. ``` taos> SELECT COUNT(*) FROM d1001; @@ -96,9 +94,9 @@ taos> SELECT FIRST(*) FROM d1001; Query OK, 1 row(s) in set (0.000849s) ``` -## 标签列 +## Tags -从 2.0.14 版本开始,支持在普通表的查询中指定 _标签列_,且标签列的值会与普通列的数据一起返回。 +Starting from version 2.0.14, tag columns can be selected together with data columns when querying sub tables. Please be noted that, however, wildcard \* doesn't represent any tag column, that means tag columns must be specified explicitly like below example. ``` taos> SELECT location, groupid, current FROM d1001 LIMIT 2; @@ -109,33 +107,26 @@ taos> SELECT location, groupid, current FROM d1001 LIMIT 2; Query OK, 2 row(s) in set (0.003112s) ``` -注意:普通表的通配符 \* 中并不包含 _标签列_。 +## Get distinct values -## 获取标签列或普通列的去重取值 - -从 2.0.15.0 版本开始,支持在超级表查询标签列时,指定 DISTINCT 关键字,这样将返回指定标签列的所有不重复取值。注意,在 2.1.6.0 版本之前,DISTINCT 只支持处理单个标签列,而从 2.1.6.0 版本开始,DISTINCT 可以对多个标签列进行处理,输出这些标签列取值不重复的组合。 +`DISTINCT` keyword can be used to get all the unique values of tag columns from a super table, it can also be used to get all the unique values of data columns from a table or sub table. ```sql SELECT DISTINCT tag_name [, tag_name ...] FROM stb_name; -``` - -从 2.1.7.0 版本开始,DISTINCT 也支持对数据子表或普通表进行处理,也即支持获取单个普通列的不重复取值,或多个普通列取值的不重复组合。 - -```sql SELECT DISTINCT col_name [, col_name ...] FROM tb_name; ``` :::info -1. cfg 文件中的配置参数 maxNumOfDistinctRes 将对 DISTINCT 能够输出的数据行数进行限制。其最小值是 100000,最大值是 100000000,默认值是 10000000。如果实际计算结果超出了这个限制,那么会仅输出这个数量范围内的部分。 -2. 由于浮点数天然的精度机制原因,在特定情况下,对 FLOAT 和 DOUBLE 列使用 DISTINCT 并不能保证输出值的完全唯一性。 -3. 在当前版本下,DISTINCT 不能在嵌套查询的子查询中使用,也不能与聚合函数、GROUP BY、或 JOIN 在同一条语句中混用。 +1. Configuration parameter `maxNumOfDistinctRes` in `taos.cfg` is used to control the number of rows to output. The minimum configurable value is 100,000, the maximum configurable value is 100,000,000, the default value is 1000,000. If the actual number of rows exceeds the value of this parameter, only the number of rows specified by this parameter will be output. +2. It can't be guaranteed that the results selected by using `DISTINCT` on columns of `FLOAT` or `DOUBLE` are exactly unique because of the precision nature of floating numbers. +3. `DISTINCT` can't be used in the sub-query of a nested query statement, and can't be used together with aggregate functions, `GROUP BY` or `JOIN` in same SQL statement. ::: -## 结果集列名 +## Columns Names of Result Set -`SELECT`子句中,如果不指定返回结果集合的列名,结果集列名称默认使用`SELECT`子句中的表达式名称作为列名称。此外,用户可使用`AS`来重命名返回结果集合中列的名称。例如: +When using `SELECT`, the column names in the result set will be same as that in the select clause if `AS` is not used. `AS` can be used to rename the column names in the result set. For example ``` taos> SELECT ts, ts AS primary_key_ts FROM d1001; @@ -147,27 +138,30 @@ taos> SELECT ts, ts AS primary_key_ts FROM d1001; Query OK, 3 row(s) in set (0.001191s) ``` -但是针对`first(*)`、`last(*)`、`last_row(*)`不支持针对单列的重命名。 +`AS` can't be used together with `first(*)`, `last(*)`, or `last_row(*)`. -## 隐式结果列 +## Implicit Columns -`Select_exprs`可以是表所属列的列名,也可以是基于列的函数表达式或计算式,数量的上限 256 个。当用户使用了`interval`或`group by tags`的子句以后,在最后返回结果中会强制返回时间戳列(第一列)和 group by 子句中的标签列。后续的版本中可以支持关闭 group by 子句中隐式列的输出,列输出完全由 select 子句控制。 +`Select_exprs` can be column names of a table, or function expression or arithmetic expression on columns. The maximum number of allowed column names and expressions is 256. Timestamp and the corresponding tag names will be returned in the result set if `interval` or `group by tags` are used, and timestamp will always be the first column in the result set. -## 表(超级表)列表 +## Table List -FROM 关键字后面可以是若干个表(超级表)列表,也可以是子查询的结果。 -如果没有指定用户的当前数据库,可以在表名称之前使用数据库的名称来指定表所属的数据库。例如:`power.d1001` 方式来跨库使用表。 +`FROM` can be followed by a number of tables or super tables, or can be followed by a sub-query. If no database is specified as current database in use, table names must be preceded with database name, like `power.d1001`. -``` +```SQL SELECT * FROM power.d1001; ------------------------------- +``` + +has same effect as + +```SQL USE power; SELECT * FROM d1001; ``` -## 特殊功能 +## Special Query -部分特殊的查询功能可以不使用 FROM 子句执行。获取当前所在的数据库 database(): +Some special query functionalities can be performed without `FORM` sub-clause. For example, below statement can be used to get the current database in use. ``` taos> SELECT DATABASE(); @@ -177,7 +171,7 @@ taos> SELECT DATABASE(); Query OK, 1 row(s) in set (0.000079s) ``` -如果登录的时候没有指定默认数据库,且没有使用`USE`命令切换数据,则返回 NULL。 +If no database is specified upon logging in and no database is specified with `USE` after login, NULL will be returned by `select database()`. ``` taos> SELECT DATABASE(); @@ -187,7 +181,7 @@ taos> SELECT DATABASE(); Query OK, 1 row(s) in set (0.000184s) ``` -获取服务器和客户端版本号: +Below statement can be used to get the version of client or server. ``` taos> SELECT CLIENT_VERSION(); @@ -203,7 +197,7 @@ taos> SELECT SERVER_VERSION(); Query OK, 1 row(s) in set (0.000077s) ``` -服务器状态检测语句。如果服务器正常,返回一个数字(例如 1)。如果服务器异常,返回 error code。该 SQL 语法能兼容连接池对于 TDengine 状态的检查及第三方工具对于数据库服务器状态的检查。并可以避免出现使用了错误的心跳检测 SQL 语句导致的连接池连接丢失的问题。 +Below statement is used to check the server status. One integer, like `1`, is returned if the server status is OK, otherwise an error code is returned. This way is compatible with the status check for TDengine from connection pool or 3rd party tools, and can avoid the problem of losing connection from connection pool when using wrong heartbeat checking SQL statement. ``` taos> SELECT SERVER_STATUS(); @@ -219,66 +213,59 @@ taos> SELECT SERVER_STATUS() AS status; Query OK, 1 row(s) in set (0.000081s) ``` -## \_block_dist 函数 +## \_block_dist -**功能说明**: 用于获得指定的(超级)表的数据块分布信息 +**Description**: Get the data block distribution of a table or STable. -```txt title="语法" +```SQL title="Syntax" SELECT _block_dist() FROM { tb_name | stb_name } ``` -**返回结果类型**:字符串。 - -**适用数据类型**:不能输入任何参数。 - -**嵌套子查询支持**:不支持子查询或嵌套查询。 +**Restrictions**:No argument is allowed, where clause is not allowed -**返回结果**: +**Sub Query**:Sub query or nested query are not supported -- 返回 FROM 子句中输入的表或超级表的数据块分布情况。不支持查询条件。 -- 返回的结果是该表或超级表的数据块所包含的行数的数据分布直方图。 +**Return value**: A string which includes the data block distribution of the specified table or STable, i.e. the histogram of rows stored in the data blocks of the table or STable. -```txt title="返回结果" +```text title="Result" summary: 5th=[392], 10th=[392], 20th=[392], 30th=[392], 40th=[792], 50th=[792] 60th=[792], 70th=[792], 80th=[792], 90th=[792], 95th=[792], 99th=[792] Min=[392(Rows)] Max=[800(Rows)] Avg=[666(Rows)] Stddev=[2.17] Rows=[2000], Blocks=[3], Size=[5.440(Kb)] Comp=[0.23] RowsInMem=[0] SeekHeaderTime=[1(us)] ``` -**上述信息的说明如下**: +**More explanation about above example**: -- 查询的(超级)表所包含的存储在文件中的数据块(data block)中所包含的数据行的数量分布直方图信息:5%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 95%, 99% 的数值; -- 所有数据块中,包含行数最少的数据块所包含的行数量, 其中的 Min 指标 392 行。 -- 所有数据块中,包含行数最多的数据块所包含的行数量, 其中的 Max 指标 800 行。 -- 所有数据块行数的算数平均值 666 行(其中的 Avg 项)。 -- 所有数据块中行数分布的均方差为 2.17 ( stddev )。 -- 数据块包含的行的总数为 2000 行(Rows)。 -- 数据块总数是 3 个数据块 (Blocks)。 -- 数据块占用磁盘空间大小 5.44 Kb (size)。 -- 压缩后的数据块的大小除以原始数据的所获得的压缩比例: 23%(Comp),及压缩后的数据规模是原始数据规模的 23%。 -- 内存中存在的数据行数是 0,表示内存中没有数据缓存。 -- 获取数据块信息的过程中读取头文件的时间开销 1 微秒(SeekHeaderTime)。 +- Histogram about the rows stored in the data blocks of the table or STable: the value of rows for 5%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 95%, and 99% +- Minimum number of rows stored in a data block, i.e. Min=[392(Rows)] +- Maximum number of rows stored in a data block, i.e. Max=[800(Rows)] +- Average number of rows stored in a data block, i.e. Avg=[666(Rows)] +- stddev of number of rows, i.e. Stddev=[2.17] +- Total number of rows, i.e. Rows[2000] +- Total number of data blocks, i.e. Blocks=[3] +- Total disk size consumed, i.e. Size=[5.440(Kb)] +- Compression ratio, which means the compressed size divided by original size, i.e. Comp=[0.23] +- Total number of rows in memory, i.e. RowsInMem=[0], which means no rows in memory +- The time spent on reading head file (to retrieve data block information), i.e. SeekHeaderTime=[1(us)], which means 1 microsecond. -**支持版本**:指定计算算法的功能从 2.1.0.x 版本开始,2.1.0.0 之前的版本不支持指定使用算法的功能。 +## Special Keywords in TAOS SQL -## TAOS SQL 中特殊关键词 +- `TBNAME`: it is treated as a special tag when selecting on a super table, representing the name of sub-tables in that super table. +- `_c0`: represents the first column of a table or super table. -- `TBNAME`: 在超级表查询中可视为一个特殊的标签,代表查询涉及的子表名 -- `_c0`: 表示表(超级表)的第一列 +## Tips -## 小技巧 +To get all the sub tables and corresponding tag values from a super table: -获取一个超级表所有的子表名及相关的标签信息: - -``` +```SQL SELECT TBNAME, location FROM meters; ``` -统计超级表下辖子表数量: +To get the number of sub tables in a super table: -``` +```SQL SELECT COUNT(TBNAME) FROM meters; ``` -以上两个查询均只支持在 WHERE 条件子句中添加针对标签(TAGS)的过滤条件。例如: +Only filter on `TAGS` are allowed in the `where` clause for above two query statements. For example: ``` taos> SELECT TBNAME, location FROM meters; @@ -297,17 +284,19 @@ taos> SELECT COUNT(tbname) FROM meters WHERE groupId > 2; Query OK, 1 row(s) in set (0.001091s) ``` -- 可以使用 \* 返回所有列,或指定列名。可以对数字列进行四则运算,可以给输出的列取列名。 - - 暂不支持含列名的四则运算表达式用于条件过滤算子(例如,不支持 `where a*2>6;`,但可以写 `where a>6/2;`)。 - - 暂不支持含列名的四则运算表达式作为 SQL 函数的应用对象(例如,不支持 `select min(2*a) from t;`,但可以写 `select 2*min(a) from t;`)。 -- WHERE 语句可以使用各种逻辑判断来过滤数字值,或使用通配符来过滤字符串。 -- 输出结果缺省按首列时间戳升序排序,但可以指定按降序排序( \_c0 指首列时间戳)。使用 ORDER BY 对其他字段进行排序,排序结果顺序不确定。 -- 参数 LIMIT 控制输出条数,OFFSET 指定从第几条开始输出。LIMIT/OFFSET 对结果集的执行顺序在 ORDER BY 之后。且 `LIMIT 5 OFFSET 2` 可以简写为 `LIMIT 2, 5`。 - - 在有 GROUP BY 子句的情况下,LIMIT 参数控制的是每个分组中至多允许输出的条数。 -- 参数 SLIMIT 控制由 GROUP BY 指令划分的分组中,至多允许输出几个分组的数据。且 `SLIMIT 5 SOFFSET 2` 可以简写为 `SLIMIT 2, 5`。 -- 通过 “>>” 输出结果可以导出到指定文件。 +- Wildcard \* can be used to get all columns, or specific column names can be specified. Arithmetic operation can be performed on columns of number types, columns can be renamed in the result set. +- Arithmetic operation on columns can't be used in where clause. For example, `where a*2>6;` is not allowed but `where a>6/2;` can be used instead for same purpose. +- Arithmetic operation on columns can't be used as the objectives of select statement. For example, `select min(2*a) from t;` is not allowed but `select 2*min(a) from t;` can be used instead. +- Logical operation can be used in `WHERE` clause to filter numeric values, wildcard can be used to filter string values. +- Result set are arranged in ascending order of the first column, i.e. timestamp, but it can be controlled to output as descending order of timestamp. If `order by` is used on other columns, the result may be not as expected. By the way, \_c0 is used to represent the first column, i.e. timestamp. +- `LIMIT` parameter is used to control the number of rows to output. `OFFSET` parameter is used to specify from which row to output. `LIMIT` and `OFFSET` are executed after `ORDER BY` in the query execution. A simple tip is that `LIMIT 5 OFFSET 2` can be abbreviated as `LIMIT 2, 5`. +- What is controlled by `LIMIT` is the number of rows in each group when `GROUP BY` is used. +- `SLIMIT` parameter is used to control the number of groups when `GROUP BY` is used. Similar to `LIMIT`, `SLIMIT 5 OFFSET 2` can be abbreviated as `SLIMIT 2, 5`. +- ">>" can be used to output the result set of `select` statement to the specified file. -## 条件过滤操作 +## Where + +Logical operations in below table can be used in `where` clause to filter the resulting rows. | **Operation** | **Note** | **Applicable Data Types** | | ------------- | ------------------------ | ----------------------------------------- | @@ -325,42 +314,41 @@ Query OK, 1 row(s) in set (0.001091s) **使用说明**: -- <\> 算子也可以写为 != ,请注意,这个算子不能用于数据表第一列的 timestamp 字段。 -- like 算子使用通配符字符串进行匹配检查。 - - 在通配符字符串中:'%'(百分号)匹配 0 到任意个字符;'\_'(下划线)匹配单个任意 ASCII 字符。 - - 如果希望匹配字符串中原本就带有的 \_(下划线)字符,那么可以在通配符字符串中写作 `\_`,也即加一个反斜线来进行转义。(从 2.2.0.0 版本开始支持) - - 通配符字符串最长不能超过 20 字节。(从 2.1.6.1 版本开始,通配符字符串的长度放宽到了 100 字节,并可以通过 taos.cfg 中的 maxWildCardsLength 参数来配置这一长度限制。但不建议使用太长的通配符字符串,将有可能严重影响 LIKE 操作的执行性能。) -- 同时进行多个字段的范围过滤,需要使用关键词 AND 来连接不同的查询条件,暂不支持 OR 连接的不同列之间的查询过滤条件。 - - 从 2.3.0.0 版本开始,已支持完整的同一列和/或不同列间的 AND/OR 运算。 -- 针对单一字段的过滤,如果是时间过滤条件,则一条语句中只支持设定一个;但针对其他的(普通)列或标签列,则可以使用 `OR` 关键字进行组合条件的查询过滤。例如: `((value > 20 AND value < 30) OR (value < 12))`。 - - 从 2.3.0.0 版本开始,允许使用多个时间过滤条件,但首列时间戳的过滤运算结果只能包含一个区间。 -- 从 2.0.17.0 版本开始,条件过滤开始支持 BETWEEN AND 语法,例如 `WHERE col2 BETWEEN 1.5 AND 3.25` 表示查询条件为“1.5 ≤ col2 ≤ 3.25”。 -- 从 2.1.4.0 版本开始,条件过滤开始支持 IN 算子,例如 `WHERE city IN ('Beijing', 'Shanghai')`。说明:BOOL 类型写作 `{true, false}` 或 `{0, 1}` 均可,但不能写作 0、1 之外的整数;FLOAT 和 DOUBLE 类型会受到浮点数精度影响,集合内的值在精度范围内认为和数据行的值完全相等才能匹配成功;TIMESTAMP 类型支持非主键的列。 -- 从 2.3.0.0 版本开始,条件过滤开始支持正则表达式,关键字 match/nmatch,不区分大小写。 +- Operator `<\>` is equal to `!=`, please be noted that this operator can't be used on the first column of any table, i.e.timestamp column. +- Operator `like` is used together with wildcards to match strings + - '%' matches 0 or any number of characters, '\_' matches any single ASCII character. + - `\_` is used to match the \_ in the string. + - The maximum length of wildcard string is 100 bytes from version 2.1.6.1 (before that the maximum length is 20 bytes). `maxWildCardsLength` in `taos.cfg` can be used to control this threshold. Too long wildcard string may slowdown the execution performance of `LIKE` operator. +- `AND` keyword can be used to filter multiple columns simultaneously. AND/OR operation can be performed on single or multiple columns from version 2.3.0.0. However, before 2.3.0.0 `OR` can't be used on multiple columns. +- For timestamp column, only one condition can be used; for other columns or tags, `OR` keyword can be used to combine multiple logical operators. For example, `((value > 20 AND value < 30) OR (value < 12))`. + - From version 2.3.0.0, multiple conditions can be used on timestamp column, but the result set can only contain single time range. +- From version 2.0.17.0, operator `BETWEEN AND` can be used in where clause, for example `WHERE col2 BETWEEN 1.5 AND 3.25` means the filter condition is equal to "1.5 ≤ col2 ≤ 3.25". +- From version 2.1.4.0, operator `IN` can be used in where clause. For example, `WHERE city IN ('Beijing', 'Shanghai')`. For bool type, both `{true, false}` and `{0, 1}` are allowed, but integers other than 0 or 1 are not allowed. FLOAT and DOUBLE types are impacted by floating precision, only values that match the condition within the tolerance will be selected. Non-primary key column of timestamp type can be used with `IN`. +- From version 2.3.0.0, regular expression is supported in where clause with keyword `match` or `nmatch`, the regular expression is case insensitive. -## 正则表达式过滤 +## Regular Expression -### 语法 +### Syntax -```txt +```SQL WHERE (column|tbname) **match/MATCH/nmatch/NMATCH** _regex_ ``` -### 正则表达式规范 +### Specification -确保使用的正则表达式符合 POSIX 的规范,具体规范内容可参见[Regular Expressions](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html) +The regular expression being used must be compliant with POSIX specification, please refer to [Regular Expressions](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html). -### 使用限制 +### Restrictions -只能针对表名(即 tbname 筛选)、binary/nchar 类型标签值进行正则表达式过滤,不支持普通列的过滤。 +Regular expression can be used against only table names, i.e. `tbname`, and tags of binary/nchar types, but can't be used against data columns. -正则匹配字符串长度不能超过 128 字节。可以通过参数 _maxRegexStringLen_ 设置和调整最大允许的正则匹配字符串,该参数是客户端配置参数,需要重启才能生效。 +The maximum length of regular expression string is 128 bytes. Configuration parameter `maxRegexStringLen` can be used to set the maximum allowed regular expression. It's a configuration parameter on client side, and will take in effect after restarting the client. -## JOIN 子句 +## JOIN -从 2.2.0.0 版本开始,TDengine 对内连接(INNER JOIN)中的自然连接(Natural join)操作实现了完整的支持。也即支持“普通表与普通表之间”、“超级表与超级表之间”、“子查询与子查询之间”进行自然连接。自然连接与内连接的主要区别是,自然连接要求参与连接的字段在不同的表/超级表中必须是同名字段。也即,TDengine 在连接关系的表达中,要求必须使用同名数据列/标签列的相等关系。 +From version 2.2.0.0, inner join is fully supported in TDengine. More specifically, the inner join between table and table, that between STable and STable, and that between sub query and sub query are supported. -在普通表与普通表之间的 JOIN 操作中,只能使用主键时间戳之间的相等关系。例如: +Only primary key, i.e. timestamp, can be used in the join operation between table and table. For example: ```sql SELECT * @@ -368,96 +356,94 @@ FROM temp_tb_1 t1, pressure_tb_1 t2 WHERE t1.ts = t2.ts ``` -在超级表与超级表之间的 JOIN 操作中,除了主键时间戳一致的条件外,还要求引入能实现一一对应的标签列的相等关系。例如: +In the join operation between STable and STable, besides the primary key, i.e. timestamp, tags can also be used. For example: ```sql SELECT * -FROM temp_stable t1, temp_stable t2 +FROM temp_STable t1, temp_STable t2 WHERE t1.ts = t2.ts AND t1.deviceid = t2.deviceid AND t1.status=0; ``` -类似地,也可以对多个子查询的查询结果进行 JOIN 操作。 +Similary, join operation can be performed on the result set of multiple sub queries. :::note +Restrictions on join operation: -JOIN语句存在如下限制要求: - -- 参与一条语句中 JOIN 操作的表/超级表最多可以有 10 个。 -- 在包含 JOIN 操作的查询语句中不支持 FILL。 -- 暂不支持参与 JOIN 操作的表之间聚合后的四则运算。 -- 不支持只对其中一部分表做 GROUP BY。 -- JOIN 查询的不同表的过滤条件之间不能为 OR。 -- JOIN 查询要求连接条件不能是普通列,只能针对标签和主时间字段列(第一列)。 +- The number of tables or STables in single join operation can't exceed 10. +- `FILL` is not allowed in the query statement that includes JOIN operation. +- Arithmetic operation is not allowed on the result set of join operation. +- `GROUP BY` is not allowed on a part of tables that participate in join operation. +- `OR` can't be used in the conditions for join operation +- join operation can't be performed on data columns, i.e. can only be performed on tags or primary key, i.e. timestamp ::: -## 嵌套查询 +## Nested Query -“嵌套查询”又称为“子查询”,也即在一条 SQL 语句中,“内层查询”的计算结果可以作为“外层查询”的计算对象来使用。 +Nested query is also called sub query, that means in a single SQL statement the result of inner query can be used as the data source of the outer query. -从 2.2.0.0 版本开始,TDengine 的查询引擎开始支持在 FROM 子句中使用非关联子查询(“非关联”的意思是,子查询不会用到父查询中的参数)。也即在普通 SELECT 语句的 tb_name_list 位置,用一个独立的 SELECT 语句来代替(这一 SELECT 语句被包含在英文圆括号内),于是完整的嵌套查询 SQL 语句形如: +From 2.2.0.0, unassociated sub query can be used in the `FROM` clause. unassociated means the sub query doesn't use the parameters in the parent query. More specifically, in the `tb_name_list` of `SELECT` statement, an independent SELECT statement can be used. So a complete nested query looks like: -``` +```SQL SELECT ... FROM (SELECT ... FROM ...) ...; ``` :::info -- 目前仅支持一层嵌套,也即不能在子查询中再嵌入子查询。 -- 内层查询的返回结果将作为“虚拟表”供外层查询使用,此虚拟表可以使用 AS 语法做重命名,以便于外层查询中方便引用。 -- 目前不能在“连续查询”功能中使用子查询。 -- 在内层和外层查询中,都支持普通的表间/超级表间 JOIN。内层查询的计算结果也可以再参与数据子表的 JOIN 操作。 -- 目前内层查询、外层查询均不支持 UNION 操作。 -- 内层查询支持的功能特性与非嵌套的查询语句能力是一致的。 - - 内层查询的 ORDER BY 子句一般没有意义,建议避免这样的写法以免无谓的资源消耗。 -- 与非嵌套的查询语句相比,外层查询所能支持的功能特性存在如下限制: - - 计算函数部分: - - 如果内层查询的结果数据未提供时间戳,那么计算过程依赖时间戳的函数在外层会无法正常工作。例如:TOP, BOTTOM, FIRST, LAST, DIFF。 - - 计算过程需要两遍扫描的函数,在外层查询中无法正常工作。例如:此类函数包括:STDDEV, PERCENTILE。 - - 外层查询中不支持 IN 算子,但在内层中可以使用。 - - 外层查询不支持 GROUP BY。 +- Only one layer of nesting is allowed, that means no sub query is allowed in a sub query +- The result set returned by the inner query will be used as a "virtual table" by the outer query, the "virtual table" can be renamed using `AS` keyword for easy reference in the outer query. +- Sub query is not allowed in continuous query. +- JOIN operation is allowed between tables/STables inside both inner and outer queries. Join operation can be performed on the result set of the inner query. +- UNION operation is not allowed in either inner query or outer query. +- The functionalities that can be used in the inner query is same as non-nested query. + - `ORDER BY` inside the inner query doesn't make any sense but will slow down the query performance significantly, so please avoid such usage. +- Compared to the non-nested query, the functionalities that can be used in the outer query have such restrictions as: + - Functions + - If the result set returned by the inner query doesn't contain timestamp column, then functions relying on timestamp can't be used in the outer query, like `TOP`, `BOTTOM`, `FIRST`, `LAST`, `DIFF`. + - Functions that need to scan the data twice can't be used in the outer query, like `STDDEV`, `PERCENTILE`. + - `IN` operator is not allowed in the outer query but can be used in the inner query. + - `GROUP BY` is not supported in the outer query. ::: -## UNION ALL 子句 +## UNION ALL -```txt title=语法 +```SQL title=Syntax SELECT ... UNION ALL SELECT ... [UNION ALL SELECT ...] ``` -TDengine 支持 UNION ALL 操作符。也就是说,如果多个 SELECT 子句返回结果集的结构完全相同(列名、列类型、列数、顺序),那么可以通过 UNION ALL 把这些结果集合并到一起。目前只支持 UNION ALL 模式,也即在结果集的合并过程中是不去重的。在同一个 sql 语句中,UNION ALL 最多支持 100 个。 +`UNION ALL` operator can be used to combine the result set from multiple select statements as long as the result set of these select statements have exactly same columns. `UNION ALL` doesn't remove redundant rows from multiple result sets. In single SQL statement, at most 100 `UNION ALL` can be supported. -### SQL 示例 +### Examples -对于下面的例子,表 tb1 用以下语句创建: +table `tb1` is created using below SQL statement: -``` +```SQL CREATE TABLE tb1 (ts TIMESTAMP, col1 INT, col2 FLOAT, col3 BINARY(50)); ``` -查询 tb1 刚过去的一个小时的所有记录: +The rows in the past one hour in `tb1` can be selected using below SQL statement: -``` +```SQL SELECT * FROM tb1 WHERE ts >= NOW - 1h; ``` -查询表 tb1 从 2018-06-01 08:00:00.000 到 2018-06-02 08:00:00.000 时间范围,并且 col3 的字符串是'nny'结尾的记录,结果按照时间戳降序: +The rows between 2018-06-01 08:00:00.000 and 2018-06-02 08:00:00.000 and col3 ends with 'nny' can be selected in the descending order of timestamp using below SQL statement: -``` +```SQL SELECT * FROM tb1 WHERE ts > '2018-06-01 08:00:00.000' AND ts <= '2018-06-02 08:00:00.000' AND col3 LIKE '%nny' ORDER BY ts DESC; ``` -查询 col1 与 col2 的和,并取名 complex, 时间大于 2018-06-01 08:00:00.000, col2 大于 1.2,结果输出仅仅 10 条记录,从第 5 条开始: +The sum of col1 and col2 for rows later than 2018-06-01 08:00:00.000 and whose col2 is bigger than 1.2 can be selected and renamed as "complex", while only 10 rows are output from the 5th row, by below SQL statement: -``` +```SQL SELECT (col1 + col2) AS 'complex' FROM tb1 WHERE ts > '2018-06-01 08:00:00.000' AND col2 > 1.2 LIMIT 10 OFFSET 5; ``` -查询过去 10 分钟的记录,col2 的值大于 3.14,并且将结果输出到文件 `/home/testoutpu.csv`: +The rows in the past 10 minutes and whose col2 is bigger than 3.14 are selected and output to the result file `/home/testoutpu.csv` with below SQL statement: -``` +```SQL SELECT COUNT(*) FROM tb1 WHERE ts >= NOW - 10m AND col2 > 3.14 >> /home/testoutpu.csv; ``` - diff --git a/docs-en/12-taos-sql/07-function.md b/docs-en/12-taos-sql/07-function.md index de993020740abe39a177f8107f0388dcc439a17e..44389f35a2a8ab50a0a5a8ed49286cf55240d597 100644 --- a/docs-en/12-taos-sql/07-function.md +++ b/docs-en/12-taos-sql/07-function.md @@ -1,11 +1,10 @@ --- -sidebar_label: SQL 函数 -title: SQL 函数 +title: Functions --- -## 聚合函数 +## Aggregate Functions -TDengine 支持针对数据的聚合查询。提供支持的聚合和选择函数如下: +Aggregate query is supported in TDengine by following aggregate functions and selection functions. ### COUNT @@ -13,21 +12,20 @@ TDengine 支持针对数据的聚合查询。提供支持的聚合和选择函 SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; ``` -**功能说明**:统计表/超级表中记录行数或某列的非空值个数。 +**Description**:Get the number of rows or the number of non-null values in a table or a super table. -**返回数据类型**:长整型 INT64。 +**Return value type**:Long integer INT64 -**应用字段**:应用全部字段。 +**Applicable column types**:All -**适用于**:表、超级表。 +**Applicable table types**: table, super table, sub table -**使用说明**: +**More explanation**: -- 可以使用星号(\*)来替代具体的字段,使用星号(\*)返回全部记录数量。 -- 针对同一表的(不包含 NULL 值)字段查询结果均相同。 -- 如果统计对象是具体的列,则返回该列中非 NULL 值的记录数量。 +- Wildcard (\*) can be used to represent all columns, it's used to get the number of all rows +- The number of non-NULL values will be returned if this function is used on a specific column -**示例**: +**Examples**: ``` taos> SELECT COUNT(*), COUNT(voltage) FROM meters; @@ -49,15 +47,15 @@ Query OK, 1 row(s) in set (0.001075s) SELECT AVG(field_name) FROM tb_name [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列的平均值。 +**Description**:Get the average value of a column in a table or STable -**返回数据类型**:双精度浮点数 Double。 +**Return value type**:Double precision floating number -**应用字段**:不能应用在 timestamp、binary、nchar、bool 字段。 +**Applicable column types**:Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表。 +**Applicable table types**:table, STable -**示例**: +**Examples**: ``` taos> SELECT AVG(current), AVG(voltage), AVG(phase) FROM meters; @@ -79,17 +77,17 @@ Query OK, 1 row(s) in set (0.000943s) SELECT TWA(field_name) FROM tb_name WHERE clause; ``` -**功能说明**:时间加权平均函数。统计表中某列在一段时间内的时间加权平均。 +**Description**:Time weighted average on a specific column within a time range -**返回数据类型**:双精度浮点数 Double。 +**Return value type**:Double precision floating number -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**:Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表。 +**Applicable table types**:table, STable -**使用说明**: +**More explanations**: -- 从 2.1.3.0 版本开始,TWA 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 +- From version 2.1.3.0, function TWA can be used on stble with `GROUP BY`, i.e. timelines generated by `GROUP BY tbname` on a STable. ### IRATE @@ -97,17 +95,17 @@ SELECT TWA(field_name) FROM tb_name WHERE clause; SELECT IRATE(field_name) FROM tb_name WHERE clause; ``` -**功能说明**:计算瞬时增长率。使用时间区间中最后两个样本数据来计算瞬时增长速率;如果这两个值呈递减关系,那么只取最后一个数用于计算,而不是使用二者差值。 +**Description**:instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values. -**返回数据类型**:双精度浮点数 Double。 +**Return value type**:Double precision floating number -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**:Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表。 +**Applicable table types**:table, STable -**使用说明**: +**More explanations**: -- 从 2.1.3.0 版本开始此函数可用,IRATE 可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 +- From version 2.1.3.0, function IRATE can be used on stble with `GROUP BY`, i.e. timelines generated by `GROUP BY tbname` on a STable. ### SUM @@ -115,15 +113,15 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; SELECT SUM(field_name) FROM tb_name [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列的和。 +**Description**:The sum of a specific column in a table or STable -**返回数据类型**:双精度浮点数 Double 和长整型 INT64。 +**Return value type**:Double precision floating number or long integer -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**:Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表。 +**Applicable table types**:table, STable -**示例**: +**Examples**: ``` taos> SELECT SUM(current), SUM(voltage), SUM(phase) FROM meters; @@ -145,15 +143,15 @@ Query OK, 1 row(s) in set (0.000980s) SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ``` -**功能说明**:统计表中某列的均方差。 +**Description**:Standard deviation of a specific column in a table or STable -**返回数据类型**:双精度浮点数 Double。 +**Return value type**:Double precision floating number -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**:Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表(从 2.0.15.1 版本开始) +**Applicable table types**:table, STable (starting from version 2.0.15.1) -**示例**: +**Examples**: ``` taos> SELECT STDDEV(current) FROM d1001; @@ -169,15 +167,15 @@ Query OK, 1 row(s) in set (0.000915s) SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause]; ``` -**功能说明**:统计表中某列的值是主键(时间戳)的拟合直线方程。start_val 是自变量初始值,step_val 是自变量的步长值。 +**Description**:统计表中某列的值是主键(时间戳)的拟合直线方程.start_val 是自变量初始值,step_val 是自变量的步长值. -**返回数据类型**:字符串表达式(斜率, 截距)。 +**Return value type**:A string in the format of "(slope, intercept)" -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**:Data types except for timestamp, binary, nchar and bool -**适用于**:表。 +**Applicable table types**:table only -**示例**: +**Examples**: ``` taos> SELECT LEASTSQUARES(current, 1, 1) FROM d1001; @@ -193,17 +191,17 @@ Query OK, 1 row(s) in set (0.000921s) SELECT MODE(field_name) FROM tb_name [WHERE clause]; ``` -**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出空。不能匹配标签、时间戳输出。 +**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence. It can't be used on timestamp column or tags. -**返回数据类型**:同应用的字段。 +**Return value type**:Same as the data type of the column being operated -**应用字段**:适合于除时间主列外的任何类型字段。 +**Applicable column types**:Data types except for timestamp -**使用说明**:由于返回数据量未知,考虑到内存因素,为了函数可以正常返回结果,建议不重复的数据量在 10 万级别,否则会报错。 +**More explanations**:Considering the number of returned result set is unpredictable, it's suggested to limit the number of unique values to 100,000, otherwise error will be returned. -**支持的版本**:2.6.0.0 及以后的版本。 +**Applicable version**:From version 2.6.0.0 -**示例**: +**Examples**: ``` taos> select voltage from d002; @@ -228,17 +226,17 @@ Query OK, 1 row(s) in set (0.019393s) SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**: - - 采用 hyperloglog 算法,返回某列的基数。该算法在数据量很大的情况下,可以明显降低内存的占用,但是求出来的基数是个估算值,标准误差(标准误差是多次实验,每次的平均数的标准差,不是与真实结果的误差)为 0.81%。 - - 在数据量较少的时候该算法不是很准确,可以使用 select count(data) from (select unique(col) as data from table) 的方法。 +**Description**:The cardinal number of a specific column is returned by using hyperloglog algorithm. -**返回结果类型**:整形。 +**Return value type**:Integer -**应用字段**:适合于任何类型字段。 +**Applicable column types**:Any data type -**支持的版本**:2.6.0.0 及以后的版本。 +**More explanations**: The benefit of using hyperloglog algorithm is that the memory usage is under control when the data volume is huge. However, when the data volume is very small, the result may be not accurate, it's recommented to use `select count(data) from (select unique(col) as data from table)` in this case. -**示例**: +**Applicable versions**:From version 2.6.0.0 + +**Examples**: ``` taos> select dbig from shll; @@ -261,9 +259,9 @@ taos> select hyperloglog(dbig) from shll; Query OK, 1 row(s) in set (0.008388s) ``` -## 选择函数 +## Selection Functions -在使用所有的选择函数的时候,可以同时指定输出 ts 列或标签列(包括 tbname),这样就可以方便地知道被选出的值是源于哪个数据行的。 +When any selective function is used, timestamp column or tag columns including `tbname` can be specified to show that the selected value are from which rows. ### MIN @@ -271,15 +269,15 @@ Query OK, 1 row(s) in set (0.008388s) SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列的值最小值。 +**Description**:The minimum value of a specific column in a table or STable -**返回数据类型**:同应用的字段。 +**Return value type**:Same as the data type of the column being operated -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**:Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表。 +**Applicable table types**:table, STable -**示例**: +**Examples**: ``` taos> SELECT MIN(current), MIN(voltage) FROM meters; @@ -301,15 +299,15 @@ Query OK, 1 row(s) in set (0.000950s) SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列的值最大值。 +**Description**:The maximum value of a specific column of a table or STable -**返回数据类型**:同应用的字段。 +**Return value type**:Same as the data type of the column being operated -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**:Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表。 +**Applicable table types**:table, STable -**示例**: +**Examples**: ``` taos> SELECT MAX(current), MAX(voltage) FROM meters; @@ -331,21 +329,21 @@ Query OK, 1 row(s) in set (0.000987s) SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列的值最先写入的非 NULL 值。 +**Description**:The first non-null value of a specific column in a table or STable -**返回数据类型**:同应用的字段。 +**Return value type**:Same as the column being operated -**应用字段**:所有字段。 +**Applicable column types**:Any data type -**适用于**:表、超级表。 +**Applicable table types**:table, STable -**使用说明**: +**More explanations**: -- 如果要返回各个列的首个(时间戳最小)非 NULL 值,可以使用 FIRST(\*); -- 如果结果集中的某列全部为 NULL 值,则该列的返回结果也是 NULL; -- 如果结果集中所有列全部为 NULL 值,则不返回结果。 +- FIRST(\*) can be used to get the first non-null value of all columns +- NULL will be returned if all the values of the specified column are all NULL +- No result will NOT be returned if all the columns in the result set are all NULL -**示例**: +**Examples**: ``` taos> SELECT FIRST(*) FROM meters; @@ -367,22 +365,21 @@ Query OK, 1 row(s) in set (0.001023s) SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列的值最后写入的非 NULL 值。 - -**返回数据类型**:同应用的字段。 +**Description**:The last non-NULL value of a specific column in a table or STable -**应用字段**:所有字段。 +**Return value type**:Same as the column being operated -**适用于**:表、超级表。 +**Applicable column types**:Any data type -**使用说明**: +**Applicable table types**:table, STable -- 如果要返回各个列的最后(时间戳最大)一个非 NULL 值,可以使用 LAST(\*); -- 如果结果集中的某列全部为 NULL 值,则该列的返回结果也是 NULL;如果结果集中所有列全部为 NULL 值,则不返回结果。 -- 在用于超级表时,时间戳完全一样且同为最大的数据行可能有多个,那么会从中随机返回一条,而并不保证多次运行所挑选的数据行必然一致。 +**More explanations**: +- LAST(\*) can be used to get the last non-NULL value of all columns +- If the values of a column in the result set are all NULL, NULL is returned for that column; if all columns in the result are all NULL, no result will be returned. +- When it's used on a STable, if there are multiple values with the timestamp in the result set, one of them will be returned randomly and it's not guaranteed that the same value is returned if the same query is run multiple times. -**示例**: +**Examples**: ``` taos> SELECT LAST(*) FROM meters; @@ -404,21 +401,21 @@ Query OK, 1 row(s) in set (0.000843s) SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**: 统计表/超级表中某列的值最大 _k_ 个非 NULL 值。如果多条数据取值一样,全部取用又会超出 k 条限制时,系统会从相同值中随机选取符合要求的数量返回。 +**Description**: The greatest _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. -**返回数据类型**:同应用的字段。 +**Return value type**:Same as the column being operated -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**:Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表。 +**Applicable table types**:table, STable -**使用说明**: +**More explanations**: -- *k*值取值范围 1≤*k*≤100; -- 系统同时返回该记录关联的时间戳列; -- 限制:TOP 函数不支持 FILL 子句。 +- _k_ must be in range [1,100] +- The timestamp associated with the selected values are returned too +- Can't be used with `FILL` -**示例**: +**Examples**: ``` taos> SELECT TOP(current, 3) FROM meters; @@ -443,21 +440,21 @@ Query OK, 2 row(s) in set (0.000810s) SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列的值最小 _k_ 个非 NULL 值。如果多条数据取值一样,全部取用又会超出 k 条限制时,系统会从相同值中随机选取符合要求的数量返回。 +**Description**:The least _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. -**返回数据类型**:同应用的字段。 +**Return value type**:Same as the column being operated -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**使用说明**: +**More explanations**: -- *k*值取值范围 1≤*k*≤100; -- 系统同时返回该记录关联的时间戳列; -- 限制:BOTTOM 函数不支持 FILL 子句。 +- _k_ must be in range [1,100] +- The timestamp associated with the selected values are returned too +- Can't be used with `FILL` -**示例**: +**Examples**: ``` taos> SELECT BOTTOM(voltage, 2) FROM meters; @@ -481,17 +478,17 @@ Query OK, 2 row(s) in set (0.000793s) SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; ``` -**功能说明**:统计表中某列的值百分比分位数。 +**Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned. -**返回数据类型**: 双精度浮点数 Double。 +**Return value type**: Double precision floating point -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**适用于**:表。 +**Applicable table types**: table -**使用说明**:*P*值取值范围 0≤*P*≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX。 +**More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. -**示例**: +**Examples**: ``` taos> SELECT PERCENTILE(current, 20) FROM d1001; @@ -508,22 +505,21 @@ SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:统计表/超级表中指定列的值百分比分位数,与 PERCENTILE 函数相似,但是返回近似结果。 +**Description**: Similar to `PERCENTILE`, but a simulated result is returned -**返回数据类型**: 双精度浮点数 Double。 +**Return value type**: Double precision floating point -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**使用说明** +**More explanations** -- **P**值有效取值范围 0≤P≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX; -- **algo_type**的有效输入:**default** 和 **t-digest** -- 用于指定计算近似分位数的算法。可不提供第三个参数的输入,此时将使用 default 的算法进行计算,即 apercentile(column_name, 50, "default") 与 apercentile(column_name, 50) 等价。 -- 当使用“t-digest”参数的时候,将使用 t-digest 方式采样计算近似分位数。但该参数指定计算算法的功能从 2.2.0.x 版本开始支持,2.2.0.0 之前的版本不支持指定使用算法的功能。 +- _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. +- **algo_type** can only be input as `default` or `t-digest`, if it's not specified `default` will be used, i.e. `apercentile(column_name, 50)` is same as `apercentile(column_name, 50, "default")`. +- When `t-digest` is used, `t-digest` sampling is used to calculate. It can be used from version 2.2.0.0. -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Nested query**: It can be used in both the outer query and inner query in a nested query. ``` taos> SELECT APERCENTILE(current, 20) FROM d1001; @@ -551,20 +547,20 @@ Query OK, 1 row(s) in set (0.011639s) SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; ``` -**功能说明**:返回表/超级表的最后一条记录。 +**Description**: The last row of a table or STable -**返回数据类型**:同应用的字段。 +**Return value type**: Same as the column being operated -**应用字段**:所有字段。 +**Applicable column types**: Any data type -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**使用说明**: +**More explanations**: -- 在用于超级表时,时间戳完全一样且同为最大的数据行可能有多个,那么会从中随机返回一条,而并不保证多次运行所挑选的数据行必然一致。 -- 不能与 INTERVAL 一起使用。 +- When it's used against a STable, multiple rows with the same and largest timestamp may exist, in this case one of them is returned randomly and it's not guaranteed that the result is same if the query is run multiple times. +- Can't be used with `INTERVAL`. -**示例**: +**Examples**: ``` taos> SELECT LAST_ROW(current) FROM meters; @@ -580,85 +576,83 @@ SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; Query OK, 1 row(s) in set (0.001042s) ``` -### INTERP [2.3.1 及之后的版本] +### INTERP [From version 2.3.1] ``` SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ RANGE(timestamp1,timestamp2) ] [EVERY(interval)] [FILL ({ VALUE | PREV | NULL | LINEAR | NEXT})]; ``` -**功能说明**:返回表/超级表的指定时间截面指定列的记录值(插值)。 +**Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned. -**返回数据类型**:同字段类型。 +**Return value type**: same as the column being operated -**应用字段**:数值型字段。 +**Applicable column types**: Numeric data types -**适用于**:表、超级表、嵌套查询。 +**Applicable table types**: table, STable, nested query +**More explanations** -**使用说明** +- `INTERP` is used to get the value that matches the specified time slice from a column. If no such value exists an interpolation value will be returned based on `FILL` parameter. +- The input data of `INTERP` is the value of the specified column, `where` can be used to filter the original data. If no `where` condition is specified then all original data is the input. +- The output time range of `INTERP` is specified by `RANGE(timestamp1,timestamp2)` parameter, with timestamp1<=timestamp2. timestamp1 is the starting point of the output time range and must be specified. timestamp2 is the ending point of the output time range and must be specified. If `RANGE` is not specified, then the timestamp of the first row that matches the filter condition is treated as timestamp1, the timestamp of the last row that matches the filter condition is treated as timestamp2. +- The number of rows in the result set of `INTERP` is determined by the parameter `EVERY`. Starting from timestamp1, one interpolation is performed for every time interval specified `EVERY` parameter. If `EVERY` parameter is not used, the time windows will be considered as no ending timestamp, i.e. there is only one time window from timestamp1. +- Interpolation is performed based on `FILL` parameter. No interpolation is performed if `FILL` is not used, that means either the original data that matches is returned or nothing is returned. +- `INTERP` can only be used to interpolate in single timeline. So it must be used with `group by tbname` when it's used on a STable. It can't be used with `GROUP BY` when it's used in the inner query of a nested query. +- The result of `INTERP` is not influenced by `ORDER BY TIMESTAMP`, which impacts the output order only.. -- INTERP 用于在指定时间断面获取指定列的记录值,如果该时间断面不存在符合条件的行数据,那么会根据 FILL 参数的设定进行插值。 -- INTERP 的输入数据为指定列的数据,可以通过条件语句(where 子句)来对原始列数据进行过滤,如果没有指定过滤条件则输入为全部数据。 -- INTERP 的输出时间范围根据 RANGE(timestamp1,timestamp2)字段来指定,需满足 timestamp1<=timestamp2。其中 timestamp1(必选值)为输出时间范围的起始值,即如果 timestamp1 时刻符合插值条件则 timestamp1 为输出的第一条记录,timestamp2(必选值)为输出时间范围的结束值,即输出的最后一条记录的 timestamp 不能大于 timestamp2。如果没有指定 RANGE,那么满足过滤条件的输入数据中第一条记录的 timestamp 即为 timestamp1,最后一条记录的 timestamp 即为 timestamp2,同样也满足 timestamp1 <= timestamp2。 -- INTERP 根据 EVERY 字段来确定输出时间范围内的结果条数,即从 timestamp1 开始每隔固定长度的时间(EVERY 值)进行插值。如果没有指定 EVERY,则默认窗口大小为无穷大,即从 timestamp1 开始只有一个窗口。 -- INTERP 根据 FILL 字段来决定在每个符合输出条件的时刻如何进行插值,如果没有 FILL 字段则默认不插值,即输出为原始记录值或不输出(原始记录不存在)。 -- INTERP 只能在一个时间序列内进行插值,因此当作用于超级表时必须跟 group by tbname 一起使用,当作用嵌套查询外层时内层子查询不能含 GROUP BY 信息。 -- INTERP 的插值结果不受 ORDER BY timestamp 的影响,ORDER BY timestamp 只影响输出结果的排序。 +**Examples**: Based on the `meters` schema used throughout the documents -**SQL示例(基于文档中广泛使用的电表 schema )**: - -- 单点线性插值 +- Single point linear interpolation between "2017-07-14 18:40:00" and "2017-07-14 18:40:00: ``` taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:40:00','2017-7-14 18:40:00') FILL(LINEAR); ``` -- 在2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行取值(不插值) +- Get an original data every 5 seconds, no interpolation, between "2017-07-14 18:00:00" and "2017-07-14 19:00:00: ``` taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s); ``` -- 在2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行线性插值 +- Linear interpolation every 5 seconds between "2017-07-14 18:00:00" and "2017-07-14 19:00:00: ``` taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); ``` -- 在所有时间范围内每隔 5 秒钟进行向后插值 +- Backward interpolation every 5 seconds ``` taos> SELECT INTERP(current) FROM t1 EVERY(5s) FILL(NEXT); ``` -- 根据 2017-07-14 17:00:00 到 2017-07-14 20:00:00 间的数据进行从 2017-07-14 18:00:00 到 2017-07-14 19:00:00 间每隔 5 秒钟进行线性插值 +- Linear interpolation every 5 seconds between "2017-07-14 17:00:00" and "2017-07-14 20:00:00" ``` - taos> SELECT INTERP(current) FROM t1 where ts >= '2017-07-14 17:00:00' and ts <= '2017-07-14 20:00:00' RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); + taos> SELECT INTERP(current) FROM t1 where ts >= '2017-07-14 17:00:00' and ts <= '2017-07-14 20:00:00' RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); ``` -### INTERP [2.3.1 之前的版本] +### INTERP [Prior to version 2.3.1] ``` SELECT INTERP(field_name) FROM { tb_name | stb_name } WHERE ts='timestamp' [FILL ({ VALUE | PREV | NULL | LINEAR | NEXT})]; ``` -**功能说明**:返回表/超级表的指定时间截面、指定字段的记录。 - -**返回数据类型**:同字段类型。 +**Description**: The value of a specific column that matches the specified time slice -**应用字段**:数值型字段。 +**Return value type**: Same as the column being operated -**适用于**:表、超级表。 +**Applicable column types**: Numeric data type -**使用说明**: +**Applicable table types**: table, STable -- 从 2.0.15.0 及以后版本可用 -- INTERP 必须指定时间断面,如果该时间断面不存在直接对应的数据,那么会根据 FILL 参数的设定进行插值。此外,条件语句里面可附带筛选条件,例如标签、tbname。 -- INTERP 查询要求查询的时间区间必须位于数据集合(表)的所有记录的时间范围之内。如果给定的时间戳位于时间范围之外,即使有插值指令,仍然不返回结果。 -- 单个 INTERP 函数查询只能够针对一个时间点进行查询,如果需要返回等时间间隔的断面数据,可以通过 INTERP 配合 EVERY 的方式来进行查询处理(而不是使用 INTERVAL),其含义是每隔固定长度的时间进行插值 +**More explanations**: -**示例**: +- It can be used from version 2.0.15.0 +- Time slice must be specified. If there is no data matching the specified time slice, interpolation is performed based on `FILL` parameter. Conditions such as tags or `tbname` can be used `Where` clause can be used to filter data. +- The timestamp specified must be within the time range of the data rows of the table or STable. If it is beyond the valid time range, nothing is returned even with `FILL` parameter. +- `INTERP` can be used to query only single time point once. `INTERP` can be used with `EVERY` to get the interpolation value every time interval. +- **Examples**: ``` taos> SELECT INTERP(*) FROM meters WHERE ts='2017-7-14 18:40:00.004'; @@ -668,7 +662,7 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } WHERE ts='timestamp' [FILL Query OK, 1 row(s) in set (0.002652s) ``` -如果给定的时间戳无对应的数据,在不指定插值生成策略的情况下,不会返回结果,如果指定了插值策略,会根据插值策略返回结果。 +If there is not any data corresponding to the specified timestamp, an interpolation value is returned if interpolation policy is specified by `FILL` parameter; or nothing is returned\ ``` taos> SELECT INTERP(*) FROM meters WHERE tbname IN ('d636') AND ts='2017-7-14 18:40:00.005'; @@ -681,7 +675,7 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } WHERE ts='timestamp' [FILL Query OK, 1 row(s) in set (0.003056s) ``` -如下所示代码表示在时间区间 `['2017-7-14 18:40:00', '2017-7-14 18:40:00.014']` 中每隔 5 毫秒 进行一次断面计算。 +Interpolation is performed every 5 milliseconds between `['2017-7-14 18:40:00', '2017-7-14 18:40:00.014']` ``` taos> SELECT INTERP(current) FROM d636 WHERE ts>='2017-7-14 18:40:00' AND ts<='2017-7-14 18:40:00.014' EVERY(5a); @@ -698,17 +692,17 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } WHERE ts='timestamp' [FILL SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; ``` -**功能说明**:返回跳过最后 offset_value 个,然后取连续 k 个记录,不忽略 NULL 值。offset_val 可以不输入。此时返回最后的 k 个记录。当有 offset_val 输入的情况下,该函数功能等效于 `order by ts desc LIMIT k OFFSET offset_val`。 +**Description**: The next _k_ rows are returned after skipping the last `offset_val` rows, NULL values are not ignored. `offset_val` is optional parameter. When it's not specified, the last _k_ rows are returned. When `offset_val` is used, the effect is same as `order by ts desc LIMIT k OFFSET offset_val`. -**参数范围**:k: [1,100] offset_val: [0,100]。 +**Parameter value range**: k: [1,100] offset_val: [0,100] -**返回结果数据类型**:同应用的字段。 +**Return value type**: Same as the column being operated -**应用字段**:适合于除时间主列外的任何类型字段。 +**Applicable column types**: Any data type except form timestamp, i.e. the primary key -**支持版本**:2.6.0.0 及之后的版本。 +**Applicable versions**: From version 2.6.0.0 -**示例**: +**Examples**: ``` taos> select ts,dbig from tail2; @@ -736,20 +730,20 @@ Query OK, 2 row(s) in set (0.002307s) SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; ``` -**功能说明**:返回该列的数值首次出现的值。该函数功能与 distinct 相似,但是可以匹配标签和时间戳信息。可以针对除时间列以外的字段进行查询,可以匹配标签和时间戳,其中的标签和时间戳是第一次出现时刻的标签和时间戳。 +**Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword, but it can also be used to match tags or timestamp. -**返回结果数据类型**:同应用的字段。 +**Return value type**: Same as the column or tag being operated -**应用字段**:适合于除时间类型以外的字段。 +**Applicable column types**: Any data types except for timestamp -**支持版本**:2.6.0.0 及之后的版本。 +**支持版本**: From version 2.6.0.0 -**使用说明**: +**More explanations**: -- 该函数可以应用在普通表和超级表上。不能和窗口操作一起使用,例如 interval/state_window/session_window 。 -- 由于返回数据量未知,考虑到内存因素,为了函数可以正常返回结果,建议不重复的数据量在 10 万级别,否则会报错。 +- It can be used against table or STable, but can't be used together with time window, like `interval`, `state_window` or `session_window` . +- Considering the number of result sets is unpredictable, it's suggested to limit the distinct values under 100,000 to control the memory usage, otherwise error will be returned. -**示例**: +**Examples**: ``` taos> select ts,voltage from unique1; @@ -776,38 +770,38 @@ ts | unique(voltage) | Query OK, 5 row(s) in set (0.108458s) ``` -## 计算函数 +## Scalar functions ### DIFF - ```sql - SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHERE clause]; - ``` +```sql +SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHERE clause]; +``` -**功能说明**:统计表中某列的值与前一行对应值的差。 ignore_negative 取值为 0|1 , 可以不填,默认值为 0. 不忽略负值。ignore_negative 为 1 时表示忽略负数。 +**Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored. -**返回结果数据类型**:同应用字段。 +**Return value type**: Same as the column being operated -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**使用说明**: +**More explanations**: -- 输出结果行数是范围内总行数减一,第一行没有结果输出。 -- 从 2.1.3.0 版本开始,DIFF 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 -- 从 2.6.0 开始,DIFF 函数支持 ignore_negative 参数 +- The number of result rows is the number of rows subtracted by one, no output for the first row +- From version 2.1.30, `DIFF` can be used on STable with `GROUP by tbname` +- From version 2.6.0, `ignore_negative` parameter is supported -**示例**: +**Examples**: - ```sql - taos> SELECT DIFF(current) FROM d1001; - ts | diff(current) | - ================================================= - 2018-10-03 14:38:15.000 | 2.30000 | - 2018-10-03 14:38:16.800 | -0.30000 | - Query OK, 2 row(s) in set (0.001162s) - ``` +```sql +taos> SELECT DIFF(current) FROM d1001; + ts | diff(current) | +================================================= +2018-10-03 14:38:15.000 | 2.30000 | +2018-10-03 14:38:16.800 | -0.30000 | +Query OK, 2 row(s) in set (0.001162s) +``` ### DERIVATIVE @@ -815,20 +809,20 @@ Query OK, 5 row(s) in set (0.108458s) SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHERE clause]; ``` -**功能说明**:统计表中某列数值的单位变化率。其中单位时间区间的长度可以通过 time_interval 参数指定,最小可以是 1 秒(1s);ignore_negative 参数的值可以是 0 或 1,为 1 时表示忽略负值。 +**Description**: The derivative of a specific column. The time rage can be specified by parameter `time_interval` 参数指定, the minimum allowed time range is 1 second (1s); the value of `ignore_negative` can be 0 or 1, 1 means negative values are ignored. -**返回数据类型**:双精度浮点数。 +**Return value type**: Double precision floating point -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**适用于**:表、超级表 +**Applicable table types**: table, STable -**使用说明**: +**More explanations**: -- 从 2.1.3.0 及以后版本可用;输出结果行数是范围内总行数减一,第一行没有结果输出。 -- DERIVATIVE 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 +- It is available from version 2.1.3.0, the number of result rows is the number of total rows in the time range subtracted by one, no output for the first row.\ +- It can be used together with `GROUP BY tbname` against a STable. -**示例**: +**Examples**: ``` taos> select derivative(current, 10m, 0) from t1; @@ -848,17 +842,17 @@ Query OK, 5 row(s) in set (0.004883s) SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列的最大值和最小值之差。 +**Description**: The difference between the max and the min of a specific column -**返回数据类型**:双精度浮点数。 +**Return value type**: Double precision floating point -**应用字段**:不能应用在 binary、nchar、bool 类型字段。 +**Applicable column types**: Data types except for binary, nchar, and bool -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**使用说明**:可用于 TIMESTAMP 字段,此时表示记录的时间覆盖范围。 +**More explanations**: Can be used on a column of TIMESTAMP type, the result is the time range size.可 -**示例**: +**Examples**: ``` taos> SELECT SPREAD(voltage) FROM meters; @@ -880,20 +874,21 @@ Query OK, 1 row(s) in set (0.000836s) SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:获得指定列的向上取整数的结果。 +**Description**: The round up value of a specific column -**返回结果类型**:与指定列的原始数据类型一致。例如,如果指定列的原始数据类型为 Float,那么返回的数据类型也为 Float;如果指定列的原始数据类型为 Double,那么返回的数据类型也为 Double。 +**Return value type**: Same as the column being used -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列,无论 tag 列的类型是什么类型。 +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**适用于**: 普通表、超级表。 +**Applicable table types**: table, STable -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable nested query**: inner query and outer query -**使用说明**: +**More explanations**: -- 支持 +、-、\*、/ 运算,如 ceil(col1) + ceil(col2)。 -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- Can't be used on any tags of any type +- Arithmetic operation can be performed on the result of `ceil` function +- Can't be used with aggregate functions ### FLOOR @@ -901,8 +896,9 @@ SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:获得指定列的向下取整数的结果。 - 其他使用说明参见 CEIL 函数描述。 +**Description**: The round down value of a specific column + +**More explanations**: The restrictions are same as `CEIL` function. ### ROUND @@ -910,492 +906,564 @@ SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:获得指定列的四舍五入的结果。 - 其他使用说明参见 CEIL 函数描述。 +**Description**: The round value of a specific column. + +**More explanations**: The restrictions are same as `CEIL` function. ### CSUM - ```sql +```sql SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` + +**Description**: The cumulative sum of each row for a specific column. The number of output rows is same as that of the input rows. + +**Return value type**: Long integer for integers; Double for floating points. Timestamp is returned for each row. - **功能说明**:累加和(Cumulative sum),输出行与输入行数相同。 +**Applicable data types**: Data types except for timestamp, binary, nchar, and bool - **返回结果类型**: 输入列如果是整数类型返回值为长整型 (int64_t),浮点数返回值为双精度浮点数(Double)。无符号整数类型返回值为无符号长整型(uint64_t)。 返回结果中同时带有每行记录对应的时间戳。 +**Applicable table types**: table, STable - **适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在标签之上。 +**Applicable nested query**: Inner query and Outer query - **嵌套子查询支持**: 适用于内层查询和外层查询。 +**More explanations**: - **使用说明**: - - - 不支持 +、-、*、/ 运算,如 csum(col1) + csum(col2)。 - - 只能与聚合(Aggregation)函数一起使用。 该函数可以应用在普通表和超级表上。 - - 使用在超级表上的时候,需要搭配 Group by tbname使用,将结果强制规约到单个时间线。 +- Can't be used on tags when it's used on STable +- Arithmetic operation can't be performed on the result of `csum` function +- Can only be used with aggregate functions +- `Group by tbname` must be used together on a STable to force the result on a single timeline -**支持版本**: 从2.3.0.x开始支持 +**Applicable versions**: From 2.3.0.x ### MAVG - ```sql +```sql SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` + +**Description**: The moving average of continuous _k_ values of a specific column. If the number of input rows is less than _k_, nothing is returned. The applicable range is _k_ is [1,1000]. + +**Return value type**: Double precision floating point - **功能说明**: 计算连续 k 个值的移动平均数(moving average)。如果输入行数小于 k,则无结果输出。参数 k 的合法输入范围是 1≤ k ≤ 1000。 +**Applicable data types**: Data types except for timestamp, binary, nchar, and bool - **返回结果类型**: 返回双精度浮点数类型。 +**Applicable nested query**: Inner query and Outer query - **适用数据类型**: 不能应用在 timestamp、binary、nchar、bool 类型上;在超级表查询中使用时,不能应用在标签之上。 +**Applicable table types**: table, STable - **嵌套子查询支持**: 适用于内层查询和外层查询。 +**More explanations**: - **使用说明**: - - - 不支持 +、-、*、/ 运算,如 mavg(col1, k1) + mavg(col2, k1); - - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用; - - 该函数可以应用在普通表和超级表上;使用在超级表上的时候,需要搭配 Group by tbname使用,将结果强制规约到单个时间线。 +- Arithmetic operation can't be performed on the result of `MAVG`. +- Can only be used with data columns, can't be used with tags. +- Can't be used with aggregate functions.\(Aggregation)函数一起使用; +- Must be used with `GROUP BY tbname` when it's used on a STable to force the result on each single timeline.该 -**支持版本**: 从2.3.0.x开始支持 +**Applicable versions**: From 2.3.0.x ### SAMPLE - ```sql +```sql SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` + +**Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,10000] + +**Return value type**: Same as the column being operated plus the associated timestamp - **功能说明**: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 +**Applicable data types**: Any data type except for tags of STable - **返回结果类型**: 同原始数据类型, 返回结果中带有该行记录的时间戳。 +**Applicable table types**: table, STable - **适用数据类型**: 在超级表查询中使用时,不能应用在标签之上。 +**Applicable nested query**: Inner query and Outer query - **嵌套子查询支持**: 适用于内层查询和外层查询。 +**More explanations**: - **使用说明**: - - - 不能参与表达式计算;该函数可以应用在普通表和超级表上; - - 使用在超级表上的时候,需要搭配 Group by tbname 使用,将结果强制规约到单个时间线。 +- Arithmetic operation can't be operated on the result of `SAMPLE` function +- Must be used with `Group by tbname` when it's used on a STable to force the result on each single timeline -**支持版本**: 从2.3.0.x开始支持 +**Applicable versions**: From 2.3.0.x ### ASIN - ```sql - SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The anti-sine of a specific column + +**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL -**功能说明**:获得指定列的反正弦结果 +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**Applicable table types**: table, STable -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**Applicable nested query**: Inner query and Outer query -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable versions**: From 2.6.0.0 -**使用说明**: +**More explanations**: -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -- 该函数可以应用在普通表和超级表上。 -- 版本2.6.0.x后支持 +- Can't be used with tags +- Can't be used with aggregate functions ### ACOS - ```sql - SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The anti-cosine of a specific column 获 -**功能说明**:获得指定列的反余弦结果 +**Return value type**: ouble if the input value is not NULL; or NULL if the input value is NULL -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**Applicable table types**: table, STable -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable nested query**: Inner query and Outer query -**使用说明**: +**Applicable versions**: From 2.6.0.0 -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -- 该函数可以应用在普通表和超级表上。 -- 版本2.6.0.x后支持 +**More explanations**: + +- Can't be used with tags +- Can't be used with aggregate functions ### ATAN - ```sql - SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: anti-tangent of a specific column -**功能说明**:获得指定列的反正切结果 +**Description**: The anti-cosine of a specific column 获 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable table types**: table, STable -**使用说明**: +**Applicable nested query**: Inner query and Outer query -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -- 该函数可以应用在普通表和超级表上。 -- 版本2.6.0.x后支持 +**Applicable versions**: From 2.6.0.0 + +**More explanations**: + +- Can't be used with tags +- Can't be used with aggregate functions ### SIN - ```sql - SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` -**功能说明**:获得指定列的正弦结果 +**Description**: The sine of a specific column -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**Description**: The anti-cosine of a specific column 获 -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**使用说明**: +**Applicable table types**: table, STable -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -- 该函数可以应用在普通表和超级表上。 -- 版本2.6.0.x后支持 +**Applicable nested query**: Inner query and Outer query + +**Applicable versions**: From 2.6.0.0 + +**More explanations**: + +- Can't be used with tags +- Can't be used with aggregate functions ### COS - ```sql - SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The cosine of a specific column + +**Description**: The anti-cosine of a specific column 获 -**功能说明**:获得指定列的余弦结果 +**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**Applicable table types**: table, STable -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable nested query**: Inner query and Outer query -**使用说明**: +**Applicable versions**: From 2.6.0.0 -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -- 该函数可以应用在普通表和超级表上。 -- 版本2.6.0.x后支持 +**More explanations**: + +- Can't be used with tags +- Can't be used with aggregate functions ### TAN - ```sql - SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The tangent of a specific column -**功能说明**:获得指定列的正切结果 +**Description**: The anti-cosine of a specific column 获 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable table types**: table, STable -**使用说明**: +**Applicable nested query**: Inner query and Outer query -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -- 该函数可以应用在普通表和超级表上。 -- 版本2.6.0.x后支持 +**Applicable versions**: From 2.6.0.0 + +**More explanations**: + +- Can't be used with tags +- Can't be used with aggregate functions ### POW - ```sql - SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The power of a specific column with `power` as the index -**功能说明**:获得指定列的指数为 power 的幂 +**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**Applicable table types**: table, STable -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable nested query**: Inner query and Outer query -**使用说明**: +**Applicable versions**: From 2.6.0.0 -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -- 该函数可以应用在普通表和超级表上。 -- 版本2.6.0.x后支持 +**More explanations**: + +- Can't be used with tags +- Can't be used with aggregate functions ### LOG - ```sql - SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The log of a specific with `base` as the radix + +**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL -**功能说明**:获得指定列对于底数 base 的对数 +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**Applicable table types**: table, STable -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**Applicable nested query**: Inner query and Outer query -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable versions**: From 2.6.0.0 -**使用说明**: +**More explanations**: -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -- 该函数可以应用在普通表和超级表上。 -- 版本2.6.0.x后支持 +- Can't be used with tags +- Can't be used with aggregate functions ### ABS - ```sql - SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The absolute of a specific column + +**Return value type**: UBIGINT if the input value is integer; DOUBLE if the input value is FLOAT/DOUBLE 如 -**功能说明**:获得指定列的绝对值 +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**返回结果类型**:如果输入值为整数,输出值是 UBIGINT 类型。如果输入值是 FLOAT/DOUBLE 数据类型,输出值是 DOUBLE 数据类型。 +**Applicable table types**: table, STable -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**Applicable nested query**: Inner query and Outer query -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable versions**: From 2.6.0.0 -**使用说明**: +**More explanations**: -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -- 该函数可以应用在普通表和超级表上。 -- 版本2.6.0.x后支持 +- Can't be used with tags +- Can't be used with aggregate functions ### SQRT - ```sql - SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The square root of a specific column + +**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL -**功能说明**:获得指定列的平方根 +**Applicable data types**: Data types except for timestamp, binary, nchar, bool -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**Applicable table types**: table, STable -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**Applicable nested query**: Inner query and Outer query -**嵌套子查询支持**:适用于内层查询和外层查询。 +**Applicable versions**: From 2.6.0.0 -**使用说明**: +**More explanations**: -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -- 该函数可以应用在普通表和超级表上。 -- 版本2.6.0.x后支持 +- Can't be used with tags +- Can't be used with aggregate functions ### CAST - ```sql - SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] +``` -**功能说明**:数据类型转换函数,输入参数 expression 支持普通列、常量、标量函数及它们之间的四则运算,不支持 tag 列,只适用于 select 子句中。 +**Description**: It's used for type casting. The input parameter `expression` can be data columns, constants, scalar functions or arithmetic between them. Can't be used with tags, and can only be used in `select` clause. -**返回结果类型**:CAST 中指定的类型(type_name)。 +**Return value type**: The type specified by parameter `type_name` -**适用数据类型**: +**Applicable data types**: -- 输入参数 expression 的类型可以是除 JSON 外目前所有类型字段(BOOL/TINYINT/SMALLINT/INT/BIGINT/FLOAT/DOUBLE/BINARY(M)/TIMESTAMP/NCHAR(M)/TINYINT UNSIGNED/SMALLINT UNSIGNED/INT UNSIGNED/BIGINT UNSIGNED); -- 输出目标类型只支持 BIGINT/BINARY(N)/TIMESTAMP/NCHAR(N)/BIGINT UNSIGNED。 +- Parameter `expression` can be any data type except for JSON, more specifically it can be any of BOOL/TINYINT/SMALLINT/INT/BIGINT/FLOAT/DOUBLE/BINARY(M)/TIMESTAMP/NCHAR(M)/TINYINT UNSIGNED/SMALLINT UNSIGNED/INT UNSIGNED/BIGINT UNSIGNED +- The output data type specified by `type_name` can only be one of BIGINT/BINARY(N)/TIMESTAMP/NCHAR(N)/BIGINT UNSIGNED -**使用说明**: +**Applicable versions**: From 2.6.0.0 -- 对于不能支持的类型转换会直接报错。 -- 如果输入值为NULL则输出值也为NULL。 -- 对于类型支持但某些值无法正确转换的情况对应的转换后的值以转换函数输出为准。目前可能遇到的几种情况: - 1)BINARY/NCHAR转BIGINT/BIGINT UNSIGNED时可能出现的无效字符情况,例如"a"可能转为0。 - 2)有符号数或TIMESTAMP转BIGINT UNSIGNED可能遇到的溢出问题。 - 3)BIGINT UNSIGNED转BIGINT可能遇到的溢出问题。 - 4)FLOAT/DOUBLE转BIGINT/BIGINT UNSIGNED可能遇到的溢出问题。 -- 版本2.6.0.x后支持 +**More explanations**: + +- Error will be reported for unsupported type casting +- NULL will be returned if the input value is NULL +- Some values of some supported data types may not be casted, below are known issues: + 1)When casting BINARY/NCHAR to BIGINT/BIGINT UNSIGNED, some characters may be treated as illegal, for example "a" may be converted to 0. + 2)There may be overflow when casting singed integer or TIMESTAMP to unsigned BIGINT + 3)There may be overflow when casting unsigned BIGINT to BIGINT + 4)There may be overflow when casting FLOAT/DOUBLE to BIGINT or UNSIGNED BIGINT ### CONCAT - ```sql - SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] - ``` +```sql +SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The concatenation result of two or more strings, the number of strings to be concatenated is at least 2 and at most 8 -**功能说明**:字符串连接函数。 +**Return value type**: Same as the columns being operated, BINARY or NCHAR; or NULL if all the input are NULL -**返回结果类型**:同输入参数类型,BINARY 或者 NCHAR。 +**Applicable data types**: The input data must be in either all BINARY or in all NCHAR; can't be used on tag columns -**适用数据类型**:输入参数或者全部是 BINARY 格式的字符串或者列,或者全部是 NCHAR 格式的字符串或者列。不能应用在 TAG 列。 +**Applicable table types**: table, STable -**使用说明**: +**Applicable nested query**: Inner query and Outer query -- 如果输入值为NULL,输出值为NULL。 -- 该函数最小参数个数为2个,最大参数个数为8个。 -- 该函数可以应用在普通表和超级表上。 -- 该函数适用于内层查询和外层查询。 -- 版本2.6.0.x后支持 +**Applicable versions**: From 2.6.0.0 ### CONCAT_WS - ``` - SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` +SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The concatenation result of two or more strings with separator, the number of strings to be concatenated is at least 3 and at most 9 + +**Return value type**: Same as the columns being operated, BINARY or NCHAR; or NULL if all the input are NULL + +**Applicable data types**: The input data must be in either all BINARY or in all NCHAR; can't be used on tag columns -**功能说明**:带分隔符的字符串连接函数。 +**Applicable table types**: table, STable -**返回结果类型**:同输入参数类型,BINARY 或者 NCHAR。 +**Applicable nested query**: Inner query and Outer query -**适用数据类型**:输入参数或者全部是 BINARY 格式的字符串或者列,或者全部是 NCHAR 格式的字符串或者列。不能应用在 TAG 列。 +**Applicable versions**: From 2.6.0.0 -**使用说明**: +**More explanations**: -- 如果separator值为NULL,输出值为NULL。如果separator值不为NULL,其他输入为NULL,输出为空串 -- 该函数最小参数个数为3个,最大参数个数为9个。 -- 该函数可以应用在普通表和超级表上。 -- 该函数适用于内层查询和外层查询。 -- 版本2.6.0.x后支持 +- If the value of `separator` is NULL, the output is NULL. If the value of `separator` is not NULL but other input are all NULL, the output is empty string. ### LENGTH - ``` - SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` +SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The length in bytes of a string + +**Return value type**: Integer -**功能说明**:以字节计数的字符串长度。 +**Applicable data types**: BINARY or NCHAR, can't be used on tags -**返回结果类型**:INT。 +**Applicable table types**: table, STable -**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 +**Applicable nested query**: Inner query and Outer query -**使用说明** +**Applicable versions**: From 2.6.0.0 -- 如果输入值为NULL,输出值为NULL。 -- 该函数可以应用在普通表和超级表上。 -- 函数适用于内层查询和外层查询。 -- 版本2.6.0.x后支持 +**More explanations** + +- If the input value is NULL, the output is NULL too ### CHAR_LENGTH - ``` - SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` +SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The length in number of characters of a string -**功能说明**:以字符计数的字符串长度。 +**Return value type**: Integer -**返回结果类型**:INT。 +**Applicable data types**: BINARY or NCHAR, can't be used on tags -**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 +**Applicable table types**: table, STable -**使用说明** +**Applicable nested query**: Inner query and Outer query -- 如果输入值为NULL,输出值为NULL。 -- 该函数可以应用在普通表和超级表上。 -- 该函数适用于内层查询和外层查询。 -- 版本2.6.0.x后支持 +**Applicable versions**: From 2.6.0.0 + +**More explanations** + +- If the input value is NULL, the output is NULL too ### LOWER - ``` - SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` +SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: Convert the input string to lower case + +**Return value type**: Same as input + +**Applicable data types**: BINARY or NCHAR, can't be used on tags -**功能说明**:将字符串参数值转换为全小写字母。 +**Applicable table types**: table, STable -**返回结果类型**:同输入类型。 +**Applicable nested query**: Inner query and Outer query -**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 +**Applicable versions**: From 2.6.0.0 -**使用说明**: +**More explanations** -- 如果输入值为NULL,输出值为NULL。 -- 该函数可以应用在普通表和超级表上。 -- 该函数适用于内层查询和外层查询。 -- 版本2.6.0.x后支持 +- If the input value is NULL, the output is NULL too ### UPPER - ``` - SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` +SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: Convert the input string to upper case + +**Return value type**: Same as input -**功能说明**:将字符串参数值转换为全大写字母。 +**Applicable data types**: BINARY or NCHAR, can't be used on tags -**返回结果类型**:同输入类型。 +**Applicable table types**: table, STable -**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 +**Applicable nested query**: Inner query and Outer query -**使用说明**: +**Applicable versions**: From 2.6.0.0 -- 如果输入值为NULL,输出值为NULL。 -- 该函数可以应用在普通表和超级表上。 -- 该函数适用于内层查询和外层查询。 -- 版本2.6.0.x后支持 +**More explanations** + +- If the input value is NULL, the output is NULL too ### LTRIM - ``` - SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` +SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: Remove the left leading blanks of a string -**功能说明**:返回清除左边空格后的字符串。 +**Return value type**: Same as input -**返回结果类型**:同输入类型。 +**Applicable data types**: BINARY or NCHAR, can't be used on tags -**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 +**Applicable table types**: table, STable -**使用说明**: +**Applicable nested query**: Inner query and Outer query -- 如果输入值为NULL,输出值为NULL。 -- 该函数可以应用在普通表和超级表上。 -- 该函数适用于内层查询和外层查询。 -- 版本2.6.0.x后支持 +**Applicable versions**: From 2.6.0.0 + +**More explanations** + +- If the input value is NULL, the output is NULL too ### RTRIM - ``` - SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` +SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: Remove the right tailing blanks of a string + +**Return value type**: Same as input + +**Applicable data types**: BINARY or NCHAR, can't be used on tags -**功能说明**:返回清除右边空格后的字符串。 +**Applicable table types**: table, STable -**返回结果类型**:同输入类型。 +**Applicable nested query**: Inner query and Outer query -**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 +**Applicable versions**: From 2.6.0.0 -**使用说明**: +**More explanations** -- 如果输入值为NULL,输出值为NULL。 -- 该函数可以应用在普通表和超级表上。 -- 该函数适用于内层查询和外层查询。 -- 版本2.6.0.x后支持 +- If the input value is NULL, the output is NULL too ### SUBSTR - ``` - SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] - ``` +``` +SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The sub-string starting from `pos` with length of `len` from the original string `str` -**功能说明**:从源字符串 str 中的指定位置 pos 开始取一个长度为 len 的子串并返回。 +**Return value type**: Same as input -**返回结果类型**:同输入类型。 +**Applicable data types**: BINARY or NCHAR, can't be used on tags -**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 +**Applicable table types**: table, STable -**使用说明**: +**Applicable nested query**: Inner query and Outer query -- 如果输入值为NULL,输出值为NULL。 -- 输入参数pos可以为正数,也可以为负数。如果pos是正数,表示开始位置从字符串开头正数计算。如果pos为负数,表示开始位置从字符串结尾倒数计算。如果输入参数len被忽略,返回的子串包含从pos开始的整个字串。 -- 该函数可以应用在普通表和超级表上。 -- 该函数适用于内层查询和外层查询。 -- 版本2.6.0.x后支持 +**Applicable versions**: From 2.6.0.0 -### 四则运算 +**More explanations**: + +- If the input is NULL, the output is NULL +- Parameter `pos` can be an positive or negative integer; If it's positive, the starting position will be counted from the beginning of the string; if it's negative, the starting position will be counted from the end of the string. +- If `len` is not specified, it means from `pos` to the end. + +### Arithmetic Operations ``` SELECT field_name [+|-|*|/|%][Value|field_name] FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列或多列间的值加、减、乘、除、取余计算结果。 +**Description**: The sum, difference, product, quotient, or remainder between one or more columns -**返回数据类型**:双精度浮点数。 +**Return value type**: Double precision floating point -**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 +**Applicable column types**: Data types except for timestamp, binary, nchar, bool -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**使用说明**: +**More explanations**: -- 支持两列或多列之间进行计算,可使用括号控制计算优先级; -- NULL 字段不参与计算,如果参与计算的某行中包含 NULL,该行的计算结果为 NULL。 +- Arithmetic operations can be performed on two or more columns, `()` can be used to control the precedence +- NULL doesn't participate the operation, if one of the operands is NULL then result is NULL + +**Examples**: ``` taos> SELECT current + voltage * phase FROM d1001; @@ -1413,27 +1481,29 @@ Query OK, 3 row(s) in set (0.001046s) SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:返回满足某个条件的连续记录的个数,结果作为新的一列追加在每行后面。条件根据参数计算,如果条件为 true 则加 1,条件为 false 则重置为-1,如果数据为 NULL,跳过该条数据。 +**Description**: The number of continuous rows satisfying the specified conditions for a specific column. The result is shown as an extra column for each row. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped. + +**Applicable parameter values**: -**参数范围**: +- oper : Can be one of LT (lower than), GT (greater than), LE (lower than or euqal to), GE (greater than or equal to), NE (not equal to), EQ (equal to), the value is case insensitive +- val : Numeric types -- oper : LT (小于)、GT(大于)、LE(小于等于)、GE(大于等于)、NE(不等于)、EQ(等于),不区分大小写。 -- val : 数值型 +**Return value type**: Integer -**返回结果类型**:整形。 +**Applicable data types**: Data types excpet for timestamp, binary, nchar, bool -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上。 +**Applicable table types**: table, STable -**嵌套子查询支持**:不支持应用在子查询上。 +**Applicable nested query**: Outer query only -**支持的版本**:2.6 开始的版本。 +**Applicable versions**: From 2.6.0.0 -**使用说明**: +**More explanations**: -- 该函数可以应用在普通表上,在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname) -- 不能和窗口操作一起使用,例如 interval/state_window/session_window。 +- Must be used together with `GROUP BY tbname` when it's used on a STable to force the result into each single timeline] +- Can't be used with window operation, like interval/state_window/session_window -**示例**: +**Examples**: ``` taos> select ts,dbig from statef2; @@ -1465,28 +1535,30 @@ Query OK, 6 row(s) in set (0.002791s) SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:返回满足某个条件的连续记录的时间长度,结果作为新的一列追加在每行后面。条件根据参数计算,如果条件为 true 则加上两个记录之间的时间长度(第一个满足条件的记录时间长度记为 0),条件为 false 则重置为-1,如果数据为 NULL,跳过该条数据。 +**Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The result is shown as an extra column for each row. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped. -**参数范围**: +**Applicable parameter values**: -- oper : LT (小于)、GT(大于)、LE(小于等于)、GE(大于等于)、NE(不等于)、EQ(等于),不区分大小写。 -- val : 数值型 -- unit : 时间长度的单位,范围[1s、1m、1h ],不足一个单位舍去。默认为 1s。 +- oper : Can be one of LT (lower than), GT (greater than), LE (lower than or euqal to), GE (greater than or equal to), NE (not equal to), EQ (equal to), the value is case insensitive +- val : Numeric types +- unit: The unit of time interval, can be [1s, 1m, 1h], default is 1s -**返回结果类型**:整形。 +**Return value type**: Integer -**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上。 +**Applicable data types**: Data types excpet for timestamp, binary, nchar, bool -**嵌套子查询支持**:不支持应用在子查询上。 +**Applicable table types**: table, STable -**支持的版本**:2.6 开始的版本。 +**Applicable nested query**: Outer query only -**使用说明**: +**Applicable versions**: From 2.6.0.0 -- 该函数可以应用在普通表上,在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname) -- 不能和窗口操作一起使用,例如 interval/state_window/session_window。 +**More explanations**: -**示例**: +- Must be used together with `GROUP BY tbname` when it's used on a STable to force the result into each single timeline] +- Can't be used with window operation, like interval/state_window/session_window + +**Examples**: ``` taos> select ts,dbig from statef2; @@ -1512,9 +1584,9 @@ ts | dbig | stateduration(dbig,gt,2) | Query OK, 6 row(s) in set (0.002613s) ``` -## 时间函数 +## Time Functions -从 2.6.0.0 版本开始,TDengine 查询引擎支持以下时间相关函数: +From version 2.6.0.0, below time related functions can be used in TDengine. ### NOW @@ -1524,21 +1596,21 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior NOW() INSERT INTO tb_name VALUES (NOW(), ...); ``` -**功能说明**:返回客户端当前系统时间。 +**Description**: The current time of the client side system -**返回结果数据类型**:TIMESTAMP 时间戳类型。 +**Return value type**: TIMESTAMP -**应用字段**:在 WHERE 或 INSERT 语句中使用时只能作用于 TIMESTAMP 类型的字段。 +**Applicable column types**: TIMESTAMP only -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**使用说明**: +**More explanations**: -- 支持时间加减操作,如 NOW() + 1s, 支持的时间单位如下: - b(纳秒)、u(微秒)、a(毫秒)、s(秒)、m(分)、h(小时)、d(天)、w(周)。 -- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 +- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be: + b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week) +- The precision of the returned timestamp is same as the precision set for the current data base in use -**示例**: +**Examples**: ```sql taos> SELECT NOW() FROM meters; @@ -1571,21 +1643,21 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior TODAY INSERT INTO tb_name VALUES (TODAY(), ...); ``` -**功能说明**:返回客户端当日零时的系统时间。 +**Description**: The timestamp of 00:00:00 of the client side system -**返回结果数据类型**:TIMESTAMP 时间戳类型。 +**Return value type**: TIMESTAMP -**应用字段**:在 WHERE 或 INSERT 语句中使用时只能作用于 TIMESTAMP 类型的字段。 +**Applicable column types**: TIMESTAMP only -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**使用说明**: +**More explanations**: -- 支持时间加减操作,如 TODAY() + 1s, 支持的时间单位如下: - b(纳秒),u(微秒),a(毫秒),s(秒),m(分),h(小时),d(天),w(周)。 -- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 +- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be: + b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week) +- The precision of the returned timestamp is same as the precision set for the current data base in use -**示例**: +**Examples**: ```sql taos> SELECT TODAY() FROM meters; @@ -1616,15 +1688,15 @@ Query OK, 1 of 1 row(s) in database (0.002210s) SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:返回客户端当前时区信息。 +**Description**: The timezone of the client side system -**返回结果数据类型**:BINARY 类型。 +**Return value type**: BINARY -**应用字段**:无 +**Applicable column types**: None -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**示例**: +**Examples**: ```sql taos> SELECT TIMEZONE() FROM meters; @@ -1640,20 +1712,20 @@ Query OK, 1 row(s) in set (0.002093s) SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:将 UNIX 时间戳转换成为 ISO8601 标准的日期时间格式,并附加客户端时区信息。 +**Description**: The ISO8601 date/time format converted from a UNIX timestamp, plus the timezone of the client side system -**返回结果数据类型**:BINARY 类型。 +**Return value type**: BINARY -**应用字段**:UNIX 时间戳常量或是 TIMESTAMP 类型的列 +**Applicable column types**: TIMESTAMP, constant or a column -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**使用说明**: +**More explanations**: -- 如果输入是 UNIX 时间戳常量,返回格式精度由时间戳的位数决定; -- 如果输入是 TIMSTAMP 类型的列,返回格式的时间戳精度与当前 DATABASE 设置的时间精度一致。 +- If the input is UNIX timestamp constant, the precision of the returned value is determined by the digits of the input timestamp +- If the input is a column of TIMESTAMP type, The precision of the returned value is same as the precision set for the current data base in use -**示例**: +**Examples**: ```sql taos> SELECT TO_ISO8601(1643738400) FROM meters; @@ -1675,20 +1747,20 @@ taos> SELECT TO_ISO8601(ts) FROM meters; SELECT TO_UNIXTIMESTAMP(datetime_string | ts_col) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:将日期时间格式的字符串转换成为 UNIX 时间戳。 +**Description**: UNIX timestamp converted from a string of date/time format -**返回结果数据类型**:长整型 INT64。 +**Return value type**: Long integer -**应用字段**:字符串常量或是 BINARY/NCHAR 类型的列。 +**Applicable column types**: Constant or column of BINARY/NCHAR -**适用于**:表、超级表。 +**Applicable table types**: table, STable -**使用说明**: +**More explanations**: -- 输入的日期时间字符串须符合 ISO8601/RFC3339 标准,无法转换的字符串格式将返回 0。 -- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 +- The input string must be compatible with ISO8601/RFC3339 standard, 0 will be returned if the string can't be covnerted +- The precision of the returned timestamp is same as the precision set for the current data base in use -**示例**: +**Examples**: ```sql taos> SELECT TO_UNIXTIMESTAMP("2022-02-02T02:00:00.000Z") FROM meters; @@ -1710,20 +1782,21 @@ taos> SELECT TO_UNIXTIMESTAMP(col_binary) FROM meters; SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:将时间戳按照指定时间单位 time_unit 进行截断。 +**Description**: Truncate the input timestamp with unit specified by `time_unit`\ + +**Return value type**: TIMESTAMP\ -**返回结果数据类型**:TIMESTAMP 时间戳类型。 +**Applicable column types**: UNIX timestamp constant, string constant of date/time format, or a column of timestamp -**应用字段**:UNIX 时间戳,日期时间格式的字符串,或者 TIMESTAMP 类型的列。 +**Applicable table types**: table, STable -**适用于**:表、超级表。 +**More explanations**: -**使用说明**: -- 支持的时间单位 time_unit 如下: - 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天)。 -- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 +- Time unit specified by `time_unit` can be: + 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day). +- The precision of the returned timestamp is same as the precision set for the current data base in use -**示例**: +**Examples**: ```sql taos> SELECT TIMETRUNCATE(1643738522000, 1h) FROM meters; @@ -1753,20 +1826,21 @@ Query OK, 3 row(s) in set (0.003903s) SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 | ts_col2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:计算两个时间戳之间的差值,并近似到时间单位 time_unit 指定的精度。 +**Description**: The difference between two timestamps, and rounded to the time unit specified by `time_unit` + +**Return value type**: Long Integer -**返回结果数据类型**:长整型 INT64。 +**Applicable column types**: UNIX timestamp constant, string constant of date/time format, or a column of TIMESTAMP type -**应用字段**:UNIX 时间戳,日期时间格式的字符串,或者 TIMESTAMP 类型的列。 +**Applicable table types**: table, STable -**适用于**:表、超级表。 +**More explanations**: -**使用说明**: -- 支持的时间单位 time_unit 如下: - 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天)。 -- 如果时间单位 time_unit 未指定, 返回的时间差值精度与当前 DATABASE 设置的时间精度一致。 +- Time unit specified by `time_unit` can be: + 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day). +- The precision of the returned timestamp is same as the precision set for the current data base in use -**示例**: +**Examples**: ```sql taos> SELECT TIMEDIFF(1643738400000, 1643742000000) FROM meters; diff --git a/docs-en/12-taos-sql/08-interval.md b/docs-en/12-taos-sql/08-interval.md index d62e11b0dbd0ba49ceedb3807e05361f060969b3..7c365fc9a66bff349bc9a13b9954f9c395510bd2 100644 --- a/docs-en/12-taos-sql/08-interval.md +++ b/docs-en/12-taos-sql/08-interval.md @@ -1,62 +1,62 @@ --- -sidebar_label: 按窗口切分聚合 -title: 按窗口切分聚合 +sidebar_label: Interval +title: Aggregate by Time Window --- +Aggregate by time window is supported in TDengine. For example, each temperature sensor reports the temperature every second, the average temperature every 10 minutes can be retrieved by query with time window. +Window related clauses are used to divide the data set to be queried into subsets and then aggregate. There are three kinds of windows, time window, status window, and session window. There are two kinds of time windows, sliding window and flip time window. -TDengine 支持按时间段窗口切分方式进行聚合结果查询,比如温度传感器每秒采集一次数据,但需查询每隔 10 分钟的温度平均值。这种场景下可以使用窗口子句来获得需要的查询结果。 -窗口子句用于针对查询的数据集合进行按照窗口切分成为查询子集并进行聚合,窗口包含时间窗口(time window)、状态窗口(status window)、会话窗口(session window)三种窗口。其中时间窗口又可划分为滑动时间窗口和翻转时间窗口。 +## Time Window -## 时间窗口 +`INTERVAL` claused is used to generate time windows of same time interval, `SLIDING` is used to specify the time step for which the time window moves forward. The query is performed on one time window each time, and the time window moves forward with time. When defining continuous query both the size of time window and the step of forward sliding time need to be specified. As shown in the figure blow, [t0s, t0e] ,[t1s , t1e], [t2s, t2e] are respectively the time range of three time windows on which continuous queries are executed. The time step for which time window moves forward is marked by `sliding time`. Query, filter and aggregate operations are executed on each time window respectively. When the time step specified by `SLIDING` is same as the time interval specified by `INTERVAL`, the sliding time window is actually a flip time window. -INTERVAL 子句用于产生相等时间周期的窗口,SLIDING 用以指定窗口向前滑动的时间。每次执行的查询是一个时间窗口,时间窗口随着时间流动向前滑动。在定义连续查询的时候需要指定时间窗口(time window )大小和每次前向增量时间(forward sliding times)。如图,[t0s, t0e] ,[t1s , t1e], [t2s, t2e] 是分别是执行三次连续查询的时间窗口范围,窗口的前向滑动的时间范围 sliding time 标识 。查询过滤、聚合等操作按照每个时间窗口为独立的单位执行。当 SLIDING 与 INTERVAL 相等的时候,滑动窗口即为翻转窗口。 +![Time Window](/img/sql/timewindow-1.png) -![时间窗口示意图](/img/sql/timewindow-1.png) - -INTERVAL 和 SLIDING 子句需要配合聚合和选择函数来使用。以下 SQL 语句非法: +`INTERVAL` and `SLIDING` should be used with aggregate functions and selection functions. Below SQL statement is illegal because no aggregate or selection function is used with `INTERVAL`. ``` SELECT * FROM temp_tb_1 INTERVAL(1m); ``` -SLIDING 的向前滑动的时间不能超过一个窗口的时间范围。以下语句非法: +The time step specified by `SLIDING` can't exceed the time interval specified by `INTERVAL`. Below SQL statement is illegal because the time length specified by `SLIDING` exceeds that specified by `INTERVAL`. ``` SELECT COUNT(*) FROM temp_tb_1 INTERVAL(1m) SLIDING(2m); ``` -当 SLIDING 与 INTERVAL 取值相等的时候,滑动窗口即为翻转窗口。 -_ 聚合时间段的窗口宽度由关键词 INTERVAL 指定,最短时间间隔 10 毫秒(10a);并且支持偏移 offset(偏移必须小于间隔),也即时间窗口划分与“UTC 时刻 0”相比的偏移量。SLIDING 语句用于指定聚合时间段的前向增量,也即每次窗口向前滑动的时长。 -_ 从 2.1.5.0 版本开始,INTERVAL 语句允许的最短时间间隔调整为 1 微秒(1u),当然如果所查询的 DATABASE 的时间精度设置为毫秒级,那么允许的最短时间间隔为 1 毫秒(1a)。 \* **注意**:用到 INTERVAL 语句时,除非极特殊的情况,都要求把客户端和服务端的 taos.cfg 配置文件中的 timezone 参数配置为相同的取值,以避免时间处理函数频繁进行跨时区转换而导致的严重性能影响。 +When the time length specified by `SLIDING` is same as that specified by `INTERVAL`, sliding window is actually flip window. The minimum time range specified by `INTERVAL` is 10 milliseconds (10a) prior to version 2.1.5.0. From version 2.1.5.0, the minimum time range by `INTERVAL` can be 1 microsecond (1u). However, if the DB precision is millisecond, the minimum time range is 1 millisecond (1a). Please be noted that the `timezone` parameter should be configured to same value in the `taos.cfg` configuration file on client side and server side. -## 状态窗口 +## Status Window -使用整数(布尔值)或字符串来标识产生记录时候设备的状态量。产生的记录如果具有相同的状态量数值则归属于同一个状态窗口,数值改变后该窗口关闭。如下图所示,根据状态量确定的状态窗口分别是[2019-04-28 14:22:07,2019-04-28 14:22:10]和[2019-04-28 14:22:11,2019-04-28 14:22:12]两个。(状态窗口暂不支持对超级表使用) +In case of using integer, bool, or string to represent the device status at a moment, the continuous rows with same status belong to same status window. Once the status changes, the status window closes. As shown in the following figure,there are two status windows according to status, [2019-04-28 14:22:07,2019-04-28 14:22:10] and [2019-04-28 14:22:11,2019-04-28 14:22:12]. Status window is not applicable to STable for now. -![时间窗口示意图](/img/sql/timewindow-3.png) +![Status Window](/img/sql/timewindow-3.png) -使用 STATE_WINDOW 来确定状态窗口划分的列。例如: +`STATE_WINDOW` is used to specify the column based on which to define status window, for example: ``` SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status); ``` -## 会话窗口 +## Session Window -会话窗口根据记录的时间戳主键的值来确定是否属于同一个会话。如下图所示,如果设置时间戳的连续的间隔小于等于 12 秒,则以下 6 条记录构成 2 个会话窗口,分别是:[2019-04-28 14:22:10,2019-04-28 14:22:30]和[2019-04-28 14:23:10,2019-04-28 14:23:30]。因为 2019-04-28 14:22:30 与 2019-04-28 14:23:10 之间的时间间隔是 40 秒,超过了连续时间间隔(12 秒)。 +```sql +SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val); +``` -![时间窗口示意图](/img/sql/timewindow-2.png) +The primary key, i.e. timestamp, is used to determine which session window the row belongs to. If the time interval between two adjacent rows is within the time range specified by `tol_val`, they belong to same session window; otherwise they belong to two different time windows. As shown in the figure below, if the limit of time interval for session window is specified as 12 seconds, then the 6 rows in the figure constitutes 2 time windows, [2019-04-28 14:22:10,2019-04-28 14:22:30] and [2019-04-28 14:23:10,2019-04-28 14:23:30], because the time difference between 2019-04-28 14:22:30 and 2019-04-28 14:23:10 is 40 seconds, which exceeds the time interval limit of 12 seconds. -在 tol_value 时间间隔范围内的结果都认为归属于同一个窗口,如果连续的两条记录的时间超过 tol_val,则自动开启下一个窗口。(会话窗口暂不支持对超级表使用) +![Session Window](/img/sql/timewindow-2.png) -``` +If the time interval between two continuous rows are withint the time interval specified by `tol_value` they belong to the same session window; otherwise a new session window is started automatically. Session window is not supported on STable for now. -SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val); -``` +## More On Window Aggregate -这种类型的查询语法如下: +### Syntax -``` +The full syntax of aggregate by window is as following: + +```sql SELECT function_list FROM tb_name [WHERE where_condition] [SESSION(ts_col, tol_val)] @@ -71,39 +71,38 @@ SELECT function_list FROM stb_name [GROUP BY tags] ``` -- 在聚合查询中,function_list 位置允许使用聚合和选择函数,并要求每个函数仅输出单个结果(例如:COUNT、AVG、SUM、STDDEV、LEASTSQUARES、PERCENTILE、MIN、MAX、FIRST、LAST),而不能使用具有多行输出结果的函数(例如:DIFF 以及四则运算)。 -- 此外 LAST_ROW 查询也不能与窗口聚合同时出现。 -- 标量函数(如:CEIL/FLOOR 等)也不能使用在窗口聚合查询中。 -- +### Restrictions -- WHERE 语句可以指定查询的起止时间和其他过滤条件。 -- FILL 语句指定某一窗口区间数据缺失的情况下的填充模式。填充模式包括以下几种: - 1. 不进行填充:NONE(默认填充模式)。 - 2. VALUE 填充:固定值填充,此时需要指定填充的数值。例如:FILL(VALUE, 1.23)。 - 3. PREV 填充:使用前一个非 NULL 值填充数据。例如:FILL(PREV)。 - 4. NULL 填充:使用 NULL 填充数据。例如:FILL(NULL)。 - 5. LINEAR 填充:根据前后距离最近的非 NULL 值做线性插值填充。例如:FILL(LINEAR)。 - 6. NEXT 填充:使用下一个非 NULL 值填充数据。例如:FILL(NEXT)。 +- Aggregate functions and selection functions can be used in `function_list`, with each function having only one output, for example COUNT, AVG, SUM, STDDEV, LEASTSQUARES, PERCENTILE, MIN, MAX, FIRST, LAST. Functions having multiple ouput can't be used, for example DIFF or arithmetic operations. +- `LAST_ROW` can't be used together with window aggregate. +- Scalar functions, like CEIL/FLOOR, can't be used with window aggregate. +- `WHERE` clause can be used to specify the starting and ending time and other filter conditions +- `FILL` clause is used to specify how to fill when there is data missing in any window, including: \ + 1. NONE: No fill (the default fill mode) + 2. VALUE:Fill with a fixed value, which should be specified together, for example `FILL(VALUE, 1.23)` + 3. PREV:Fill with the previous non-NULL value, `FILL(PREV)` + 4. NULL:Fill with NULL, `FILL(NULL)` + 5. LINEAR:Fill with the closest non-NULL value, `FILL(LINEAR)` + 6. NEXT:Fill with the next non-NULL value, `FILL(NEXT)` :::info -1. 使用 FILL 语句的时候可能生成大量的填充输出,务必指定查询的时间区间。针对每次查询,系统可返回不超过 1 千万条具有插值的结果。 -2. 在时间维度聚合中,返回的结果中时间序列严格单调递增。 -3. 如果查询对象是超级表,则聚合函数会作用于该超级表下满足值过滤条件的所有表的数据。如果查询中没有使用 GROUP BY 语句,则返回的结果按照时间序列严格单调递增;如果查询中使用了 GROUP BY 语句分组,则返回结果中每个 GROUP 内不按照时间序列严格单调递增。 +1. Huge volume of interpolation output may be returned using `FILL`, so it's recommended to specify the time range when using `FILL`. The maximum interpolation values that can be returned in single query is 10,000,000. +2. The result set is in the ascending order of timestamp in aggregate by time window aggregate. +3. If aggregate by window is used on STable, the aggregate function is performed on all the rows matching the filter conditions. If `GROUP BY` is not used in the query, the result set will be returned in ascending order of timestamp; otherwise the result set is not exactly in the order of ascending timestamp in each group. + ::: -::: +Aggregate by time window is also used in continuous query, please refer to [Continuous Query](/develop/continuous-query). -时间聚合也常被用于连续查询场景,可以参考文档 [连续查询(Continuous Query)](/develop/continuous-query)。 +## Examples -## 示例 +The table of intelligent meters can be created like below SQL statement: -智能电表的建表语句如下: - -``` +```sql CREATE TABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT); ``` -针对智能电表采集的数据,以 10 分钟为一个阶段,计算过去 24 小时的电流数据的平均值、最大值、电流的中位数。如果没有计算值,用前一个非 NULL 值填充。使用的查询语句如下: +The average current, maximum current and median of current in every 10 minutes of the past 24 hours can be calculated using below SQL statement, with missing value filled with the previous non-NULL value. ``` SELECT AVG(current), MAX(current), APERCENTILE(current, 50) FROM meters diff --git a/docs-en/12-taos-sql/09-limit.md b/docs-en/12-taos-sql/09-limit.md index 3c86a3862174377e6a00d046fb69627c773fe76e..873e484fbb4731294d00df323f8e0d2cbc6b1d30 100644 --- a/docs-en/12-taos-sql/09-limit.md +++ b/docs-en/12-taos-sql/09-limit.md @@ -1,54 +1,77 @@ --- -sidebar_label: 边界限制 -title: 边界限制 +title: Limits & Restrictions --- -## 一般限制 +## Naming Rules -- 数据库名最大长度为 32。 -- 表名最大长度为 192,不包括数据库名前缀和分隔符 -- 每行数据最大长度 16k 个字符, 从 2.1.7.0 版本开始,每行数据最大长度 48k 个字符(注意:数据行内每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置)。 -- 列名最大长度为 64,最多允许 4096 列,最少需要 2 列,第一列必须是时间戳。注:从 2.1.7.0 版本(不含)以前最多允许 4096 列 -- 标签名最大长度为 64,最多允许 128 个,至少要有 1 个标签,一个表中标签值的总长度不超过 16k 个字符。 -- SQL 语句最大长度 1048576 个字符,也可通过客户端配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576。 -- SELECT 语句的查询结果,最多允许返回 4096 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错。注: 2.1.7.0 版本(不含)之前为最多允许 1024 列 -- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制。 +1. Only English characters, digits and underscore are allowed +2. Can't be started with digits +3. Case Insensitive without escape character "\`" +4. Identifier with escape character "\`" + To support more flexible table or column names, a new escape character "\`" is introduced. For more details please refer to [escape](/taos-sql/escape). -## GROUP BY 的限制 +## Password Rule -TAOS SQL 支持对标签、TBNAME 进行 GROUP BY 操作,也支持普通列进行 GROUP BY,前提是:仅限一列且该列的唯一值小于 10 万个。注意:group by 不支持 float,double 类型。 +The legal character set is `[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]`. -## IS NOT NULL 的限制 +## General Limits -IS NOT NULL 与不为空的表达式适用范围。 +- Maximum length of database name is 32 bytes +- Maximum length of table name is 192 bytes, excluding the database name prefix and the separator +- Maximum length of each data row is 48K bytes from version 2.1.7.0 , before which the limit is 16K bytes. Please be noted that the upper limit includes the extra 2 bytes consumed by each column of BINARY/NCHAR type. +- Maximum of column name is 64. +- Maximum number of columns is 4096. There must be at least 2 columns, and the first column must be timestamp. +- Maximum length of tag name is 64. +- Maximum number of tags is 128. There must be at least 1 tag. The total length of tag values should not exceed 16K bytes. +- Maximum length of singe SQL statement is 1048576, i.e. 1 MB bytes. It can be configured in the parameter `maxSQLLength` in the client side, the applicable range is [65480, 1048576]. +- At most 4096 columns (or 1024 prior to 2.1.7.0) can be returned by `SELECT`, functions in the query statement may constitute columns. Error will be returned if the limit is exceeded. +- Maximum numbers of databases, STables, tables are only depending on the system resources. +- Maximum of database name is 32 bytes, can't include "." and special characters. +- Maximum replica number of database is 3 +- Maximum length of user name is 23 bytes +- Maximum length of password is 15 bytes +- Maximum number of rows depends on the storage space only. +- Maximum number of tables depends on the number of nodes only. +- Maximum number of databases depends on the number of nodes only. +- Maximum number of vnodes for single database is 64. -IS NOT NULL 支持所有类型的列。不为空的表达式为 <\>"",仅对非数值类型的列适用。 +## Restrictions of `GROUP BY` -## ORDER BY 的限制 +`GROUP BY` can be performed on tags and `TBNAME`. It can be performed on data columns too, with one restriction that only one column and the number of unique values on that column is lower than 100,000. Please be noted that `GROUP BY` can't be performed on float or double type. -- 非超级表只能有一个 order by. -- 超级表最多两个 order by, 并且第二个必须为 ts. -- order by tag,必须和 group by tag 一起,并且是同一个 tag。 tbname 和 tag 一样逻辑。 只适用于超级表 -- order by 普通列,必须和 group by 一起或者和 top/bottom 一起,并且是同一个普通列。 适用于超级表和普通表。如果同时存在 group by 和 top/bottom 一起,order by 优先必须和 group by 同一列。 -- order by ts. 适用于超级表和普通表。 -- order by ts 同时含有 group by 时 针对 group 内部用 ts 排序 +## Restrictions of `IS NOT NULL` -## 表(列)名合法性说明 +`IS NOT NULL` can be used on any data type of columns. The non-empty string evaluation expression, i.e. `<\>""` can only be used on non-numeric data types. -### TDengine 中的表(列)名命名规则如下: -只能由字母、数字、下划线构成,数字不能在首位,长度不能超过 192 字节,不区分大小写。这里表名称不包括数据库名的前缀和分隔符。 +## Restrictions of `ORDER BY` -### 转义后表(列)名规则: -为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`",可以避免表名与关键词的冲突,同时不受限于上述表名合法性约束检查,转义符不计入表名的长度。 -转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一。 +- Only one `order by` is allowed for normal table and sub table. +- At most two `order by` are allowed for STable, and the second one must be `ts`. +- `order by tag` must be used with `group by tag` on same tag, this rule is also applicable to `tbname`. +- `order by column` must be used with `group by column` or `top/bottom` on same column. This rule is applicable to table and STable. +- `order by ts` is applicable to table and STable. +- If `order by ts` is used with `group by`, the result set is sorted using `ts` in each group. -例如: -\`aBc\` 和 \`abc\` 是不同的表(列)名,但是 abc 和 aBc 是相同的表(列)名。 +## Restrictions of Table/Column Names + +### Name Restrictions of Table/Column + +The name of a table or column can only be composed of ASCII characters, digits and underscore, while digit can't be used as the beginning. The maximum length is 192 bytes. Names are case insensitive. The name mentioned in this rule doesn't include the database name prefix and the separator. + +### Name Restrictions After Escaping + +To support more flexible table or column names, new escape character "`" is introduced in TDengine to avoid the conflict between table name and keywords and break the above restrictions for table name. The escape character is not counted in the length of table name. + +With escaping, the string inside escape characters are case sensitive, i.e. will not be converted to lower case internally. + +For example: +\`aBc\` and \`abc\` are different table or column names, but "abc" and "aBc" are same names because internally they are all "abc". :::note -转义字符中的内容必须是可打印字符。 +The characters inside escape characters must be printable characters. ::: -### 支持版本 -支持转义符的功能从 2.3.0.1 版本开始。 \ No newline at end of file +### Applicable Versions + +Escape character "\`" is available from version 2.3.0.1. diff --git a/docs-en/12-taos-sql/10-json.md b/docs-en/12-taos-sql/10-json.md index 4a4a8cca732ac433ba5ada1ec3805ebfa663edb3..60468f1e0fd75cc04cae8a91b0a1a22b9bd3600b 100644 --- a/docs-en/12-taos-sql/10-json.md +++ b/docs-en/12-taos-sql/10-json.md @@ -1,91 +1,82 @@ --- -sidebar_label: JSON 类型使用说明 -title: JSON 类型使用说明 +title: JSON Type --- +## Syntax -## 语法说明 +1. Tag of JSON type -1. 创建 json 类型 tag + ```sql + create STable s1 (ts timestamp, v1 int) tags (info json); + create table s1_1 using s1 tags ('{"k1": "v1"}'); ``` - create stable s1 (ts timestamp, v1 int) tags (info json) - create table s1_1 using s1 tags ('{"k1": "v1"}') - ``` - -2. json 取值操作符 -> +2. -> Operator of JSON - ``` - select * from s1 where info->'k1' = 'v1' + ```sql + select * from s1 where info->'k1' = 'v1'; - select info->'k1' from s1 + select info->'k1' from s1; ``` -3. json key 是否存在操作符 contains +3. contains Operator of JSON - ``` - select * from s1 where info contains 'k2' + ```sql + select * from s1 where info contains 'k2'; - select * from s1 where info contains 'k1' + select * from s1 where info contains 'k1'; ``` -## 支持的操作 +## Applicable Operations -1. 在 where 条件中时,支持函数 match/nmatch/between and/like/and/or/is null/is no null,不支持 in +1. When JSON data type is used in `where`, `match/nmatch/between and/like/and/or/is null/is no null` can be used but `in` can't be used. - ``` + ```sql select * from s1 where info->'k1' match 'v*'; select * from s1 where info->'k1' like 'v%' and info contains 'k2'; select * from s1 where info is null; - select * from s1 where info->'k1' is not null + select * from s1 where info->'k1' is not null; ``` -2. 支持 json tag 放在 group by、order by、join 子句、union all 以及子查询中,比如 group by json->'key' +2. Tag of JSON type can be used in `group by`, `order by`, `join`, `union all` and sub query, for example `group by json->'key'` -3. 支持 distinct 操作. +3. `Distinct` can be used with tag of JSON type + ```sql + select distinct info->'k1' from s1; ``` - select distinct info->'k1' from s1 - ``` - -4. 标签操作 - 支持修改 json 标签值(全量覆盖) +4. Tag Operations - 支持修改 json 标签名 + The value of JSON tag can be altered. Please be noted that the full JSON will be override when doing this. - 不支持添加 json 标签、删除 json 标签、修改 json 标签列宽 + The name of JSON tag can be altered. A tag of JSON type can't be added or removed. The column length of a JSON tag can't be changed. -## 其他约束条件 +## Other Restrictions -1. 只有标签列可以使用 json 类型,如果用 json 标签,标签列只能有一个。 +- JSON type can only be used for tag. There can be only one tag of JSON type, and it's exclusive to any other types of tag. -2. 长度限制:json 中 key 的长度不能超过 256,并且 key 必须为可打印 ascii 字符;json 字符串总长度不超过 4096 个字节。 +- The maximum length of keys in JSON is 256 bytes, and key must be printable ASCII characters. The maximum total length of a JSON is 4,096 bytes. -3. json 格式限制: +- JSON format: - 1. json 输入字符串可以为空("","\t"," "或 null)或 object,不能为非空的字符串,布尔型和数组。 - 2. object 可为{},如果 object 为{},则整个 json 串记为空。key 可为"",若 key 为"",则 json 串中忽略该 k-v 对。 - 3. value 可以为数字(int/double)或字符串或 bool 或 null,暂不可以为数组。不允许嵌套。 - 4. 若 json 字符串中出现两个相同的 key,则第一个生效。 - 5. json 字符串里暂不支持转义。 + - The input string for JSON can be empty, i.e. "", "\t", or NULL, but can't be non-NULL string, bool or array. + - object can be {}, and the whole JSON is empty if so. Key can be "", and it's ignored if so. + - value can be int, double, string, boll or NULL, can't be array. Nesting is not allowed, that means value can't be another JSON. + - If one key occurs twice in JSON, only the first one is valid. + - Escape characters are not allowed in JSON. -4. 当查询 json 中不存在的 key 时,返回 NULL +- NULL is returned if querying a key that doesn't exist in JSON. -5. 当 json tag 作为子查询结果时,不再支持上层查询继续对子查询中的 json 串做解析查询。 +- If a tag of JSON is the result of inner query, it can't be parsed and queried in the outer query. - 比如暂不支持 +For example, below SQL statements are not supported. - ``` - select jtag->'key' from (select jtag from stable) - ``` - - 不支持 - - ``` - select jtag->'key' from (select jtag from stable) where jtag->'key'>0 - ``` +```sql; +select jtag->'key' from (select jtag from STable); +select jtag->'key' from (select jtag from STable) where jtag->'key'>0; +``` diff --git a/docs-en/12-taos-sql/11-escape.md b/docs-en/12-taos-sql/11-escape.md index 756e5c81591e7414827fdc65e228cfafc96214ad..34ce9f7848a9d60811a23286a6675e8afa4f04fe 100644 --- a/docs-en/12-taos-sql/11-escape.md +++ b/docs-en/12-taos-sql/11-escape.md @@ -1,30 +1,30 @@ --- -title: 转义字符说明 +title: Escape Characters --- -## 转义字符表 +Below table is the list of escape characters used in TDengine. -| 字符序列 | **代表的字符** | -| :------: | -------------- | -| `\'` | 单引号' | -| `\"` | 双引号" | -| \n | 换行符 | -| \r | 回车符 | -| \t | tab 符 | -| `\\` | 斜杠\ | -| `\%` | % 规则见下 | -| `\_` | \_ 规则见下 | +| Escape Character | **Actual Meaning** | +| :--------------: | ------------------------ | +| `\'` | Single quote ' | +| `\"` | Double quote " | +| \n | Line Break | +| \r | Carriage Return | +| \t | tab | +| `\\` | Back Slash \ | +| `\%` | % see below for details | +| `\_` | \_ see below for details | :::note -转义符的功能从 2.4.0.4 版本开始 +Escape characters are available from version 2.4.0.4 . ::: -## 转义字符使用规则 +## Restrictions -1. 标识符里有转义字符(数据库名、表名、列名) - 1. 普通标识符: 直接提示错误的标识符,因为标识符规定必须是数字、字母和下划线,并且不能以数字开头。 - 2. 反引号``标识符: 保持原样,不转义 -2. 数据里有转义字符 - 1. 遇到上面定义的转义字符会转义(%和\_见下面说明),如果没有匹配的转义字符会忽略掉转义符\。 - 2. 对于%和\_,因为在 like 里这两个字符是通配符,所以在模式匹配 like 里用`\%`%和`\_`表示字符里本身的%和\_,如果在 like 模式匹配上下文之外使用`\%`或`\_`,则它们的计算结果为字符串`\%`和`\_`,而不是%和\_。 +1. If there are escape characters in identifiers (database name, table name, column name) + - Identifier without ``: Error will be returned because identifier must be constituted of digits, ASCII characters or underscore and can't be started with digits + - Identifier quoted with ``: Original content is kept, no escaping +2. If there are escape characters in values + - The escape characters will be escaped as the above table. If the escape character doesn't match any supported one, the escape character "\" will be ignored. + - "%" and "\_" are used as wildcards in `like`. `\%` and `\_` should be used to represent literal "%" and "\_" in `like`,. If `\%` and `\_` are used out of `like` context, the evaluation result is "`\%`"and "`\_`", instead of "%" and "\_". diff --git a/docs-en/12-taos-sql/12-keywords.md b/docs-en/12-taos-sql/12-keywords.md new file mode 100644 index 0000000000000000000000000000000000000000..fa750300b71251e1172dba13f91d05822f9ac1f4 --- /dev/null +++ b/docs-en/12-taos-sql/12-keywords.md @@ -0,0 +1,48 @@ +--- +title: Keywords +--- + +There are about 200 keywords reserved by TDengine, they can't be used as the name of database, STable or table with either upper case, lower case or mixed case. + +**Keywords List** + +| | | | | | +| ----------- | ---------- | --------- | ---------- | ------------ | +| ABORT | CREATE | IGNORE | NULL | STAR | +| ACCOUNT | CTIME | IMMEDIATE | OF | STATE | +| ACCOUNTS | DATABASE | IMPORT | OFFSET | STATEMENT | +| ADD | DATABASES | IN | OR | STATE_WINDOW | +| AFTER | DAYS | INITIALLY | ORDER | STORAGE | +| ALL | DBS | INSERT | PARTITIONS | STREAM | +| ALTER | DEFERRED | INSTEAD | PASS | STREAMS | +| AND | DELIMITERS | INT | PLUS | STRING | +| AS | DESC | INTEGER | PPS | SYNCDB | +| ASC | DESCRIBE | INTERVAL | PRECISION | TABLE | +| ATTACH | DETACH | INTO | PREV | TABLES | +| BEFORE | DISTINCT | IS | PRIVILEGE | TAG | +| BEGIN | DIVIDE | ISNULL | QTIME | TAGS | +| BETWEEN | DNODE | JOIN | QUERIES | TBNAME | +| BIGINT | DNODES | KEEP | QUERY | TIMES | +| BINARY | DOT | KEY | QUORUM | TIMESTAMP | +| BITAND | DOUBLE | KILL | RAISE | TINYINT | +| BITNOT | DROP | LE | REM | TOPIC | +| BITOR | EACH | LIKE | REPLACE | TOPICS | +| BLOCKS | END | LIMIT | REPLICA | TRIGGER | +| BOOL | EQ | LINEAR | RESET | TSERIES | +| BY | EXISTS | LOCAL | RESTRICT | UMINUS | +| CACHE | EXPLAIN | LP | ROW | UNION | +| CACHELAST | FAIL | LSHIFT | RP | UNSIGNED | +| CASCADE | FILE | LT | RSHIFT | UPDATE | +| CHANGE | FILL | MATCH | SCORES | UPLUS | +| CLUSTER | FLOAT | MAXROWS | SELECT | USE | +| COLON | FOR | MINROWS | SEMI | USER | +| COLUMN | FROM | MINUS | SESSION | USERS | +| COMMA | FSYNC | MNODES | SET | USING | +| COMP | GE | MODIFY | SHOW | VALUES | +| COMPACT | GLOB | MODULES | SLASH | VARIABLE | +| CONCAT | GRANTS | NCHAR | SLIDING | VARIABLES | +| CONFLICT | GROUP | NE | SLIMIT | VGROUPS | +| CONNECTION | GT | NONE | SMALLINT | VIEW | +| CONNECTIONS | HAVING | NOT | SOFFSET | VNODES | +| CONNS | ID | NOTNULL | STable | WAL | +| COPY | IF | NOW | STableS | WHERE | diff --git a/docs-en/12-taos-sql/12-keywords/_category_.yml b/docs-en/12-taos-sql/12-keywords/_category_.yml deleted file mode 100644 index 67738650a4564477f017542aea81767b3de72922..0000000000000000000000000000000000000000 --- a/docs-en/12-taos-sql/12-keywords/_category_.yml +++ /dev/null @@ -1 +0,0 @@ -label: 参数限制与保留关键字 \ No newline at end of file diff --git a/docs-en/12-taos-sql/12-keywords/index.md b/docs-en/12-taos-sql/12-keywords/index.md deleted file mode 100644 index 608d4e080967cfd97072706cf0963ae669960be6..0000000000000000000000000000000000000000 --- a/docs-en/12-taos-sql/12-keywords/index.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -sidebar_label: 参数限制与保留关键字 -title: TDengine 参数限制与保留关键字 ---- - -## 名称命名规则 - -1. 合法字符:英文字符、数字和下划线 -2. 允许英文字符或下划线开头,不允许以数字开头 -3. 不区分大小写 -4. 转义后表(列)名规则: - 为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`"。可用让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。 - 转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一。 - - 例如:\`aBc\` 和 \`abc\` 是不同的表(列)名,但是 abc 和 aBc 是相同的表(列)名。 - 需要注意的是转义字符中的内容必须是可打印字符。 - 支持转义符的功能从 2.3.0.1 版本开始。 - -## 密码合法字符集 - -`[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]` - -去掉了 `` ‘“`\ `` (单双引号、撇号、反斜杠、空格) - -- 数据库名:不能包含“.”以及特殊字符,不能超过 32 个字符 -- 表名:不能包含“.”以及特殊字符,与所属数据库名一起,不能超过 192 个字符,每行数据最大长度 16k 个字符 -- 表的列名:不能包含特殊字符,不能超过 64 个字符 -- 数据库名、表名、列名,都不能以数字开头,合法的可用字符集是“英文字符、数字和下划线” -- 表的列数:不能超过 1024 列,最少需要 2 列,第一列必须是时间戳(从 2.1.7.0 版本开始,改为最多支持 4096 列) -- 记录的最大长度:包括时间戳 8 byte,不能超过 16KB(每个 BINARY/NCHAR 类型的列还会额外占用 2 个 byte 的存储位置) -- 单条 SQL 语句默认最大字符串长度:1048576 byte,但可通过系统配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576 byte -- 数据库副本数:不能超过 3 -- 用户名:不能超过 23 个 byte -- 用户密码:不能超过 15 个 byte -- 标签(Tags)数量:不能超过 128 个,可以 0 个 -- 标签的总长度:不能超过 16K byte -- 记录条数:仅受存储空间限制 -- 表的个数:仅受节点个数限制 -- 库的个数:仅受节点个数限制 -- 单个库上虚拟节点个数:不能超过 64 个 -- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制 -- SELECT 语句的查询结果,最多允许返回 1024 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错。(从 2.1.7.0 版本开始,改为最多允许 4096 列) - -## 保留关键字 - -目前 TDengine 有将近 200 个内部保留关键字,这些关键字无论大小写均不可以用作库名、表名、STable 名、数据列名及标签列名等。这些关键字列表如下: - -| 关键字列表 | | | | | -| ----------- | ---------- | --------- | ---------- | ------------ | -| ABORT | CREATE | IGNORE | NULL | STAR | -| ACCOUNT | CTIME | IMMEDIATE | OF | STATE | -| ACCOUNTS | DATABASE | IMPORT | OFFSET | STATEMENT | -| ADD | DATABASES | IN | OR | STATE_WINDOW | -| AFTER | DAYS | INITIALLY | ORDER | STORAGE | -| ALL | DBS | INSERT | PARTITIONS | STREAM | -| ALTER | DEFERRED | INSTEAD | PASS | STREAMS | -| AND | DELIMITERS | INT | PLUS | STRING | -| AS | DESC | INTEGER | PPS | SYNCDB | -| ASC | DESCRIBE | INTERVAL | PRECISION | TABLE | -| ATTACH | DETACH | INTO | PREV | TABLES | -| BEFORE | DISTINCT | IS | PRIVILEGE | TAG | -| BEGIN | DIVIDE | ISNULL | QTIME | TAGS | -| BETWEEN | DNODE | JOIN | QUERIES | TBNAME | -| BIGINT | DNODES | KEEP | QUERY | TIMES | -| BINARY | DOT | KEY | QUORUM | TIMESTAMP | -| BITAND | DOUBLE | KILL | RAISE | TINYINT | -| BITNOT | DROP | LE | REM | TOPIC | -| BITOR | EACH | LIKE | REPLACE | TOPICS | -| BLOCKS | END | LIMIT | REPLICA | TRIGGER | -| BOOL | EQ | LINEAR | RESET | TSERIES | -| BY | EXISTS | LOCAL | RESTRICT | UMINUS | -| CACHE | EXPLAIN | LP | ROW | UNION | -| CACHELAST | FAIL | LSHIFT | RP | UNSIGNED | -| CASCADE | FILE | LT | RSHIFT | UPDATE | -| CHANGE | FILL | MATCH | SCORES | UPLUS | -| CLUSTER | FLOAT | MAXROWS | SELECT | USE | -| COLON | FOR | MINROWS | SEMI | USER | -| COLUMN | FROM | MINUS | SESSION | USERS | -| COMMA | FSYNC | MNODES | SET | USING | -| COMP | GE | MODIFY | SHOW | VALUES | -| COMPACT | GLOB | MODULES | SLASH | VARIABLE | -| CONCAT | GRANTS | NCHAR | SLIDING | VARIABLES | -| CONFLICT | GROUP | NE | SLIMIT | VGROUPS | -| CONNECTION | GT | NONE | SMALLINT | VIEW | -| CONNECTIONS | HAVING | NOT | SOFFSET | VNODES | -| CONNS | ID | NOTNULL | STABLE | WAL | -| COPY | IF | NOW | STABLES | WHERE | diff --git a/docs-en/12-taos-sql/_category_.yml b/docs-en/12-taos-sql/_category_.yml index 62290997ece68ce1a61d391c3976e338033c0dd1..0bfd46c860da0afdade1ad12e04f02737c39cedc 100644 --- a/docs-en/12-taos-sql/_category_.yml +++ b/docs-en/12-taos-sql/_category_.yml @@ -1 +1 @@ -label: SQL 手册 +label: SQL diff --git a/docs-en/12-taos-sql/index.md b/docs-en/12-taos-sql/index.md index c34c1e5dc812ad589a0c4fdf89a8d02ff4fd18a4..93ba8ff87e8ee7fc6ef90bf369a85f1c8e0d6f9e 100644 --- a/docs-en/12-taos-sql/index.md +++ b/docs-en/12-taos-sql/index.md @@ -1,24 +1,24 @@ --- title: TAOS SQL -description: "TAOS SQL 支持的语法规则、主要查询功能、支持的 SQL 查询函数,以及常用技巧等内容" +description: "The syntax supported by TAOS SQL " --- -本文档说明 TAOS SQL 支持的语法规则、主要查询功能、支持的 SQL 查询函数,以及常用技巧等内容。阅读本文档需要读者具有基本的 SQL 语言的基础。 +This document explains the syntax about operating database, table, STable, inserting data, selecting data, functions and some tips that can be used in TAOS SQL. It would be easier to understand with some fundamental knowledge of SQL. -TAOS SQL 是用户对 TDengine 进行数据写入和查询的主要工具。TAOS SQL 为了便于用户快速上手,在一定程度上提供与标准 SQL 类似的风格和模式。严格意义上,TAOS SQL 并不是也不试图提供标准的 SQL 语法。此外,由于 TDengine 针对的时序性结构化数据不提供删除功能,因此在 TAO SQL 中不提供数据删除的相关功能。 +TAOS SQL is the major interface for users to write data into or query from TDengine. For users to easily use, syntax similar to standard SQL is provided. However, please be noted that TAOS SQL is not standard SQL. Besides, because TDengine doesn't provide the functionality of deleting time series data, corresponding statements are not provided in TAOS SQL. -TAOS SQL 不支持关键字的缩写,例如 DESCRIBE 不能缩写为 DESC。 +TAOS SQL doesn't support abbreviation for keywords, for example `DESCRIBE` can't be abbreviated as `DESC`. -本章节 SQL 语法遵循如下约定: +Syntax Specifications used in this chapter: -- <\> 里的内容是用户需要输入的,但不要输入 <\> 本身 -- \[ \] 表示内容为可选项,但不能输入 [] 本身 -- | 表示多选一,选择其中一个即可,但不能输入 | 本身 -- … 表示前面的项可重复多个 +- The content inside <\> needs to be input by the user, excluding <\> itself. +- \[ \] means optional input, excluding [] itself. +- | means one of a few options, excluding | itself. +- … means the item prior to it can be repeated multiple times. -为更好地说明 SQL 语法的规则及其特点,本文假设存在一个数据集。以智能电表(meters)为例,假设每个智能电表采集电流、电压、相位三个量。其建模如下: +To better demonstrate the syntax, usage and rules of TAOS SQL, hereinafter it's assumed that there is a data set of meters. Assuming each meter collects 3 data: current, voltage, phase. The data model is as below: -``` +```sql taos> DESCRIBE meters; Field | Type | Length | Note | ================================================================================= @@ -30,4 +30,4 @@ taos> DESCRIBE meters; groupid | INT | 4 | TAG | ``` -数据集包含 4 个智能电表的数据,按照 TDengine 的建模规则,对应 4 个子表,其名称分别是 d1001, d1002, d1003, d1004。 \ No newline at end of file +The data set includes the data collected by 4 meters, the corresponding table name is d1001, d1002, d1003, d1004 respectively based on the data model of TDengine. diff --git a/docs-en/13-operation/01-pkg-install.md b/docs-en/13-operation/01-pkg-install.md index 92b04a42ec9b3a80187d4482f465190288038f8d..00802506e681a9e27e338fef363e4157379c5a85 100644 --- a/docs-en/13-operation/01-pkg-install.md +++ b/docs-en/13-operation/01-pkg-install.md @@ -1,22 +1,22 @@ --- -title: 安装和卸载 -description: 安装、卸载、启动、停止和升级 +title: Install & Uninstall +description: Install, Uninstall, Start, Stop and Upgrade --- import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; -TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包。 +TDengine community version provides dev and rpm package for users to choose based on the system environment. deb supports Debian, Ubuntu and systems derived from them. rpm supports CentOS, RHEL, SUSE and systems derived from them. Furthermore, tar.gz package is provided for enterprise customers. -## 安装 +## Install - + -1、从官网下载获得 deb 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.deb; -2、进入到 TDengine-server-2.4.0.7-Linux-x64.deb 安装包所在目录,执行如下的安装命令: +1. Download deb package from official website, for example TDengine-server-2.4.0.7-Linux-x64.deb +2. In the directory where the package is located, execute below command -``` +```bash $ sudo dpkg -i TDengine-server-2.4.0.7-Linux-x64.deb (Reading database ... 137504 files and directories currently installed.) Preparing to unpack TDengine-server-2.4.0.7-Linux-x64.deb ... @@ -43,10 +43,10 @@ TDengine is installed successfully! - + -1、从官网下载获得 rpm 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.rpm; -2、进入到 TDengine-server-2.4.0.7-Linux-x64.rpm 安装包所在目录,执行如下的安装命令: +1. Download rpm package from official website, for example TDengine-server-2.4.0.7-Linux-x64.rpm; +2. In the directory where the package is located, execute below command ``` $ sudo rpm -ivh TDengine-server-2.4.0.7-Linux-x64.rpm @@ -74,12 +74,12 @@ TDengine is installed successfully! - + -1、从官网下载获得 tar.gz 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.tar.gz; -2、进入到 TDengine-server-2.4.0.7-Linux-x64.tar.gz 安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本: +1. Download the tar.gz package, for example TDengine-server-2.4.0.7-Linux-x64.tar.gz; + 2、In the directory where the package is located, firstly decompress the file, then switch to the sub-directory generated in decompressing, i.e. "TDengine-enterprise-server-2.4.0.7/" in this example, and execute the `install.sh` script. -``` +```bash $ tar xvzf TDengine-enterprise-server-2.4.0.7-Linux-x64.tar.gz TDengine-enterprise-server-2.4.0.7/ TDengine-enterprise-server-2.4.0.7/driver/ @@ -124,7 +124,7 @@ taoskeeper is installed, enable it by `systemctl enable taoskeeper` ``` :::info -install.sh 安装脚本在执行过程中,会通过命令行交互界面询问一些配置信息。如果希望采取无交互安装方式,那么可以用 -e no 参数来执行 install.sh 脚本。运行 `./install.sh -h` 指令可以查看所有参数的详细说明信息。 +Some configuration will be prompted for users to provide when install.sh is executing, the interactive mode can be disabled by executing `./install.sh -e no`. `./install -h` can show all parameters and detailed explanation. ::: @@ -132,18 +132,18 @@ install.sh 安装脚本在执行过程中,会通过命令行交互界面询问 :::note -当安装第一个节点时,出现 Enter FQDN:提示的时候,不需要输入任何内容。只有当安装第二个或以后更多的节点时,才需要输入已有集群中任何一个可用节点的 FQDN,支持该新节点加入集群。当然也可以不输入,而是在新节点启动前,配置到新节点的配置文件中。 +When installing on the first node in the cluster, when "Enter FQDN:" is prompted, nothing needs to be provided. When installing on following nodes, when "Enter FQDN:" is prompted, the end point of the first dnode in the cluster can be input if it has been already up; or just ignore it and configure later after installation is done. ::: -## 卸载 +## Uninstall - + -卸载命令如下: +Deb package of TDengine can be uninstalled as below: -``` +```bash $ sudo dpkg -r tdengine (Reading database ... 137504 files and directories currently installed.) Removing tdengine (2.4.0.7) ... @@ -153,9 +153,9 @@ TDengine is removed successfully! - + -卸载命令如下: +RPM package of TDengine can be uninstalled as below: ``` $ sudo rpm -e tdengine @@ -164,9 +164,9 @@ TDengine is removed successfully! - + -卸载命令如下: +tar.gz package of TDengine can be uninstalled as below: ``` $ rmtaos @@ -179,32 +179,28 @@ taosKeeper is removed successfully! -:::info -- TDengine 提供了多种安装包,但最好不要在一个系统上同时使用 tar.gz 安装包和 deb 或 rpm 安装包。否则会相互影响,导致在使用时出现问题。 +:::note -- 对于 deb 包安装后,如果安装目录被手工误删了部分,出现卸载、或重新安装不能成功。此时,需要清除 TDengine 包的安装信息,执行如下命令: +- It's strongly suggested not to use multiple kinds of installation packages on single host TDengine +- After deb package is installed, if the installation directory is removed manually so that uninstall or reinstall can't succeed, it can be resolved by cleaning up TDengine package information as below command and then reinstalling. - ``` +```bash $ sudo rm -f /var/lib/dpkg/info/tdengine* - ``` - -然后再重新进行安装就可以了。 +``` -- 对于 rpm 包安装后,如果安装目录被手工误删了部分,出现卸载、或重新安装不能成功。此时,需要清除 TDengine 包的安装信息,执行如下命令: +- After rpm package is installed, if the installation directory is removed manually so that uninstall or reinstall can't succeed, it can be resolved by cleaning up TDengine package information as below command and then reinstalling. - ``` +```bash $ sudo rpm -e --noscripts tdengine - ``` - -然后再重新进行安装就可以了。 +``` ::: -## 安装目录说明 +## Installation Directory -TDengine 成功安装后,主安装目录是 /usr/local/taos,目录内容如下: +TDengine is installed at /usr/local/taos if successful. -``` +```bash $ cd /usr/local/taos $ ll $ ll @@ -220,64 +216,67 @@ drwxr-xr-x 2 root root 4096 Feb 22 09:34 include/ lrwxrwxrwx 1 root root 13 Feb 22 09:34 log -> /var/log/taos/ ``` -- 自动生成配置文件目录、数据库目录、日志目录。 -- 配置文件缺省目录:/etc/taos/taos.cfg, 软链接到 /usr/local/taos/cfg/taos.cfg; -- 数据库缺省目录:/var/lib/taos, 软链接到 /usr/local/taos/data; -- 日志缺省目录:/var/log/taos, 软链接到 /usr/local/taos/log; -- /usr/local/taos/bin 目录下的可执行文件,会软链接到 /usr/bin 目录下; -- /usr/local/taos/driver 目录下的动态库文件,会软链接到 /usr/lib 目录下; -- /usr/local/taos/include 目录下的头文件,会软链接到到 /usr/include 目录下; +During the installation process: -## 卸载和更新文件说明 +- Configuration directory, data directory, and log directory are created automatically if they don't exist +- The default configuration file is located at /etc/taos/taos.cfg, which is a copy of /usr/local/taos/cfg/taos.cfg if not existing +- The default data directory is /var/lib/taos, which is a soft link to /usr/local/taos/data +- The default log directory is /var/log/taos, which is a soft link to /usr/local/taos/log +- The executables at /usr/local/taos/bin are linked to /usr/bin +- The DLL files at /usr/local/taos/driver are linked to /usr/lib +- The header files at /usr/local/taos/include are linked to /usr/include -卸载安装包的时候,将保留配置文件、数据库文件和日志文件,即 /etc/taos/taos.cfg 、 /var/lib/taos 、 /var/log/taos 。如果用户确认后不需保留,可以手工删除,但一定要慎重,因为删除后,数据将永久丢失,不可以恢复! +:::note -如果是更新安装,当缺省配置文件( /etc/taos/taos.cfg )存在时,仍然使用已有的配置文件,安装包中携带的配置文件修改为 taos.cfg.orig 保存在 /usr/local/taos/cfg/ 目录,可以作为设置配置参数的参考样例;如果不存在配置文件,就使用安装包中自带的配置文件。 +- When TDengine is uninstalled, the configuration /etc/taos/taos.cfg, data directory /var/lib/taos, log directory /var/log/taos are kept. They can be deleted manually with caution because data can't be recovered once +- When reinstalling TDengine, if the default configuration file /etc/taos/taos.cfg exists, it will be kept and the configuration file in the installation package will be renamed to taos.cfg.orig and stored at /usr/loca/taos/cfg to be used as configuration sample. Otherwise the configuration file in the installation package will be installed to /etc/taos/taos.cfg and used. -## 启动和停止 +## Start and Stop -TDengine 使用 Linux 系统的 systemd/systemctl/service 来管理系统的启动和、停止、重启操作。TDengine 的服务进程是 taosd,默认情况下 TDengine 在系统启动后将自动启动。DBA 可以通过 systemd/systemctl/service 手动操作停止、启动、重新启动服务。 +Linux system services `systemd`, `systemctl` or `service` is used to start, stop and restart TDengine. The server process of TDengine is `taosd`, which is started automatically after the Linux system is started. System operator can use `systemd`, `systemctl` or `service` to start, stop or restart TDengine server. -以 systemctl 为例,命令如下: +For example, if using `systemctl` , the commands to start, stop, restart and check TDengine server are as below: -- 启动服务进程:`systemctl start taosd` +- Start server:`systemctl start taosd` -- 停止服务进程:`systemctl stop taosd` +- Stop server:`systemctl stop taosd` -- 重启服务进程:`systemctl restart taosd` +- Restart server:`systemctl restart taosd` -- 查看服务状态:`systemctl status taosd` +- Check server status:`systemctl status taosd` -注意:TDengine 在 2.4 版本之后包含一个独立组件 taosAdapter 需要使用 systemctl 命令管理 taosAdapter 服务的启动和停止。 +From version 2.4.0.0, a new independent component named as `taosAdapter` has been included in TDengine. `taosAdapter` should be started and stopped using `systemctl`. -如果服务进程处于活动状态,则 status 指令会显示如下的相关信息: +If the server process is OK, the output of `systemctl status` is like below: - ``` - Active: active (running) - ``` +``` +Active: active (running) +``` -如果后台服务进程处于停止状态,则 status 指令会显示如下的相关信息: +Otherwise, the output is as below: - ``` - Active: inactive (dead) - ``` +``` +Active: inactive (dead) +``` + +## Upgrade -## 升级 -升级分为两个层面:升级安装包 和 升级运行中的实例。 +There are two aspects in upgrade operation: upgrade installation package and upgrade a running server. -升级安装包请遵循前述安装和卸载的步骤先卸载旧版本再安装新版本。 +Upgrading package should follow the steps mentioned previously to firstly uninstall old version then install new version. -升级运行中的实例则要复杂得多,首先请注意版本号,TDengine 的版本号目前分为四段,如 2.4.0.14 和 2.4.0.16,只有前三段版本号一致(即只有第四段版本号不同)才能把一个运行中的实例进行升级。升级步骤如下: -- 停止数据写入 -- 确保所有数据落盘,即写入时序数据库 -- 停止 TDengine 集群 -- 卸载旧版本并安装新版本 -- 重新启动 TDengine 集群 -- 进行简单的查询操作确认旧数据没有丢失 -- 进行简单的写入操作确认 TDengine 集群可用 -- 重新恢复业务数据的写入 +Upgrading a running server is much more complex. Firstly please check the version number of old version and new version. The version number of TDengine consists of 4 sections, only the first 3 section match can the old version be upgraded to the new version. The steps of upgrading a running server are as below: + +- Stop inserting data +- Make sure all data persisted into disk +- Stop the cluster of TDengine +- Uninstall old version and install new version +- Start the cluster of TDengine +- Make some simple queries to make sure no data loss +- Make some simple data insertion to make sure the cluster works well +- Restore business data :::warning -TDengine 不保证低版本能够兼容高版本的数据,所以任何时候都不推荐降级 +TDengine doesn't guarantee any lower version is compatible with the data generated by a higher version, so it's never recommended to downgrade the version. -::: \ No newline at end of file +::: diff --git a/docs-en/13-operation/02-planning.mdx b/docs-en/13-operation/02-planning.mdx index 954ba7ca00ebdcb10cfcad515292d96127106ff3..d0fc4cccbce29e596304787edae84b94056ff75f 100644 --- a/docs-en/13-operation/02-planning.mdx +++ b/docs-en/13-operation/02-planning.mdx @@ -1,81 +1,82 @@ --- -sidebar_label: 容量规划 -title: 容量规划 +title: Resource Planning --- -使用 TDengine 来搭建一个物联网大数据平台,计算资源、存储资源需要根据业务场景进行规划。下面分别讨论系统运行所需要的内存、CPU 以及硬盘空间。 +The computing and storage resources need to be planned if using TDengine to build an IoT platform. How to plan the CPU, memory and disk required will be described in this chapter. -## 内存需求 +## Memory Requirement of Server Side -每个 Database 可以创建固定数目的 vgroup,默认与 CPU 核数相同,可通过 maxVgroupsPerDb 配置;vgroup 中的每个副本会是一个 vnode;每个 vnode 会占用固定大小的内存(大小与数据库的配置参数 blocks 和 cache 有关);每个 Table 会占用与标签总长度有关的内存;此外,系统会有一些固定的内存开销。因此,每个 DB 需要的系统内存可通过如下公式计算: +The number of vgroups created for each database is same as the number of CPU cores by default and can be configured by parameter `maxVgroupsPerDb`, each vnode in a vgroup stores one replica. Each vnode consumes fixed size of memory, i.e. `blocks` \* `cache`. Besides, some memory is required for tag values associated with each table. A fixed amount of memory is required for each cluster. So, the memory required for each DB can be calculated using below formula: ``` Database Memory Size = maxVgroupsPerDb * replica * (blocks * cache + 10MB) + numOfTables * (tagSizePerTable + 0.5KB) ``` -示例:假设 maxVgroupPerDB 是缺省值 64,cache 是缺省大小 16M, blocks 是缺省值 6,并且一个 DB 中有 10 万张表,单副本,标签总长度是 256 字节,则这个 DB 总的内存需求为:64 \* 1 \* (16 \* 6 + 10) + 100000 \* (0.25 + 0.5) / 1000 = 6792M。 +For example, assuming the default value of `maxVgroupPerDB` is 64, the default value of `cache` 16M, the default value of `blocks` is 6, there are 100,000 tables in a DB, the replica number is 1, total length of tag values is 256 bytes, the total memory required for this DB is: 并且一个 DB 中有 10 万张表,单副本,标签总长度是 256 字节,则这个 DB 总的内存需求为:64 \* 1 \* (16 \* 6 + 10) + 100000 \* (0.25 + 0.5) / 1000 = 6792M. -在实际的系统运维中,我们通常会更关心 TDengine 服务进程(taosd)会占用的内存量。 +In real operation of TDengine, we are more concerned about the memory used by each TDengine server process `taosd`.在 ``` -taosd 内存总量 = vnode 内存 + mnode 内存 + 查询内存 + taosd_memory = vnode_memory + mnode_memory + query_memory ``` -其中: +In the above formula: -1. “vnode 内存”指的是集群中所有的 Database 存储分摊到当前 taosd 节点上所占用的内存资源。可以按上文“Database Memory Size”计算公式估算每个 DB 的内存占用量进行加总,再按集群中总共的 TDengine 节点数做平均(如果设置为多副本,则还需要乘以对应的副本倍数)。 -2. “mnode 内存”指的是集群中管理节点所占用的资源。如果一个 taosd 节点上分布有 mnode 管理节点,则内存消耗还需要增加“0.2KB \* 集群中数据表总数”。 -3. “查询内存”指的是服务端处理查询请求时所需要占用的内存。单条查询语句至少会占用“0.2KB \* 查询涉及的数据表总数”的内存量。 +1. "vnode_memory" of a `taosd` process is the memory used by all vnodes hosted by this `taosd` process. It can be roughly calculated by firstly adding up the total memory of all DBs whose memory usage can be derived according to the formula mentioned previously then dividing by number of dnodes and multiplying the number of replicas. -注意:以上内存估算方法,主要讲解了系统的“必须内存需求”,而不是“内存总数上限”。在实际运行的生产环境中,由于操作系统缓存、资源管理调度等方面的原因,内存规划应当在估算结果的基础上保留一定冗余,以维持系统状态和系统性能的稳定性。并且,生产环境通常会配置系统资源的监控工具,以便及时发现硬件资源的紧缺情况。 +``` + vnode_memory = sum(Database memory) / number_of_dnodes \* replica +``` + +2. "mnode_memory" of a `taosd` process is the memory consumed by a mnode. If there is one (and only one) mnode hosted in a `taosd` process, the memory consumed by "mnode" is "0.2KB \* the total number of tables in the cluster". -最后,如果内存充裕,可以考虑加大 Blocks 的配置,这样更多数据将保存在内存里,提高写入和查询速度。 +3. "query_memory" is the memory used when processing query requests. Each ongoing query consumes at least "0.2 KB \* total number of involved tables". -### 客户端内存需求 +Please be noted that the above formulas can only be used to estimate the minimum memory requirement, instead of maximum memory usage. In a real production environment, it's better to preserve some redundance beyond the estimated minimum memory requirement. If memory is abundant, it's suggested to increase the value of parameter `blocks` to speed up data insertion and data query. -客户端应用采用 taosc 客户端驱动连接服务端,会有内存需求的开销。 +## Memory Requirement of Client Side -客户端的内存开销主要由写入过程中的 SQL 语句、表的元数据信息缓存、以及结构性开销构成。系统最大容纳的表数量为 N(每个通过超级表创建的表的 meta data 开销约 256 字节),最大并行写入线程数量 T,最大 SQL 语句长度 S(通常是 1 Mbytes)。由此可以进行客户端内存开销的估算(单位 MBytes): +The client programs use TDengine client driver `taosc` to connect to the server side, there is also memory requirement for a client program. + +The memory consumed by a client program is mainly about the SQL statements for data insertion, caching of table metadata, and some internal use. Assuming maximum number of tables is N (the memory consumed by the metadata of each table is 256 bytes), maximum number of threads for parallel insertion is T, maximum length of a SQL statement is S (normally 1 MB), the memory required by a client program can be estimated using below formula: ``` M = (T * S * 3 + (N / 4096) + 100) ``` -举例如下:用户最大并发写入线程数 100,子表数总数 10,000,000,那么客户端的内存最低要求是: +For example, if the number of parallel data insertion threads is 100, total number of tables is 10,000,000, then minimum memory requirement of a client program is: ``` 100 * 3 + (10000000 / 4096) + 100 = 2741 (MBytes) ``` -即配置 3 GBytes 内存是最低要求。 +So, at least 3GB needs to be reserved for such a client. -## CPU 需求 +## CPU Requirement -CPU 的需求取决于如下两方面: +The CPU resources required depend on two aspects: -- **数据插入** TDengine 单核每秒能至少处理一万个插入请求。每个插入请求可以带多条记录,一次插入一条记录与插入 10 条记录,消耗的计算资源差别很小。因此每次插入,条数越大,插入效率越高。如果一个插入请求带 200 条以上记录,单核就能达到每秒插入 100 万条记录的速度。但对前端数据采集的要求越高,因为需要缓存记录,然后一批插入。 -- **查询需求** TDengine 提供高效的查询,但是每个场景的查询差异很大,查询频次变化也很大,难以给出客观数字。需要用户针对自己的场景,写一些查询语句,才能确定。 +- **Data Insertion** Each dnode of TDengine can process at least 10,000 insertion requests in one second, while each insertion request can have multiple rows. The computing resource consumed between inserting 1 row one time and inserting 10 rows one time is very small. So, the more the rows to insert one time, the higher the efficiency. Inserting in bach also exposes requirement for the client side which needs to cache rows and insert in batch once the cached rows reaches a threshold. +- **Data Query** High efficiency query is provided in TDengine, but it's hard to estimate the CPU resource required because the queries used in different use cases and the frequency of queries vary significantly. It can only be verified with the query statements, query frequency, data size to be queried, etc provided by user. -因此仅对数据插入而言,CPU 是可以估算出来的,但查询所耗的计算资源无法估算。在实际运营过程中,不建议 CPU 使用率超过 50%,超过后,需要增加新的节点,以获得更多计算资源。 +In short words, the CPU resource required for data insertion can be estimated but it's hard to do so for query use cases. In real operation, it's suggested to control CPU usage below 50%. If this threshold is exceeded, it's a reminder for system operator to add more nodes in the cluster to expand resources. -## 存储需求 +## Disk Requirement -TDengine 相对于通用数据库,有超高的压缩比,在绝大多数场景下,TDengine 的压缩比不会低于 5 倍,有的场合,压缩比可达到 10 倍以上,取决于实际场景的数据特征。压缩前的原始数据大小可通过如下方式计算: +The compression ratio in TDengine is much higher than that in RDBMS. In most cases, the compression ratio in TDengine is bigger than 5, or even 10 in some cases, depending on the characteristics of the original data. The data size before compression can be calculated based on below formula: ``` Raw DataSize = numOfTables * rowSizePerTable * rowsPerTable ``` -示例:1000 万台智能电表,每台电表每 15 分钟采集一次数据,每次采集的数据 128 字节,那么一年的原始数据量是:10000000 \* 128 \* 24 \* 60 / 15 \* 365 = 44.8512T。TDengine 大概需要消耗 44.851 / 5 = 8.97024T 空间。 - -用户可以通过参数 keep,设置数据在磁盘中的最大保存时长。为进一步减少存储成本,TDengine 还提供多级存储,最冷的数据可以存放在最廉价的存储介质上,应用的访问不用做任何调整,只是读取速度降低了。 +For example, there are 10,000,000 meters, while each meter collects data every 15 minutes and the data size of each collection si 128 bytes, so the raw data size of one year is: 10000000 \* 128 \* 24 \* 60 / 15 \* 365 = 44.8512(TB). Assuming compression ratio is 5, the actual disk size is: 44.851 / 5 = 8.97024(TB). -为提高速度,可以配置多块硬盘,这样可以并发写入或读取数据。需要提醒的是,TDengine 采取多副本的方式提供数据的高可靠,因此不再需要采用昂贵的磁盘阵列。 +Parameter `keep` can be used to set how long the data will be kept on disk. To further reduce storage cost, multiple storage levels can be enabled in TDengine, with the coldest data stored on the cheapest storage device, and this is transparent to application programs. -## 物理机或虚拟机台数 +To increase the performance, multiple disks can be setup for parallel data reading or data inserting. Please be noted that expensive disk array is not necessary because replications are used in TDengine to provide high availability. -根据上面的内存、CPU、存储的预估,就可以知道整个系统需要多少核、多少内存、多少存储空间。如果数据副本数不为 1,总需求量需要再乘以副本数。 +## Number of Hosts -因为 TDengine 具有很好的水平扩展能力,根据总量,再根据单个物理机或虚拟机的资源,就可以轻松决定需要购置多少台物理机或虚拟机了。 +A host can be either physical or virtual. The total memory, total CPU, total disk required can be estimated according to the formulas mentioned previously. Then, according to the system resources that a single host can provide, assuming all hosts are same in resources, the number of hosts can be derived easily. -**立即计算 CPU、内存、存储,请参见:[资源估算方法](https://www.taosdata.com/config/config.html)。** +**Quick Estimation for CPU, Memory and Disk** Please refer to [Resource Estimate](https://www.taosdata.com/config/config.html). diff --git a/docs-en/13-operation/03-tolerance.md b/docs-en/13-operation/03-tolerance.md index 054e5c4cee07f7066038a6bfc5c4b25306b033ce..367474cddb7395ea84a4a33623d1643e487f9d09 100644 --- a/docs-en/13-operation/03-tolerance.md +++ b/docs-en/13-operation/03-tolerance.md @@ -1,28 +1,29 @@ --- -title: 容错和灾备 +sidebar_label: Fault Tolerance +title: Fault Tolerance & Disaster Recovery --- -## 容错 +## Fault Tolerance -TDengine 支持**WAL**(Write Ahead Log)机制,实现数据的容错能力,保证数据的高可用。 +TDengine uses **WAL**, i.e. Write Ahead Log, to achieve fault tolerance and high reliability. -TDengine 接收到应用的请求数据包时,先将请求的原始数据包写入数据库日志文件,等数据成功写入数据库数据文件后,再删除相应的 WAL。这样保证了 TDengine 能够在断电等因素导致的服务重启时从数据库日志文件中恢复数据,避免数据的丢失。 +When a data block is received by TDengine, the original data block is firstly written into WAL. The log in WAL will be deleted only after the data has been written into data files in the database. Data can be recovered from WAL in case the server is stopped abnormally due to any reason and then restarted. -涉及的系统配置参数有两个: +There are 2 configuration parameters related to WAL: -- walLevel:WAL 级别,0:不写 wal; 1:写 wal, 但不执行 fsync; 2:写 wal, 而且执行 fsync。 -- fsync:当 walLevel 设置为 2 时,执行 fsync 的周期。设置为 0,表示每次写入,立即执行 fsync。 +- walLevel:0:wal is disabled; 1:wal is enabled without fsync; 2:wal is enabled with fsync. +- fsync:only valid when walLevel is set to 2, it specified the interval of invoking fsync. If set to 0, it means fsync is invoked immediately once WAL is written. -如果要 100%的保证数据不丢失,需要将 walLevel 设置为 2,fsync 设置为 0。这时写入速度将会下降。但如果应用侧启动的写数据的线程数达到一定的数量(超过 50),那么写入数据的性能也会很不错,只会比 fsync 设置为 3000 毫秒下降 30%左右。 +To achieve absolutely no data loss, walLevel needs to be set to 2 and fsync needs to be set to 1. The penalty is the performance of data ingestion downgrades. However, if the concurrent threads of data insertion on the client side can reach a big enough number, for example 50, the data ingestion performance would be still good enough, our verification shows that the drop is only 30% compared to fsync is set to 3,000 milliseconds. -## 灾备 +## Disaster Recovery -TDengine 的集群通过多个副本的机制,来提供系统的高可用性,实现灾备能力。 +TDengine uses replications to provide high availability and disaster recovery capability. -TDengine 集群是由 mnode 负责管理的,为保证 mnode 的高可靠,可以配置多个 mnode 副本,副本数由系统配置参数 numOfMnodes 决定,为了支持高可靠,需要设置大于 1。为保证元数据的强一致性,mnode 副本之间通过同步方式进行数据复制,保证了元数据的强一致性。 +TDengine cluster is managed by mnode. To make sure the high availability of mnode, multiple replicas can be configured by system parameter `numOfMnodes`. The data replication between mnode replicas is in synchronous way to guarantee the metadata consistency. -TDengine 集群中的时序数据的副本数是与数据库关联的,一个集群里可以有多个数据库,每个数据库可以配置不同的副本数。创建数据库时,通过参数 replica 指定副本数。为了支持高可靠,需要设置副本数大于 1。 +The number of replicas for time series data in TDengine is associated with each database, there can be a lot of databases in a cluster while each database can be configured with a different number of replicas. When creating a database, parameter `replica` is used to configure the number of replications. To achieve high availability, `replica` needs to be higher than 1. -TDengine 集群的节点数必须大于等于副本数,否则创建表时将报错。 +The number of dnodes in a TDengine cluster must NOT be lower than the number of replicas for any database, otherwise it would fail when trying to create table. -当 TDengine 集群中的节点部署在不同的物理机上,并设置多个副本数时,就实现了系统的高可靠性,无需再使用其他软件或工具。TDengine 企业版还可以将副本部署在不同机房,从而实现异地容灾。 +As long as the dnodes of a TDengine cluster are deployed on different physical machines and replica number is set to bigger than 1, high availability can be achieved without any other assistance. If dnodes of TDengine cluster are deployed in geographically different data centers, disaster recovery can be achieved too. diff --git a/docs-en/13-operation/06-admin.md b/docs-en/13-operation/06-admin.md index 7934d31eafb774fb45e1902bee29e8b518d152d6..1ca0dfeaf4a4b0b4c597e1a5ec6ece20224e2dba 100644 --- a/docs-en/13-operation/06-admin.md +++ b/docs-en/13-operation/06-admin.md @@ -1,42 +1,50 @@ --- -title: 用户管理 +title: User Management --- -系统管理员可以在 CLI 界面里添加、删除用户,也可以修改密码。CLI 里 SQL 语法如下: +System operator can use TDengine CLI `taos` to create or remove user or change password. The SQL command is as low: + +## Create User ```sql CREATE USER PASS <'password'>; ``` -创建用户,并指定用户名和密码,密码需要用单引号引起来,单引号为英文半角 +When creating a user and specifying the user name and password, password needs to be quoted using single quotes. + +## Drop User ```sql DROP USER ; ``` -删除用户,限 root 用户使用 +Drop a user can only be performed by root. + +## Change Password ```sql ALTER USER PASS <'password'>; ``` -修改用户密码,为避免被转换为小写,密码需要用单引号引用,单引号为英文半角 +To keep the case of the password when changing password, password needs to be quoted using single quotes. + +## Change Privilege ```sql ALTER USER PRIVILEGE ; ``` -修改用户权限为:write 或 read,不需要添加单引号 +The privileges that can be changed to are `read` or `write` without single quotes. + +Note:there is another privilege `super`, which not allowed to be authorized to any user. -说明:系统内共有 super/write/read 三种权限级别,但目前不允许通过 alter 指令把 super 权限赋予用户。 +## Show Users ```sql SHOW USERS; ``` -显示所有用户 - :::note -SQL 语法中,< >表示需要用户输入的部分,但请不要输入< >本身。 +In SQL syntax, `< >` means the part that needs to be input by user, excluding the `< >` itself. ::: diff --git a/docs-en/13-operation/07-import.md b/docs-en/13-operation/07-import.md index 7dee05720d4c3446181e8e0d81a5c27e35300ba8..7077dcebf0986aca9ee67eb1e07c239ddbce7a17 100644 --- a/docs-en/13-operation/07-import.md +++ b/docs-en/13-operation/07-import.md @@ -1,27 +1,27 @@ --- -title: 数据导入 +title: Data Import --- -TDengine 提供多种方便的数据导入功能,一种按脚本文件导入,一种按数据文件导入,一种是 taosdump 工具导入本身导出的文件。 +There are multiple ways of importing data provided byTDengine: import with script, import from data file, import using `taosdump`. -## 按脚本文件导入 +## Import Using Script -TDengine 的 shell 支持 source filename 命令,用于批量运行文件中的 SQL 语句。用户可将建库、建表、写数据等 SQL 命令写在同一个文件中,每条命令单独一行,在 shell 中运行 source 命令,即可按顺序批量运行文件中的 SQL 语句。以‘#’开头的 SQL 语句被认为是注释,shell 将自动忽略。 +TDengine CLI `taos` supports `source ` command for executing the SQL statements in the file in batch. The SQL statements for creating databases, creating tables, and inserting rows can be written in single file with one statement on each line, then the file can be executed using `source` command in TDengine CLI `taos` to execute the SQL statements in order and in batch. In the script file, any line beginning with "#" is treated as comments and ignored silently. -## 按数据文件导入 +## Import from Data File -TDengine 也支持在 shell 对已存在的表从 CSV 文件中进行数据导入。CSV 文件只属于一张表且 CSV 文件中的数据格式需与要导入表的结构相同,在导入的时候,其语法如下: +In TDengine CLI, data can be imported from a CSV file into an existing table. The data in single CSV must belong to same table and must be consistent with the schema of that table. The SQL statement is as below:也 ```sql insert into tb1 file 'path/data.csv'; ``` :::note -注意:如果 CSV 文件首行存在描述信息,请手动删除后再导入。如某列为空,填 NULL,无引号。\*\* +If there is description in the first line of a CSV file, please remove it before importing. If there is no value for a column, please use `NULL` without quotes. ::: -例如,现在存在一个子表 d1001, 其表结构如下: +For example, there is a sub table d1001 whose schema is as below: ```sql taos> DESCRIBE d1001 @@ -35,7 +35,7 @@ taos> DESCRIBE d1001 groupid | INT | 4 | TAG | ``` -要导入的 data.csv 的格式如下: +The format of the CSV file to be imported, data.csv, is as below: ```csv '2018-10-04 06:38:05.000',10.30000,219,0.31000 @@ -49,13 +49,13 @@ taos> DESCRIBE d1001 '2018-10-12 06:38:05.000',18.30000,219,0.31000 ``` -那么可以用如下命令导入数据: +Then, below SQL statement can be used to import data from file "data.csv", assuming the file is located under the home directory of current Linux user. ```sql taos> insert into d1001 file '~/data.csv'; Query OK, 9 row(s) affected (0.004763s) ``` -## taosdump 工具导入 +## Import using taosdump -TDengine 提供了方便的数据库导入导出工具 taosdump。用户可以将 taosdump 从一个系统导出的数据,导入到其他系统中。具体使用方法,请参见:[TDengine 数据备份工具: taosdump](/reference/taosdump)。 +A convenient tool for importing and exporting data is provided by TDengine, `taosdump`, which can used to export data from one TDengine cluster and import into another one. For the details of using `taosdump` please refer to [Tool for exporting and importing data: taosdump](/reference/taosdump). diff --git a/docs-en/13-operation/08-export.md b/docs-en/13-operation/08-export.md index 042ecc7ba29f976d50bbca1e3155bd03b2ae7ccc..fa9625a7c5f6b0e6706d726bff410cee647286bb 100644 --- a/docs-en/13-operation/08-export.md +++ b/docs-en/13-operation/08-export.md @@ -1,20 +1,19 @@ --- -title: 数据导出 +title: Data Export --- -为方便数据导出,TDengine 提供了两种导出方式,分别是按表导出和用 taosdump 导出。 +There are two ways of exporting data from a TDengine cluster, one is SQL statement in TDengine CLI, the other one is `taosdump`. -## 按表导出 CSV 文件 +## Export Using SQL -如果用户需要导出一个表或一个 STable 中的数据,可在 taos shell 中运行: +If you want to export the data of a table or a STable, please execute below SQL statement in TDengine CLI. ```sql select * from >> data.csv; ``` -这样,表 tb_name 中的数据就会按照 CSV 格式导出到文件 data.csv 中。 +The data of table or STable specified by `tb_name` will be exported into a file named `data.csv` in CSV format. -## 用 taosdump 导出数据 +## Export Using taosdump -利用 taosdump,用户可以根据需要选择导出所有数据库、一个数据库或者数据库中的一张表,所有数据或一时间段的数据,甚至仅仅表的定义。具体使用方法,请参见: -[TDengine 数据备份工具: taosdump](/reference/taosdump)。 +With `taosdump`, you can choose to export the data of all databases, a database, a table or a STable, you can also choose export the data within a time range, or even only export the schema definition of a table. For the details of using `taosdump` please refer to [Tool for exporting and importing data: taosdump](/reference/taosdump). diff --git a/docs-en/13-operation/09-status.md b/docs-en/13-operation/09-status.md index e7ae78bace91f6dab06591340965ba04efdd5edb..3f3c6c9f1e86f9f33bafc7edfd79bebb175871cc 100644 --- a/docs-en/13-operation/09-status.md +++ b/docs-en/13-operation/09-status.md @@ -1,53 +1,54 @@ --- -title: 系统连接、任务查询管理 +sidebar_label: Connections & Tasks +title: Manage Connections and Query Tasks --- -系统管理员可以从 CLI 查询系统的连接、正在进行的查询、流式计算,并且可以关闭连接、停止正在进行的查询和流式计算。 +System operator can use TDengine CLI to show the connections, ongoing queries, stream computing, and can close connection or stop ongoing query task or stream computing. -## 显示数据库的连接 +## Show Connections ```sql SHOW CONNECTIONS; ``` -其结果中的一列显示 ip:port, 为连接的 IP 地址和端口号。 +One column of the output of the above SQL command is "ip:port", which is the end point of the client. -## 强制关闭数据库连接 +## Close Connections Forcedly ```sql KILL CONNECTION ; ``` -其中的 connection-id 是 SHOW CONNECTIONS 中显示的第一列的数字。 +In the above SQL command, `connection-id` is from the first column of the output of `SHOW CONNECTIONS`. -## 显示数据查询 +## Show Ongoing Queries ```sql SHOW QUERIES; ``` -其中第一列显示的以冒号隔开的两个数字为 query-id,为发起该 query 应用连接的 connection-id 和查询次数。 +The first column of the output is query ID, which is composed of the corresponding connection ID and the sequence number of the current query task started on this connection, in format of "connection-id:query-no". -## 强制关闭数据查询 +## Close Queries Forcedly ```sql KILL QUERY ; ``` -其中 query-id 是 SHOW QUERIES 中显示的 connection-id:query-no 字串,如“105:2”,拷贝粘贴即可。 +In the above SQL command, `query-id` is from the first column of the output of `SHOW QUERIES `. -## 显示连续查询 +## Show Continuous Query ```sql SHOW STREAMS; ``` -其中第一列显示的以冒号隔开的两个数字为 stream-id, 为启动该 stream 应用连接的 connection-id 和发起 stream 的次数。 +The first column of the output is stream ID, which is composed of the connection ID and the sequence number of the current stream started on this connection, in the format of "connection-id:stream-no". -## 强制关闭连续查询 +## Close Continuous Query Forcedly ```sql KILL STREAM ; ``` -其中的 stream-id 是 SHOW STREAMS 中显示的 connection-id:stream-no 字串,如 103:2,拷贝粘贴即可。 +The the above SQL command, `stream-id` is from the first column of the output of `SHOW STREAMS`. diff --git a/docs-en/13-operation/10-monitor.md b/docs-en/13-operation/10-monitor.md index e30be775fb5c337b2a621bea92d3af31a2cb5cc0..bb5d18b3b2fec3cd2a5e4ebc333537806699ce1d 100644 --- a/docs-en/13-operation/10-monitor.md +++ b/docs-en/13-operation/10-monitor.md @@ -1,54 +1,60 @@ --- -title: 系统监控 +title: TDengine Monitoring --- -TDengine 启动后,会自动创建一个监测数据库 log,并自动将服务器的 CPU、内存、硬盘空间、带宽、请求数、磁盘读写速度、慢查询等信息定时写入该数据库。TDengine 还将重要的系统操作(比如登录、创建、删除数据库等)日志以及各种错误报警信息记录下来存放在 log 库里。系统管理员可以从 CLI 直接查看这个数据库,也可以在 WEB 通过图形化界面查看这些监测信息。 +After TDengine is started, a database named `log` for monitoring is created automatically. The information about CPU, memory, disk, bandwidth, number of requests, disk I/O speed, slow query is written into `log` database on the basis of a predefined interval. Besides, some important system operations, like logon, create user, drop database, and alerts and warnings generated in TDengine are written into `log` database too. System operator can view the data in `log` database from TDengine CLI or from a web console. -这些监测信息的采集缺省是打开的,但可以修改配置文件里的选项 monitor 将其关闭或打开。 +Collection of the monitoring information is enabled by default, but can be disabled by parameter `monitor` in configuration file. -## TDinsight - 使用监控数据库 + Grafana 对 TDengine 进行监控的解决方案 +## TDinsight -从 2.3.3.0 开始,监控数据库将提供更多的监控项,您可以从 [TDinsight Grafana Dashboard](https://grafana.com/grafana/dashboards/15167) 了解如何使用 TDinsight 方案对 TDengine 进行监控。 +TDinsight is a total solution which uses the monitor database `log` mentioned previously and Grafana to monitor a TDengine cluster. -我们提供了一个自动化脚本 `TDinsight.sh` 对 TDinsight 进行部署。 +From version 2.3.3.0, more monitoring data has been added in the `log` database. Please refer to [TDinsight Grafana Dashboard](https://grafana.com/grafana/dashboards/15167) to learn more details about using TDinsight to monitor TDengine. -下载 `TDinsight.sh`: +A script `TDinsight.sh` is provided to deploy TDinsight in automatic way. + +Download `TDinsight.sh` with below command: ```bash wget https://github.com/taosdata/grafanaplugin/raw/master/dashboards/TDinsight.sh chmod +x TDinsight.sh ``` -准备: +Prepare: + +1. TDengine Server -1. TDengine Server 信息: + - The URL of REST service:for example `http://localhost:6041` if TDengine is deployed locally + - User name and password - - TDengine RESTful 服务:对本地而言,可以是 `http://localhost:6041`,使用参数 `-a`。 - - TDengine 用户名和密码,使用 `-u` `-p` 参数设置。 +2. Grafana Alert Notification -2. Grafana 告警通知 +There are two ways to setup Grafana alert notification. - - 使用已经存在的 Grafana Notification Channel `uid`,参数 `-E`。该参数可以使用 `curl -u admin:admin localhost:3000/api/alert-notifications |jq` 来获取。 +- An existing Grafana Notification Channel can be specified with parameter `-E`, the notifier uid of the channel can be obtained by `curl -u admin:admin localhost:3000/api/alert-notifications |jq` ```bash sudo ./TDinsight.sh -a http://localhost:6041 -u root -p taosdata -E ``` - - 使用 TDengine 数据源插件内置的阿里云短信告警通知,使用 `-s` 启用之,并设置如下参数: +- The AliClund SMS alert built in TDengine data source plugin can be enabled with parameter `-s`, the parameters of this way are as follows: - 1. 阿里云短信服务 Key ID,参数 `-I` - 2. 阿里云短信服务 Key Secret,参数 `K` - 3. 阿里云短信服务签名,参数 `-S` - 4. 短信通知模板号,参数 `-C` - 5. 短信通知模板输入参数,JSON 格式,参数 `-T`,如 `{"alarm_level":"%s","time":"%s","name":"%s","content":"%s"}` - 6. 逗号分隔的通知手机列表,参数 `-B` + - `-I`: AliCloud SMS Key ID + - `-K`: AliCloud SMS Key Secret + - `-S`: AliCloud SMS Signature + - `-C`: SMS notification template + - `-T`: Input parameters in JSON format for the SMS notification template, for example`{"alarm_level":"%s","time":"%s","name":"%s","content":"%s"}` + - `-B`: List of mobile numbers to be notified - ```bash + Below is an example of the full command using this way. + + ```bash sudo ./TDinsight.sh -a http://localhost:6041 -u root -p taosdata -s \ -I XXXXXXX -K XXXXXXXX -S taosdata -C SMS_1111111 -B 18900000000 \ -T '{"alarm_level":"%s","time":"%s","name":"%s","content":"%s"}' - ``` + ``` -运行程序并重启 Grafana 服务,打开面板:`http://localhost:3000/d/tdinsight`。 +Launch `TDinsight.sh` as above command and restart Grafana, then open Dashboard `http://localhost:3000/d/tdinsight`. -更多使用场景和限制请参考[TDinsight](/reference/tdinsight/) 文档。 +For more use cases and restrictions please refer to [TDinsight](/reference/tdinsight/). diff --git a/docs-en/13-operation/11-optimize.md b/docs-en/13-operation/11-optimize.md index 57411dbbb0705ae4c9c4568bb09909918bcee6a3..7cccfc8b0d51a4bfda9ae4827130a3747f10e649 100644 --- a/docs-en/13-operation/11-optimize.md +++ b/docs-en/13-operation/11-optimize.md @@ -1,99 +1,99 @@ --- -title: 性能优化 +title: Performance Optimization --- -因数据行 [update](/train-faq/faq/#update)、表删除、数据过期等原因,TDengine 的磁盘存储文件有可能出现数据碎片,影响查询操作的性能表现。从 2.1.3.0 版本开始,新增 SQL 指令 COMPACT 来启动碎片重整过程: +After a TDengine cluster has been running for long enough time, because of updating data, deleting tables and deleting expired data, there may be fragments in data files and query performance may be impacted. To resolve the problem of fragments, from version 2.1.3.0 a new SQL command `COMPACT` can be used to defragment the data files. ```sql COMPACT VNODES IN (vg_id1, vg_id2, ...) ``` -COMPACT 命令对指定的一个或多个 VGroup 启动碎片重整,系统会通过任务队列尽快安排重整操作的具体执行。COMPACT 指令所需的 VGroup id,可以通过 `SHOW VGROUPS;` 指令的输出结果获取;而且在 `SHOW VGROUPS;` 中会有一个 compacting 列,值为 2 时表示对应的 VGroup 处于排队等待进行重整的状态,值为 1 时表示正在进行碎片重整,为 0 时则表示并没有处于重整状态(未要求进行重整或已经完成重整)。 +`COMPACT` can be used to defragment one or more vgroups. The defragmentation work will be put in task queue for scheduling execution by TDengine. `SHOW VGROUPS` command can be used to get the vgroup ids to be used in `COMPACT` command. There is a column `compacting` in the output of `SHOW GROUPS` to indicate the compacting status of the vgroup: 2 means the vgroup is waiting in task queue for compacting, 1 means compacting is in progress, and 0 means the vgroup has nothing to do with compacting. -需要注意的是,碎片重整操作会大幅消耗磁盘 I/O。因此在重整进行期间,有可能会影响节点的写入和查询性能,甚至在极端情况下导致短时间的阻写。 +Please be noted that a lot of disk I/O is required for defragementation operation, during which the performance may be impacted significantly for data insertion and query, data insertion may be blocked shortly in extreme cases. -## 存储参数优化 +## Optimize Storage Parameters -不同应用场景的数据往往具有不同的数据特征,比如保留天数、副本数、采集频次、记录大小、采集点的数量、压缩等都可完全不同。为获得在存储上的最高效率,TDengine 提供如下存储相关的系统配置参数(既可以作为 create database 指令的参数,也可以写在 taos.cfg 配置文件中用来设定创建新数据库时所采用的默认值): +The data in different use cases may have different characteristics, such as the days to keep, number of replicas, collection interval, record size, number of collection points, compression or not, etc. To achieve best efficiency in storage, the parameters in below table can be used, all of them can be either configured in `taos.cfg` as default configuration or in the command `create database`. For detailed definition of these parameters please refer to [Configuration Parameters](/reference/config/). -| # | 配置参数名称 | 单位 | 含义 | **取值范围** | **缺省值** | -| --- | ------------ | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------- | -| 1 | days | 天 | 一个数据文件存储数据的时间跨度 | 1-3650 | 10 | -| 2 | keep | 天 | (可通过 alter database 修改)数据库中数据保留的天数。 |1-36500 |3650 | -| 3 | cache | MB | 内存块的大小 | 1-128 | 16 | -| 4 | blocks | | (可通过 alter database 修改)每个 VNODE(TSDB)中有多少个 cache 大小的内存块。因此一个 VNODE 使用的内存大小粗略为(cache \* blocks)。 | 3-10000 | 6 | -| 5 | quorum | | (可通过 alter database 修改)多副本环境下指令执行的确认数要求 | 1-2 | 1 | -| 6 | minRows | | 文件块中记录的最小条数 | 10-1000 | 100 | -| 7 | maxRows | | 文件块中记录的最大条数 | 200-10000 | 4096 | -| 8 | comp | | (可通过 alter database 修改)文件压缩标志位 | 0:关闭,1:一阶段压缩,2:两阶段压缩 | 2 | -| 9 | walLevel | | (作为 database 的参数时名为 wal;在 taos.cfg 中作为参数时需要写作 walLevel)WAL 级别 | 1:写 wal,但不执行 fsync;2:写 wal, 而且执行 fsync | 1 | -| 10 | fsync | 毫秒 | 当 wal 设置为 2 时,执行 fsync 的周期。设置为 0,表示每次写入,立即执行 fsync。 | | 3000 | -| 11 | replica | | (可通过 alter database 修改)副本个数 | 1-3 | 1 | -| 12 | precision | | 时间戳精度标识(2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。)(从 2.1.5.0 版本开始,新增对纳秒时间精度的支持) | ms 表示毫秒,us 表示微秒,ns 表示纳秒 | ms | -| 13 | update | | 是否允许数据更新(从 2.1.7.0 版本开始此参数支持 0 ~ 2 的取值范围,在此之前取值只能是 [0, 1];而 2.0.8.0 之前的版本在 SQL 指令中不支持此参数。) | 0:不允许;1:允许更新整行;2:允许部分列更新。 | 0 | -| 14 | cacheLast | | (可通过 alter database 修改)是否在内存中缓存子表的最近数据(从 2.1.2.0 版本开始此参数支持 0 ~ 3 的取值范围,在此之前取值只能是 [0, 1];而 2.0.11.0 之前的版本在 SQL 指令中不支持此参数。)(2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。) | 0:关闭;1:缓存子表最近一行数据;2:缓存子表每一列的最近的非 NULL 值;3:同时打开缓存最近行和列功能 | 0 | +| # | Parameter | Unit | Definition | **Value Range** | **Default Value** | +| --- | --------- | ---- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | ----------------- | +| 1 | days | Day | The time range of the data stored in a single data file | 1-3650 | 10 | +| 2 | keep | Day | The number of days the data is kept in the database | 1-36500 | 3650 | +| 3 | cache | MB | The size of each memory block | 1-128 | 16 | +| 4 | blocks | None | The number of memory blocks used by each vnode | 3-10000 | 6 | +| 5 | quorum | None | The number of required confirmation in case of multiple replicas | 1-2 | 1 | +| 6 | minRows | None | The minimum number of rows in a data file | 10-1000 | 100 | +| 7 | maxRows | None | The maximum number of rows in a daa file | 200-10000 | 4096 | +| 8 | comp | None | Whether to compress the data | 0:uncompressed; 1: One Phase compression; 2: Two Phase compression | 2 | +| 9 | walLevel | None | wal sync level (named as "wal" in create database ) | 1:wal enabled without fsync; 2:wal enabled with fsync | 1 | +| 10 | fsync | ms | The time to wait for invoking fsync when walLevel is set to 2; 0 means no wait | 3000 | +| 11 | replica | none | The number of replications | 1-3 | 1 | +| 12 | precision | none | Time precision | ms: millisecond; us: microsecond;ns: nanosecond | ms | +| 13 | update | none | Whether to allow updating data | 0: not allowed; 1: a row must be updated as whole; 2: a part of columns in a row can be updated | 0 | +| 14 | cacheLast | none | Whether the latest data of a table is cached in memory | 0: not cached; 1: the last row is cached; 2: the latest non-NULL value of each column is cached | 0 | -对于一个应用场景,可能有多种数据特征的数据并存,最佳的设计是将具有相同数据特征的表放在一个库里,这样一个应用有多个库,而每个库可以配置不同的存储参数,从而保证系统有最优的性能。TDengine 允许应用在创建库时指定上述存储参数,如果指定,该参数就将覆盖对应的系统配置参数。举例,有下述 SQL: +For a specific use case, there may be multiple kinds of data with different characteristics, it's best to put data with same characteristics in same database. So there may be multiple databases in a system while each database can be configured with different storage parameters to achieve best performance. The above parameters can be used when creating a database to override the default setting in configuration file. ```sql CREATE DATABASE demo DAYS 10 CACHE 32 BLOCKS 8 REPLICA 3 UPDATE 1; ``` -该 SQL 创建了一个库 demo, 每个数据文件存储 10 天数据,内存块为 32 兆字节,每个 VNODE 占用 8 个内存块,副本数为 3,允许更新,而其他参数与系统配置完全一致。 - -一个数据库创建成功后,仅部分参数可以修改并实时生效,其余参数不能修改: - -| **参数名** | **能否修改** | **范围** | **修改语法示例** | -| ----------- | ------------ | ---------------------------------------------------------- | -------------------------------------- | -| name | | | | -| create time | | | | -| ntables | | | | -| vgroups | | | | -| replica | **YES** | 在线 dnode 数目为:
1:1-1;
2:1-2;
\>=3:1-3 | ALTER DATABASE REPLICA _n_ | -| quorum | **YES** | 1-2 | ALTER DATABASE QUORUM _n_ | -| days | | | | -| keep | **YES** | days-365000 | ALTER DATABASE KEEP _n_ | -| cache | | | | -| blocks | **YES** | 3-1000 | ALTER DATABASE BLOCKS _n_ | -| minrows | | | | -| maxrows | | | | -| wal | | | | -| fsync | | | | -| comp | **YES** | 0-2 | ALTER DATABASE COMP _n_ | -| precision | | | | -| status | | | | -| update | | | | -| cachelast | **YES** | 0 \| 1 \| 2 \| 3 | ALTER DATABASE CACHELAST _n_ | - -**说明:**在 2.1.3.0 版本之前,通过 ALTER DATABASE 语句修改这些参数后,需要重启服务器才能生效。 - -TDengine 集群中加入一个新的 dnode 时,涉及集群相关的一些参数必须与已有集群的配置相同,否则不能成功加入到集群中。会进行校验的参数如下: - -- numOfMnodes:系统中管理节点个数。默认值:3。(2.0 版本从 2.0.20.11 开始、2.1 及以上版本从 2.1.6.0 开始,numOfMnodes 默认值改为 1。) -- mnodeEqualVnodeNum: 一个 mnode 等同于 vnode 消耗的个数。默认值:4。 -- offlineThreshold: dnode 离线阈值,超过该时间将导致该 dnode 从集群中删除。单位为秒,默认值:86400\*10(即 10 天)。 -- statusInterval: dnode 向 mnode 报告状态时长。单位为秒,默认值:1。 -- maxTablesPerVnode: 每个 vnode 中能够创建的最大表个数。默认值:1000000。 -- maxVgroupsPerDb: 每个数据库中能够使用的最大 vgroup 个数。 -- arbitrator: 系统中裁决器的 end point,缺省为空。 -- timezone、locale、charset 的配置见客户端配置。(2.0.20.0 及以上的版本里,集群中加入新节点已不要求 locale 和 charset 参数取值一致) -- balance:是否启用负载均衡。0:否,1:是。默认值:1。 -- flowctrl:是否启用非阻塞流控。0:否,1:是。默认值:1。 -- slaveQuery:是否启用 slave vnode 参与查询。0:否,1:是。默认值:1。 -- adjustMaster:是否启用 vnode master 负载均衡。0:否,1:是。默认值:1。 - -为方便调试,可通过 SQL 语句临时调整每个 dnode 的日志配置,系统重启后会失效: +The above SQL statement creates a database named as `demo`, in which each data file stores data across 10 days, the size of each memory block is 32 MB and each vnode is allocated with 8 blocks, the replica is set to 3, update operation is allowed, and all other parameters not specified in the command follow the default configuration in `taos.cfg`. + +Once a database is created, only some parameters can be changed and be effective immediately while others are can't. + +| **Parameter** | **Alterable** | **Value Range** | **Syntax** | +| ------------- | ------------- | ---------------- | -------------------------------------- | +| name | | | | +| create time | | | | +| ntables | | | | +| vgroups | | | | +| replica | **YES** | 1-3 | ALTER DATABASE REPLICA _n_ | +| quorum | **YES** | 1-2 | ALTER DATABASE QUORUM _n_ | +| days | | | | +| keep | **YES** | days-365000 | ALTER DATABASE KEEP _n_ | +| cache | | | | +| blocks | **YES** | 3-1000 | ALTER DATABASE BLOCKS _n_ | +| minrows | | | | +| maxrows | | | | +| wal | | | | +| fsync | | | | +| comp | **YES** | 0-2 | ALTER DATABASE COMP _n_ | +| precision | | | | +| status | | | | +| update | | | | +| cachelast | **YES** | 0 \| 1 \| 2 \| 3 | ALTER DATABASE CACHELAST _n_ | + +**Explanation:** Prior to version 2.1.3.0, `taosd` server process needs to be restarted for these parameters to take in effect if they are changed using `ALTER DATABASE`. + +When trying to join a new dnode into a running TDengine cluster, all the parameters related to cluster in the new dnode configuration must be consistent with the cluster, otherwise it can't join the cluster. The parameters that are checked when joining a dnode are as below. For detailed definition of these parameters please refer to [Configuration Parameters](/reference/config/). + +- numOfMnodes +- mnodeEqualVnodeNum +- offlineThreshold +- statusInterval +- maxTablesPerVnode +- maxVgroupsPerDb +- arbitrator +- timezone +- balance +- flowctrl +- slaveQuery +- adjustMaster + +For the convenience of debugging, the log setting of a dnode can be changed temporarily. The temporary change will be lost once the server is restarted. ```sql ALTER DNODE ``` -- dnode_id: 可以通过 SQL 语句"SHOW DNODES"命令获取 -- config: 要调整的日志参数,在如下列表中取值 - > resetlog 截断旧日志文件,创建一个新日志文件 - > debugFlag < 131 | 135 | 143 > 设置 debugFlag 为 131、135 或者 143 +- dnode_id: from output of "SHOW DNODES" +- config: the parameter to be changed, as below + - resetlog: close the old log file and create the new on + - debugFlag: 131 (INFO/ERROR/WARNING), 135 (DEBUG), 143 (TRACE) -例如: +For example ``` alter dnode 1 debugFlag 135; diff --git a/docs-en/13-operation/17-diagnose.md b/docs-en/13-operation/17-diagnose.md index e2a2ef035a33a295b206c77ec08edf8f7842671f..590e19cbbcd86e4ab30b251c6961adbdea40203c 100644 --- a/docs-en/13-operation/17-diagnose.md +++ b/docs-en/13-operation/17-diagnose.md @@ -1,23 +1,22 @@ --- -title: 诊断及其他 +title: Problem Diagnostics --- -## 网络连接诊断 +## Network Connection Diagnostics -当出现客户端应用无法访问服务端时,需要确认客户端与服务端之间网络的各端口连通情况,以便有针对性地排除故障。 +When the client is unable to access the server, the network connection between the client side and the server side needs to be checked to find out the root cause and resolve problems. -目前网络连接诊断支持在:Linux 与 Linux,Linux 与 Windows 之间进行诊断测试。 +The diagnostic for network connection can be executed between Linux and Linux or between Linux and Windows. -诊断步骤: +Diagnostic steps: -1. 如拟诊断的端口范围与服务器 taosd 实例的端口范围相同,须先停掉 taosd 实例 -2. 服务端命令行输入:`taos -n server -P -l ` 以服务端身份启动对端口 port 为基准端口的监听 -3. 客户端命令行输入:`taos -n client -h -P -l ` 以客户端身份启动对指定的服务器、指定的端口发送测试包 +1. If the port range to be diagnosed are being occupied by a `taosd` server process, please firstly stop `taosd. +2. On the server side, execute command `taos -n server -P -l ` to monitor the port range starting from the port specified by `-P` parameter with the role of "server. +3. On the client side, execute command `taos -n client -h -P -l ` to send testing package to the specified server and port. --l : 测试网络包的大小(单位:字节)。最小值是 11、最大值是 64000,默认值为 1000。 -注:两端命令行中指定的测试包长度必须一致,否则测试显示失败。 +-l : The size of the testing package, in bytes. The value range is [11, 64,000] and default value is 1,000. Please be noted that the package length must be same in the above 2 commands executed on server side and client side respectively. -服务端运行正常的话会输出以下信息: +Output of the server side is as below for example: ```bash # taos -n server -P 6000 @@ -48,7 +47,7 @@ title: 诊断及其他 12/21 14:50:22.721261 0x7f53427ec700 UTL UDP: send:1000 bytes to 172.27.0.8 at 6011 ``` -客户端运行正常会输出以下信息: +Output of the client side is as below for example: ```bash # taos -n client -h 172.27.0.7 -P 6000 @@ -66,66 +65,58 @@ title: 诊断及其他 12/21 14:50:22.721274 0x7fc95d859200 UTL successed to test UDP port:6011 ``` -仔细阅读打印出来的错误信息,可以帮助管理员找到原因,以解决问题。 +The output needs to be checked carefully for the system operator to find out root cause and solve the problem. -## 启动状态及 RPC 诊断 +## Startup Status and RPC Diagnostic -`taos -n startup -h ` +`taos -n startup -h ` can be used to check the startup status of a `taosd` process. This is a comman task for a system operator to do to determine whether `taosd` has been started successfully, especially in case of cluster. -判断 taosd 服务端是否成功启动,是数据库管理员经常遇到的一种情形。特别当若干台服务器组成集群时,判断每个服务端实例是否成功启动就会是一个重要问题。除检索 taosd 服务端日志文件进行问题定位、分析外,还可以通过 `taos -n startup -h ` 来诊断一个 taosd 进程的启动状态。 +`taos -n rpc -h ` can be used to check whether the port of a started `taosd` can be accessed or not. If `taosd` process doesn't respond or work abnormally, this command can be used to initiate a rpc communication with the specified fqdn to determine whether it's network problem or `taosd` is abnormal. -针对多台服务器组成的集群,当服务启动过程耗时较长时,可通过该命令行来诊断每台服务器的 taosd 实例的启动状态,以准确定位问题。 +## Sync and Arbitrator Diagnostic -`taos -n rpc -h ` - -该命令用来诊断已经启动的 taosd 实例的端口是否可正常访问。如果 taosd 程序异常或者失去响应,可以通过 `taos -n rpc -h ` 来发起一个与指定 fqdn 的 rpc 通信,看看 taosd 是否能收到,以此来判定是网络问题还是 taosd 程序异常问题。 - -## sync 及 arbitrator 诊断 - -``` +```bash taos -n sync -P 6040 -h taos -n sync -P 6042 -h ``` -用来诊断 sync 端口是否工作正常,判断服务端 sync 模块是否成功工作。另外,-P 6042 用来诊断 arbitrator 是否配置正常,判断指定服务器的 arbitrator 是否能正常工作。 +The above commands can be executed on Linux Shell to check whether the port for sync works well and whether the sync module of the server side works well. Besides, `-P 6042` is used to check whether the arbitrator is configured properly and works well. -## 网络速度诊断 +## Network Speed Diagnostic `taos -n speed -h -P 6030 -N 10 -l 10000000 -S TCP` -从 2.2.0.0 版本开始,taos 工具新提供了一个网络速度诊断的模式,可以对一个正在运行中的 taosd 实例或者 `taos -n server` 方式模拟的一个服务端实例,以非压缩传输的方式进行网络测速。这个模式下可供调整的参数如下: +From version 2.2.0.0, the above command can be executed on Linux Shell to test the network speed, it sends uncompressed package to a running `taosd` server process or a simulated server process started by `taos -n server` to test the network speed. Parameters can be used when testing network speed are as below: --n:设为“speed”时,表示对网络速度进行诊断。 --h:所要连接的服务端的 FQDN 或 ip 地址。如果不设置这一项,会使用本机 taos.cfg 文件中 FQDN 参数的设置作为默认值。 --P:所连接服务端的网络端口。默认值为 6030。 --N:诊断过程中使用的网络包总数。最小值是 1、最大值是 10000,默认值为 100。 --l:单个网络包的大小(单位:字节)。最小值是 1024、最大值是 1024 `*` 1024 `*` 1024,默认值为 1024。 --S:网络封包的类型。可以是 TCP 或 UDP,默认值为 TCP。 +-n:When set to "speed", it means testing network speed +-h:The FQDN or IP of the server process to be connected to; if not set, the FQDN configured in `taos.cfg` is used +-P:The port of the server process to connect to, the default value is 6030 +-N:The number of packages that will be sent in the test, range is [1,10000], default value is 100 +-l:The size of each package in bytes, range is [1024, 1024 \* 1024 \* 1024], default value is 1024 +-S:The type of network packages to send, can be either TCP or UDP, default value is -## FQDN 解析速度诊断 +## FQDN Resolution Diagnostic `taos -n fqdn -h ` -从 2.2.0.0 版本开始,taos 工具新提供了一个 FQDN 解析速度的诊断模式,可以对一个目标 FQDN 地址尝试解析,并记录解析过程中所消耗的时间。这个模式下可供调整的参数如下: - --n:设为“fqdn”时,表示对 FQDN 解析进行诊断。 --h:所要解析的目标 FQDN 地址。如果不设置这一项,会使用本机 taos.cfg 文件中 FQDN 参数的设置作为默认值。 +From version 2.2.0.0, the above command can be executed on Linux Shell to test the resolution speed of FQDN. It can be used to try to resolve a FQDN to an IP address and record the time spent in this process. The parameters that can be used for this purpose are as below: -## 服务端日志 +-n:When set to "fqdn", it means testing the speed of resolving FQDN +-h:The FQDN to be resolved. If not set, the `FQDN` parameter in `taos.cfg` is used by default. -taosd 服务端日志文件标志位 debugflag 默认为 131,在 debug 时往往需要将其提升到 135 或 143 。 +## Server Log -一旦设定为 135 或 143,日志文件增长很快,特别是写入、查询请求量较大时,增长速度惊人。如合并保存日志,很容易把日志内的关键信息(如配置信息、错误信息等)冲掉。为此,服务端将重要信息日志与其他日志分开存放: +The parameter `debugFlag` is used to control the log level of `taosd` server process. The default value is 131, for debug purpose it needs to be escalated to 135 or 143. -- taosinfo 存放重要信息日志, 包括:INFO/ERROR/WARNING 级别的日志信息。不记录 DEBUG、TRACE 级别的日志。 -- taosdlog 服务器端生成的日志,记录 taosinfo 中全部信息外,还根据设置的日志输出级别,记录 DEBUG(日志级别 135)、TRACE(日志级别是 143)。 +Once this parameter is set to 135 or 143, the log file grows very quickly especially when there is huge volume of data insertion and data query requests. If all the logs are stored together, some important information may be missed very easily, so on server side important information is stored at different place from other logs.一 -## 客户端日志 +- The log at level of INFO, WARNING and ERROR is stored in `taosinfo` so that it is easy to find important information +- The log at level of DEBUG (135) and TRACE (143) and other information not handled by `taosinfo` are stored in `taosdlog` -每个独立运行的客户端(一个进程)生成一个独立的客户端日志,其命名方式采用 taoslog+<序号> 的方式命名。文件标志位 debugflag 默认为 131,在 debug 时往往需要将其提升到 135 或 143 。 +## Client Log -- taoslog 客户端(driver)生成的日志,默认记录客户端 INFO/ERROR/WARNING 级别日志,还根据设置的日志输出级别,记录 DEBUG(日志级别 135)、TRACE(日志级别是 143)。 +An independent log file, named as "taoslog+" is generated for each client program, i.e. a client process. The default value of `debugfalg` is also 131 and only log at level of INFO/ERROR/WARNING is recorded, it and needs to be changed to 135 or 143 so that log at DEBUG or TRACE level can be recorded for debugging purpose. -其中,日志文件最大长度由 numOfLogLines 来进行配置,一个 taosd 实例最多保留两个文件。 +The maximum length of a single log file is controlled by parameter `numOfLogLines` and only 2 log files are kept for each `taosd` server process. -taosd 服务端日志采用异步落盘写入机制,优点是可以避免硬盘写入压力太大,对性能造成很大影响。缺点是,在极端情况下,存在少量日志行数丢失的可能。 +log file is written in async way to minimize the workload on disk, bu the penalty is that a few log lines may be lost in some extreme conditions. diff --git a/docs-en/13-operation/_category_.yml b/docs-en/13-operation/_category_.yml index 930e441defdc80215ce5d90375a9cbd2d4bad947..3231ce910dc959a0700eb3bd4dbf8c2a727dd09b 100644 --- a/docs-en/13-operation/_category_.yml +++ b/docs-en/13-operation/_category_.yml @@ -1,4 +1 @@ -label: 运维指南 -link: - slug: /operation/ - type: generated-index +label: Administration diff --git a/docs-en/13-operation/index.md b/docs-en/13-operation/index.md new file mode 100644 index 0000000000000000000000000000000000000000..af3bf646e7aea5650df359d365707ba483ebd171 --- /dev/null +++ b/docs-en/13-operation/index.md @@ -0,0 +1,10 @@ +--- +title: Administration +--- + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-en/14-reference/02-rest-api/02-rest-api.mdx b/docs-en/14-reference/02-rest-api/02-rest-api.mdx index defa1e094c59622c437924af00ff80492ceda514..1b7887cc58294e2a755b7bc12cefe6761286998d 100644 --- a/docs-en/14-reference/02-rest-api/02-rest-api.mdx +++ b/docs-en/14-reference/02-rest-api/02-rest-api.mdx @@ -2,28 +2,28 @@ title: REST API --- -为支持各种不同类型平台的开发,TDengine 提供符合 REST 设计标准的 API,即 REST API。为最大程度降低学习成本,不同于其他数据库 REST API 的设计方法,TDengine 直接通过 HTTP POST 请求 BODY 中包含的 SQL 语句来操作数据库,仅需要一个 URL。REST 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。 +TDengine provides an API that conforms to REST design standards to support development on various platforms, i.e., the REST API. To minimize learning costs, and unlike other databases' REST API design approaches, TDengine operates on databases directly through HTTP POST requests for SQL statements contained in the BODY, requiring only a URL. See the [video tutorial](https://www.taosdata.com/blog/2020/11/11/1965.html) to use the REST connector. -注意:与原生连接器的一个区别是,RESTful 接口是无状态的,因此 `USE db_name` 指令没有效果,所有对表名、超级表名的引用都需要指定数据库名前缀。(从 2.2.0.0 版本开始,支持在 RESTful url 中指定 db_name,这时如果 SQL 语句中没有指定数据库名前缀的话,会使用 url 中指定的这个 db_name。从 2.4.0.0 版本开始,RESTful 默认由 taosAdapter 提供,要求必须在 url 中指定 db_name。) +Note: One difference from the native connector is that the RESTful interface is stateless, so the `USE db_name` directive has no effect. All references to table names and super table names need to be specified with a database name prefix. (Starting with version 2.2.0.0, RESTful supports specifying db_name in the RESTful URL, so if the database name prefix is not specified in the SQL statement, the db_name specified in the URL will be used. (db_name.) -## 安装 +## Installation -RESTful 接口不依赖于任何 TDengine 的库,因此客户端不需要安装任何 TDengine 的库,只要客户端的开发语言支持 HTTP 协议即可。 +The RESTful interface does not rely on any TDengine libraries, so the client does not need to install any TDengine libraries. The client's development language supports the HTTP protocol. -## 验证 +## Verification -在已经安装 TDengine 服务器端的情况下,可以按照如下方式进行验证。 +If the TDengine server side is already installed, it can be verified as follows: -下面以 Ubuntu 环境中使用 curl 工具(确认已经安装)来验证 RESTful 接口的正常。 +The following is an Ubuntu environment using the curl tool (to confirm that it is installed) to verify that the RESTful interface is working. -下面示例是列出所有的数据库,请把 h1.taosdata.com 和 6041(缺省值)替换为实际运行的 TDengine 服务 fqdn 和端口号: +The following example lists all databases, replacing h1.taosdata.com and 6041 (the default) with the actual running TDengine service FQDN and port number. ```html curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' h1.taosdata.com:6041/rest/sql ``` -返回值结果如下表示验证通过: +The following return value results indicate that the validation passed. ```json { @@ -72,111 +72,111 @@ h1.taosdata.com:6041/rest/sql } ``` -## HTTP 请求格式 +## HTTP request URL format ``` http://:/rest/sql/[db_name] ``` -参数说明: +Parameter Description. -- fqnd: 集群中的任一台主机 FQDN 或 IP 地址 -- port: 配置文件中 httpPort 配置项,缺省为 6041 -- db_name: 可选参数,指定本次所执行的 SQL 语句的默认数据库库名。(从 2.2.0.0 版本开始支持) +- fqnd: FQDN or IP address of any host in the cluster +- port: httpPort configuration item in the configuration file, default is 6041 +- db_name: Optional parameter that specifies the default database name for the executed SQL statement. (supported since version 2.2.0.0) -例如:http://h1.taos.com:6041/rest/sql/test 是指向地址为 h1.taos.com:6041 的 url,并将默认使用的数据库库名设置为 test。 +For example, http://h1.taos.com:6041/rest/sql/test is a URL to h1.taos.com:6041 and sets the default database name to test. -HTTP 请求的 Header 里需带有身份认证信息,TDengine 支持 Basic 认证与自定义认证两种机制,后续版本将提供标准安全的数字签名机制来做身份验证。 +TDengine supports both Basic authentication and custom authentication mechanisms, and subsequent versions will provide a standard secure digital signature mechanism for authentication. -- 自定义身份认证信息如下所示(token 稍后介绍) +- The custom authentication information is as follows (Let's introduce token later) ``` Authorization: Taosd ``` -- Basic 身份认证信息如下所示 +- Basic authentication information is shown below ``` Authorization: Basic ``` -HTTP 请求的 BODY 里就是一个完整的 SQL 语句,SQL 语句中的数据表应提供数据库前缀,例如 \.\。如果表名不带数据库前缀,又没有在 url 中指定数据库名的话,系统会返回错误。因为 HTTP 模块只是一个简单的转发,没有当前 DB 的概念。 +The HTTP request's BODY is a complete SQL statement, and the data table in the SQL statement should be provided with a database prefix, e.g., \. \. If the table name does not have a database prefix and the database name is not specified in the URL, the system will return an error because the HTTP module is a simple forwarder and has no concept of the current DB. -使用 curl 通过自定义身份认证方式来发起一个 HTTP Request,语法如下: +Use curl to initiate an HTTP Request with a custom authentication method, with the following syntax. ```bash curl -H 'Authorization: Basic ' -d '' :/rest/sql/[db_name] ``` -或者 +Or ```bash curl -u username:password -d '' :/rest/sql/[db_name] ``` -其中,`TOKEN` 为 `{username}:{password}` 经过 Base64 编码之后的字符串,例如 `root:taosdata` 编码后为 `cm9vdDp0YW9zZGF0YQ==` +where `TOKEN` is the string after Base64 encoding of `{username}:{password}`, e.g. `root:taosdata` is encoded as `cm9vdDp0YW9zZGF0YQ==` -## HTTP 返回格式 +## HTTP Return Format -返回值为 JSON 格式,如下: +The return value is in JSON format, as follows: ```json { "status": "succ", - "head": ["ts","current", …], - "column_meta": [["ts",9,8],["current",6,4], …], + "head": ["ts", "current", ...], + "column_meta": [["ts",9,8],["current",6,4], ...], "data": [ - ["2018-10-03 14:38:05.000", 10.3, …], - ["2018-10-03 14:38:15.000", 12.6, …] + ["2018-10-03 14:38:05.000", 10.3, ...], + ["2018-10-03 14:38:15.000", 12.6, ...] ], "rows": 2 } ``` -说明: +Description. -- status: 告知操作结果是成功还是失败。 -- head: 表的定义,如果不返回结果集,则仅有一列 “affected_rows”。(从 2.0.17.0 版本开始,建议不要依赖 head 返回值来判断数据列类型,而推荐使用 column_meta。在未来版本中,有可能会从返回值中去掉 head 这一项。) -- column_meta: 从 2.0.17.0 版本开始,返回值中增加这一项来说明 data 里每一列的数据类型。具体每个列会用三个值来说明,分别为:列名、列类型、类型长度。例如`["current",6,4]`表示列名为“current”;列类型为 6,也即 float 类型;类型长度为 4,也即对应 4 个字节表示的 float。如果列类型为 binary 或 nchar,则类型长度表示该列最多可以保存的内容长度,而不是本次返回值中的具体数据长度。当列类型是 nchar 的时候,其类型长度表示可以保存的 unicode 字符数量,而不是 bytes。 -- data: 具体返回的数据,一行一行的呈现,如果不返回结果集,那么就仅有 [[affected_rows]]。data 中每一行的数据列顺序,与 column_meta 中描述数据列的顺序完全一致。 -- rows: 表明总共多少行数据。 +- status: tell if the operation result is success or failure. +- head: the definition of the table, or just one column "affected_rows" if no result set is returned. (As of version 2.0.17.0, it is recommended not to rely on the head return value to determine the data column type but rather use column_meta. In future versions, the head item may be removed from the return value.) +- column_meta: this item is added to the return value to indicate the data type of each column in the data with version 2.0.17.0 and later versions. Each column is described by three values: column name, column type, and type length. For example, `["current",6,4]` means that the column name is "current", the column type is 6, which is the float type, and the type length is 4, which is the float type with 4 bytes. If the column type is binary or nchar, the type length indicates the maximum length of content stored in the column, not the length of the specific data in this return value. When the column type is nchar, the type length indicates the number of Unicode characters that can be saved, not bytes. +- data: The exact data returned, presented row by row, or just [[affected_rows]] if no result set is returned. The order of the data columns in each row of data is the same as that of the data columns described in column_meta. +- rows: Indicates how many rows of data there are. -column_meta 中的列类型说明: +The column types in column_meta are described as follows: -- 1:BOOL -- 2:TINYINT -- 3:SMALLINT -- 4:INT -- 5:BIGINT -- 6:FLOAT -- 7:DOUBLE -- 8:BINARY -- 9:TIMESTAMP -- 10:NCHAR +- 1:BOOL +- 2:TINYINT +- 3:SMALLINT +- 4:INT +- 5:BIGINT +- 6:FLOAT +- 7:DOUBLE +- 8:BINARY +- 9:TIMESTAMP +- 10:NCHAR -## 自定义授权码 +## Custom Authorization Code -HTTP 请求中需要带有授权码 ``,用于身份识别。授权码通常由管理员提供,可简单的通过发送 `HTTP GET` 请求来获取授权码,操作如下: +HTTP requests require an authorization code `` for identification purposes. The administrator usually provides the authorization code, and it can be obtained simply by sending an ``HTTP GET`` request as follows: ```bash curl http://:/rest/login// ``` -其中,`fqdn` 是 TDengine 数据库的 fqdn 或 ip 地址,port 是 TDengine 服务的端口号,`username` 为数据库用户名,`password` 为数据库密码,返回值为 `JSON` 格式,各字段含义如下: +Where `fqdn` is the FQDN or IP address of the TDengine database. `port` is the port number of the TDengine service. `username` is the database username. `password` is the database password. The return value is in `JSON` format, and the meaning of each field is as follows. -- status:请求结果的标志位 +- status: flag bit of the request result -- code:返回值代码 +- code: return value code -- desc:授权码 +- desc: authorization code -获取授权码示例: +Example of getting authorization code. ```bash curl http://192.168.0.1:6041/rest/login/root/taosdata ``` -返回值: +Response body: ```json { @@ -186,15 +186,15 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata } ``` -## 使用示例 +## For example -- 在 demo 库里查询表 d1001 的所有记录: +- query all records from table d1001 of database demo ```bash curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql ``` - 返回值: + Response body: ```json { @@ -214,13 +214,13 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata } ``` -- 创建库 demo: +- Create database demo: ```bash curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql ``` - 返回值: + Response body: ```json { @@ -232,17 +232,17 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata } ``` -## 其他用法 +## Other Uses -### 结果集采用 Unix 时间戳 +### Unix timestamps for result sets -HTTP 请求 URL 采用 `sqlt` 时,返回结果集的时间戳将采用 Unix 时间戳格式表示,例如 +When the HTTP request URL uses `sqlt`, the timestamp of the returned result set will be in Unix timestamp format, for example: ```bash curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sqlt ``` -返回值: +Response body: ```json { @@ -262,15 +262,15 @@ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001 } ``` -### 结果集采用 UTC 时间字符串 +### UTC format for the result set -HTTP 请求 URL 采用 `sqlutc` 时,返回结果集的时间戳将采用 UTC 时间字符串表示,例如 +When the HTTP request URL uses `sqlutc`, the timestamp of the returned result set will be expressed as a UTC format, for example: ```bash curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.t1' 192.168.0.1:6041/rest/sqlutc ``` -返回值: +Respones body: ```json { @@ -290,18 +290,18 @@ HTTP 请求 URL 采用 `sqlutc` 时,返回结果集的时间戳将采用 UTC } ``` -## 重要配置项 +## Important configuration items -下面仅列出一些与 RESTful 接口有关的配置参数,其他系统参数请看配置文件里的说明。 +Only some configuration parameters related to the RESTful interface are listed below. Please see the description in the configuration file for other system parameters. -- 对外提供 RESTful 服务的端口号,默认绑定到 6041(实际取值是 serverPort + 11,因此可以通过修改 serverPort 参数的设置来修改)。 -- httpMaxThreads: 启动的线程数量,默认为 2(2.0.17.0 版本开始,默认值改为 CPU 核数的一半向下取整)。 -- restfulRowLimit: 返回结果集(JSON 格式)的最大条数,默认值为 10240。 -- httpEnableCompress: 是否支持压缩,默认不支持,目前 TDengine 仅支持 gzip 压缩格式。 -- httpDebugFlag: 日志开关,默认 131。131:仅错误和报警信息,135:调试信息,143:非常详细的调试信息,默认 131。 -- httpDbNameMandatory: 是否必须在 RESTful url 中指定默认的数据库名。默认为 0,即关闭此检查。如果设置为 1,那么每个 RESTful url 中都必须设置一个默认数据库名,否则无论此时执行的 SQL 语句是否需要指定数据库,都会返回一个执行错误,拒绝执行此 SQL 语句。 +- The port number of the external RESTful service is bound to 6041 by default (the actual value is serverPort + 11, so it can be changed by modifying the setting of the serverPort parameter). +- httpMaxThreads: the number of threads to start, default is 2 (the default value is rounded down to half of the CPU cores with version 2.0.17.0 and later versions). +- restfulRowLimit: the maximum number of result sets (in JSON format) to return. The default value is 10240. +- httpEnableCompress: whether to support compression, the default is not supported. Currently, TDengine only supports the gzip compression format. +- httpDebugFlag: logging switch, default 131. 131: error and alarm messages only, 135: debug messages, 143: very detailed debug messages, default 131. +- httpDbNameMandatory: users must specify the default database name in the RESTful URL. The default is 0, which turns off this check. If set to 1, users must put a default database name in every RESTful URL. Otherwise, it will return an execution error and reject this SQL statement, regardless of whether the SQL statement executed at this time requires a specified database. :::note -如果使用 taosd 提供的 REST API, 那么以上配置需要写在 taosd 的配置文件 taos.cfg 中。如果使用 taosAdaper 提供的 REST API, 那么需要参考 taosAdaper [对应的配置方法](/reference/taosadapter/)。 +If you are using the REST API provided by taosd, you should write the above configuration in taosd's configuration file taos.cfg. If you use the REST API of taosAdaper, you need to refer to taosAdaper [corresponding configuration method](/reference/taosadapter/). ::: diff --git a/docs-en/14-reference/03-connector/03-connector.mdx b/docs-en/14-reference/03-connector/03-connector.mdx index c0e714f148a7821e070be38a5484484fdd747e9a..f392692f80690506c697b187b452fb4e2c174c54 100644 --- a/docs-en/14-reference/03-connector/03-connector.mdx +++ b/docs-en/14-reference/03-connector/03-connector.mdx @@ -1,79 +1,79 @@ --- -title: 连接器 +title: Connector --- -TDengine 提供了丰富的应用程序开发接口,为了便于用户快速开发自己的应用,TDengine 支持了多种编程语言的连接器,其中官方连接器包括支持 C/C++、Java、Python、Go、Node.js、C# 和 Rust 的连接器。这些连接器支持使用原生接口(taosc)和 REST 接口(部分语言暂不支持)连接 TDengine 集群。社区开发者也贡献了多个非官方连接器,例如 ADO.NET 连接器、Lua 连接器和 PHP 连接器。 +TDengine provides a rich application development interface. To facilitate users to develop their own applications quickly, TDengine supports connectors for multiple programming languages, including official connectors for C/C++, Java, Python, Go, Node.js, C#, and Rust. These connectors support connecting to TDengine clusters using both native interfaces (taosc) and REST interfaces (not supported in some languages yet). Community developers have also contributed several unofficial connectors, such as the ADO.NET connector, the Lua connector, and the PHP connector. ![image-connector](/img/connector.png) -## 支持的平台 +## Supported platforms -目前 TDengine 的原生接口连接器可支持的平台包括:X64/X86/ARM64/ARM32/MIPS/Alpha 等硬件平台,以及 Linux/Win64/Win32 等开发环境。对照矩阵如下: +Currently, TDengine's native interface connectors can support platforms such as X64/X86/ARM64/ARM32/MIPS/Alpha hardware platforms and Linux/Win64/Win32 development environments. The comparison matrix is as follows. -| **CPU** | **OS** | **JDBC** | **Python** | **Go** | **Node.js** | **C#** | **Rust** | C/C++ | +| **CPU** | **OS** | **JDBC** | **Python** | **Go** | **Node.js** | **C#** | **Rust** | C/C++ | | -------------- | --------- | -------- | ---------- | ------ | ----------- | ------ | -------- | ----- | -| **X86 64bit** | **Linux** | ● | ● | ● | ● | ● | ● | ● | -| **X86 64bit** | **Win64** | ● | ● | ● | ● | ● | ● | ● | -| **X86 64bit** | **Win32** | ● | ● | ● | ● | ○ | ○ | ● | -| **X86 32bit** | **Win32** | ○ | ○ | ○ | ○ | ○ | ○ | ● | -| **ARM64** | **Linux** | ● | ● | ● | ● | ○ | ○ | ● | -| **ARM32** | **Linux** | ● | ● | ● | ● | ○ | ○ | ● | -| **MIPS 龙芯** | **Linux** | ○ | ○ | ○ | ○ | ○ | ○ | ○ | -| **Alpha 申威** | **Linux** | ○ | ○ | -- | -- | -- | -- | ○ | -| **X86 海光** | **Linux** | ○ | ○ | ○ | -- | -- | -- | ○ | +| | **X86 64bit** | **Linux** | ● | ● | ● | ● | ● | ● | ● | ● +| **X86 64bit** | **Win64** | ● | ● | ● | ● | ● | ● | ● | ● +| **X86 64bit** | **Win32** | ● | ● ● | ○ | ○ | ● +| **X86 32bit** | **Win32** | ○ | ○ | ○ | ○ | ○ | ● +| **ARM64** | **Linux** | ● | ● ● | ○ | ○ | ● +| **ARM32** | **Linux** | ● ● ● ● ● ● | ○ | ○ | ● +| **MIPS Longcore** | **Linux** | ○ | ○ | ○ | ○ | ○ | ○ | ○ +| **Alpha Shenwei** | **Linux** | ○ | ○ ○ | -- | -- | --- | --- | ○ | +| **X86 Haiguang** | **Linux** | ○ | ○ | ○ | -- | -- | --- | ○ | -其中 ● 表示官方测试验证通过,○ 表示非官方测试验证通过,-- 表示未经验证。 +Where ● means the official test verification passed, ○ means the unofficial test verification passed, -- means no assurance. -使用 REST 连接由于不依赖客户端驱动可以支持更广泛的操作系统。 +Using REST connection can support a broader range of operating systems as it does not rely on client drivers. -## 版本支持 +## Version support -TDengine 版本更新往往会增加新的功能特性,列表中的连接器版本为连接器最佳适配版本。 +TDengine version updates often add new features, and the connector versions in the list are the best-fit versions of the connector. -| **TDengine 版本** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** | +| **TDengine Versions** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** | | --------------------- | -------- | ---------- | ------------ | ------------- | --------------- | -------- | -| **2.4.0.14 及以上** | 2.0.38 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 | -| **2.4.0.6 及以上** | 2.0.37 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 | -| **2.4.0.4 - 2.4.0.5** | 2.0.37 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 | -| **2.2.x.x ** | 2.0.36 | 当前版本 | master 分支 | n/a | 2.0.7 - 2.0.9 | 当前版本 | -| **2.0.x.x ** | 2.0.34 | 当前版本 | master 分支 | n/a | 2.0.1 - 2.0.6 | 当前版本 | +| **2.4.0.14 and up** | 2.0.38 | current version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version | +| **2.4.0.6 and up** | 2.0.37 | current version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version | +| **2.4.0.4 - 2.4.0.5** | 2.0.37 | current version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version | +| **2.2.x.x ** | 2.0.36 | current version | master branch | n/a | 2.0.7 - 2.0.9 | current version | +| **2.0.x.x ** | 2.0.34 | current version | master branch | n/a | 2.0.1 - 2.0.6 | current version | -## 功能特性 +## Functional Features -连接器对 TDengine 功能特性的支持对照如下: +Comparing the connector support for TDengine functional features as follows. -### 使用原生接口(taosc) +### Using the native interface (taosc) -| **功能特性** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** | +| **Functional Features** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** | | -------------- | -------- | ---------- | ------ | ------ | ----------- | -------- | -| **连接管理** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **普通查询** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **连续查询** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **参数绑定** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **订阅功能** | 支持 | 支持 | 支持 | 支持 | 支持 | 暂不支持 | -| **Schemaless** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **DataFrame** | 不支持 | 支持 | 不支持 | 不支持 | 不支持 | 不支持 | +| **Connection Management** | Support | Support | Support | Support | Support | Support | Support +| Support | Support | Support | Support | Support | Support | Support | Support | Support +| Support | Support | Support | Support | Support | Support | Support | Support | Support +| **Parameter Binding** | Support | Support | Support | Support | Support | Support | Support +| Support | Support | Support | Support | Support | Support | Support | Not Supported +| **Schemaless** | Support | Support | Support | Support | Support | Support | Support +| **DataFrame** | Not Supported | Support | Not Supported | Not Supported | Not Supported | Not Supported :::info -由于不同编程语言数据库框架规范不同,并不意味着所有 C/C++ 接口都需要对应封装支持。 +The different database framework specifications for various programming languages do not mean that all C/C++ interfaces need a wrapper. ::: -### 使用 REST 接口 +### Using the REST interface -| **功能特性** | **Java** | **Python** | **Go** | **C#(暂不支持)** | **Node.js** | **Rust** | +| **Functional Features** | **Java** | **Python** | **Go** | **C# (not supported yet)** | **Node.js** | **Rust** | | ------------------------------ | -------- | ---------- | -------- | ------------------ | ----------- | -------- | -| **连接管理** | 支持 | 支持 | 支持 | N/A | 支持 | 支持 | -| **普通查询** | 支持 | 支持 | 支持 | N/A | 支持 | 支持 | -| **连续查询** | 支持 | 支持 | 支持 | N/A | 支持 | 支持 | -| **参数绑定** | 不支持 | 不支持 | 不支持 | N/A | 不支持 | 不支持 | -| **订阅功能** | 不支持 | 不支持 | 不支持 | N/A | 不支持 | 不支持 | -| **Schemaless** | 暂不支持 | 暂不支持 | 暂不支持 | N/A | 暂不支持 | 暂不支持 | -| **批量拉取(基于 WebSocket)** | 支持 | 暂不支持 | 暂不支持 | N/A | 暂不支持 | 暂不支持 | -| **DataFrame** | 不支持 | 支持 | 不支持 | N/A | 不支持 | 不支持 | +| **Connection Management** | Support | Support | Support | N/A | Support | Support | Support +| Support | Support | N/A | Support | Support | Support +| Support | Support | N/A | Support | Support | Support +| Support | N/A | Support | N/A | Support | N/A +| | N/A | Support | N/A | Support | N/A +| **Schemaless** | Not supported | N/A | Not supported | Not supported | N/A +| N/A | Not Supported | Not Supported | N/A +| **DataFrame** | Not supported | Support | Not supported | N/A | Not supported | Not supported :::warning -- 无论选用何种编程语言的连接器,2.0 及以上版本的 TDengine 推荐数据库应用的每个线程都建立一个独立的连接,或基于线程建立连接池,以避免连接内的“USE statement”状态量在线程之间相互干扰(但连接的查询和写入操作都是线程安全的)。 +- Regardless of the programming language chosen for the connector, TDengine versions 2.0 and above recommend that each thread of a database application create a separate connection. Or create a connection pool based on threads to avoid interference between threads with the "USE statement" state within a connection (but the connection's query and write operations are thread-safe). ::: @@ -84,14 +84,14 @@ import InstallOnLinux from "./_windows_install.mdx"; import VerifyWindows from "./_verify_windows.mdx"; import VerifyLinux from "./_verify_linux.mdx"; -## 安装客户端驱动 +## Install client driver :::info -只有在没有安装 TDengine 服务端软件的系统上使用原生接口连接器才需要安装客户端驱动。 +The client driver needs to be installed if you use the native interface connector on a system that does not have the TDengine server software installed. ::: -### 安装步骤 +### Installation steps @@ -102,9 +102,9 @@ import VerifyLinux from "./_verify_linux.mdx"; -### 安装验证 +### Installation Verification -以上安装和配置完成后,并确认 TDengine 服务已经正常启动运行,此时可以执行 TDengine CLI 工具进行登录。 +After completing the above installation and configuration and you have confirmed that the TDengine service is up and running, you can execute the TDengine CLI tool to log in. diff --git a/docs-en/14-reference/03-connector/_category_.yml b/docs-en/14-reference/03-connector/_category_.yml index abd3f666f3b93697fde59931ffd7b10a0308b6b7..e470f64aa013b137f05f03db112641faf2956297 100644 --- a/docs-en/14-reference/03-connector/_category_.yml +++ b/docs-en/14-reference/03-connector/_category_.yml @@ -1 +1 @@ -label: "连接器" \ No newline at end of file +label: "connector" \ No newline at end of file diff --git a/docs-en/14-reference/03-connector/_linux_install.mdx b/docs-en/14-reference/03-connector/_linux_install.mdx index 6437583b43d905272a9676703d318b9fdb74d941..0cd2c617633c7d6f7a73594249266db8285c63fb 100644 --- a/docs-en/14-reference/03-connector/_linux_install.mdx +++ b/docs-en/14-reference/03-connector/_linux_install.mdx @@ -1,30 +1,34 @@ import PkgList from "/components/PkgList"; -1. 下载客户端安装包 +1. Download the TDengine client installation package - [所有下载](https://www.taosdata.com/cn/all-downloads/) + [All Packages](https://www.taosdata.com/en/all-downloads/) -2. 解压缩软件包 +2. Unzip - 将软件包放置在当前用户可读写的任意目录下,然后执行下面的命令:`tar -xzvf TDengine-client-VERSION.tar.gz` - 其中 VERSION 需要替换为实际版本的字符串。 -3. 执行安装脚本 + Download the package to any directory the current user has read/write permission. Then execute `tar -xzvf TDengine-client-VERSION.tar.gz` command. + The VERSION should be the version of the package you just downloaded. - 解压软件包之后,会在解压目录下看到以下文件(目录): - - _ install_client.sh_:安装脚本,用于应用驱动程序 - - _ taos.tar.gz_:应用驱动安装包 - - _ driver_:TDengine 应用驱动 driver - - _examples_: 各种编程语言的示例程序(c/C#/go/JDBC/MATLAB/python/R) - 运行 install_client.sh 进行安装。 -4. 配置 taos.cfg +3. Execute the install script - 编辑 taos.cfg 文件(默认路径/etc/taos/taos.cfg),将 firstEP 修改为 TDengine 服务器的 End Point,例如:`h1.tdengine.com:6030` + Once the package is unzipped, you will see the following files in the directory: + - _ install_client.sh_: install script + - _ taos.tar.gz_: application driver package + - _ driver_: TDengine application driver + - _examples_: some example programs of different programming languages (C/C#/go/JDBC/MATLAB/python/R) + + You can run `install_client.sh` to install it. + +4. Edit taos.cfg + + Edit `taos.cfg` file (full path is `/etc/taos/taos.cfg` by default), modify `firstEP` with actual TDengine server's End Point, for example `h1.tdengine.com:6030` :::tip -1. 如本机没有部署 TDengine 服务,仅安装了应用驱动,则 taos.cfg 中仅需配置 firstEP,无需在本机配置 FQDN。 -2. 为防止与服务器端连接时出现“Unable to resolve FQDN”错误,建议确认本机的 hosts 文件已经配置了服务器正确的 FQDN 值,或配置好了 DNS 服务。 +1. If the computer does not run the TDengine service but installs the TDengine application driver, then you need to config `firstEP` in `taos.cfg` only, and there is no need to configure `FQDN`; + +2. If you encounter the "Unable to resolve FQDN" error, please make sure the FQDN in the `/etc/hosts` file of the current computer is correctly configured, or the DNS service is correctly configured. ::: diff --git a/docs-en/14-reference/03-connector/_preparition.mdx b/docs-en/14-reference/03-connector/_preparition.mdx index 87538ebfd8c60507aec90ee86e427d85979dbc4a..8f48d997b1588da8ae8c425b657037d90f1abd45 100644 --- a/docs-en/14-reference/03-connector/_preparition.mdx +++ b/docs-en/14-reference/03-connector/_preparition.mdx @@ -1,10 +1,10 @@ -- 已安装客户端驱动(使用原生连接必须安装,使用 REST 连接无需安装) +- Client driver installed (mandatory for native connections, not required for REST connections) :::info -由于 TDengine 的客户端驱动使用 C 语言编写,使用原生连接时需要加载系统对应安装在本地的客户端驱动共享库文件,通常包含在 TDengine 安装包。TDengine Linux 服务端安装包附带了 TDengine 客户端,也可以单独安装 [Linux 客户端](/get-started/) 。在 Windows 环境开发时需要安装 TDengine 对应的 [Windows 客户端](https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client) 。 +Since the TDengine client driver is written in C, using the native connection requires loading the client driver shared library file, which is usually included in the TDengine installer. You can install either standard TDengine server installation package or [TDengine client installtion package](/get-started/). For Windows development, you need to install the corresponding [Windows client](https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client) for TDengine. -- libtaos.so: 在 Linux 系统中成功安装 TDengine 后,依赖的 Linux 版客户端驱动 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。 -- taos.dll: 在 Windows 系统中安装完客户端之后,依赖的 Windows 版客户端驱动 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。 +- libtaos.so: After successful installation of TDengine on a Linux system, the dependent Linux version of the client driver libtaos.so file will be automatically copied to /usr/lib/libtaos.so, which is included in the Linux scanable path and does not need to be specified separately. +- taos.dll: After installing the client on Windows, the dependent Windows version of the client driver taos.dll file will be automatically copied to the system default search path C:/Windows/System32, again without the need to specify it separately. ::: diff --git a/docs-en/14-reference/03-connector/_verify_linux.mdx b/docs-en/14-reference/03-connector/_verify_linux.mdx index 120ef0e5a72c3e9486d56be282c51ad0d77fb69c..291c3d95aadffa0949fef271fb98cb619c941db5 100644 --- a/docs-en/14-reference/03-connector/_verify_linux.mdx +++ b/docs-en/14-reference/03-connector/_verify_linux.mdx @@ -1,4 +1,4 @@ -在 Linux shell 下直接执行 `taos` 连接到 TDegine 服务,进入到 TDengine CLI 界面,示例如下: +Execute `taos` directly from the Linux shell to connect to the TDengine service and enter the TDengine CLI interface, as shown in the following example. ```text $ taos diff --git a/docs-en/14-reference/03-connector/_verify_windows.mdx b/docs-en/14-reference/03-connector/_verify_windows.mdx index 87c9fbd024f2c80b88434d47f35d919ed1ea77b2..bb3e97856fb51c4906ad0321b9863de1c6d17349 100644 --- a/docs-en/14-reference/03-connector/_verify_windows.mdx +++ b/docs-en/14-reference/03-connector/_verify_windows.mdx @@ -1,14 +1,14 @@ -在 cmd 下进入到 C:\TDengine 目录下直接执行 `taos.exe`,连接到 TDengine 服务,进入到 TDengine CLI 界面,示例如下: - -```text - C:\TDengine>taos - Welcome to the TDengine shell from Linux, Client Version:2.0.5.0 - Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. - taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep1,keep2,keep(D) | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | precision | status | - =================================================================================================================================================================================================================================================================== - test | 2020-10-14 10:35:48.617 | 10 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready | - log | 2020-10-12 09:08:21.651 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready | - Query OK, 2 row(s) in set (0.045000s) - taos> -``` +Go to the C:\TDengine directory from `cmd` and execute `taos.exe` directly to connect to the TDengine service and enter the TDengine CLI interface, for example, as follows: + +```text + C:\TDengine>taos + Welcome to the TDengine shell from Linux, Client Version:2.0.5.0 + Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. + taos> show databases; + name | created_time | ntables | vgroups | replica | quorum | days | keep1,keep2,keep(D) | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | precision | status | + =================================================================================================================================================================================================================================================================== + test | 2020-10-14 10:35:48.617 | 10 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready | + log | 2020-10-12 09:08:21.651 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready | + Query OK, 2 row(s) in set (0.045000s) + taos> +``` diff --git a/docs-en/14-reference/03-connector/_windows_install.mdx b/docs-en/14-reference/03-connector/_windows_install.mdx index 755f96b2d728621de5752ce752e5d249cda0f6d9..a3d9caeb0555944c8397de36efa7304dd5fe1d3d 100644 --- a/docs-en/14-reference/03-connector/_windows_install.mdx +++ b/docs-en/14-reference/03-connector/_windows_install.mdx @@ -1,31 +1,31 @@ import PkgList from "/components/PkgList"; -1. 下载客户端安装包 +1. Download the client installation package - [所有下载](https://www.taosdata.com/cn/all-downloads/) + [All downloads](https://www.taosdata.com/cn/all-downloads/) -2. 执行安装程序,按提示选择默认值,完成安装 -3. 安装路径 +2. Execute the installer, select the default value as prompted, and complete the installation +3. Installation path - 默认安装路径为:C:\TDengine,其中包括以下文件(目录): + The default installation path is C:\TDengine, including the following files (directories). - - _taos.exe_:TDengine CLI 命令行程序 - - _cfg_ : 配置文件目录 - - _driver_: 应用驱动动态链接库 - - _examples_: 示例程序 bash/C/C#/go/JDBC/Python/Node.js - - _include_: 头文件 - - _log_ : 日志文件 - - _unins000.exe_: 卸载程序 + - _taos.exe_ : TDengine CLI command line program + - _cfg_ : configuration file directory + - _driver_: application driver dynamic link library + - _examples_: sample programs bash/C/C#/go/JDBC/Python/Node.js + - _include_: header files + - _log_ : log file + - _unins000.exe_: uninstaller -4. 配置 taos.cfg +4. configure taos.cfg - 编辑 taos.cfg 文件(默认路径 C:\TDengine\cfg\taos.cfg),将 firstEP 修改为 TDengine 服务器的 End Point,例如:`h1.tdengine.com:6030`。 + Edit the taos.cfg file (default path C:\TDengine\cfg\taos.cfg) and change the firstEP to the End Point of the TDengine server, for example: `h1.tdengine.com:6030`. :::tip -1. 如利用 FQDN 连接服务器,必须确认本机网络环境 DNS 已配置好,或在 hosts 文件中添加 FQDN 寻址记录, 如编辑 C:\Windows\system32\drivers\etc\hosts,添加类似如下的记录:`192.168.1.99 h1.taos.com` -2. 卸载:运行 unins000.exe 可卸载 TDengine 应用驱动。 +1. If you use FQDN to connect to the server, you must ensure the local network environment DNS is configured, or add FQDN addressing records in the `hosts` file, e.g., edit C:\Windows\system32\drivers\etc\hosts and add a record like the following: `192.168.1.99 h1.tados.com`.. +2. Uninstall: Run unins000.exe to uninstall the TDengine application driver. ::: diff --git a/docs-en/14-reference/03-connector/cpp.mdx b/docs-en/14-reference/03-connector/cpp.mdx index 29aebaed3d8ca852950508ba751b8c86689724ca..6e653df0ae1b411aa2578df04f67f7e83837a28c 100644 --- a/docs-en/14-reference/03-connector/cpp.mdx +++ b/docs-en/14-reference/03-connector/cpp.mdx @@ -4,39 +4,39 @@ sidebar_label: C/C++ title: C/C++ Connector --- -C/C++ 开发人员可以使用 TDengine 的客户端驱动,即 C/C++连接器 (以下都用 TDengine 客户端驱动表示),开发自己的应用来连接 TDengine 集群完成数据存储、查询以及其他功能。TDengine 客户端驱动的 API 类似于 MySQL 的 C API。应用程序使用时,需要包含 TDengine 头文件 _taos.h_,里面列出了提供的 API 的函数原型;应用程序还要链接到所在平台上对应的动态库。 +C/C++ developers can use TDengine's client driver, the C/C++ connector (hereafter referred to as the TDengine client driver), to develop their applications to connect to TDengine clusters for data storing, querying, and other functions. To use it, you need to include the TDengine header file _taos.h_, which lists the function prototypes of the provided APIs; the application also needs to link to the corresponding dynamic libraries on the platform where it is located. ```c #include ``` -TDengine 服务端或客户端安装后,`taos.h` 位于: +After TDengine server or client installation, `taos.h` is located at -- Linux:`/usr/local/taos/include` -- Windows:`C:\TDengine\include` +- Linux: `/usr/local/taos/include` +- Windows: `C:\TDengine\include` -TDengine 客户端驱动的动态库位于: +The dynamic libraries for the TDengine client driver are located in. - Linux: `/usr/local/taos/driver/libtaos.so` - Windows: `C:\TDengine\taos.dll` -## 支持的平台 +## Supported platforms -请参考[支持的平台列表](/reference/connector#支持的平台) +Please refer to [list of supported platforms](/reference/connector#supported platforms) -## 支持的版本 +## Supported versions -TDengine 客户端驱动的版本号与 TDengine 服务端的版本号是一一对应的强对应关系,建议使用与 TDengine 服务端完全相同的客户端驱动。虽然低版本的客户端驱动在前三段版本号一致(即仅第四段版本号不同)的情况下也能够与高版本的服务端相兼容,但这并非推荐用法。强烈不建议使用高版本的客户端驱动访问低版本的服务端。 +The version number of the TDengine client driver and the version number of the TDengine server require one-to-one correspondence and recommend using the same client driver as the TDengine server. Although a lower version of the client driver is compatible with a higher version of the server, if the first three version numbers are the same (i.e., only the fourth version number is different), it is not recommended. It is strongly discouraged to use a high version of the client driver to access a low version of the server. -## 安装步骤 +## Installation steps -TDengine 客户端驱动的安装请参考 [安装指南](/reference/connector#安装步骤) +Please refer to the [Installation Guide](/reference/connector#installation steps) for TDengine client driver installation -## 建立连接 +## Establishing a connection -使用客户端驱动访问 TDengine 集群的基本过程为:建立连接、查询和写入、关闭连接、清除资源。 +The basic process of accessing a TDengine cluster using the client driver is to establish a connection, query and write, close the connection, and clear the resource. -下面为建立连接的示例代码,其中省略了查询和写入部分,展示了如何建立连接、关闭连接以及清除资源。 +The following is sample code for establishing a connection, which omits the query and writing sections and shows how to establish a connection, close a connection, and clear a resource. ```c TAOS *taos = taos_connect("localhost:6030", "root", "taosdata", NULL, 0); @@ -45,29 +45,29 @@ TDengine 客户端驱动的安装请参考 [安装指南](/reference/connector# exit(1); } - /* put your code here for read and write */ + /* put your code here for query and writing */ taos_close(taos); taos_cleanup(); ``` -在上面的示例代码中, `taos_connect` 建立到客户端程序所在主机的 6030 端口的连接,`taos_close`关闭当前连接,`taos_cleanup`清除客户端驱动所申请和使用的资源。 +In the above example code, `taos_connect` establishes a connection to port 6030 on the host where the client application is located, `taos_close` closes the current connection, and `taos_cleanup` clears the resources requested and used by the client driver. :::note -- 如未特别说明,当 API 的返回值是整数时,_0_ 代表成功,其它是代表失败原因的错误码,当返回值是指针时, _NULL_ 表示失败。 -- 所有的错误码以及对应的原因描述在 taoserror.h 文件中。 +- If not specified, when the return value of the API is an integer, _0_ means success, the others are error codes representing the reason for failure, and when the return value is a pointer, _NULL_ means failure. +- All error codes and their corresponding causes are described in the taoserror.h file. ::: -## 示例程序 +## Example program -本节展示了使用客户端驱动访问 TDengine 集群的常见访问方式的示例代码。 +This section shows sample code for standard access methods to TDengine clusters using the client driver. -### 同步查询示例 +### Synchronous query example
-同步查询 +Synchronous query ```c {{#include examples/c/demo.c}} @@ -75,10 +75,10 @@ TDengine 客户端驱动的安装请参考 [安装指南](/reference/connector#
-### 异步查询示例 +### Asynchronous query example
-异步查询 +Asynchronous queries ```c {{#include examples/c/asyncdemo.c}} @@ -86,10 +86,10 @@ TDengine 客户端驱动的安装请参考 [安装指南](/reference/connector#
-### 参数绑定示例 +### Parameter binding example
-参数绑定 +Parameter Binding ```c {{#include examples/c/prepare.c}} @@ -97,10 +97,10 @@ TDengine 客户端驱动的安装请参考 [安装指南](/reference/connector#
-### 无模式写入示例 +### Pattern-free writing example
-无模式写入 +Mode free write ```c {{#include examples/c/schemaless.c}} @@ -108,10 +108,10 @@ TDengine 客户端驱动的安装请参考 [安装指南](/reference/connector#
-### 订阅和消费示例 +### Subscription and consumption example
-订阅和消费 +Subscribe and consume ```c {{#include examples/c/subscribe.c}} @@ -120,188 +120,190 @@ TDengine 客户端驱动的安装请参考 [安装指南](/reference/connector#
:::info -更多示例代码及下载请见 [github](https://github.com/taosdata/TDengine/tree/develop/examples/c) -也可以在安装目录下的 examples/c 路径下找到。 该目录下有 makefile,在 Linux 环境下,直接执行 make 就可以编译得到执行文件。 -**提示:**在 ARM 环境下编译时,请将 makefile 中的 `-msse4.2` 去掉,这个选项只有在 x64/x86 硬件平台上才能支持。 +More example code and downloads are available at [github](https://github.com/taosdata/TDengine/tree/develop/examples/c) +You can find it in the installation directory under the examples/c path. This directory has a makefile and can be compiled under Linux by executing make directly. +**Hint:** When compiling in an ARM environment, please remove `-msse4.2` from the makefile. This option is only supported on x64/x86 hardware platforms. ::: -## API 参考 +## API reference -以下分别介绍 TDengine 客户端驱动的基础 API、同步 API、异步 API、订阅 API 和无模式写入 API。 +The following describes the basic API, synchronous API, asynchronous API, subscription API, and modeless write API of TDengine client driver, respectively. -### 基础 API +### Basic API -基础 API 用于完成创建数据库连接等工作,为其它 API 的执行提供运行时环境。 +The base API is used to do things like create database connections and provide a runtime environment for the execution of other APIs. - `void taos_init()` - 初始化运行环境。如果应用没有主动调用该 API,那么应用在调用 `taos_connect()` 时将自动调用,故应用程序一般无需手动调用该 API。 + Initializes the runtime environment. If the API is not actively called, the driver will automatically call the API when `taos_connect()` is called, so the program generally does not need to call it manually. - `void taos_cleanup()` - 清理运行环境,应用退出前应调用此 API。 + Clean up the runtime environment and should be called before the application exits. -- `int taos_options(TSDB_OPTION option, const void * arg, ...)` +- ` int taos_options(TSDB_OPTION option, const void * arg, ...) ` - 设置客户端选项,目前支持区域设置(`TSDB_OPTION_LOCALE`)、字符集设置(`TSDB_OPTION_CHARSET`)、时区设置(`TSDB_OPTION_TIMEZONE`)、配置文件路径设置(`TSDB_OPTION_CONFIGDIR`)。区域设置、字符集、时区默认为操作系统当前设置。 + Set client options, currently supports region setting (`TSDB_OPTION_LOCALE`), character set +(`TSDB_OPTION_CHARSET`), time zone +(`TSDB_OPTION_TIMEZONE`), configuration file path (`TSDB_OPTION_CONFIGDIR`) . The region setting, character set, and time zone default to the current settings of the operating system. - `char *taos_get_client_info()` - 获取客户端版本信息。 + Get client version information. - `TAOS *taos_connect(const char *host, const char *user, const char *pass, const char *db, int port)` - 创建数据库连接,初始化连接上下文。其中需要用户提供的参数包含: + Creates a database connection and initializes the connection context. Among the parameters required from the user are - - host:TDengine 管理主节点的 FQDN - - user:用户名 - - pass:密码 - - db:数据库名字,如果用户没有提供,也可以正常连接,用户可以通过该连接创建新的数据库,如果用户提供了数据库名字,则说明该数据库用户已经创建好,缺省使用该数据库 - - port:TDengine 管理主节点的端口号 + - host: FQDN of any node in the TDengine cluster + - user: user name + - pass: password + - db: database name, if the user does not provide, it can also be connected correctly, the user can create a new database through this connection, if the user provides the database name, it means that the database user has already created, the default use of the database + - port: the port the tasd program is listening on - 返回值为空表示失败。应用程序需要保存返回的参数,以便后续 API 调用。 + A null return value indicates a failure. The application needs to save the returned parameters for subsequent use. :::info - 同一进程可以根据不同的 host/port 连接多个 TDengine 集群 + The same process can connect to multiple TDengine clusters according to different host/port ::: - `char *taos_get_server_info(TAOS *taos)` - 获取服务端版本信息。 + Get server-side version information. -- `int taos_select_db(TAOS *taos, const char *db)` +- ` int taos_select_db(TAOS *taos, const char *db)` - 将当前的缺省数据库设置为 `db`。 + Set the current default database to `db`. - `void taos_close(TAOS *taos)` - 关闭连接,其中`taos`是 `taos_connect()` 函数返回的指针。 + Closes the connection, where `taos` is the handle returned by `taos_connect()`. -### 同步查询 API +### Synchronous query APIs -传统的数据库操作 API,都属于同步操作。应用调用 API 后,一直处于阻塞状态,直到服务端返回结果。 +The APIs described in this subsection are all synchronous interfaces. After being called by the application, it blocks and waits for a response until it gets a return result or an error message. - `TAOS_RES* taos_query(TAOS *taos, const char *sql)` - 该 API 用来执行 SQL 语句,可以是 DQL、DML 或 DDL 语句。 其中的 `taos` 参数是通过 `taos_connect()` 获得的指针。不能通过返回值是否是 `NULL` 来判断执行结果是否失败,而是需要用 `taos_errno()` 函数解析结果集中的错误代码来进行判断。 + Executes an SQL statement, either a DQL, DML, or DDL statement. The `taos` parameter is a handle obtained with `taos_connect()`. You can't tell if the result failed by whether the return value is `NULL`, but by parsing the error code in the result set with the `taos_errno()` function. - `int taos_result_precision(TAOS_RES *res)` - 返回结果集时间戳字段的精度,`0` 代表毫秒,`1` 代表微秒,`2` 代表纳秒。 + Returns the precision of the result set timestamp field, `0` for milliseconds, `1` for microseconds, and `2` for nanoseconds. - `TAOS_ROW taos_fetch_row(TAOS_RES *res)` - 按行获取查询结果集中的数据。 + Fetch the data in the query result set by row. -- `int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows)` +- ` int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows)` - 批量获取查询结果集中的数据,返回值为获取到的数据的行数。 + Batch fetches the data in the query result set. The return value is the number of rows of the fetched data. -- `int taos_num_fields(TAOS_RES *res)` 和 `int taos_field_count(TAOS_RES *res)` +- `int taos_num_fields(TAOS_RES *res)` and `int taos_field_count(TAOS_RES *res)` - 这两个 API 等价,用于获取查询结果集中的列数。 + These two APIs are equivalent and are used to get the number of columns in the query result set. - `int* taos_fetch_lengths(TAOS_RES *res)` - 获取结果集中每个字段的长度。返回值是一个数组,其长度为结果集的列数。 + Gets the lengths of each field in the result set. The return value is an array whose length is the number of columns in the result set. - `int taos_affected_rows(TAOS_RES *res)` - 获取被所执行的 SQL 语句影响的行数。 + Get the number of rows affected by the executed SQL statement. -- `TAOS_FIELD *taos_fetch_fields(TAOS_RES *res)` +- ` TAOS_FIELD *taos_fetch_fields(TAOS_RES *res)` - 获取查询结果集每列数据的属性(列的名称、列的数据类型、列的长度),与 `taos_num_fileds()` 配合使用,可用来解析 `taos_fetch_row()` 返回的一个元组(一行)的数据。 `TAOS_FIELD` 的结构如下: + Gets the properties of each column of the query result set (column name, column data type, column length), used in conjunction with `taos_num_fileds()` to parse a tuple (one row) of data returned by `taos_fetch_row()`. The structure of `TAOS_FIELD` is as follows. ```c typedef struct taosField { - char name[65]; // column name - uint8_t type; // data type - int16_t bytes; // length, in bytes + char name[65]; // column name + uint8_t type; // data type + int16_t bytes; // length, in bytes } TAOS_FIELD; ``` - `void taos_stop_query(TAOS_RES *res)` - 停止一个查询的执行。 + Stops the execution of the current query. -- `void taos_free_result(TAOS_RES *res)` +- ` void taos_free_result(TAOS_RES *res)` - 释放查询结果集以及相关的资源。查询完成后,务必调用该 API 释放资源,否则可能导致应用内存泄露。但也需注意,释放资源后,如果再调用 `taos_consume()` 等获取查询结果的函数,将导致应用崩溃。 + Frees the query result set and the associated resources. Be sure to call this API to free the resources after the query is completed. Otherwise, it may lead to a memory leak in the application. However, note that the application will crash if you call a function like `taos_consume()` to get the query results after freeing the resources. - `char *taos_errstr(TAOS_RES *res)` - 获取最近一次 API 调用失败的原因,返回值为字符串。 + Get the reason for the failure of the last API call. The return value is an error message identified by a string. -- `int taos_errno(TAOS_RES *res)` +- 'int taos_errno(TAOS_RES *res)` - 获取最近一次 API 调用失败的原因,返回值为错误代码。 + Get the reason for the last API call failure. The return value is the error code. :::note -2.0 及以上版本 TDengine 推荐数据库应用的每个线程都建立一个独立的连接,或基于线程建立连接池。而不推荐在应用中将该连接 (TAOS\*) 结构体传递到不同的线程共享使用。基于 TAOS 结构体发出的查询、写入等操作具有多线程安全性,但 “USE statement” 等状态量有可能在线程之间相互干扰。此外,C 语言的连接器可以按照需求动态建立面向数据库的新连接(该过程对用户不可见),同时建议只有在程序最后退出的时候才调用 `taos_close()` 关闭连接。 +TDengine version 2.0 and above recommends that each thread of a database application create a separate connection or a connection pool based on threads. It is not recommended to pass the connection (TAOS\*) structure to different threads for shared use in the application. Queries, writes, etc., issued based on TAOS structures are multi-thread safe, but state quantities such as "USE statement" may interfere between threads. In addition, the C connector can dynamically create new database-oriented connections on demand (this procedure is not visible to the user), and it is recommended that `taos_close()` be called only at the final exit of the program to close the connection. ::: -### 异步查询 API +### Asynchronous query API -同步 API 之外,TDengine 还提供性能更高的异步调用 API 处理数据插入、查询操作。在软硬件环境相同的情况下,异步 API 处理数据插入的速度比同步 API 快 2 ~ 4 倍。异步 API 采用非阻塞式的调用方式,在系统真正完成某个具体数据库操作前,立即返回。调用的线程可以去处理其他工作,从而可以提升整个应用的性能。异步 API 在网络延迟严重的情况下,优点尤为突出。 +TDengine also provides a higher performance asynchronous API to handle data insertion and query operations. Given the same hardware and software environment, the asynchronous API can run data insertion 2 to 4 times faster than the synchronous API. The asynchronous API is called non-blocking and returns immediately before the system completes a specific database operation. The calling thread can go to work on other tasks, which can improve the performance of the whole application. Asynchronous APIs are particularly advantageous in the case of severe network latency. -异步 API 都需要应用提供相应的回调函数,回调函数参数设置如下:前两个参数都是一致的,第三个参数依不同的 API 而定。第一个参数 param 是应用调用异步 API 时提供给系统的,用于回调时,应用能够找回具体操作的上下文,依具体实现而定。第二个参数是 SQL 操作的结果集,如果为空,比如 insert 操作,表示没有记录返回,如果不为空,比如 select 操作,表示有记录返回。 +The asynchronous APIs require the application to provide a callback function with the following parameters: the first two parameters are consistent, and the third parameter depends on the API. The first parameter, param, is provided to the system when the application calls the asynchronous API. It is used for the callback so that the application can retrieve the context of the specific operation, depending on the implementation. The second parameter is the result set of the SQL operation. If it is empty, such as insert operation, it means that there are no records returned, and if it is not empty, such as select operation, it means that there are records returned. -异步 API 对于使用者的要求相对较高,用户可根据具体应用场景选择性使用。下面是两个重要的异步 API: +The asynchronous API has relatively high user requirements, so users can use it selectively according to specific application scenarios. The following are two important asynchronous APIs. - `void taos_query_a(TAOS *taos, const char *sql, void (*fp)(void *param, TAOS_RES *, int code), void *param);` - 异步执行 SQL 语句。 + Execute SQL statements asynchronously. - - taos:调用 `taos_connect()` 返回的数据库连接 - - sql:需要执行的 SQL 语句 - - fp:用户定义的回调函数,其第三个参数 `code` 用于指示操作是否成功,`0` 表示成功,负数表示失败(调用 `taos_errstr()` 可获取失败原因)。应用在定义回调函数的时候,主要处理第二个参数 `TAOS_RES *`,该参数是查询返回的结果集 - - param:应用提供一个用于回调的参数 + - taos: the database connection returned by calling `taos_connect()` + - sql: the SQL statement to be executed + - fp: user-defined callback function whose third parameter `code` is used to indicate whether the operation was successful or not, `0` means success, a negative number means failure (call `taos_errstr()` to get the reason for failure). When defining the callback function, the application mainly handles the second parameter `TAOS_RES *`, which is the result set returned by the query + - param: the application provides a parameter for the callback - `void taos_fetch_rows_a(TAOS_RES *res, void (*fp)(void *param, TAOS_RES *, int numOfRows), void *param);` - 批量获取异步查询的结果集,只能与 `taos_query_a()` 配合使用。其中: + Batch get the result set of an asynchronous query, which can only be used with `taos_query_a()`. The parameters are: - - res:`taos_query_a()` 回调时返回的结果集 - - fp:回调函数。其参数 `param` 是用户可定义的传递给回调函数的参数结构体;`numOfRows` 是获取到的数据的行数(不是整个查询结果集的函数)。 在回调函数中,应用可以通过调用 `taos_fetch_row()` 前向迭代获取批量记录中每一行记录。读完一块内的所有记录后,应用需要在回调函数中继续调用 `taos_fetch_rows_a()` 获取下一批记录进行处理,直到返回的记录数 `numOfRows` 为零(结果返回完成)或记录数为负值(查询出错)。 + - res: the result set returned by the `taos_query_a()` callback + - fp: callback function. Its parameter `param` is a user-definable parameter structure passed to the callback function; `numOfRows` is the number of rows of the fetched data (not a function of the entire query result set). In the callback function, the application can iterate forward to fetch each row of records in the batch by calling `taos_fetch_row()`. After reading all the rows in a block, the application needs to continue calling `taos_fetch_rows_a()` in the callback function to get the next batch of rows for processing until the number of rows returned, `numOfRows`, is zero (result return complete) or the number of rows is negative (query error). -TDengine 的异步 API 均采用非阻塞调用模式。应用程序可以用多线程同时打开多张表,并可以同时对每张打开的表进行查询或者插入操作。需要指出的是,**客户端应用必须确保对同一张表的操作完全串行化**,即对同一个表的插入或查询操作未完成时(未返回时),不能够执行第二个插入或查询操作。 +TDengine's asynchronous APIs all use a non-blocking call pattern. Applications can open multiple tables simultaneously using multiple threads and perform queries or inserts on each open table at the same time. It is important to note that **client applications must ensure that operations on the same table are fully serialized**. i.e., no second insert or query operation can be performed while an insert or query operation on the same table is incomplete (not returned). -### 参数绑定 API +### Parameter Binding API -除了直接调用 `taos_query()` 进行查询,TDengine 也提供了支持参数绑定的 Prepare API,风格与 MySQL 类似,目前也仅支持用问号 `?` 来代表待绑定的参数。 +In addition to direct calls to `taos_query()` to perform queries, TDengine also provides a Prepare API that supports parameter binding, similar in style to MySQL, and currently only supports using a question mark `? ` to represent the parameter to be bound. -从 2.1.1.0 和 2.1.2.0 版本开始,TDengine 大幅改进了参数绑定接口对数据写入(INSERT)场景的支持。这样在通过参数绑定接口写入数据时,就避免了 SQL 语法解析的资源消耗,从而在绝大多数情况下显著提升写入性能。此时的典型操作步骤如下: +Starting with versions 2.1.1.0 and 2.1.2.0, TDengine has significantly improved the parameter binding interface's support for data writing (INSERT) scenarios. This avoids the resource consumption of SQL syntax parsing when writing data through the parameter binding interface, thus significantly improving write performance in most cases. A typical operation, in this case, is as follows. -1. 调用 `taos_stmt_init()` 创建参数绑定对象; -2. 调用 `taos_stmt_prepare()` 解析 INSERT 语句; -3. 如果 INSERT 语句中预留了表名但没有预留 TAGS,那么调用 `taos_stmt_set_tbname()` 来设置表名; -4. 如果 INSERT 语句中既预留了表名又预留了 TAGS(例如 INSERT 语句采取的是自动建表的方式),那么调用 `taos_stmt_set_tbname_tags()` 来设置表名和 TAGS 的值; -5. 调用 `taos_stmt_bind_param_batch()` 以多列的方式设置 VALUES 的值,或者调用 `taos_stmt_bind_param()` 以单行的方式设置 VALUES 的值; -6. 调用 `taos_stmt_add_batch()` 把当前绑定的参数加入批处理; -7. 可以重复第 3 ~ 6 步,为批处理加入更多的数据行; -8. 调用 `taos_stmt_execute()` 执行已经准备好的批处理指令; -9. 执行完毕,调用 `taos_stmt_close()` 释放所有资源。 +1. call `taos_stmt_init()` to create the parameter binding object. +2. call `taos_stmt_prepare()` to parse the INSERT statement. 3. +3. call `taos_stmt_set_tbname()` to set the table name if it is reserved in the INSERT statement but not the TAGS. +4. call `taos_stmt_set_tbname_tags()` to set the table name and TAGS values if the table name and TAGS are reserved in the INSERT statement (for example, if the INSERT statement takes an automatic table build). +5. call `taos_stmt_bind_param_batch()` to set the value of VALUES in multiple columns, or call `taos_stmt_bind_param()` to set the value of VALUES in a single row. +6. call `taos_stmt_add_batch()` to add the currently bound parameters to the batch. +7. you can repeat steps 3 to 6 to add more rows of data to the batch. +8. call `taos_stmt_execute()` to execute the prepared batch instructions. +9. When execution is complete, call `taos_stmt_close()` to release all resources. -说明:如果 `taos_stmt_execute()` 执行成功,假如不需要改变 SQL 语句的话,那么是可以复用 `taos_stmt_prepare()` 的解析结果,直接进行第 3 ~ 6 步绑定新数据的。但如果执行出错,那么并不建议继续在当前的环境上下文下继续工作,而是建议释放资源,然后从 `taos_stmt_init()` 步骤重新开始。 +Note: If `taos_stmt_execute()` succeeds, you can reuse the parsed result of `taos_stmt_prepare()` to bind new data in steps 3 to 6 if you don't need to change the SQL statement. However, if there is an execution error, it is not recommended to continue working in the current context but release the resources and start again with `taos_stmt_init()` steps. -接口相关的具体函数如下(也可以参考 [prepare.c](https://github.com/taosdata/TDengine/blob/develop/examples/c/prepare.c) 文件中使用对应函数的方式): +The specific functions related to the interface are as follows (see also the [prepare.c](https://github.com/taosdata/TDengine/blob/develop/examples/c/prepare.c) file for the way to use the corresponding functions) - `TAOS_STMT* taos_stmt_init(TAOS *taos)` - 创建一个 TAOS_STMT 对象用于后续调用。 + Creates a TAOS_STMT object for subsequent calls. -- `int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length)` +- ` int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length)` - 解析一条 SQL 语句,将解析结果和参数信息绑定到 stmt 上,如果参数 length 大于 0,将使用此参数作为 SQL 语句的长度,如等于 0,将自动判断 SQL 语句的长度。 + Parse a SQL statement, and bind the parsed result and parameter information to stmt. If the parameter length is greater than 0, use this parameter as the length of the SQL statement. If it is equal to 0, the length of the SQL statement will be determined automatically. - `int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind)` - 不如 `taos_stmt_bind_param_batch()` 效率高,但可以支持非 INSERT 类型的 SQL 语句。 - 进行参数绑定,bind 指向一个数组(代表所要绑定的一行数据),需保证此数组中的元素数量和顺序与 SQL 语句中的参数完全一致。TAOS_BIND 的使用方法与 MySQL 中的 MYSQL_BIND 类似,具体定义如下: + Not as efficient as `taos_stmt_bind_param_batch()`, but can support non-INSERT type SQL statements. + To bind parameters, bind points to an array (representing the row of data to be bound), making sure that the number and order of the elements in this array are the same as the parameters in the SQL statement. taos_bind is used similarly to MYSQL_BIND in MySQL, as defined below. ```c typedef struct TAOS_BIND { @@ -317,80 +319,80 @@ TDengine 的异步 API 均采用非阻塞调用模式。应用程序可以用多 - `int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name)` - (2.1.1.0 版本新增,仅支持用于替换 INSERT 语句中的参数值) - 当 SQL 语句中的表名使用了 `?` 占位时,可以使用此函数绑定一个具体的表名。 + (New in version 2.1.1.0, only supported for replacing parameter values in INSERT statements) + When the table name in the SQL statement uses `? ` placeholder, you can use this function to bind a specific table name. - `int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags)` - (2.1.2.0 版本新增,仅支持用于替换 INSERT 语句中的参数值) - 当 SQL 语句中的表名和 TAGS 都使用了 `?` 占位时,可以使用此函数绑定具体的表名和具体的 TAGS 取值。最典型的使用场景是使用了自动建表功能的 INSERT 语句(目前版本不支持指定具体的 TAGS 列)。TAGS 参数中的列数量需要与 SQL 语句中要求的 TAGS 数量完全一致。 + (New in version 2.1.2.0, only supported for replacing parameter values in INSERT statements) + When the table name and TAGS in the SQL statement both use `? `, you can use this function to bind the specific table name and the specific TAGS value. The most typical usage scenario is an INSERT statement that uses the automatic table building function (the current version does not support specifying specific TAGS columns.) The number of columns in the TAGS parameter needs to be the same as the number of TAGS requested in the SQL statement. - `int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind)` - (2.1.1.0 版本新增,仅支持用于替换 INSERT 语句中的参数值) - 以多列的方式传递待绑定的数据,需要保证这里传递的数据列的顺序、列的数量与 SQL 语句中的 VALUES 参数完全一致。TAOS_MULTI_BIND 的具体定义如下: + (new in version 2.1.1.0, only supported for replacing parameter values in INSERT statements) + To pass the data to be bound in a multi-column manner, it is necessary to ensure that the order of the data columns and the number of columns given here are the same as the VALUES parameter in the SQL statement. The specific definition of TAOS_MULTI_BIND is as follows. ```c typedef struct TAOS_MULTI_BIND { - int buffer_type; - void * buffer; - uintptr_t buffer_length; - uintptr_t * length; - char * is_null; - int num; // the number of columns + int buffer_type; + void * buffer; + uintptr_t buffer_length; + uintptr_t * length; + char * is_null; + int num; // the number of columns } TAOS_MULTI_BIND; ``` -- `int taos_stmt_add_batch(TAOS_STMT *stmt)` +- ` int taos_stmt_add_batch(TAOS_STMT *stmt)` - 将当前绑定的参数加入批处理中,调用此函数后,可以再次调用 `taos_stmt_bind_param()` 或 `taos_stmt_bind_param_batch()` 绑定新的参数。需要注意,此函数仅支持 INSERT/IMPORT 语句,如果是 SELECT 等其他 SQL 语句,将返回错误。 + Adds the currently bound parameter to the batch. After calling this function, you can call `taos_stmt_bind_param()` or `taos_stmt_bind_param_batch()` again to bind a new parameter. Note that this function only supports INSERT/IMPORT statements. Other SQL statements such as SELECT will return an error. - `int taos_stmt_execute(TAOS_STMT *stmt)` - 执行准备好的语句。目前,一条语句只能执行一次。 + Execute the prepared statement. Currently, a statement can only be executed once. -- `TAOS_RES* taos_stmt_use_result(TAOS_STMT *stmt)` +- ` TAOS_RES* taos_stmt_use_result(TAOS_STMT *stmt)` - 获取语句的结果集。结果集的使用方式与非参数化调用时一致,使用完成后,应对此结果集调用 `taos_free_result()` 以释放资源。 + Gets the result set of a statement. Use the result set in the same way as in the non-parametric call. When finished, `taos_free_result()` should be called on this result set to free resources. - `int taos_stmt_close(TAOS_STMT *stmt)` - 执行完毕,释放所有资源。 + Finish execution and release all resources. -- `char * taos_stmt_errstr(TAOS_STMT *stmt)` +- ` char * taos_stmt_errstr(TAOS_STMT *stmt)` - (2.1.3.0 版本新增) - 用于在其他 STMT API 返回错误(返回错误码或空指针)时获取错误信息。 + (new in version 2.1.3.0) + Used to get error information if other STMT APIs return errors (return error codes or null pointers). -### 无模式写入 API +### Write-without-mode API -除了使用 SQL 方式或者使用参数绑定 API 写入数据外,还可以使用 Schemaless 的方式完成写入。Schemaless 可以免于预先创建超级表/数据子表的数据结构,而是可以直接写入数据,TDengine 系统会根据写入的数据内容自动创建和维护所需要的表结构。Schemaless 的使用方式详见 [Schemaless 写入](/reference/schemaless/) 章节,这里介绍与之配套使用的 C/C++ API。 +In addition to writing data using the SQL method or the parameter binding API, writing can also be done using Schemaless, which eliminates the need to create a super table/data sub-table structure in advance and writes the data directly. The TDengine system automatically creates and maintains the required table structure based on the written data content. The use of Schemaless is described in the chapter [Schemaless Writing](/reference/schemaless/), and the C/C++ API used with it is described here. - `TAOS_RES* taos_schemaless_insert(TAOS* taos, const char* lines[], int numLines, int protocol, int precision)` - **功能说明** - 该接口将行协议的文本数据写入到 TDengine 中。 + **Function description** + This interface writes the text data of the line protocol to TDengine. - **参数说明** - taos: 数据库连接,通过 `taos_connect()` 函数建立的数据库连接。 - lines:文本数据。满足解析格式要求的无模式文本字符串。 - numLines:文本数据的行数,不能为 0 。 - protocol: 行协议类型,用于标识文本数据格式。 - precision:文本数据中的时间戳精度字符串。 + **Parameter description** + taos: database connection, established by the `taos_connect()` function. + lines: text data. A pattern-free text string that meets the parsing format requirements. + numLines: the number of lines of text data, cannot be 0. + protocol: the protocol type of the lines, used to identify the text data format. + precision: precision string for the timestamp in the text data. - **返回值** - TAOS_RES 结构体,应用可以通过使用 `taos_errstr()` 获得错误信息,也可以使用 `taos_errno()` 获得错误码。 - 在某些情况下,返回的 TAOS_RES 为 `NULL`,此时仍然可以调用 `taos_errno()` 来安全地获得错误码信息。 - 返回的 TAOS_RES 需要调用方来负责释放,否则会出现内存泄漏。 + **return value** + TAOS_RES structure, application can get error message by using `taos_errstr()` and also error code by using `taos_errno()`. + In some cases, the returned TAOS_RES is `NULL`, and it is still possible to call `taos_errno()` to safely get the error code information. + The returned TAOS_RES needs to be freed by the caller. Otherwise, a memory leak will occur. - **说明** - 协议类型是枚举类型,包含以下三种格式: + **Description** + The protocol type is enumerated and contains the following three formats. - - TSDB_SML_LINE_PROTOCOL:InfluxDB 行协议(Line Protocol) - - TSDB_SML_TELNET_PROTOCOL: OpenTSDB Telnet 文本行协议 - - TSDB_SML_JSON_PROTOCOL: OpenTSDB Json 协议格式 + - TSDB_SML_LINE_PROTOCOL: InfluxDB line protocol (Line Protocol) + - TSDB_SML_TELNET_PROTOCOL: OpenTSDB Telnet Text Line Protocol + - TSDB_SML_JSON_PROTOCOL: OpenTSDB Json protocol format - 时间戳分辨率的定义,定义在 taos.h 文件中,具体内容如下: + The timestamp resolution definitions are in the taos.h file, as follows - TSDB_SML_TIMESTAMP_NOT_CONFIGURED = 0, - TSDB_SML_TIMESTAMP_HOURS, @@ -400,51 +402,51 @@ TDengine 的异步 API 均采用非阻塞调用模式。应用程序可以用多 - TSDB_SML_TIMESTAMP_MICRO_SECONDS, - TSDB_SML_TIMESTAMP_NANO_SECONDS - 需要注意的是,时间戳分辨率参数只在协议类型为 `SML_LINE_PROTOCOL` 的时候生效。 - 对于 OpenTSDB 的文本协议,时间戳的解析遵循其官方解析规则 — 按照时间戳包含的字符的数量来确认时间精度。 + Note that the timestamp resolution parameter only takes effect when the protocol type is `SML_LINE_PROTOCOL`. + For OpenTSDB's text protocol, timestamp resolution follows its official resolution rules - time precision is confirmed by the number of characters contained in the timestamp. - **支持版本** - 该功能接口从 2.3.0.0 版本开始支持。 + **Supported Versions** + This feature interface is supported from version 2.3.0.0. -### 订阅和消费 API +### Subscription and Consumption API -订阅 API 目前支持订阅一张或多张表,并通过定期轮询的方式不断获取写入表中的最新数据。 +The Subscription API currently supports subscribing to one or more tables and continuously fetching the latest data written to them by polling periodically. - `TAOS_SUB *taos_subscribe(TAOS* taos, int restart, const char* topic, const char *sql, TAOS_SUBSCRIBE_CALLBACK fp, void *param, int interval)` - 该函数负责启动订阅服务,成功时返回订阅对象,失败时返回 `NULL`,其参数为: + This function is responsible for starting the subscription service, returning the subscription object on success and `NULL` on failure, with the following parameters. - - taos:已经建立好的数据库连接 - - restart:如果订阅已经存在,是重新开始,还是继续之前的订阅 - - topic:订阅的主题(即名称),此参数是订阅的唯一标识 - - sql:订阅的查询语句,此语句只能是 `select` 语句,只应查询原始数据,只能按时间正序查询数据 - - fp:收到查询结果时的回调函数(稍后介绍函数原型),只在异步调用时使用,同步调用时此参数应该传 `NULL` - - param:调用回调函数时的附加参数,系统 API 将其原样传递到回调函数,不进行任何处理 - - interval:轮询周期,单位为毫秒。异步调用时,将根据此参数周期性的调用回调函数,为避免对系统性能造成影响,不建议将此参数设置的过小;同步调用时,如两次调用 `taos_consume()` 的间隔小于此周期,API 将会阻塞,直到时间间隔超过此周期。 + - taos: the database connection that has been established + - restart: if the subscription already exists, whether to restart or continue the previous subscription + - topic: the topic of the subscription (i.e., the name). This parameter is the unique identifier of the subscription + - sql: the query statement of the subscription, this statement can only be `select` statement, only the original data should be queried, only the data can be queried in time order + - fp: the callback function when the query result is received (the function prototype will be introduced later), only used when called asynchronously. This parameter should be passed `NULL` when called synchronously + - param: additional parameter when calling the callback function, the system API will pass it to the callback function as it is, without any processing + - interval: polling period in milliseconds. The callback function will be called periodically according to this parameter when called asynchronously. not recommended to set this parameter too small To avoid impact on system performance when called synchronously. If the interval between two calls to `taos_consume()` is less than this period, the API will block until the interval exceeds this period. -- `typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code)` +- ` typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code)` - 异步模式下,回调函数的原型,其参数为: + The prototype of the callback function in asynchronous mode with the following parameters - - tsub:订阅对象 - - res:查询结果集,注意结果集中可能没有记录 - - param:调用 `taos_subscribe()` 时客户程序提供的附加参数 - - code:错误码 + - tsub: subscription object + - res: query result set, note that there may be no records in the result set + - param: additional parameters provided by the client program when calling `taos_subscribe()` + - code: error code :::note - 在这个回调函数里不可以做耗时过长的处理,尤其是对于返回的结果集中数据较多的情况,否则有可能导致客户端阻塞等异常状态。如果必须进行复杂计算,则建议在另外的线程中进行处理。 + The callback function should not take too long to process, especially if the returned result set has a lot of data. Otherwise, it may lead to an abnormal state, such as client blocking. If you must perform complex calculations, we recommend handling them in a separate thread. ::: - `TAOS_RES *taos_consume(TAOS_SUB *tsub)` - 同步模式下,该函数用来获取订阅的结果。 用户应用程序将其置于一个循环之中。 如两次调用 `taos_consume()` 的间隔小于订阅的轮询周期,API 将会阻塞,直到时间间隔超过此周期。如果数据库有新记录到达,该 API 将返回该最新的记录,否则返回一个没有记录的空结果集。 如果返回值为 `NULL`,说明系统出错。 异步模式下,用户程序不应调用此 API。 + In synchronous mode, this function is used to fetch the results of a subscription. The user application places it in a loop. If the interval between two calls to `taos_consume()` is less than the polling period of the subscription, the API will block until the interval exceeds this period. If a new record arrives in the database, the API returns that latest record. Otherwise, it returns an empty result set with no records. If the return value is `NULL`, there is a system error. This API should not be called by user programs in asynchronous mode. :::note - 在调用 `taos_consume()` 之后,用户应用应确保尽快调用 `taos_fetch_row()` 或 `taos_fetch_block()` 来处理订阅结果,否则服务端会持续缓存查询结果数据等待客户端读取,极端情况下会导致服务端内存消耗殆尽,影响服务稳定性。 + After calling `taos_consume()`, the user application should make sure to call `taos_fetch_row()` or `taos_fetch_block()` to process the subscription results as soon as possible. Otherwise, the server-side will keep caching the query result data waiting to be read by the client, which in extreme cases will cause the server side to run out of memory and affect the stability of the service. ::: - `void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress)` - 取消订阅。 如参数 `keepProgress` 不为 0,API 会保留订阅的进度信息,后续调用 `taos_subscribe()` 时可以基于此进度继续;否则将删除进度信息,后续只能重新开始读取数据。 + Unsubscribe. If the parameter `keepProgress` is not 0, the API will keep the progress information of the subscription, and subsequent calls to `taos_subscribe()` will continue based on this progress; otherwise, the progress information will be deleted, and subsequent readings will have to be restarted. diff --git a/docs-en/14-reference/03-connector/csharp.mdx b/docs-en/14-reference/03-connector/csharp.mdx index bbefaacb459153ab5116d557fdf1940d487b4bd3..336039c18fdaafaf31e5dab304d529d2bf1aef87 100644 --- a/docs-en/14-reference/03-connector/csharp.mdx +++ b/docs-en/14-reference/03-connector/csharp.mdx @@ -16,54 +16,55 @@ import CSOpenTSDBJson from "../../04-develop/03-insert-data/_cs_opts_json.mdx" import CSQuery from "../../04-develop/04-query-data/_cs.mdx" import CSAsyncQuery from "../../04-develop/04-query-data/_cs_async.mdx" -`TDengine.Connector` 是 TDengine 提供的 C# 语言连接器。C# 开发人员可以通过它开发存取 TDengine 集群数据的 C# 应用软件。 -`TDengine.Connector` 连接器支持通过 TDengine 客户端驱动(taosc)建立与 TDengine 运行实例的连接,提供数据写入、查询、订阅、schemaless 数据写入、参数绑定接口数据写入等功能 `TDengine.Connector` 目前暂未提供 REST 连接方式,用户可以参考 [RESTful APIs](https://docs.taosdata.com//reference/restful-api/) 文档自行编写。 +TDengine.Connector` is a C# language connector provided by TDengine that allows C# developers to develop C# applications that access TDengine cluster data. -本文介绍如何在 Linux 或 Windows 环境中安装 `TDengine.Connector`,并通过 `TDengine.Connector` 连接 TDengine 集群,进行数据写入、查询等基本操作。 +The `TDengine.Connector` connector supports connection to TDengine runtime instances via the TDengine client driver (taosc), providing data writing, querying, subscription, schemaless data writing, bind interface data writing, etc. The `TDengine.Connector` currently does not provide a REST connection. REST connection is not yet available. Users can write their RESTful APIs by referring to the [RESTful APIs](https://docs.taosdata.com//reference/restful-api/) documentation. -`TDengine.Connector` 的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-dotnet)。 +This article describes how to install `TDengine.Connector` in a Linux or Windows environment and connect to TDengine clusters via `TDengine.Connector` to perform basic operations such as data writing and querying. -## 支持的平台 +The source code of `TDengine.Connector` is hosted on [GitHub](https://github.com/taosdata/taos-connector-dotnet). -支持的平台和 TDengine 客户端驱动支持的平台一致。 +## Supported Platforms -## 版本支持 +The supported platforms are the same as those supported by the TDengine client driver. -请参考[版本支持列表](/reference/connector#版本支持) +## Version support -## 支持的功能特性 +Please refer to [version support list](/reference/connector#version support) -1. 连接管理 -2. 普通查询 -3. 连续查询 -4. 参数绑定 -5. 订阅功能 +## Supported features + +1. connection management +2. general query +3. continuous query +4. parameter binding +5. subscription function 6. Schemaless -## 安装步骤 +## Installation Steps -### 安装前准备 +### Pre-installation preparation -* 安装 [.NET SDK](https://dotnet.microsoft.com/download) -* [Nuget 客户端](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools) (可选安装) -* 安装 TDengine 客户端驱动,具体步骤请参考[安装客户端驱动](/reference/connector#安装客户端驱动) +* Install the [.NET SDK](https://dotnet.microsoft.com/download) +* [Nuget Client](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools) (optional installation) +* Install TDengine client driver, please refer to [Install client driver](/reference/connector#Install client driver) for details -### 使用 dotnet CLI 安装 +### Install using dotnet CLI - + -可以在当前 .NET 项目的路径下,通过 dotnet 命令引用 Nuget 中发布的 `TDengine.Connector` 到当前项目。 +You can reference the `TDengine.Connector` published in Nuget to the current project via the `dotnet` command under the path of the existing .NET project. ``` bash dotnet add package TDengine.Connector ``` - + -可以下载 TDengine 的源码,直接引用最新版本的 TDengine.Connector 库 +You can download TDengine's source code and directly reference the latest version of the TDengine.Connector library ```bash git clone https://github.com/taosdata/TDengine.git @@ -76,7 +77,7 @@ dotnet add TDengineDriver/TDengineDriver.csproj -## 建立连接 +## Create a connection ``` C# using TDengineDriver; @@ -111,79 +112,79 @@ namespace TDengineExample ``` -## 使用示例 +## Usage examples -### 写入数据 +### Write data -#### SQL 写入 +#### SQL Write -#### InfluxDB 行协议写入 +#### InfluxDB line protocol write -#### OpenTSDB Telnet 行协议写入 +#### OpenTSDB Telnet line protocol write -#### OpenTSDB JSON 行协议写入 +#### OpenTSDB JSON line protocol write -### 查询数据 +### Query data -#### 同步查询 +#### Synchronous Query -#### 异步查询 +#### Asynchronous query -### 更多示例程序 +### More sample programs -|示例程序 | 示例程序描述 | -|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------| -| [C#checker](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/C%23checker) | 使用 TDengine.Connector 可以通过 help 命令中提供的参数,测试C# Driver的同步写入和查询 | -| [TDengineTest](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/TDengineTest) | 使用 TDengine.Connector 实现的简单写入和查询的示例 | -| [insertCn](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/insertCn) | 使用 TDengine.Connector 实现的写入和查询中文字符的示例 | -| [jsonTag](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/jsonTag) | 使用 TDengine.Connector 实现的写入和查询 json tag 类型数据的示例 | -| [stmt](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/stmt) | 使用 TDengine.Connector 实现的参数绑定的示例 | -| [schemaless](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/schemaless) | 使用 TDengine.Connector 实现的使用 schemaless 写入的示例 | -| [benchmark](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/taosdemo) | 使用 TDengine.Connector 实现的简易 Benchmark | -| [async query](https://github.com/taosdata/taos-connector-dotnet/blob/develop/examples/QueryAsyncSample.cs) | 使用 TDengine.Connector 实现的异步查询的示例 | -| [subscribe](https://github.com/taosdata/taos-connector-dotnet/blob/develop/examples/SubscribeSample.cs) | 使用 TDengine.Connector 实现的订阅数据的示例 | +|Sample program |Sample program description | +|--------------------------------------------------------------------------------------------------------------------|------------ --------------------------------| +| [C#checker](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/C%23checker) | Using TDengine.Connector, you can test C# Driver's synchronous writes and queries | +| [TDengineTest](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/TDengineTest) | A simple example of writing and querying using TDengine. +| [insertCn](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/insertCn) | Example of writing and querying Chinese characters using TDengine. +| [jsonTag](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/jsonTag) | Example of writing and querying JSON tag type data using TDengine. +| [stmt](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/stmt) | Example of parameter binding using TDengine. +| [schemaless](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/schemaless) | Example of writing with schemaless implemented using TDengine. |schemaless +| [benchmark](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/taosdemo) | A simple benchmark implemented using TDengine. +| [async query](https://github.com/taosdata/taos-connector-dotnet/blob/develop/examples/QueryAsyncSample.cs) | Example of an asynchronous query implemented using TDengine. Example of an asynchronous query +| [subscribe](https://github.com/taosdata/taos-connector-dotnet/blob/develop/examples/SubscribeSample.cs) | Example of subscribing to data using TDengine. Data example -## 重要更新记录 +## Important update records -| TDengine.Connector | 说明 | +| TDengine.Connector | Description | |--------------------|--------------------------------| -| 1.0.6 | 修复 schemaless 在 1.0.4 和 1.0.5 中失效 bug。 | -| 1.0.5 | 修复 Windows 同步查询中文报错 bug。 | -| 1.0.4 | 新增异步查询,订阅等功能。修复绑定参数 bug。 | -| 1.0.3 | 新增参数绑定、schemaless、 json tag等功能。 | -| 1.0.2 | 新增连接管理、同步查询、错误信息等功能。 | +| 1.0.6 | Fix schemaless bug in 1.0.4 and 1.0.5. | +| 1.0.5 | Fix Windows sync query Chinese error bug. | 1.0.4 | Fix schemaless bug. +| 1.0.4 | Add asynchronous query, subscription, and other functions. Fix the binding parameter bug. +| 1.0.3 | Add parameter binding, schemaless, JSON tag, etc. | new +| 1.0.2 | Add connection management, synchronous query, error messages, etc. ## Other -## 其他说明 +## Other descriptions -### 第三方驱动 +### Third-party driver -`Maikebing.Data.Taos` 是一个 TDengine 的 ADO.NET 连接器,支持 Linux,Windows 平台。该连接器由社区贡献者`麦壳饼@@maikebing` 提供,具体请参考: +`Taos` is an ADO.NET connector for TDengine, supporting Linux and Windows platforms. Community contributor `Maikebing@@maikebing contributes the connector`. Please refer to: -* 接口下载: -* 用法说明: +* Interface download: +* Usage notes: -## 常见问题 +## Frequently Asked Questions -1. "Unable to establish connection","Unable to resolve FQDN" +1. "Unable to establish connection", "Unable to resolve FQDN" - 一般是因为 FQDN 配置不正确。可以参考[如何彻底搞懂 TDengine 的 FQDN](https://www.taosdata.com/blog/2021/07/29/2741.html)解决。 + Usually, because the FQDN configuration is incorrect, you can refer to [How to understand TDengine's FQDN thoroughly](https://www.taosdata.com/blog/2021/07/29/2741.html) to solve it. 2. -2. Unhandled exception. System.DllNotFoundException: Unable to load DLL 'taos' or one of its dependencies: 找不到指定的模块。 +Unhandled exception. System.DllNotFoundException: Unable to load DLL 'taos' or one of its dependencies: The specified module cannot be found. - 一般是因为程序没有找到依赖的客户端驱动。解决方法为:Windows 下可以将 `C:\TDengine\driver\taos.dll` 拷贝到 `C:\Windows\System32\ ` 目录下,Linux 下建立如下软链接 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 + This is usually because the program did not find the dependent client driver. The solution is to copy `C:\TDengine\driver\taos.dll` to the `C:\Windows\System32\` directory on Windows, and create the following softlink on Linux `ln -s /usr/local/taos/driver/libtaos.so.x.x .x.x /usr/lib/libtaos.so` will work. -## API 参考 +## API Reference -[API 参考](https://docs.taosdata.com/api/connector-csharp/html/860d2ac1-dd52-39c9-e460-0829c4e5a40b.htm) +[API Reference](https://docs.taosdata.com/api/connector-csharp/html/860d2ac1-dd52-39c9-e460-0829c4e5a40b.htm) diff --git a/docs-en/14-reference/03-connector/go.mdx b/docs-en/14-reference/03-connector/go.mdx index c5f448916a39acdf7f0ffff01bf431d93f2143b4..90f60410423a80a6c230fd5552db2d72eab1dce9 100644 --- a/docs-en/14-reference/03-connector/go.mdx +++ b/docs-en/14-reference/03-connector/go.mdx @@ -15,67 +15,67 @@ import GoOpenTSDBTelnet from "../../04-develop/03-insert-data/_go_opts_telnet.md import GoOpenTSDBJson from "../../04-develop/03-insert-data/_go_opts_json.mdx" import GoQuery from "../../04-develop/04-query-data/_go.mdx" -`driver-go` 是 TDengine 的官方 Go 语言连接器,实现了 Go 语言[ database/sql ](https://golang.org/pkg/database/sql/) 包的接口。Go 开发人员可以通过它开发存取 TDengine 集群数据的应用软件。 +`driver-go` is the official Go language connector for TDengine, which implements the interface to the Go language [ database/sql ](https://golang.org/pkg/database/sql/) package. Go developers can use it to develop applications that access TDengine cluster data. -`driver-go` 提供两种建立连接的方式。一种是**原生连接**,它通过 TDengine 客户端驱动程序(taosc)原生连接 TDengine 运行实例,支持数据写入、查询、订阅、schemaless 接口和参数绑定接口等功能。另外一种是 **REST 连接**,它通过 taosAdapter 提供的 REST 接口连接 TDengine 运行实例。REST 连接实现的功能特性集合和原生连接有少量不同。 +`driver-go` provides two ways to establish connections. One is **native connection**, which connects to TDengine runtime instances natively through the TDengine client driver (taosc), supporting data writing, querying, subscriptions, schemaless interface, and parameter binding interface. The other is the **REST connection**, which connects to TDengine runtime instances via the REST interface provided by taosAdapter. The set of features implemented by the REST connection differs slightly from the native connection. -本文介绍如何安装 `driver-go`,并通过 `driver-go` 连接 TDengine 集群、进行数据查询、数据写入等基本操作。 +This article describes how to install `driver-go` and connect to TDengine clusters and perform basic operations such as data query and data writing through `driver-go`. -`driver-go` 的源码托管在 [GitHub](https://github.com/taosdata/driver-go)。 +The source code of `driver-go` is hosted on [GitHub](https://github.com/taosdata/driver-go). -## 支持的平台 +## Supported Platforms -原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。 -REST 连接支持所有能运行 Go 的平台。 +Native connections are supported on the same platforms as the TDengine client driver. +REST connections are supported on all platforms that can run Go. -## 版本支持 +## Version support -请参考[版本支持列表](/reference/connector#版本支持) +Please refer to [version support list](/reference/connector#version support) -## 支持的功能特性 +## Supported features -### 原生连接 +### Native connections -“原生连接”指连接器通过 TDengine 客户端驱动(taosc)直接与 TDengine 运行实例建立的连接。支持的功能特性有: +A "native connection" is established by the connector directly to the TDengine runtime instance via the TDengine client driver (taosc). The supported functional features are -* 普通查询 -* 连续查询 -* 订阅 -* schemaless 接口 -* 参数绑定接口 +* Normal queries +* Continuous queries +* Subscriptions +* schemaless interface +* parameter binding interface -### REST 连接 +### REST connection -"REST 连接"指连接器通过 taosAdapter 组件提供的 REST API 与 TDengine 运行实例建立的连接。支持的功能特性有: +A "REST connection" is a connection between a connector and a TDengine runtime instance via the REST API provided by the taosAdapter component. The following features are supported. -* 普通查询 -* 连续查询 +* General queries +* Continuous queries -## 安装步骤 +## Installation steps -### 安装前准备 +### Pre-installation -* 安装 Go 开发环境(Go 1.14 及以上,GCC 4.8.5 及以上) -* 如果使用原生连接器,请安装 TDengine 客户端驱动,具体步骤请参考[安装客户端驱动](/reference/connector#安装客户端驱动) +* Install Go development environment (Go 1.14 and above, GCC 4.8.5 and above) +* If you use the native connector, please install the TDengine client driver. Please refer to [Install Client Driver](/reference/connector#Install Client Driver) for specific steps -配置好环境变量,检查命令: +Configure the environment variables and check the command. -* ```go env``` -* ```gcc -v``` +* ```go env`` +* ```gcc -v`` -### 使用 go get 安装 +### Use go get to install -`go get -u github.com/taosdata/driver-go/v2@develop` +``go get -u github.com/taosdata/driver-go/v2@develop`` -### 使用 go mod 管理 +### Manage with go mod -1. 使用 `go mod` 命令初始化项目: +1. Initialize the project with the `go mod` command. - ```text + ``text go mod init taos-demo - ``` + ``` text -2. 引入 taosSql : +2. Introduce taosSql: ``text ```go import ( @@ -84,46 +84,46 @@ REST 连接支持所有能运行 Go 的平台。 ) ``` -3. 使用 `go mod tidy` 更新依赖包: +3. Update the dependency packages with `go mod tidy`. ```text go mod tidy - ``` + ``` 4. -4. 使用 `go run taos-demo` 运行程序或使用 `go build` 命令编译出二进制文件。 +4. Run the program with `go run taos-demo` or compile the binary with the `go build` command. ```text go run taos-demo go build ``` -## 建立连接 +## Create a connection -### 数据源名称(DSN) +### Data source name (DSN) -数据源名称具有通用格式,例如 [PEAR DB](http://pear.php.net/manual/en/package.database.db.intro-dsn.php),但没有类型前缀(方括号表示可选): +Data source names have a standard format, e.g. [PEAR DB](http://pear.php.net/manual/en/package.database.db.intro-dsn.php), but no type prefix (square brackets indicate optionally): the ``` text -[username[:password]@][protocol[(address)]]/[dbname][?param1=value1&...¶mN=valueN] +[username[:password]@][protocol[(address)]]/[dbname][?param1=value1&... ¶mN=valueN] ``` -完整形式的 DSN: +DSN in full form. ```text username:password@protocol(address)/dbname?param=value ``` -### 使用连接器进行连接 +### Connecting using connectors - + -_taosSql_ 通过 cgo 实现了 Go 的 `database/sql/driver` 接口。只需要引入驱动就可以使用 [`database/sql`](https://golang.org/pkg/database/sql/) 的接口。 +_taosSql_ implements Go's `database/sql/driver` interface via cgo. You can use the [`database/sql`](https://golang.org/pkg/database/sql/) interface by simply introducing the driver. -使用 `taosSql` 作为 `driverName` 并且使用一个正确的 [DSN](#DSN) 作为 `dataSourceName`,DSN 支持的参数: +Use `taosSql` as `driverName` and use a correct [DSN](#DSN) as `dataSourceName`, DSN supports the following parameters. -* configPath 指定 taos.cfg 目录 +* configPath specifies the taos.cfg directory -示例: +Example. ```go package main @@ -136,9 +136,9 @@ import ( ) func main() { - var taosUri = "root:taosdata/tcp(localhost:6030)/" + var taosUri = "root:taosdata@tcp(localhost:6030)/" taos, err := sql.Open("taosSql", taosUri) - if err != nil { + if err ! = nil { fmt.Println("failed to connect TDengine, err:", err) return } @@ -146,16 +146,16 @@ func main() { ``` - + -_taosRestful_ 通过 `http client` 实现了 Go 的 `database/sql/driver` 接口。只需要引入驱动就可以使用[`database/sql`](https://golang.org/pkg/database/sql/)的接口。 +_taosRestful_ implements Go's `database/sql/driver` interface via `http client`. You can use the [`database/sql`](https://golang.org/pkg/database/sql/) interface by simply introducing the driver. -使用 `taosRestful` 作为 `driverName` 并且使用一个正确的 [DSN](#DSN) 作为 `dataSourceName`,DSN 支持的参数: +Use `taosRestful` as `driverName` and use a correct [DSN](#DSN) as `dataSourceName` with the following parameters supported by the DSN. -* `disableCompression` 是否接受压缩数据,默认为 true 不接受压缩数据,如果传输数据使用 gzip 压缩设置为 false。 -* `readBufferSize` 读取数据的缓存区大小默认为 4K(4096),当查询结果数据量多时可以适当调大该值。 +* `disableCompression` whether to accept compressed data, default is true do not accept compressed data, set to false if transferring data using gzip compression. +* `readBufferSize` The default size of the buffer for reading data is 4K (4096), which can be adjusted upwards when the query result has a lot of data. -示例: +Example. ```go package main @@ -168,9 +168,9 @@ import ( ) func main() { - var taosUri = "root:taosdata/http(localhost:6041)/" + var taosUri = "root:taosdata@http(localhost:6041)/" taos, err := sql.Open("taosRestful", taosUri) - if err != nil { + if err ! = nil { fmt.Println("failed to connect TDengine, err:", err) return } @@ -179,42 +179,42 @@ func main() { -## 使用示例 +## Usage examples -### 写入数据 +### Write data -#### SQL 写入 +#### SQL Write -#### InfluxDB 行协议写入 +#### InfluxDB line protocol write -#### OpenTSDB Telnet 行协议写入 +#### OpenTSDB Telnet line protocol write -#### OpenTSDB JSON 行协议写入 +#### OpenTSDB JSON line protocol write -### 查询数据 +### Query data -### 更多示例程序 +### More sample programs -* [示例程序](https://github.com/taosdata/TDengine/tree/develop/examples/go) -* [视频教程](https://www.taosdata.com/blog/2020/11/11/1951.html)。 +* [sample program](https://github.com/taosdata/TDengine/tree/develop/examples/go) +* [Video tutorial](https://www.taosdata.com/blog/2020/11/11/1951.html). -## 使用限制 +## Usage limitations -由于 REST 接口无状态所以 `use db` 语法不会生效,需要将 db 名称放到 SQL 语句中,如:`create table if not exists tb1 (ts timestamp, a int)`改为`create table if not exists test.tb1 (ts timestamp, a int)`否则将报错`[0x217] Database not specified or available`。 +Since the REST interface is stateless, the `use db` syntax will not work. You need to put the db name into the SQL statement, e.g. `create table if not exists tb1 (ts timestamp, a int)` to `create table if not exists test.tb1 (ts timestamp, a int)` otherwise it will report the error `[0x217] Database not specified or available`. -也可以将 db 名称放到 DSN 中,将 `root:taosdata@http(localhost:6041)/` 改为 `root:taosdata@http(localhost:6041)/test`,此方法在 TDengine 2.4.0.5 版本的 taosAdapter 开始支持。当指定的 db 不存在时执行 `create database` 语句不会报错,而执行针对该 db 的其他查询或写入操作会报错。 +You can also put the db name in the DSN by changing `root:taosdata@http(localhost:6041)/` to `root:taosdata@http(localhost:6041)/test`. This method is supported by taosAdapter in TDengine 2.4.0.5. is supported since TDengine 2.4.0.5. Executing the `create database` statement when the specified db does not exist will not report an error while executing other queries or writing against that db will report an error. -完整示例如下: +The complete example is as follows. ```go package main @@ -264,148 +264,148 @@ func main() { } ``` -## 常见问题 +## Frequently Asked Questions -1. 无法找到包 `github.com/taosdata/driver-go/v2/taosRestful` +1. Cannot find the package `github.com/taosdata/driver-go/v2/taosRestful` - 将 `go.mod` 中 require 块对`github.com/taosdata/driver-go/v2`的引用改为`github.com/taosdata/driver-go/v2 develop`,之后执行 `go mod tidy`。 + Change the reference to `github.com/taosdata/driver-go/v2` in the require block in `go.mod` to `github.com/taosdata/driver-go/v2 develop`, then execute `go mod tidy`. -2. database/sql 中 stmt(参数绑定)相关接口崩溃 +2. stmt (parameter binding) related interface in database/sql crashes - REST 不支持参数绑定相关接口,建议使用`db.Exec`和`db.Query`。 + REST does not support parameter binding related interface. It is recommended to use `db.Exec` and `db.Query`. -3. 使用 `use db` 语句后执行其他语句报错 `[0x217] Database not specified or available` +3. error `[0x217] Database not specified or available` after executing other statements with `use db` statement - 在 REST 接口中 SQL 语句的执行无上下文关联,使用 `use db` 语句不会生效,解决办法见上方使用限制章节。 + The execution of SQL statements in the REST interface is not contextual, so using `use db` statement will not work, see the usage restrictions section above. -4. 使用 taosSql 不报错使用 taosRestful 报错 `[0x217] Database not specified or available` +4. use taosSql without error use taosRestful with error `[0x217] Database not specified or available` - 因为 REST 接口无状态,使用 `use db` 语句不会生效,解决办法见上方使用限制章节。 + Because the REST interface is stateless, using the `use db` statement will not take effect. See the usage restrictions section above. -5. 升级 `github.com/taosdata/driver-go/v2/taosRestful` +5. Upgrade `github.com/taosdata/driver-go/v2/taosRestful` - 将 `go.mod` 文件中对 `github.com/taosdata/driver-go/v2` 的引用改为 `github.com/taosdata/driver-go/v2 develop`,之后执行 `go mod tidy`。 + Change the reference to `github.com/taosdata/driver-go/v2` in the `go.mod` file to `github.com/taosdata/driver-go/v2 develop`, then execute `go mod tidy`. -6. `readBufferSize` 参数调大后无明显效果 +6. `readBufferSize` parameter has no significant effect after being increased - `readBufferSize` 调大后会减少获取结果时 `syscall` 的调用。如果查询结果的数据量不大,修改该参数不会带来明显提升,如果该参数修改过大,瓶颈会在解析 JSON 数据。如果需要优化查询速度,需要根据实际情况调整该值来达到查询效果最优。 + If you increase `readBufferSize` will reduce the number of `syscall` calls when fetching results. If the query result is more petite, modifying this parameter will not improve significantly. If you increase the parameter too much, the bottleneck will be parsing JSON data. If you need to optimize the query speed, you must adjust the value according to the actual situation to achieve the best query result. -7. `disableCompression` 参数设置为 `false` 时查询效率降低 +7. `disableCompression` parameter is set to `false` when the query efficiency is reduced - 当 `disableCompression` 参数设置为 `false` 时查询结果会使用 `gzip` 压缩后传输,拿到数据后要先进行 `gzip` 解压。 + When set `disableCompression` parameter to `false`, the query result will be compressed by `gzip` and then transmitted, so you have to decompress the data by `gzip` after getting it. -8. `go get` 命令无法获取包,或者获取包超时 +8. `go get` command can't get the package, or timeout to get the package - 设置 Go 代理 `go env -w GOPROXY=https://goproxy.cn,direct`。 + Set Go proxy `go env -w GOPROXY=https://goproxy.cn,direct`. -## 常用 API +## Common APIs ### database/sql API * `sql.Open(DRIVER_NAME string, dataSourceName string) *DB` - 该 API 用来打开 DB,返回一个类型为 \*DB 的对象。 + Use This API to open a DB, returning an object of type \*DB. :::info -该 API 成功创建的时候,并没有做权限等检查,只有在真正执行 Query 或者 Exec 的时候才能真正的去创建连接,并同时检查 user/password/host/port 是不是合法。 +This API is created successfully without checking permissions, but only when you execute a Query or Exec, and check if user/password/host/port is legal. ::: -* `func (db *DB) Exec(query string, args ...interface{}) (Result, error)` +* `func (db *DB) Exec(query string, args . .interface{}) (Result, error)` - `sql.Open` 内置的方法,用来执行非查询相关 SQL。 + `sql.Open` built-in method to execute non-query related SQL. -* `func (db *DB) Query(query string, args ...interface{}) (*Rows, error)` +* `func (db *DB) Query(query string, args ... . interface{}) (*Rows, error)` - `sql.Open` 内置的方法,用来执行查询语句。 + `sql.Open` Built-in method to execute query statements. -### 高级功能(af)API +### Advanced functions (af) API -`af` 包封装了连接管理、订阅、schemaless、参数绑定等 TDengine 高级功能。 +The `af` package encapsulates TDengine advanced functions such as connection management, subscriptions, schemaless, parameter binding, etc. -#### 连接管理 +#### Connection management * `af.Open(host, user, pass, db string, port int) (*Connector, error)` - 该 API 通过 cgo 创建与 taosd 的连接。 + This API creates a connection to taosd via cgo. * `func (conn *Connector) Close() error` - 关闭与 taosd 的连接。 + Closes the connection. -#### 订阅 +#### Subscribe to * `func (conn *Connector) Subscribe(restart bool, topic string, sql string, interval time.Duration) (Subscriber, error)` - 订阅数据。 + Subscribe to data. * `func (s *taosSubscriber) Consume() (driver.Rows, error)` - 消费订阅数据,返回 `database/sql/driver` 包的 `Rows` 结构。 + Consume the subscription data, returning the `Rows` structure of the `database/sql/driver` package. * `func (s *taosSubscriber) Unsubscribe(keepProgress bool)` - 取消订阅数据。 + Unsubscribe from data. #### schemaless * `func (conn *Connector) InfluxDBInsertLines(lines []string, precision string) error` - 写入 influxDB 行协议。 + Write to influxDB line protocol. * `func (conn *Connector) OpenTSDBInsertTelnetLines(lines []string) error` - 写入 OpenTDSB telnet 协议数据。 + Write OpenTDSB telnet protocol data. * `func (conn *Connector) OpenTSDBInsertJsonPayload(payload string) error` - 写入 OpenTSDB JSON 协议数据。 + Writes OpenTSDB JSON protocol data. -#### 参数绑定 +#### parameter binding * `func (conn *Connector) StmtExecute(sql string, params *param.Param) (res driver.Result, err error)` - 参数绑定单行插入。 + Parameter bound single row insert. * `func (conn *Connector) StmtQuery(sql string, params *param.Param) (rows driver.Rows, err error)` - 参数绑定查询,返回 `database/sql/driver` 包的 `Rows` 结构。 + Parameter bound query that returns the `Rows` structure of the `database/sql/driver` package. -* `func (conn *Connector) InsertStmt() *insertstmt.InsertStmt` +* `func (conn *Connector) InsertStmt() *insertstmt. - 初始化参数。 + Initialize the parameters. * `func (stmt *InsertStmt) Prepare(sql string) error` - 参数绑定预处理 SQL 语句。 + Parameter binding preprocessing SQL statement. * `func (stmt *InsertStmt) SetTableName(name string) error` - 参数绑定设置表名。 + Bind the set table name parameter. * `func (stmt *InsertStmt) SetSubTableName(name string) error` - 参数绑定设置子表名。 + Parameter binding to set the sub table name. * `func (stmt *InsertStmt) BindParam(params []*param.Param, bindType *param.ColumnType) error` - 参数绑定多行数据。 + Parameter bind multiple rows of data. * `func (stmt *InsertStmt) AddBatch() error` - 添加到参数绑定批处理。 + Add to a parameter-bound batch. * `func (stmt *InsertStmt) Execute() error` - 执行参数绑定。 + Execute a parameter binding. * `func (stmt *InsertStmt) GetAffectedRows() int` - 获取参数绑定插入受影响行数。 + Gets the number of affected rows inserted by the parameter binding. * `func (stmt *InsertStmt) Close() error` - 结束参数绑定。 + Closes the parameter binding. -## API 参考 +## API Reference -全部 API 见 [driver-go 文档](https://pkg.go.dev/github.com/taosdata/driver-go/v2) +Full API see [driver-go documentation](https://pkg.go.dev/github.com/taosdata/driver-go/v2) diff --git a/docs-en/14-reference/03-connector/java.mdx b/docs-en/14-reference/03-connector/java.mdx index 970f8aeb7f1095544361f07ef758eb35de709a19..a68258d50bf86c5dbfcbe8e4b8d857d31315df69 100644 --- a/docs-en/14-reference/03-connector/java.mdx +++ b/docs-en/14-reference/03-connector/java.mdx @@ -3,45 +3,45 @@ toc_max_heading_level: 4 sidebar_position: 2 sidebar_label: Java title: TDengine Java Connector -description: TDengine Java 连接器基于标准 JDBC API 实现, 并提供原生连接与 REST连接两种连接器。 +description: TDengine Java based on JDBC API and provide both native and REST connections --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -`taos-jdbcdriver` 是 TDengine 的官方 Java 语言连接器,Java 开发人员可以通过它开发存取 TDengine 数据库的应用软件。`taos-jdbcdriver` 实现了 JDBC driver 标准的接口,并提供两种形式的连接器。一种是通过 TDengine 客户端驱动程序(taosc)原生连接 TDengine 实例,支持数据写入、查询、订阅、schemaless 接口和参数绑定接口等功能,一种是通过 taosAdapter 提供的 REST 接口连接 TDengine 实例(2.0.18 及更高版本)。REST 连接实现的功能集合和原生连接有少量不同。 +'taos-jdbcdriver' is TDengine's official Java language connector, which allows Java developers to develop applications that access the TDengine database. 'taos-jdbcdriver' implements the interface of the JDBC driver standard and provides two forms of connectors. One is to connect to a TDengine instance natively through the TDengine client driver (taosc), which supports functions such as data writing, querying, subscription, schemaless interface, and parameter binding interface. And the other is to connect to a TDengine instance through the REST interface provided by taosAdapter (2.0.18 and later). Rest connections implement small differences between the set of features implemented and native connections. -![tdengine-connector](tdengine-jdbc-connector.png) +! [tdengine-connector] (tdengine-jdbc-connector.png) -上图显示了两种 Java 应用使用连接器访问 TDengine 的两种方式: +The preceding diagram shows two ways for a Java app to access TDengine using connectors: -- JDBC 原生连接:Java 应用在物理节点 1(pnode1)上使用 TSDBDriver 直接调用客户端驱动(libtaos.so 或 taos.dll)的 API 将写入和查询请求发送到位于物理节点 2(pnode2)上的 taosd 实例。 -- JDBC REST 连接:Java 应用通过 RestfulDriver 将 SQL 封装成一个 REST 请求,发送给物理节点 2 的 REST 服务器(taosAdapter),通过 REST 服务器请求 taosd 并返回结果。 +- JDBC native connectivity: Java applications use TSDBDriver on physical node 1 (pnode1) to call client-driven directly (libtaos.so or taos.dll) APIs to send writing and query requests to taosd instances located on physical node 2 (pnode2). +- JDBC REST connection: The Java application encapsulates the SQL as a REST request via RestfulDriver, sends it to the REST server of physical node 2 (taosAdapter), requests taosd through the REST server, and returns the result. -使用 REST 连接,不依赖 TDengine 客户端驱动,可以跨平台,更加方便灵活,但性能比原生连接器低约 30%。 +Using REST connectivity, which does not rely on TDengine client drivers, can be cross-platform, more convenient, and flexible but has about 30% lower performance than native connectors. :::info -TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致,但 TDengine 与关系对象型数据库的使用场景和技术特征存在差异,所以`taos-jdbcdriver` 与传统的 JDBC driver 也存在一定差异。在使用时需要注意以下几点: +TDengine's JDBC driver implementation is as consistent as possible with the relational database driver. Still, there are differences in the use scenarios and technical characteristics of TDengine and relational object databases, so 'taos-jdbcdriver' also has some differences from traditional JDBC drivers. You need to pay attention to the following points when using: -- TDengine 目前不支持针对单条数据记录的删除操作。 -- 目前不支持事务操作。 +- TDengine does not currently support delete operations for individual data records. +- Transactional operations are not currently supported. ::: -## 支持的平台 +## Supported platforms -原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。 -REST 连接支持所有能运行 Java 的平台。 +Native connectivity supports the same platform as TDengine client-driven support. +REST connectivity supports all platforms that can run Java. -## 版本支持 +## Version support -请参考[版本支持列表](/reference/connector#版本支持) +Please refer to [Version Support List] (/reference/connector# version support) -## TDengine DataType 和 Java DataType +## TDengine DataType vs. Java DataType -TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对应类型转换如下: +TDengine currently supports timestamp, number, character, Boolean type, and the corresponding type conversion with Java is as follows: -| TDengine DataType | JDBCType (driver 版本 < 2.0.24) | JDBCType (driver 版本 >= 2.0.24) | +| TDengine DataType | JDBCType (driver version < 2.0.24) | JDBCType (driver version > = 2.0.24) | | ----------------- | --------------------------------- | ---------------------------------- | | TIMESTAMP | java.lang.Long | java.sql.Timestamp | | INT | java.lang.Integer | java.lang.Integer | @@ -55,29 +55,27 @@ TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对 | NCHAR | java.lang.String | java.lang.String | | JSON | - | java.lang.String | -**注意**:JSON 类型仅在 tag 中支持。 +**Note**: Only TAG supports JSON types -## 安装步骤 +## Installation steps -### 安装前准备 +### Pre-installation preparation -使用 Java Connector 连接数据库前,需要具备以下条件: +Before using Java Connector to connect to the database, the following conditions are required. -- 已安装 Java 1.8 或以上版本运行时环境和 Maven 3.6 或以上版本 -- 已安装 TDengine 客户端驱动(使用原生连接必须安装,使用 REST 连接无需安装),具体步骤请参考[安装客户端驱动](/reference/connector#安装客户端驱动) +- Java 1.8 or above runtime environment and Maven 3.6 or above installed +- TDengine client driver installed (required for native connections, not required for REST connections), please refer to [Installing Client Driver](/reference/connector#Install Client Driver) -### 安装连接器 +### Install the connectors - - -目前 taos-jdbcdriver 已经发布到 [Sonatype Repository](https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver) 仓库,且各大仓库都已同步。 + - [sonatype](https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver) - [mvnrepository](https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver) - [maven.aliyun](https://maven.aliyun.com/mvn/search) -Maven 项目中,在 pom.xml 中添加以下依赖: +Add following dependency in the pom.xml file of your Maven project: ```xml-dtd @@ -88,9 +86,9 @@ Maven 项目中,在 pom.xml 中添加以下依赖: ``` - + -可以通过下载 TDengine 的源码,自己编译最新版本的 Java connector +You can build Java connector from source code after clone TDengine project: ```shell git clone https://github.com/taosdata/TDengine.git @@ -98,17 +96,17 @@ cd TDengine/src/connector/jdbc mvn clean install -Dmaven.test.skip=true ``` -编译后,在 target 目录下会产生 taos-jdbcdriver-2.0.XX-dist.jar 的 jar 包,并自动将编译的 jar 文件放在本地的 Maven 仓库中。 +After compilation, a jar package of taos-jdbcdriver-2.0.XX-dist .jar is generated in the target directory, and the compiled jar file is automatically placed in the local Maven repository. -## 建立连接 +## Establish a connection -TDengine 的 JDBC URL 规范格式为: -`jdbc:[TAOS|TAOS-RS]://[host_name]:[port]/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]` +TDengine's JDBC URL specification format is: +`jdbc:[TAOS| TAOS-RS]://[host_name]:[port]/[database_name]? [user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]` -对于建立连接,原生连接与 REST 连接有细微不同。 +For establishing connections, native connections differ slightly from REST connections. @@ -119,28 +117,28 @@ String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata Connection conn = DriverManager.getConnection(jdbcUrl); ``` -以上示例,使用了 JDBC 原生连接的 TSDBDriver,建立了到 hostname 为 taosdemo.com,端口为 6030(TDengine 的默认端口),数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。 +In the above example, TSDBDriver, which uses a JDBC native connection, establishes a connection to a hostname of taosdemo.com, port 6030 (the default port for TDengine), and a database named test. In this URL, the user name (user) is specified as root, and the password (password) is taosdata. -**注意**:使用 JDBC 原生连接,taos-jdbcdriver 需要依赖客户端驱动(Linux 下是 libtaos.so;Windows 下是 taos.dll)。 +Note: With JDBC native connections, taos-jdbcdriver relies on the client driver (libtaos.so under Linux; taos .dll under Windows). -url 中的配置参数如下: +The configuration parameters in the URL are as follows: -- user:登录 TDengine 用户名,默认值 'root'。 -- password:用户登录密码,默认值 'taosdata'。 -- cfgdir:客户端配置文件目录路径,Linux OS 上默认值 `/etc/taos`,Windows OS 上默认值 `C:/TDengine/cfg`。 -- charset:客户端使用的字符集,默认值为系统字符集。 -- locale:客户端语言环境,默认值系统当前 locale。 -- timezone:客户端使用的时区,默认值为系统当前时区。 -- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。开启批量拉取同时获取一批数据在查询数据量较大时批量拉取可以有效的提升查询性能。 -- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败将继续执行下面的 SQL。false:不再执行失败 SQL 后的任何语句。默认值为:false。 +- user: Log in to the TDengine username. The default value is 'root'. +- password: User login password, the default value is 'taosdata'. +- cfgdir: client configuration file directory path, default '/etc/taos' on Linux OS, 'C:/TDengine/cfg' on Windows OS. +- charset: The character set used by the client, the default value is the system character set. +- locale: Client locale, by default, use the system's current locale. +- timezone: The time zone used by the client, the default value is the system's current time zone. +- batchfetch: true: pulls result sets in batches when executing queries; false: pulls result sets row by row. The default value is: false. Enabling batch pull and obtaining a batch of data can improve query performance when the query data volume is large. +- batchErrorIgnore:true: When executing statement executeBatch, if there is a SQL execution failure in the middle, the following SQL will continue to be executed. false: No more statements after the failed SQL are executed. The default value is: false. -JDBC 原生连接的使用请参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1955.html)。 +For more information about JDBC native connections, see [Video Tutorial] (https://www.taosdata.com/blog/2020/11/11/1955.html). -**使用 TDengine 客户端驱动配置文件建立连接 ** +**Connect using the TDengine client-driven configuration file ** -当使用 JDBC 原生连接连接 TDengine 集群时,可以使用 TDengine 客户端驱动配置文件,在配置文件中指定集群的 firstEp、secondEp 等参数。如下所示: +When you use a JDBC native connection to connect to a TDengine cluster, you can use the TDengine client-driven configuration file to specify parameters such as firstEp and secondEp of the cluster in the configuration file as below: -1. 在 Java 应用中不指定 hostname 和 port +1. Do not specify hostname and port in Java applications. ```java public Connection getConn() throws Exception{ @@ -155,7 +153,7 @@ public Connection getConn() throws Exception{ } ``` -2. 在配置文件中指定 firstEp 和 secondEp +2. specify the firstEp and the secondEp in the configuration file taos.cfg ```shell # first fully qualified domain name (FQDN) for TDengine system @@ -171,11 +169,11 @@ secondEp cluster_node2:6030 # locale en_US.UTF-8 ``` -以上示例,jdbc 会使用客户端的配置文件,建立到 hostname 为 cluster_node1、端口为 6030、数据库名为 test 的连接。当集群中 firstEp 节点失效时,JDBC 会尝试使用 secondEp 连接集群。 +In the above example, JDBC uses the client's configuration file to establish a connection to a hostname of cluster_node1, port 6030, and a database named test. When the firstEp node in the cluster fails, JDBC attempts to connect to the cluster using secondEp. -TDengine 中,只要保证 firstEp 和 secondEp 中一个节点有效,就可以正常建立到集群的连接。 +In TDengine, as long as one node in firstEp and secondEp is valid, the connection to the cluster can be established normally. -> **注意**:这里的配置文件指的是调用 JDBC Connector 的应用程序所在机器上的配置文件,Linux OS 上默认值 /etc/taos/taos.cfg ,Windows OS 上默认值 C://TDengine/cfg/taos.cfg。 +> **Note**: The configuration file here refers to the configuration file on the machine where the application that calls the JDBC Connector is located, the default value of /etc/taos/taos .cfg on Linux OS, and the default value of C://TDengine/cfg/taos.cfg on Windows OS. @@ -186,46 +184,46 @@ String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosd Connection conn = DriverManager.getConnection(jdbcUrl); ``` -以上示例,使用了 JDBC REST 连接的 RestfulDriver,建立了到 hostname 为 taosdemo.com,端口为 6041,数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。 +In the above example, a RestfulDriver with a JDBC REST connection is used to establish a connection to a database named test with hostname taosdemo.com on port 6041. The URL specifies the user name (user) as root and the password (password) as taosdata. -使用 JDBC REST 连接,不需要依赖客户端驱动。与 JDBC 原生连接相比,仅需要: +There is no dependency on the client driver when Using a JDBC REST connection. Compared to a JDBC native connection, only the following are required: 1. -1. driverClass 指定为“com.taosdata.jdbc.rs.RestfulDriver”; -2. jdbcUrl 以“jdbc:TAOS-RS://”开头; -3. 使用 6041 作为连接端口。 +1. driverClass specified as "com.taosdata.jdbc.rs.RestfulDriver". +2. jdbcUrl starting with "jdbc:TAOS-RS://". 3. +3. use 6041 as the connection port. -url 中的配置参数如下: +The configuration parameters in the URL are as follows. -- user:登录 TDengine 用户名,默认值 'root'。 -- password:用户登录密码,默认值 'taosdata'。 -- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。逐行拉取结果集使用 HTTP 方式进行数据传输。从 taos-jdbcdriver-2.0.38 和 TDengine 2.4.0.12 版本开始,JDBC REST 连接增加批量拉取数据功能。taos-jdbcdriver 与 TDengine 之间通过 WebSocket 连接进行数据传输。相较于 HTTP,WebSocket 可以使 JDBC REST 连接支持大数据量查询,并提升查询性能。 -- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 SQL 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。 +- user: Login TDengine user name, default value 'root'. +- password: user login password, default value 'taosdata'. +- batchfetch: true: pull the result set in batch when executing the query; false: pull the result set row by row. The default value is false. batchfetch uses HTTP for data transfer. The JDBC REST connection supports bulk data pulling function in taos-jdbcdriver-2.0.38 and TDengine 2.4.0.12 and later versions. taos-jdbcdriver and TDengine transfer data via WebSocket connection. Compared with HTTP, WebSocket enables JDBC REST connection to support large data volume querying and improve query performance. +- batchErrorIgnore: true: when executing executeBatch of Statement, if one SQL execution fails in the middle, continue to execute the following SQL. false: no longer execute any statement after the failed SQL. The default value is: false. -**注意**:部分配置项(比如:locale、timezone)在 REST 连接中不生效。 +**Note**: Some configuration items (e.g., locale, timezone) do not work in the REST connection. :::note -- 与原生连接方式不同,REST 接口是无状态的。在使用 JDBC REST 连接时,需要在 SQL 中指定表、超级表的数据库名称。例如: +- Unlike the native connection method, the REST interface is stateless. When using the JDBC REST connection, you need to specify the database name of the table and super table in SQL. For example. ```sql INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES(now, 24.6); ``` -- 从 taos-jdbcdriver-2.0.36 和 TDengine 2.2.0.0 版本开始,如果在 url 中指定了 dbname,那么,JDBC REST 连接会默认使用/rest/sql/dbname 作为 resful 请求的 url,在 SQL 中不需要指定 dbname。例如:url 为 jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行 sql:insert into t1 using weather(ts, temperatrue) tags('beijing') values(now, 24.6); +- Starting from taos-jdbcdriver-2.0.36 and TDengine 2.2.0.0, if dbname is specified in the url, JDBC REST connections will use /rest/sql/dbname as the url for restful requests by default, and there is no need to specify dbname in SQL. For example, if the url is jdbc:TAOS-RS://127.0.0.1:6041/test, then the sql can be executed: insert into t1 using weather(ts, temperature) tags('beijing') values(now, 24.6); ::: -### 指定 URL 和 Properties 获取连接 +### Specify the URL and Properties to get the connection -除了通过指定的 URL 获取连接,还可以使用 Properties 指定建立连接时的参数。 +In addition to getting the connection from the specified URL, you can use Properties to specify parameters when the connection is established. -**注意**: +**Note**: -- 应用中设置的 client parameter 为进程级别的,即如果要更新 client 的参数,需要重启应用。这是因为 client parameter 是全局参数,仅在应用程序的第一次设置生效。 -- 以下示例代码基于 taos-jdbcdriver-2.0.36。 +- The client parameter set in the application is process-level. If you want to update the parameters of the client, you need to restart the application. This is because the client parameter is a global parameter that takes effect only the first time the application is set. +- The following sample code is based on taos-jdbcdriver-2.0.36. ```java public Connection getConn() throws Exception{ @@ -251,33 +249,33 @@ public Connection getRestConn() throws Exception{ } ``` -以上示例,建立一个到 hostname 为 taosdemo.com,端口为 6030/6041,数据库名为 test 的连接。这个连接在 url 中指定了用户名(user)为 root,密码(password)为 taosdata,并在 connProps 中指定了使用的字符集、语言环境、时区、是否开启批量拉取等信息。 +In the above example, a connection is established to taosdemo.com with hostname taosdemo.com, port 6030/6041, and database named test. The connection specifies the user name (user) as root and the password (password) as taosdata in the URL and specifies the character set, language environment, time zone, and whether to enable bulk fetching in the connProps. -properties 中的配置参数如下: +The configuration parameters in properties are as follows. -- TSDBDriver.PROPERTY_KEY_USER:登录 TDengine 用户名,默认值 'root'。 -- TSDBDriver.PROPERTY_KEY_PASSWORD:用户登录密码,默认值 'taosdata'。 -- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。 -- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 sq 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。 -- TSDBDriver.PROPERTY_KEY_CONFIG_DIR:仅在使用 JDBC 原生连接时生效。客户端配置文件目录路径,Linux OS 上默认值 `/etc/taos`,Windows OS 上默认值 `C:/TDengine/cfg`。 -- TSDBDriver.PROPERTY_KEY_CHARSET:仅在使用 JDBC 原生连接时生效。 客户端使用的字符集,默认值为系统字符集。 -- TSDBDriver.PROPERTY_KEY_LOCALE:仅在使用 JDBC 原生连接时生效。 客户端语言环境,默认值系统当前 locale。 -- TSDBDriver.PROPERTY_KEY_TIME_ZONE:仅在使用 JDBC 原生连接时生效。 客户端使用的时区,默认值为系统当前时区。 -- 此外对 JDBC 原生连接,通过指定 URL 和 Properties 还可以指定其他参数,比如日志级别、SQL 长度等。更多详细配置请参考[客户端配置](/reference/config/#仅客户端适用)。 +- TSDBDriver.PROPERTY_KEY_USER: Login TDengine user name, default value 'root'. +- TSDBDriver.PROPERTY_KEY_PASSWORD: user login password, default value 'tasdata'. +- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true: pull the result set in batch when executing query; false: pull the result set row by row. The default value is: false. +- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE: true: when executing executeBatch of Statement, if there is a SQL execution failure in the middle, continue to execute the following sq. false: no longer execute any statement after the failed SQL. The default value is: false. +- TSDBDriver.PROPERTY_KEY_CONFIG_DIR: Only works when using JDBC native connection. Client configuration file directory path, default value `/etc/taos` on Linux OS, default value `C:/TDengine/cfg` on Windows OS. +- TSDBDriver.PROPERTY_KEY_CHARSET: takes effect only when using JDBC native connection. In the character set used by the client, the default value is the system character set. +- TSDBDriver.PROPERTY_KEY_LOCALE: this only takes effect when using JDBC native connection. Client language environment, the default value is system current locale. +- TSDBDriver.PROPERTY_KEY_TIME_ZONE: only takes effect when using JDBC native connection. In the time zone used by the client, the default value is the system's current time zone. +For JDBC native connections, you can specify other parameters, such as log level, SQL length, etc., by specifying URL and Properties. For more detailed configuration, please refer to [Client Configuration](/reference/config/#Client only). -### 配置参数的优先级 +### Priority of configuration parameters -通过前面三种方式获取连接,如果配置参数在 url、Properties、客户端配置文件中有重复,则参数的`优先级由高到低`分别如下: +If the configuration parameters are duplicated in the URL, Properties, or client configuration file, the `priority` of the parameters, from highest to lowest, are as follows. -1. JDBC URL 参数,如上所述,可以在 JDBC URL 的参数中指定。 +1. JDBC URL parameters, as described above, can be specified in the parameters of the JDBC URL. 2. Properties connProps -3. 使用原生连接时,TDengine 客户端驱动的配置文件 taos.cfg +3. the configuration file taos.cfg of the TDengine client driver when using a native connection -例如:在 url 中指定了 password 为 taosdata,在 Properties 中指定了 password 为 taosdemo,那么,JDBC 会使用 url 中的 password 建立连接。 +For example, if you specify the password as `taosdata` in the URL and specify the password as `taosdemo` in the Properties simultaneously. In this case, JDBC will use the password in the URL to establish the connection. -## 使用示例 +## Usage examples -### 创建数据库和表 +### Create database and tables ```java Statement stmt = conn.createStatement(); @@ -292,9 +290,9 @@ stmt.executeUpdate("use db"); stmt.executeUpdate("create table if not exists tb (ts timestamp, temperature int, humidity float)"); ``` -> **注意**:如果不使用 `use db` 指定数据库,则后续对表的操作都需要增加数据库名称作为前缀,如 db.tb。 +> **Note**: If you do not use `use db` to specify the database, all subsequent operations on the table need to add the database name as a prefix, such as db.tb. -### 插入数据 +### Insert data ```java // insert data @@ -303,10 +301,10 @@ int affectedRows = stmt.executeUpdate("insert into tb values(now, 23, 10.3) (now System.out.println("insert " + affectedRows + " rows."); ``` -> now 为系统内部函数,默认为客户端所在计算机当前时间。 -> `now + 1s` 代表客户端当前时间往后加 1 秒,数字后面代表时间单位:a(毫秒),s(秒),m(分),h(小时),d(天),w(周),n(月),y(年)。 +> now is an internal function. The default is the current time of the client's computer. +> `now + 1s` represents the current time of the client plus 1 second, followed by the number representing the unit of time: a (milliseconds), s (seconds), m (minutes), h (hours), d (days), w (weeks), n (months), y (years). -### 查询数据 +### Querying data ```java // query data @@ -325,11 +323,11 @@ while(resultSet.next()){ } ``` -> 查询和操作关系型数据库一致,使用下标获取返回字段内容时从 1 开始,建议使用字段名称获取。 +> The query is consistent with operating a relational database. When using subscripts to get the contents of the returned fields, starting from 1, it is recommended to use the field names to get them. -### 处理异常 +### Handling exceptions -在报错后,通过 SQLException 可以获取到错误的信息和错误码: +After an error is reported, the error message and error code can be obtained through SQLException. ```java try (Statement statement = connection.createStatement()) { @@ -344,23 +342,27 @@ try (Statement statement = connection.createStatement()) { } ``` -JDBC 连接器可能报错的错误码包括 3 种:JDBC driver 本身的报错(错误码在 0x2301 到 0x2350 之间),原生连接方法的报错(错误码在 0x2351 到 0x2400 之间),TDengine 其他功能模块的报错。 +There are three types of error codes that the JDBC connector can report: + +- Error code of the JDBC driver itself (error code between 0x2301 and 0x2350) +- Error code of the native connection method (error code between 0x2351 and 0x2400) +- Error code of other TDengine function modules -具体的错误码请参考: +For specific error codes, please refer to. -- https://github.com/taosdata/TDengine/blob/develop/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java -- https://github.com/taosdata/TDengine/blob/develop/src/inc/taoserror.h +- [TDengine Java Connector](https://github.com/taosdata/TDengine/blob/develop/src/connector/jdbc/src/main/java/com/taosdata/jdbc/ TSDBErrorNumbers.java) +- [TDengine_ERROR_CODE](https://github.com/taosdata/TDengine/blob/develop/src/inc/taoserror.h) -### 通过参数绑定写入数据 +### Writing data via parameter binding -从 2.1.2.0 版本开始,TDengine 的 JDBC 原生连接实现大幅改进了参数绑定方式对数据写入(INSERT)场景的支持。采用这种方式写入数据时,能避免 SQL 语法解析的资源消耗,从而在很多情况下显著提升写入性能。 +TDengine's native JDBC connection implementation has significantly improved its support for data writing (INSERT) scenarios via parameter binding with version 2.1.2.0 and later versions. Writing data in this way avoids the resource consumption of SQL syntax parsing, resulting in significant write performance improvements in many cases. -**注意**: +**Note**. -- JDBC REST 连接目前不支持参数绑定 -- 以下示例代码基于 taos-jdbcdriver-2.0.36 -- binary 类型数据需要调用 setString 方法,nchar 类型数据需要调用 setNString 方法 -- setString 和 setNString 都要求用户在 size 参数里声明表定义中对应列的列宽 +- JDBC REST connections do not currently support parameter binding +- The following sample code is based on taos-jdbcdriver-2.0.36 +- The setString method should be called for binary type data, and the setNString method should be called for nchar type data +- both setString and setNString require the user to declare the width of the corresponding column in the size parameter of the table definition ```java public class ParameterBindingDemo { @@ -588,7 +590,7 @@ public class ParameterBindingDemo { } ``` -用于设定 TAGS 取值的方法总共有: +The methods to set TAGS values: ```java public void setTagNull(int index, int type) @@ -604,7 +606,7 @@ public void setTagString(int index, String value) public void setTagNString(int index, String value) ``` -用于设定 VALUES 数据列的取值的方法总共有: +The methods to set VALUES columns: ```java public void setInt(int columnIndex, ArrayList list) throws SQLException @@ -619,14 +621,14 @@ public void setString(int columnIndex, ArrayList list, int size) throws public void setNString(int columnIndex, ArrayList list, int size) throws SQLException ``` -### 无模式写入 +### Writing without mode -从 2.2.0.0 版本开始,TDengine 增加了对无模式写入功能。无模式写入兼容 InfluxDB 的 行协议(Line Protocol)、OpenTSDB 的 telnet 行协议和 OpenTSDB 的 JSON 格式协议。详情请参见[无模式写入](/reference/schemaless/)。 +Starting with version 2.2.0.0, TDengine has added the ability to write without mode. It is compatible with InfluxDB's Line Protocol, OpenTSDB's telnet line protocol, and OpenTSDB's JSON format protocol. See [schemaless writing](/reference/schemaless/) for details. -**注意**: +**Note**. -- JDBC REST 连接目前不支持无模式写入 -- 以下示例代码基于 taos-jdbcdriver-2.0.36 +- JDBC REST connections do not currently support schemaless writes +- The following sample code is based on taos-jdbcdriver-2.0.36 ```java public class SchemalessInsertTest { @@ -657,25 +659,25 @@ public class SchemalessInsertTest { } ``` -### 订阅 +### Subscriptions -TDengine Java 连接器支持订阅功能,应用 API 如下: +The TDengine Java Connector supports subscription functionality with the following application API. -#### 创建订阅 +#### Create subscriptions ```java TSDBSubscribe sub = ((TSDBConnection)conn).subscribe("topic", "select * from meters", false); ``` -`subscribe` 方法的三个参数含义如下: +The three parameters of the `subscribe` method have the following meanings. -- topic:订阅的主题(即名称),此参数是订阅的唯一标识 -- sql:订阅的查询语句,此语句只能是 `select` 语句,只应查询原始数据,只能按时间正序查询数据 -- restart:如果订阅已经存在,是重新开始,还是继续之前的订阅 +- topic: the subscribed topic (i.e., name). This parameter is the unique identifier of the subscription +- sql: the query statement of the subscription, this statement can only be `select` statement, only the original data should be queried, and you can query only the data in the positive time order +- restart: if the subscription already exists, whether to restart or continue the previous subscription -如上面的例子将使用 SQL 语句 `select * from meters` 创建一个名为 `topic` 的订阅,如果这个订阅已经存在,将继续之前的查询进度,而不是从头开始消费所有的数据。 +The above example will use the SQL statement `select * from meters` to create a subscription named `topic`. If the subscription exists, it will continue the progress of the previous query instead of consuming all the data from the beginning. -#### 订阅消费数据 +#### Subscribe to consume data ```java int total = 0; @@ -691,17 +693,17 @@ while(true) { } ``` -`consume` 方法返回一个结果集,其中包含从上次 `consume` 到目前为止的所有新数据。请务必按需选择合理的调用 `consume` 的频率(如例子中的 `Thread.sleep(1000)`),否则会给服务端造成不必要的压力。 +The `consume` method returns a result set containing all new data from the last `consume`. Be sure to choose a reasonable frequency for calling `consume` as needed (e.g. `Thread.sleep(1000)` in the example). Otherwise, it will cause unnecessary stress on the server-side. -#### 关闭订阅 +#### Close subscriptions ```java sub.close(true); ``` -`close` 方法关闭一个订阅。如果其参数为 `true` 表示保留订阅进度信息,后续可以创建同名订阅继续消费数据;如为 `false` 则不保留订阅进度。 +The ``close`` method closes a subscription. If its argument is ``true`'' it means that the subscription progress information is retained, and the subscription with the same name can be created to continue consuming data; if it is ``false`'' it does not retain the subscription progress. -### 关闭资源 +### Closing resources ```java resultSet.close(); @@ -709,13 +711,13 @@ stmt.close(); conn.close(); ``` -> `注意务必要将 connection 进行关闭`,否则会出现连接泄露。 +> ``Be sure to close the connection``, otherwise, there will be a connection leak. -### 与连接池使用 +### Use with connection pools #### HikariCP -使用示例如下: +Example usage is as follows. ```java public static void main(String[] args) throws SQLException { @@ -744,12 +746,12 @@ conn.close(); } ``` -> 通过 HikariDataSource.getConnection() 获取连接后,使用完成后需要调用 close() 方法,实际上它并不会关闭连接,只是放回连接池中。 -> 更多 HikariCP 使用问题请查看[官方说明](https://github.com/brettwooldridge/HikariCP)。 +> getConnection(), you need to call the close() method after you finish using it. It doesn't close the connection. It just puts it back into the connection pool. +> For more questions about using HikariCP, please see the [official instructions](https://github.com/brettwooldridge/HikariCP). #### Druid -使用示例如下: +Example usage is as follows. ```java public static void main(String[] args) throws Exception { @@ -776,64 +778,64 @@ public static void main(String[] args) throws Exception { } ``` -> 更多 druid 使用问题请查看[官方说明](https://github.com/alibaba/druid)。 +> For more questions about using druid, please see [Official Instructions](https://github.com/alibaba/druid). -**注意事项:** +**Caution:** -- TDengine `v1.6.4.1` 版本开始提供了一个专门用于心跳检测的函数 `select server_status()`,所以在使用连接池时推荐使用 `select server_status()` 进行 Validation Query。 +- TDengine `v1.6.4.1` provides a special function `select server_status()` for heartbeat detection, so it is recommended to use `select server_status()` for Validation Query when using connection pooling. -如下所示,`select server_status()` 执行成功会返回 `1`。 +As you can see below, `select server_status()` returns `1` on successful execution. ```sql taos> select server_status(); server_status()| ================ -1 | +1 | Query OK, 1 row(s) in set (0.000141s) ``` -### 更多示例程序 +### More sample programs -示例程序源码位于 `TDengine/examples/JDBC` 下: +The source code of the sample application is under `TDengine/examples/JDBC`: -- JDBCDemo:JDBC 示例源程序。 -- JDBCConnectorChecker:JDBC 安装校验源程序及 jar 包。 -- connectionPools:HikariCP, Druid, dbcp, c3p0 等连接池中使用 taos-jdbcdriver。 -- SpringJdbcTemplate:Spring JdbcTemplate 中使用 taos-jdbcdriver。 -- mybatisplus-demo:Springboot + Mybatis 中使用 taos-jdbcdriver。 +- JDBCDemo: JDBC sample source code. +- JDBCConnectorChecker: JDBC installation checker source and jar package. +- connectionPools: using taos-jdbcdriver in connection pools such as HikariCP, Druid, dbcp, c3p0, etc. +- SpringJdbcTemplate: using taos-jdbcdriver in Spring JdbcTemplate. +- mybatisplus-demo: using taos-jdbcdriver in Springboot + Mybatis. -请参考:[JDBC example](https://github.com/taosdata/TDengine/tree/develop/examples/JDBC) +Please refer to: [JDBC example](https://github.com/taosdata/TDengine/tree/develop/examples/JDBC) -## 重要更新记录 +## Important update logs -| taos-jdbcdriver 版本 | 主要变化 | +| taos-jdbcdriver version | major changes | | :------------------: | :----------------------------: | -| 2.0.38 | JDBC REST 连接增加批量拉取功能 | -| 2.0.37 | 增加对 json tag 支持 | -| 2.0.36 | 增加对 schemaless 写入支持 | +| 2.0.38 | JDBC REST connections add bulk pull function | +| 2.0.37 | Added support for json tags | +| 2.0.36 | Add support for schemaless writing | -## 常见问题 +## Frequently Asked Questions -1. 使用 Statement 的 `addBatch` 和 `executeBatch` 来执行“批量写入/更行”,为什么没有带来性能上的提升? +1. Why is there no performance improvement when using Statement's `addBatch` and `executeBatch` to perform `batch writes/reviews`? - **原因**:TDengine 的 JDBC 实现中,通过 `addBatch` 方法提交的 SQL 语句,会按照添加的顺序,依次执行,这种方式没有减少与服务端的交互次数,不会带来性能上的提升。 + **Cause**: In TDengine's JDBC implementation, SQL statements submitted by `addBatch` method are executed sequentially in the order they are added, which does not reduce the number of interactions with the server and does not bring performance improvement. - **解决方法**:1. 在一条 insert 语句中拼接多个 values 值;2. 使用多线程的方式并发插入;3. 使用参数绑定的写入方式 + **Solution**: 1. splice multiple values in a single insert statement; 2. use multi-threaded concurrent insertion; 3. use parameter-bound writing 2. java.lang.UnsatisfiedLinkError: no taos in java.library.path - **原因**:程序没有找到依赖的本地函数库 taos。 + **Cause**: The program did not find the dependent native library taos. - **解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 + **Solution**: Under Windows you can copy C:\TDengine\driver\taos.dll to the C:\Windows\System32\ directory, under Linux the following softlink will be created `ln -s /usr/local/taos/driver/libtaos.so.x.x. x.x /usr/lib/libtaos.so` will work. -3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform +3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on an IA 32-bit platform - **原因**:目前 TDengine 只支持 64 位 JDK。 + **Cause**: Currently, TDengine only supports 64-bit JDK. - **解决方法**:重新安装 64 位 JDK。 + **Solution**: Reinstall the 64-bit JDK. 4. -4. 其它问题请参考 [FAQ](/train-faq/faq) +For other questions, please refer to [FAQ](/train-faq/faq) -## API 参考 +## API Reference [taos-jdbcdriver doc](https://docs.taosdata.com/api/taos-jdbcdriver) diff --git a/docs-en/14-reference/03-connector/node.mdx b/docs-en/14-reference/03-connector/node.mdx index 0afcf2457dfdb11c01657abd983601322899b8fb..6c615a61feebe4e72c9dcce0c140e2ad65361ec9 100644 --- a/docs-en/14-reference/03-connector/node.mdx +++ b/docs-en/14-reference/03-connector/node.mdx @@ -16,86 +16,86 @@ import NodeOpenTSDBJson from "../../04-develop/03-insert-data/_js_opts_json.mdx" import NodeQuery from "../../04-develop/04-query-data/_js.mdx"; import NodeAsyncQuery from "../../04-develop/04-query-data/_js_async.mdx"; -`td2.0-connector` 和 `td2.0-rest-connector` 是 TDengine 的官方 Node.js 语言连接器。Node.js 开发人员可以通过它开发可以存取 TDengine 集群数据的应用软件。 +`td2.0-connector` and `td2.0-rest-connector` are the official Node.js language connectors for TDengine, through which Node.js developers can develop applications that can access TDengine cluster data. -`td2.0-connector` 是**原生连接器**,它通过 TDengine 客户端驱动程序(taosc)连接 TDengine 运行实例,支持数据写入、查询、订阅、schemaless 接口和参数绑定接口等功能。`td2.0-rest-connector` 是 **REST 连接器**,它通过 taosAdapter 提供的 REST 接口连接 TDengine 的运行实例。REST 连接器可以在任何平台运行,但性能略为下降,接口实现的功能特性集合和原生接口有少量不同。 +`td2.0-connector` is a **native connector** that connects to TDengine runtime instances via the TDengine client driver (taosc) and supports data writing, querying, subscriptions, schemaless interface, and parameter binding interface. The `td2.0-rest-connector` is a **REST connector** that connects to TDengine runtime instances via the REST interface provided by taosAdapter. The REST connector can run on any platform, but performance is slightly degraded, and the interface implements a somewhat different set of functional features than the native interface. -Node.js 连接器源码托管在 [GitHub](https://github.com/taosdata/taos-connector-node)。 +The Node.js connector source code is hosted on [GitHub](https://github.com/taosdata/taos-connector-node). -## 支持的平台 +## Supported Platforms -原生连接器支持的平台和 TDengine 客户端驱动支持的平台一致。 -REST 连接器支持所有能运行 Node.js 的平台。 +The platforms supported by the native connector are the same as those supported by the TDengine client driver. +The REST connector supports all platforms that can run Node.js. -## 版本支持 +## Version support -请参考[版本支持列表](/reference/connector#版本支持) +Please refer to [version support list](/reference/connector#version support) -## 支持的功能特性 +## Supported features -### 原生连接器 +### Native connectors -1. 连接管理 -2. 普通查询 -3. 连续查询 -4. 参数绑定 -5. 订阅功能 +1. connection management +2. general query +3. continuous query +4. parameter binding +5. subscription function 6. Schemaless -### REST 连接器 +### REST Connector -1. 连接管理 -2. 普通查询 -3. 连续查询 +1. connection management +2. general queries +3. Continuous query -## 安装步骤 +## Installation steps -### 安装前准备 +### Pre-installation -- 安装 Node.js 开发环境 -- 如果使用 REST 连接器,跳过此步。但如果使用原生连接器,请安装 TDengine 客户端驱动,具体步骤请参考[安装客户端驱动](/reference/connector#安装客户端驱动)。我们使用 [node-gyp](https://github.com/nodejs/node-gyp) 和 TDengine 实例进行交互,还需要根据具体操作系统来安装下文提到的一些依赖工具。 +- Install the Node.js development environment +- If you are using the REST connector, skip this step. However, if you use the native connector, please install the TDengine client driver. Please refer to [install client driver](/reference/connector#install-client-driver) for more details. We use [node-gyp](https://github.com/nodejs/node-gyp) to interact with TDengine instances and also need to install some dependencies mentioned below depending on the specific OS. - + -- `python` (建议`v2.7` , `v3.x.x` 目前还不支持) -- `td2.0-connector` 2.0.6 支持 Node.js LTS v10.9.0 或更高版本, Node.js LTS v12.8.0 或更高版本;2.0.5 及更早版本支持 Node.js LTS v10.x 版本。其他版本可能存在包兼容性的问题 +- `python` (recommended for `v2.7` , `v3.x.x` currently not supported) +- `td2.0-connector` 2.0.6 supports Node.js LTS v10.9.0 or later, Node.js LTS v12.8.0 or later; 2.0.5 and earlier support Node.js LTS v10.x versions. Other versions may have package compatibility issues - `make` -- C 语言编译器,[GCC](https://gcc.gnu.org) v4.8.5 或更高版本 +- C compiler, [GCC](https://gcc.gnu.org) v4.8.5 or higher - + -- 安装方法 1 +- Installation method 1 -使用微软的[ windows-build-tools ](https://github.com/felixrieseberg/windows-build-tools)在`cmd` 命令行界面执行`npm install --global --production windows-build-tools` 即可安装所有的必备工具。 +Use Microsoft's [ windows-build-tools ](https://github.com/felixrieseberg/windows-build-tools) to execute `npm install --global --production` from the `cmd` command-line interface to install all the necessary tools. -- 安装方法 2 +- Installation method 2 -手动安装以下工具: +Manually install the following tools. -- 安装 Visual Studio 相关:[Visual Studio Build 工具](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools) 或者 [Visual Studio 2017 Community](https://visualstudio.microsoft.com/pl/thank-you-downloading-visual-studio/?sku=Community) -- 安装 [Python](https://www.python.org/downloads/) 2.7(`v3.x.x` 暂不支持) 并执行 `npm config set python python2.7` -- 进入`cmd`命令行界面,`npm config set msvs_version 2017` +- Install Visual Studio related: [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools) or [ Visual Studio 2017 Community](https://visualstudio.microsoft.com/pl/thank-you-downloading-visual-studio/?sku=Community) +- Install [Python](https://www.python.org/downloads/) 2.7 (`v3.x.x` is not supported) and execute `npm config set python python2.7`. +- Go to the `cmd` command line interface, `npm config set msvs_version 2017` -参考微软的 Node.js 用户手册[ Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules)。 +Refer to Microsoft's Node.js User Manual [ Microsoft's Node.js Guidelines for Windows ](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows- environment. md#compiling-native-addon-modules). -如果在 Windows 10 ARM 上使用 ARM64 Node.js,还需添加 "Visual C++ compilers and libraries for ARM64" 和 "Visual C++ ATL for ARM64"。 +If using ARM64 Node.js on Windows 10 ARM, you must add "Visual C++ compilers and libraries for ARM64" and "Visual C++ ATL for ARM64". -### 使用 npm 安装 +### Install via npm - + ```bash npm install td2.0-connector ``` - + ```bash npm i td2.0-rest-connector @@ -104,15 +104,15 @@ npm i td2.0-rest-connector -### 安装验证 +### Installation verification -在安装好 TDengine 客户端后,使用 nodejsChecker.js 程序能够验证当前环境是否支持 Node.js 方式访问 TDengine。 +After installing the TDengine client, use the nodejsChecker.js program to verify that the current environment supports Node.js access to TDengine. -验证方法: +Validation method. -- 新建安装验证目录,例如:`~/tdengine-test`,下载 GitHub 上 [nodejsChecker.js 源代码](https://github.com/taosdata/TDengine/tree/develop/examples/nodejs/nodejsChecker.js)到本地。 +- Create a new installation verification directory, e.g. `~/tdengine-test`, and download the [nodejsChecker.js source code](https://github.com/taosdata/TDengine/tree/develop/examples/nodejs/) from GitHub. nodejsChecker.js) to local. -- 在命令行中执行以下命令。 +- Execute the following command from the command line. ```bash npm init -y @@ -120,16 +120,16 @@ npm install td2.0-connector node nodejsChecker.js host=localhost ``` -- 执行以上步骤后,在命令行会输出 nodejsChecker.js 连接 TDengine 实例,并执行简单插入和查询的结果。 +- After executing the above steps, the command line will output the result of nodejsChecker.js connecting to the TDengine instance and performing a simple insert and query. -## 建立连接 +## Establishing a connection -请选择使用一种连接器。 +Please choose to use one of the connectors. - + -安装并引用 `td2.0-connector` 包。 +Install and refer to `td2.0-connector` package: ```javascript //A cursor also needs to be initialized in order to interact with TDengine from Node.js. @@ -150,7 +150,7 @@ conn.close(); -安装并引用 `td2.0-rest-connector` 包。 +Install and refer to `td2.0-rest-connector`package: ```javascript //A cursor also needs to be initialized in order to interact with TDengine from Node.js. @@ -167,93 +167,93 @@ let cursor = conn.cursor(); -## 使用示例 +## Usage examples -### 写入数据 +### Write data -#### SQL 写入 +#### SQL Writing -#### InfluxDB 行协议写入 +#### InfluxDB line protocol writing -#### OpenTSDB Telnet 行协议写入 +#### OpenTSDB Telnet line protocol writing -#### OpenTSDB JSON 行协议写入 +#### OpenTSDB JSON line protocol writing -### 查询数据 +### Query data -#### 同步查询 +#### Synchronous queries -#### 异步查询 +#### asynchronous query -## 更多示例程序 +## More Sample Programs -| 示例程序 | 示例程序描述 | -| ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------- | -| [connection](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/cursorClose.js) | 建立连接的示例。 | -| [stmtBindBatch](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindParamBatchSample.js) | 绑定多行参数插入的示例。 | -| [stmtBind](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindParamSample.js) | 一行一行绑定参数插入的示例。 | -| [stmtBindSingleParamBatch](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindSingleParamBatchSample.js) | 按列绑定参数插入的示例。 | -| [stmtUseResult](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtUseResultSample.js) | 绑定参数查询的示例。 | -| [json tag](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testJsonTag.js) | Json tag 的使用示例。 | -| [Nanosecond](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testNanoseconds.js) | 时间戳为纳秒精度的使用的示例。 | -| [Microsecond](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testMicroseconds.js) | 时间戳为微秒精度的使用的示例。 | -| [schemless insert](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testSchemalessInsert.js) | schemless 插入的示例。 | -| [subscribe](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testSubscribe.js) | 订阅的使用示例。 | -| [asyncQuery](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/tset.js) | 异步查询的使用示例。 | -| [REST](https://github.com/taosdata/taos-connector-node/blob/develop/typescript-rest/example/example.ts) | 使用 REST 连接的 TypeScript 使用示例。 | +| Sample Programs | Sample Program Description | +| --------------------------------------------------------------------------------------------------------------------------------- --------- | -------------------------------------- | +| [connection](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/cursorClose.js) | Example of establishing a connection. | +| [stmtBindBatch](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindParamBatchSample.js) | Example of binding a multi-line parameter Example of inserting. | +| [stmtBind](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindParamSample.js) | Example of a line-by-line bind parameter insertion. | +| [stmtBindSingleParamBatch](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/) stmtBindSingleParamBatchSample.js) | Example of binding parameters by column. | +| [stmtUseResult](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtUseResultSample.js) | Example of a bound parameter query. | +| [json tag](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testJsonTag.js) | Example of using Json tag. | +| [Nanosecond](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testNanoseconds.js) | An example of using timestamps with nanosecond precision. | +| [Microsecond](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testMicroseconds.js) | Example of using microsecond timestamp. | +| [schemless insert](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testSchemalessInsert.js) | schemless Example of a schemless insert. | +| [subscribe](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testSubscribe.js) | Example of using subscribe. | +| [asyncQuery](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/tset.js) | An example of using asynchronous queries. | +| [REST](https://github.com/taosdata/taos-connector-node/blob/develop/typescript-rest/example/example.ts) | An example of using TypeScript with REST connections. | -## 使用限制 +## Usage restrictions -Node.js 连接器 >= v2.0.6 目前支持 node 的版本为:支持 >=v12.8.0 <= v12.9.1 || >=v10.20.0 <= v10.9.0 ;2.0.5 及更早版本支持 v10.x 版本,其他版本可能存在包兼容性的问题。 +Node.js Connector >= v2.0.6 currently supports node versions >=v12.8.0 <= v12.9.1 || >=v10.20.0 <= v10.9.0; v10.x versions are supported in 2.0.5 and earlier, other versions may have package compatibility issues. -## 其他说明 +## Other notes -Node.js 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1957.html)。 +See [video tutorial](https://www.taosdata.com/blog/2020/11/11/1957.html) for the Node.js connector. -## 常见问题 +## Frequently Asked Questions -1. 使用 REST 连接需要启动 taosadapter。 +1. Using REST connections requires starting taosadapter. ```bash sudo systemctl start taosadapter ``` -2. Node.js 版本 +2. Node.js version - 连接器 >v2.0.6 目前兼容的 Node.js 版本为:>=v10.20.0 <= v10.9.0 || >=v12.8.0 <= v12.9.1 + Connector >v2.0.6 Currently compatible Node.js versions are: >=v10.20.0 <= v10.9.0 || >=v12.8.0 <= v12.9.1 -3. "Unable to establish connection","Unable to resolve FQDN" +3. "Unable to establish connection", "Unable to resolve FQDN" - 一般都是因为配置 FQDN 不正确。 可以参考[如何彻底搞懂 TDengine 的 FQDN](https://www.taosdata.com/blog/2021/07/29/2741.html) 。 + Usually, it is because the FQDN is not configured correctly. You can refer to [How to understand TDengine's FQDN thoroughly](https://www.taosdata.com/blog/2021/07/29/2741.html). -## 重要更新记录 +## Important Updates -### 原生连接器 +### Native connectors -| td2.0-connector 版本 | 说明 | +| td2.0-connector version | description | | -------------------- | ---------------------------------------------------------------- | -| 2.0.12 | 修复 cursor.close() 报错的 bug。 | -| 2.0.11 | 支持绑定参数、json tag、schemaless 接口等功能。 | -| 2.0.10 | 支持连接管理,普通查询、连续查询、获取系统信息、订阅功能等功能。 | +| 2.0.12 | Fix bug with cursor.close() error. | 2.0.12 | Fix bug with cursor.close() error. +| 2.0.11 | Support for binding parameters, json tag, schemaless interface, etc. | +| 2.0.10 | Support connection management, general query, continuous query, get system information, subscribe function, etc. | ### REST Connector -### REST 连接器 +### REST Connector -| td2.0-rest-connector 版本 | 说明 | +| td2.0-rest-connector version | Description | | ------------------------- | ---------------------------------------------------------------- | -| 1.0.3 | 支持连接管理、普通查询、获取系统信息、错误信息、连续查询等功能。 | +| 1.0.3 | Support connection management, general query, get system information, error message, continuous query, etc. |# API Reference -## API 参考 +## API Reference -[API 参考](https://docs.taosdata.com/api/td2.0-connector/) +[API Reference](https://docs.taosdata.com/api/td2.0-connector/) diff --git a/docs-en/14-reference/03-connector/python.mdx b/docs-en/14-reference/03-connector/python.mdx index 5e6cdfba4fc3ee7fd6073b0264b54705c444bead..721e545e0ce6c0d7f898f3c98b66ca5d5f68af14 100644 --- a/docs-en/14-reference/03-connector/python.mdx +++ b/docs-en/14-reference/03-connector/python.mdx @@ -2,75 +2,75 @@ sidebar_position: 3 sidebar_label: Python title: TDengine Python Connector -description: "taospy 是 TDengine 的官方 Python 连接器。taospy 提供了丰富的 API, 使得 Python 应用可以很方便地使用 TDengine。tasopy 对 TDengine 的原生接口和 REST 接口都进行了封装, 分别对应 tasopy 的两个子模块:tasos 和 taosrest。除了对原生接口和 REST 接口的封装,taospy 还提供了符合 Python 数据访问规范(PEP 249)的编程接口。这使得 taospy 和很多第三方工具集成变得简单,比如 SQLAlchemy 和 pandas" +description: "taospy is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. tasopy wraps both the native and REST interfaces of TDengine, corresponding to the two submodules of tasopy: taos and taosrest. In addition to wrapping the native and REST interfaces, taospy also provides a programming interface that conforms to the Python Data Access Specification (PEP 249), making it easy to integrate taospy with many third-party tools, such as SQLAlchemy and pandas." --- import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; -`taospy` 是 TDengine 的官方 Python 连接器。`taospy` 提供了丰富的 API, 使得 Python 应用可以很方便地使用 TDengine。`taospy` 对 TDengine 的[原生接口](/reference/connector/cpp)和 [REST 接口](/reference/rest-api)都进行了封装, 分别对应 `taospy` 包的 `taos` 模块 和 `taosrest` 模块。 -除了对原生接口和 REST 接口的封装,`taospy` 还提供了符合 [Python 数据访问规范(PEP 249)](https://peps.python.org/pep-0249/) 的编程接口。这使得 `taospy` 和很多第三方工具集成变得简单,比如 [SQLAlchemy](https://www.sqlalchemy.org/) 和 [pandas](https://pandas.pydata.org/)。 +`taospy` is the official Python connector for TDengine. `taospy` provides a rich API that makes it easy for Python applications to use TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively. +In addition to wrapping the native and REST interfaces, `taospy` also provides a programming interface that conforms to the [Python Data Access Specification (PEP 249)](https://peps.python.org/pep-0249/). It is easy to integrate `taospy` with many third-party tools, such as [SQLAlchemy](https://www.sqlalchemy.org/) and [pandas](https://pandas.pydata.org/). -使用客户端驱动提供的原生接口直接与服务端建立的连接的方式下文中称为“原生连接”;使用 taosAdapter 提供的 REST 接口与服务端建立的连接的方式下文中称为“REST 连接”。 +The connection to the server directly using the native interface provided by the client driver is referred to hereinafter as a "native connection"; the connection to the server using the REST interface provided by taosAdapter is referred to hereinafter as a "REST connection". ". -Python 连接器的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-python)。 +The source code for the Python connector is hosted on [GitHub](https://github.com/taosdata/taos-connector-python). -## 支持的平台 +## Supported Platforms -- 原生连接[支持的平台](/reference/connector/#支持的平台)和 TDengine 客户端支持的平台一致。 -- REST 连接支持所有能运行 Python 的平台。 +- The native connection [supported platforms](/reference/connector/#supported-platforms) is the same as the one supported by the TDengine client. +- REST connections are supported on all platforms that can run Python. -## 版本选择 +## Version selection -无论使用什么版本的 TDengine 都建议使用最新版本的 `taospy`。 +We recommend using the latest version of `taospy`, regardless of the version of TDengine used. -## 支持的功能 +## Supported features -- 原生连接支持 TDeingine 的所有核心功能, 包括: 连接管理、执行 SQL、参数绑定、订阅、无模式写入(schemaless)。 -- REST 连接支持的功能包括:连接管理、执行 SQL。 (通过执行 SQL 可以: 管理数据库、管理表和超级表、写入数据、查询数据、创建连续查询等)。 +- Native connections support all the core features of TDeingine, including connection management, SQL execution, parameter binding, subscriptions, and schemaless writing. +- REST connections support features such as connection management and SQL execution. (SQL execution allows you to: manage databases, tables, and supertables, write data, query data, create continuous queries, etc.). -## 安装 +## Installation -### 准备 +### Preparation -1. 安装 Python。建议使用 Python >= 3.6。如果系统上还没有 Python 可参考 [Python BeginnersGuide](https://wiki.python.org/moin/BeginnersGuide/Download) 安装。 -2. 安装 [pip](https://pypi.org/project/pip/)。大部分情况下 Python 的安装包都自带了 pip 工具, 如果没有请参考 [pip docuemntation](https://pip.pypa.io/en/stable/installation/) 安装。 -3. 如果使用原生连接,还需[安装客户端驱动](../#安装客户端驱动)。客户端软件包含了 TDengine 客户端动态链接库(libtaos.so 或 taos.dll) 和 TDengine CLI。 +1. Install Python. Python >= 3.6 is recommended. If Python is not available on your system, refer to the [Python BeginnersGuide](https://wiki.python.org/moin/BeginnersGuide/Download) to install it. 2. +Install [pip](https://pypi.org/project/pip/). In most cases, the Python installer comes with the pip utility. If not, please refer to [pip docuemntation](https://pip.pypa.io/en/stable/installation/) to install it. +If you use a native connection, you will also need to [install the client driver](../#install client driver). The client software contains the TDengine client dynamic link library (libtaos.so or taos.dll) and the TDengine CLI. -### 使用 pip 安装 +### Install using pip -#### 卸载旧版本 +#### Uninstalling an older version -如果以前安装过旧版本的 Python 连接器, 请提前卸载。 +If you have previously installed an older version of the Python Connector, please uninstall it beforehand. ``` pip3 uninstall taos taospy ``` :::note -较早的 TDengine 客户端软件包含了 Python 连接器。如果从客户端软件的安装目录安装了 Python 连接器,那么对应的 Python 包名是 `taos`。 所以上述卸载命令包含了 `taos`, 不存在也没关系。 +Earlier TDengine client software includes the Python connector. If the Python connector is installed from the client software's installation directory, the corresponding Python package name is `taos`. So the above uninstall command includes `taos`, and it doesn't matter if it doesn't exist. ::: -#### 安装 `taospy` +#### to install `taospy` - + -安装最新版本 +Install the latest version of ``` pip3 install taospy ``` -也可以指定某个特定版本安装。 +You can also specify a specific version to install. ``` pip3 install taospy==2.3.0 ``` - + ``` pip3 install git+https://github.com/taosdata/taos-connector-python.git @@ -79,21 +79,21 @@ pip3 install git+https://github.com/taosdata/taos-connector-python.git -### 安装验证 +### Installation verification - + -对于原生连接,需要验证客户端驱动和 Python 连接器本身是否都正确安装。如果能成功导入 `taos` 模块,则说明已经正确安装了客户端驱动和 Python 连接器。可在 Python 交互式 Shell 中输入: +For native connections, you need to verify that both the client driver and the Python connector itself are installed correctly. The client driver and Python connector have been installed properly if you can successfully import the `taos` module. In the Python Interactive Shell, you can type. ```python import taos ``` - + -对于 REST 连接,只需验证是否能成功导入 `taosrest` 模块。可在 Python 交互式 Shell 中输入: +For REST connections, verifying that the ``taosrest`'' module can be imported successfully can be done in the Python Interactive Shell by typing. ```python import taosrest @@ -103,50 +103,50 @@ import taosrest :::tip -如果系统上有多个版本的 Python,则可能有多个 `pip` 命令。要确保使用的 `pip` 命令路径是正确的。上面我们用 `pip3` 命令安装,排除了使用 Python 2.x 版本对应的 `pip` 的可能性。但是如果系统上有多个 Python 3.x 版本,仍需检查安装路径是否正确。最简单的验证方式是,在命令再次输入 `pip3 install taospy`, 就会打印出 `taospy` 的具体安装位置,比如在 Windows 上: +If you have multiple versions of Python on your system, you may have various `pip` commands. Be sure to use the correct path for the `pip` command. Above, we installed the `pip3` command, which rules out the possibility of using the `pip` corresponding to Python 2.x versions. However, if you have more than one version of Python 3.x on your system, you still need to check that the installation path is correct. The easiest way to verify this is to type `pip3 install taospy` again in the command, and it will print out the exact location of `taospy`, for example, on Windows. ``` C:\> pip3 install taospy Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: taospy in c:\users\username\appdata\local\programs\python\python310\lib\site-packages (2.3.0) -``` +ðŸ™'ðŸ™' ::: -## 建立连接 +## Establish connection -### 连通性测试 +### Connectivity testing -在用连接器建立连接之前,建议先测试本地 TDengine CLI 到 TDengine 集群的连通性。 +Before establishing a connection with the connector, we recommend testing the connectivity of the local TDengine CLI to the TDengine cluster. - + -请确保 TDengine 集群已经启动, 且集群中机器的 FQDN (如果启动的是单机版,FQDN 默认为 hostname)在本机能够解析, 可用 ping 命令进行测试: +Ensure that the TDengine cluster is up and that the FQDN of the machines in the cluster (the FQDN defaults to hostname if you are starting a standalone version) can be resolved locally, by testing with the ping command. ``` ping ``` -然后测试用 TDengine CLI 能否正常连接集群: +Then test if the cluster can be appropriately connected with TDengine CLI: ``` ping ``` ``` taos -h -p ``` -上面的 FQDN 可以为集群中任意一个 dnode 的 FQDN, PORT 为这个 dnode 对应的 serverPort。 +The FQDN above can be the FQDN of any dnode in the cluster, and the PORT is the serverPort corresponding to this dnode. - + -对于 REST 连接, 除了确保集群已经启动,还要确保 taosAdapter 组件已经启动。可以使用如下 curl 命令测试: +For REST connections and making sure the cluster is up, make sure the taosAdapter component is up. This can be tested using the following `curl ` command. ``` curl -u root:taosdata http://:/rest/sql -d "select server_version()" ``` -上面的 FQDN 为运行 taosAdapter 的机器的 FQDN, PORT 为 taosAdapter 配置的监听端口, 默认为 6041。 -如果测试成功,会输出服务器版本信息,比如: +The FQDN above is the FQDN of the machine running taosAdapter, PORT is the port taosAdapter listening, default is 6041. +If the test is successful, it will output the server version information, e.g. ```json { @@ -161,49 +161,49 @@ curl -u root:taosdata http://:/rest/sql -d "select server_version()" -### 使用连接器建立连接 +### Using connectors to establish connections -以下示例代码假设 TDengine 安装在本机, 且 FQDN 和 serverPort 都使用了默认配置。 +The following example code assumes that TDengine is installed locally and that the default configuration is used for both FQDN and serverPort. - + ```python {{#include docs-examples/python/connect_native_reference.py}} ``` -`connect` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明: +All arguments of the ``connect`` function are optional keyword arguments. The following are the connection parameters specified. -- `host` : 要连接的节点的 FQDN。 没有默认值。如果不同提供此参数,则会连接客户端配置文件中的 firstEP。 -- `user` :TDengine 用户名。 默认值是 root。 -- `password` : TDengine 用户密码。 默认值是 taosdata。 -- `port` : 要连接的数据节点的起始端口,即 serverPort 配置。默认值是 6030。只有在提供了 host 参数的时候,这个参数才生效。 -- `config` : 客户端配置文件路径。 在 Windows 系统上默认是 `C:\TDengine\cfg`。 在 Linux 系统上默认是 `/etc/taos/`。 -- `timezone` : 查询结果中 TIMESTAMP 类型的数据,转换为 python 的 datetime 对象时使用的时区。默认为本地时区。 +- `host` : The FQDN of the node to connect to. There is no default value. If this parameter is not provided, the firstEP in the client configuration file will be connected. +- `user` : The TDengine user name. The default value is `root`. +- `password` : TDengine user password. The default value is `taosdata`. +- `port` : The starting port of the data node to connect to, i.e., the serverPort configuration. The default value is 6030, which will only take effect if the host parameter is provided. +- `config` : The path to the client configuration file. On Windows systems, the default is `C:\TDengine\cfg`. The default is `/etc/taos/` on Linux systems. +- `timezone` : The timezone used to convert the TIMESTAMP data in the query results to python `datetime` objects. The default is the local timezone. :::warning -`config` 和 `timezone` 都是进程级别的配置。建议一个进程建立的所有连接都使用相同的参数值。否则可能产生无法预知的错误。 +`config` and `timezone` are both process-level configurations. we recommend that all connections made by a process use the same parameter values. Otherwise, unpredictable errors may occur. ::: :::tip -`connect` 函数返回 `taos.TaosConnection` 实例。 在客户端多线程的场景下,推荐每个线程申请一个独立的连接实例,而不建议多线程共享一个连接。 +The `connect` function returns a `taos.TaosConnection` instance. In client-side multi-threaded scenarios, we recommend that each thread request a separate connection instance rather than sharing a connection between multiple threads. ::: - + ```python {{#include docs-examples/python/connect_rest_examples.py:connect}} ``` -`connect` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明: +All arguments to the `connect` function are optional keyword arguments. The following are the connection parameters specified. -- `host`: 要连接的主机。默认是 localhost。 -- `user`: TDenigne 用户名。默认是 root。 -- `password`: TDeingine 用户密码。默认是 taosdata。 -- `port`: taosAdapter REST 服务监听端口。默认是 6041. -- `timeout`: HTTP 请求超时时间。单位为秒。默认为 `socket._GLOBAL_DEFAULT_TIMEOUT`。 一般无需配置。 +- `host`: The host to connect to. The default is localhost. +- `user`: TDenigne user name. The default is `root`. +- `password`: TDeingine user password. The default is `taosdata`. +- `port`: The port on which the taosAdapter REST service listens. Default is 6041. +- `timeout`: HTTP request timeout in seconds. The default is `socket._GLOBAL_DEFAULT_TIMEOUT`. Usually, no configuration is needed. :::note @@ -212,89 +212,87 @@ curl -u root:taosdata http://:/rest/sql -d "select server_version()" -## 示例程序 +## Sample program -### 基本使用 +### Basic use - + -##### TaosConnection 类的使用 +Use of the ##### TaosConnection class -`TaosConnection` 类既包含对 PEP249 Connection 接口的实现(如:`cursor`方法和 `close` 方法),也包含很多扩展功能(如: `execute`、 `query`、`schemaless_insert` 和 `subscribe` 方法。 +The `TaosConnection` class contains both an implementation of the PEP249 Connection interface (e.g., the `cursor` method and the `close` method) and many extensions (e.g., the `execute`, `query`, `schemaless_insert`, and `subscribe` methods). . -```python title="execute 方法" +```python title="execute method" {{#include docs-examples/python/connection_usage_native_reference.py:insert}} ``` -```python title="query 方法" +```python title="query method" {{#include docs-examples/python/connection_usage_native_reference.py:query}} ``` :::tip -查询结果只能获取一次。比如上面的示例中 `featch_all` 和 `fetch_all_into_dict` 只能用一个。重复获取得到的结果为空列表。 +The queried results can only be fetched once. For example, only one of `featch_all` and `fetch_all_into_dict` can be used in the example above. Repeated fetches will result in an empty list. ::: -##### TaosResult 类的使用 +##### Use of TaosResult class -上面 `TaosConnection` 类的使用示例中,我们已经展示了两种获取查询结果的方法: `featch_all` 和 `fetch_all_into_dict`。除此之外 `TaosResult` 还提供了按行迭代(`rows_iter`)或按数据块迭代(`blocks_iter`)结果集的方法。在查询数据量较大的场景,使用这两个方法会更高效。 +In the above example of using the `TaosConnection` class, we have shown two ways to get the result of a query: `featch_all` and `fetch_all_into_dict`. In addition, `TaosResult` also provides methods to iterate through the result set by rows (`rows_iter`) or by data blocks (`blocks_iter`). Using these two methods will be more efficient in scenarios where the query has a large amount of data. -```python title="blocks_iter 方法" +```python title="blocks_iter method" {{#include docs-examples/python/result_set_examples.py}} ``` -##### TaosCursor 类的使用 +##### Use of the TaosCursor class -`TaosConnection` 类和 `TaosResult` 类已经实现了原生接口的所有功能。如果你对 PEP249 规范中的接口比较熟悉也可以使用 `TaosCursor` 类提供的方法。 +The `TaosConnection` class and the `TaosResult` class already implement all the functionality of the native interface. If you are familiar with the interfaces in the PEP249 specification, you can also use the methods provided by the `TaosCursor` class. -```python title="TaosCursor 的使用" +```python title="Use of TaosCursor" {{#include docs-examples/python/cursor_usage_native_reference.py}} ``` :::note -TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线程的场景下,这个游标实例必须保持线程独享,不能跨线程共享使用,否则会导致返回结果出现错误。 +The TaosCursor class uses native connections for write and query operations. In a client-side multi-threaded scenario, this cursor instance must remain thread exclusive and cannot be shared across threads for use, otherwise, it will result in errors in the returned results. ::: - + -##### TaosRestCursor 类的使用 +##### Use of TaosRestCursor class -`TaosRestCursor` 类是对 PEP249 Cursor 接口的实现。 +The ``TaosRestCursor`` class is an implementation of the PEP249 Cursor interface. -```python title="TaosRestCursor 的使用" +```python title="Use of TaosRestCursor" {{#include docs-examples/python/connect_rest_examples.py:basic}} ``` -- `cursor.execute` : 用来执行任意 SQL 语句。 -- `cursor.rowcount`: 对于写入操作返回写入成功记录数。对于查询操作,返回结果集行数。 -- `cursor.description` : 返回字段的描述信息。关于描述信息的具体格式请参考[TaosRestCursor](https://docs.taosdata.com/api/taospy/taosrest/cursor.html)。 +- `cursor.execute` : Used to execute arbitrary SQL statements. +- `cursor.rowcount` : For write operations, returns the number of successful rows written. For query operations, returns the number of rows in the result set. +- `cursor.description` : Returns the description of the field. Please refer to [TaosRestCursor](https://docs.taosdata.com/api/taospy/taosrest/cursor.html) for the specific format of the description information. -##### RestClient 类的使用 +##### Use of the RestClient class -`RestClient` 类是对于 [REST API](/reference/rest-api) 的直接封装。它只包含一个 `sql()` 方法用于执行任意 SQL 语句, 并返回执行结果。 +The `RestClient` class is a direct wrapper for the [REST API](/reference/rest-api). It contains only a ``sql()` method for executing arbitrary SQL statements and returning the result. -```python title="RestClient 的使用" +```python title="Use of RestClient" {{#include docs-examples/python/rest_client_example.py}} ``` -对于 `sql()` 方法更详细的介绍, 请参考 [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html)。 - - +For a more detailed description of the `sql()` method, please refer to [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html). -### 与 pandas 一起使用 +### Used with pandas - + ```python {{#include docs-examples/python/conn_native_pandas.py}} ``` - + ```python {{#include docs-examples/python/conn_rest_pandas.py}} @@ -303,51 +301,50 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 -### 其它示例程序 +### Other sample programs -| 示例程序链接 | 示例程序内容 | -| ------------------------------------------------------------------------------------------------------------- | ----------------------- | -| [bind_multi.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-multi.py) | 参数绑定, 一次绑定多行 | -| [bind_row.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-row.py) | 参数绑定,一次绑定一行 | -| [insert_lines.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/insert-lines.py) | InfluxDB 行协议写入 | -| [json_tag.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/json-tag.py) | 使用 JSON 类型的标签 | -| [subscribe-async.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/subscribe-async.py) | 异步订阅 | -| [subscribe-sync.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/subscribe-sync.py) | 同步订阅 | +| Example program links | Example program content | +| ------------------------------------------------------------------------------------------------------------- | ------------------- ---- | +| [bind_multi.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-multi.py) | parameter binding, bind multiple rows at once | +| [bind_row.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-row.py) | bind_row.py +| [insert_lines.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/insert-lines.py) | InfluxDB row protocol write | +| [json_tag.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/json-tag.py) | Use JSON type tags | +| [subscribe-async.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/subscribe-async.py) | Asynchronous subscription | +| [subscribe-sync.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/subscribe-sync.py) | synchronous-subscribe | -## 其它说明 +## Other notes -### 异常处理 +### Exception handling -所有数据库操作如果出现异常,都会直接抛出来。由应用程序负责异常处理。比如: +All database operations will be thrown directly if an exception occurs. The application is responsible for exception handling. For example: ```python {{#include docs-examples/python/handle_exception.py}} ``` -### 关于纳秒 (nanosecond) +### About nanoseconds -由于目前 Python 对 nanosecond 支持的不完善(见下面的链接),目前的实现方式是在 nanosecond 精度时返回整数,而不是 ms 和 us 返回的 datetime 类型,应用开发者需要自行处理,建议使用 pandas 的 to_datetime()。未来如果 Python 正式完整支持了纳秒,Python 连接器可能会修改相关接口。 +Due to the current imperfection of Python's nanosecond support (see link below), the current implementation returns integers at nanosecond precision instead of the `datetime` type produced by `ms and `us`, which application developers will need to handle on their own. And it is recommended to use pandas' to_datetime(). The Python Connector may modify the interface in the future if Python officially supports nanoseconds in full. 1. https://stackoverflow.com/questions/10611328/parsing-datetime-strings-containing-nanoseconds 2. https://www.python.org/dev/peps/pep-0564/ -## 常见问题 +## Frequently Asked Questions -欢迎[提问或报告问题](https://github.com/taosdata/taos-connector-python/issues)。 +Welcome to [ask questions or report questions] (https://github.com/taosdata/taos-connector-python/issues). -## 重要更新 +## Important Update -| 连接器版本 | 重要更新 | 发布日期 | +| Connector version | Important Update | Release date | | ---------- | --------------------------------------------------------------------------------- | ---------- | | 2.3.1 | 1. support TDengine REST API
2. remove support for Python version below 3.6 | 2022-04-28 | | 2.2.5 | support timezone option when connect | 2022-04-13 | | 2.2.2 | support sqlalchemy dialect plugin | 2022-03-28 | +[**Release Notes**] (https://github.com/taosdata/taos-connector-python/releases) -[**Release Notes**](https://github.com/taosdata/taos-connector-python/releases) - -## API 参考 +## API Reference - [taos](https://docs.taosdata.com/api/taospy/taos/) - [taosrest](https://docs.taosdata.com/api/taospy/taosrest) diff --git a/docs-en/14-reference/03-connector/rust.mdx b/docs-en/14-reference/03-connector/rust.mdx index b6aac45c6ab30405190ab3ced39de017033e760a..8d0de2afa996dd9a1a7fc7de96de7e51bf75cafb 100644 --- a/docs-en/14-reference/03-connector/rust.mdx +++ b/docs-en/14-reference/03-connector/rust.mdx @@ -15,50 +15,48 @@ import RustOpenTSDBTelnet from "../../04-develop/03-insert-data/_rust_opts_telne import RustOpenTSDBJson from "../../04-develop/03-insert-data/_rust_opts_json.mdx" import RustQuery from "../../04-develop/04-query-data/_rust.mdx" -[![Crates.io](https://img.shields.io/crates/v/libtaos)](https://crates.io/crates/libtaos) ![Crates.io](https://img.shields.io/crates/d/libtaos) [![docs.rs](https://img.shields.io/docsrs/libtaos)](https://docs.rs/libtaos) +`libtaos` is the official Rust language connector for TDengine, through which Rust developers can develop applications that access the TDengine database. -`libtaos` 是 TDengine 的官方 Rust 语言连接器。Rust 开发人员可以通过它开发存取 TDengine 数据库的应用软件。 +`libtaos` provides two ways to establish connections. One is the **Native Connection**, which connects to TDengine runtime instances via the TDengine client driver (taosc). The other is **REST connection**, which connects to TDengine runtime instances via taosAdapter's REST interface. The REST connection supports any platform, but the native connection supports all platforms on which the TDengine client can run. -`libtaos` 提供两种建立连接的方式。一种是**原生连接**,它通过 TDengine 客户端驱动程序(taosc)连接 TDengine 运行实例。另外一种是 **REST 连接**,它通过 taosAdapter 的 REST 接口连接 TDengine 运行实例。你可以通过不同的 “特性(即 Cargo 关键字 features)” 来指定使用哪种连接器。REST 连接支持任何平台,但原生连接支持所有 TDengine 客户端能运行的平台。 +The source code for `libtaos` is hosted on [GitHub](https://github.com/taosdata/libtaos-rs). -`libtaos` 的源码托管在 [GitHub](https://github.com/taosdata/libtaos-rs)。 +## Supported platforms -## 支持的平台 +The platforms supported by native connections are the same as those supported by the TDengine client driver. +REST connections are supported on all platforms that can run Rust. -原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。 -REST 连接支持所有能运行 Rust 的平台。 +## Version support -## 版本支持 +Please refer to [version support list](/reference/connector#version support) -请参考[版本支持列表](/reference/connector#版本支持) +The Rust Connector is still under rapid development and is not guaranteed to be backward compatible before 1.0. Recommend to use TDengine version 2.4 or higher to avoid known issues. -Rust 连接器仍然在快速开发中,1.0 之前无法保证其向后兼容。建议使用 2.4 版本以上的 TDengine,以避免已知问题。 +## Installation -## 安装 +### Pre-installation +* Install the Rust development toolchain +* If using the native connection, please install the TDengine client driver. Please refer to [install client driver](/reference/connector#install client driver) -### 安装前准备 -* 安装 Rust 开发工具链 -* 如果使用原生连接,请安装 TDengine 客户端驱动,具体步骤请参考[安装客户端驱动](/reference/connector#安装客户端驱动) +### Adding libtaos dependencies -### 添加 libtaos 依赖 - -根据选择的连接方式,按照如下说明在 [Rust](https://rust-lang.org) 项目中添加 [libtaos][libtaos] 依赖: +Add the [libtaos][libtaos] dependency to the [Rust](https://rust-lang.org) project as follows, depending on the connection method selected. - + -在 `Cargo.toml` 文件中添加 [libtaos][libtaos]: +Add [libtaos][libtaos] to the ``Cargo.toml`'' file. -```toml +``toml [dependencies] # use default feature libtaos = "*" ``` - - + -在 `Cargo.toml` 文件中添加 [libtaos][libtaos],并启用 `rest` 特性。 +Add [libtaos][libtaos] to the ``Cargo.toml`'' file and enable the ``rest`'' feature. ```toml [dependencies] @@ -70,9 +68,9 @@ libtaos = { version = "*", features = ["rest"]} -### 使用连接池 +### Using connection pools -请在 `Cargo.toml` 中启用 `r2d2` 特性。 +Please enable the `r2d2` feature in `Cargo.toml`. ```toml [dependencies] @@ -82,9 +80,9 @@ libtaos = { version = "*", features = ["r2d2"] } libtaos = { version = "*", features = ["rest", "r2d2"] } ``` -## 建立连接 +## Create a connection -[TaosCfgBuilder] 为使用者提供构造器形式的 API,以便于后续创建连接或使用连接池。 +The [TaosCfgBuilder] provides the user with an API in the form of a constructor for the subsequent creation of connections or use of connection pools. ```rust let cfg: TaosCfg = TaosCfgBuilder::default() @@ -98,97 +96,97 @@ let cfg: TaosCfg = TaosCfgBuilder::default() } ``` -现在您可以使用该对象创建连接: +You can now use this object to create the connection. ```rust -let conn = cfg.connect()?; +let conn = cfg.connect()? ; ``` -连接对象可以创建多个: +The connection object can create more than one. ```rust -let conn = cfg.connect()?; -let conn2 = cfg.connect()?; +let conn = cfg.connect()? ; +let conn2 = cfg.connect()? ; ``` -可以在应用中使用连接池: +You can use connection pools in applications. ```rust let pool = r2d2::Pool::builder() .max_size(10000) // max connections - .build(cfg)?; + .build(cfg)? ; // ... // Use pool to get connection -let conn = pool.get()?; +let conn = pool.get()? ; ``` -之后您可以对数据库进行相关操作: +After that, you can perform the following operations on the database. ```rust async fn demo() -> Result<(), Error> { // get connection ... // create database - conn.exec("create database if not exists demo").await?; + conn.exec("create database if not exists demo").await? // change database context - conn.exec("use demo").await?; + conn.exec("use demo").await? // create table - conn.exec("create table if not exists tb1 (ts timestamp, v int)").await?; + conn.exec("create table if not exists tb1 (ts timestamp, v int)").await? // insert - conn.exec("insert into tb1 values(now, 1)").await?; + conn.exec("insert into tb1 values(now, 1)").await? // query - let rows = conn.query("select * from tb1").await?; + let rows = conn.query("select * from tb1").await? for row in rows.rows { println!("{}", row.into_iter().join(",")); } } ``` -## 使用示例 +## Usage examples -### 写入数据 +### Write data -#### SQL 写入 +#### SQL Write -#### InfluxDB 行协议写入 +#### InfluxDB line protocol write -#### OpenTSDB Telnet 行协议写入 +#### OpenTSDB Telnet line protocol write -#### OpenTSDB JSON 行协议写入 +#### OpenTSDB JSON line protocol write -### 查询数据 +### Query data -### 更多示例程序 +### More sample programs -| 程序路径 | 程序说明 | +| Program Path | Program Description | | -------------- | ----------------------------------------------------------------------------- | -| [demo.rs] | 基本API 使用示例 | -| [bailongma-rs] | 使用 TDengine 作为存储后端的 Prometheus 远程存储 API 适配器,使用 r2d2 连接池 | +| [demo.rs] | Basic API Usage Examples | +| [bailongma-rs] | Using TDengine as the Prometheus remote storage API adapter for the storage backend, using the r2d2 connection pool | -## API 参考 +## API Reference -### 连接构造器 API +### Connection constructor API -[Builder Pattern](https://doc.rust-lang.org/1.0.0/style/ownership/builders.html) 构造器模式是 Rust 处理复杂数据类型或可选配置类型的解决方案。[libtaos] 实现中,使用连接构造器 [TaosCfgBuilder] 作为 TDengine Rust 连接器的入口。[TaosCfgBuilder] 提供对服务器、端口、数据库、用户名和密码等的可选配置。 +The [Builder Pattern](https://doc.rust-lang.org/1.0.0/style/ownership/builders.html) constructor pattern is Rust's solution for handling complex data types or optional configuration types. The [libtaos] implementation uses the connection constructor [TaosCfgBuilder] as the entry point for the TDengine Rust connector. The [TaosCfgBuilder] provides optional configuration of servers, ports, databases, usernames, passwords, etc. -使用 `default()` 方法可以构建一个默认参数的 [TaosCfg],用于后续连接数据库或建立连接池。 +Using the ``default()` method, you can construct a [TaosCfg] with default parameters for subsequent connections to the database or establishing connection pools. ```rust -let cfg = TaosCfgBuilder::default().build()?; +let cfg = TaosCfgBuilder::default().build()? ; ``` -使用构造器模式,用户可按需设置: +Using the constructor pattern, the user can set on-demand. ```rust let cfg = TaosCfgBuilder::default() @@ -197,26 +195,26 @@ let cfg = TaosCfgBuilder::default() .pass("taosdata") .db("log") .port(6030u16) - .build()?; + .build()? ; ``` -使用 [TaosCfg] 对象创建 TDengine 连接: +Create TDengine connection using [TaosCfg] object. ```rust let conn: Taos = cfg.connect(); ``` -### 连接池 +### Connection pooling -在复杂应用中,建议启用连接池。[libtaos] 的连接池使用 [r2d2] 实现。 +In complex applications, recommand to enable connection pooling. Connection pooling for [libtaos] is implemented using [r2d2]. -如下,可以生成一个默认参数的连接池。 +As follows, a connection pool with default parameters can be generated. ```rust -let pool = r2d2::Pool::new(cfg)?; +let pool = r2d2::Pool::new(cfg)? ; ``` -同样可以使用连接池的构造器,对连接池参数进行设置: +You can set the same connection pool parameters using the connection pool's constructor. ```rust use std::time::Duration; @@ -228,40 +226,38 @@ let pool = r2d2::Pool::new(cfg)?; .build(cfg); ``` -在应用代码中,使用 `pool.get()?` 来获取一个连接对象 [Taos]。 +In the application code, use ``pool.get()? ` to get a connection object [Taos]. ```rust -let taos = pool.get()?; +let taos = pool.get()? ; ``` -### 连接 +The [Taos] structure is the connection manager in [libtaos] and provides two main APIs. -[Taos] 结构体是 [libtaos] 中的连接管理者,主要提供了两个 API: - -1. `exec`: 执行某个非查询类 SQL 语句,例如 `CREATE`,`ALTER`,`INSERT` 等。 +1. ``exec``: Execute some non-query SQL statements, such as ``CREATE`, ``ALTER`, ``INSERT`, etc. ```rust - taos.exec().await?; + taos.exec().await? ``` -2. `query`:执行查询语句,返回 [TaosQueryData] 对象。 +2. ``query``: Execute the query statement and return the [TaosQueryData] object. ```rust - let q = taos.query("select * from log.logs").await?; + let q = taos.query("select * from log.logs").await? ``` - [TaosQueryData] 对象存储了查询结果数据和返回的列的基本信息(列名,类型,长度): + The [TaosQueryData] object stores the query result data and basic information about the returned columns (column name, type, length). - 列信息使用 [ColumnMeta] 存储: + Column information is stored using [ColumnMeta]. - ```rust + ``rust let cols = &q.column_meta; for col in cols { - println!("name: {}, type: {:?}, bytes: {}", col.name, col.type_, col.bytes); + println!("name: {}, type: {:?} , bytes: {}", col.name, col.type_, col.bytes); } ``` - 逐行获取数据: + It fetches data line by line. ```rust for (i, row) in q.rows.iter().enumerate() { @@ -271,109 +267,109 @@ let taos = pool.get()?; } ``` -需要注意的是,需要使用 Rust 异步函数和异步运行时。 +Note that Rust asynchronous functions and an asynchronous runtime are required. -[Taos] 提供部分 SQL 的 Rust 方法化以减少 `format!` 代码块的频率: +[Taos] provides partial Rust methodization of SQL to reduce the frequency of `format!` code blocks. -- `.describe(table: &str)`: 执行 `DESCRIBE` 并返回一个 Rust 数据结构。 -- `.create_database(database: &str)`: 执行 `CREATE DATABASE` 语句。 -- `.use_database(database: &str)`: 执行 `USE` 语句。 +- `.describe(table: &str)`: Executes `DESCRIBE` and returns a Rust data structure. +- `.create_database(database: &str)`: Executes the `CREATE DATABASE` statement. +- `.use_database(database: &str)`: Executes the `USE` statement. -除此之外,该结构也是 [参数绑定](#参数绑定接口) 和 [行协议接口](#行协议接口) 的入口,使用方法请参考具体的 API 说明。 +In addition, this structure is also the entry point for [Parameter Binding](#Parameter Binding Interface) and [Row Protocol Interface](#Row Protocol Interface). Please refer to the specific API descriptions for usage. -### 参数绑定接口 +### Parameter Binding Interface -与 C 接口类似,Rust 提供参数绑定接口。首先,通过 [Taos] 对象创建一个 SQL 语句的参数绑定对象 [Stmt]: +Similar to the C interface, Rust provides a parameter binding interface. First, create a parameter binding object [Stmt] for a SQL statement from the [Taos] object. ```rust -let mut stmt: Stmt = taos.stmt("insert into ? values(?,?)")?; +let mut stmt: Stmt = taos.stmt("insert into ? values(? ,?)") ? ; ``` -参数绑定对象提供了一组接口用于实现参数绑定: +The parameter binding object provides a set of interfaces for implementing parameter binding. ##### `.set_tbname(tbname: impl ToCString)` -用于绑定表名。 +To bind table names. ##### `.set_tbname_tags(tbname: impl ToCString, tags: impl IntoParams)` -当 SQL 语句使用超级表时,用于绑定子表表名和标签值: +Bind sub-table table names and tag values when the SQL statement uses a super table. ```rust -let mut stmt = taos.stmt("insert into ? using stb0 tags(?) values(?,?)")?; +let mut stmt = taos.stmt("insert into ? using stb0 tags(?) values(? ,?)") ? ; // tags can be created with any supported type, here is an example using JSON -let v = Field::Json(serde_json::from_str("{\"tag1\":\"一二三四五六七八九十\"}").unwrap()); -stmt.set_tbname_tags("tb0", [&tag])?; +let v = Field::Json(serde_json::from_str("{\"tag1\":\"one, two, three, four, five, six, seven, eight, nine, ten\"}").unwrap()); +stmt.set_tbname_tags("tb0", [&tag])? ; ``` ##### `.bind(params: impl IntoParams)` -用于绑定值类型。使用 [Field] 结构体构建需要的类型并绑定: +Bind value types. Use the [Field] structure to construct the desired type and bind. ```rust let ts = Field::Timestamp(Timestamp::now()); let value = Field::Float(0.0); -stmt.bind(vec![ts, value].iter())?; +stmt.bind(vec![ts, value].iter())? ; ``` ##### `.execute()` -执行 SQL。[Stmt] 对象可以复用,在执行后可以重新绑定并执行。 +Execute SQL.[Stmt] objects can be reused, re-binded, and executed after execution. ```rust -stmt.execute()?; +stmt.execute()? ; // next bind cycle. -//stmt.set_tbname()?; -//stmt.bind()?; -//stmt.execute()?; +// stmt.set_tbname()? ; +//stmt.bind()? ; +//stmt.execute()? ; ``` -### 行协议接口 +### Row protocol interface -行协议接口支持多种模式和不同精度,需要引入 schemaless 模块中的常量以进行设置: +The line protocol interface supports multiple modes and different precision and requires the introduction of constants in the schemaless module to set. ```rust use libtaos::*; use libtaos::schemaless::*; ``` -- InfluxDB 行协议 +- InfluxDB row protocol ```rust let lines = [ "st,t1=abc,t2=def,t3=anything c1=3i64,c3=L\"pass\",c2=false 1626006833639000000" "st,t1=abc,t2=def,t3=anything c1=3i64,c3=L\"abc\",c4=4f64 1626006833639000000" ]; - taos.schemaless_insert(&lines, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANOSECONDS)?; + taos.schemaless_insert(&lines, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANOSECONDS)? ; ``` -- OpenTSDB Telnet 协议 +- OpenTSDB Telnet Protocol ```rust let lines = ["sys.if.bytes.out 1479496100 1.3E3 host=web01 interface=eth0"]; - taos.schemaless_insert(&lines, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_SECONDS)?; + taos.schemaless_insert(&lines, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_SECONDS)? ; ``` -- OpenTSDB JSON 协议 +- OpenTSDB JSON protocol ```rust let lines = [r#" { - "metric": "st", - "timestamp": 1626006833, - "value": 10, - "tags": { - "t1": true, - "t2": false, - "t3": 10, - "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" + "metric": "st", + "timestamp": 1626006833, + "value": 10, + "tags": { + "t1": true, + "t2": false, + "t3": 10, + "t4": "123_abc_.! @#$%^&*:;,. /? |+-=()[]{}<>" } }"#]; - taos.schemaless_insert(&lines, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_SECONDS)?; + taos.schemaless_insert(&lines, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_SECONDS)? ; ``` -其他相关结构体 API 使用说明请移步 Rust 文档托管网页:。 +Please move to the Rust documentation hosting page for other related structure API usage instructions: . [libtaos]: https://github.com/taosdata/libtaos-rs [tdengine]: https://github.com/taosdata/TDengine diff --git a/docs-en/14-reference/04-taosadapter.md b/docs-en/14-reference/04-taosadapter.md index 158d4ab008c3b3eca28cd469c38f451b22678518..b176be4fa47db4ba038c9dcc48eee465726f497f 100644 --- a/docs-en/14-reference/04-taosadapter.md +++ b/docs-en/14-reference/04-taosadapter.md @@ -1,6 +1,6 @@ --- title: "taosAdapter" -description: "taosAdapter 是一个 TDengine 的配套工具,是 TDengine 集群和应用程序之间的桥梁和适配器。它提供了一种易于使用和高效的方式来直接从数据收集代理软件(如 Telegraf、StatsD、collectd 等)摄取数据。它还提供了 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine" +description: "taosAdapter is a TDengine companion tool that acts as a bridge and adapter between TDengine clusters and applications. It provides an easy-to-use and efficient way to ingest data directly from data collection agent software such as Telegraf, StatsD, collectd, etc. It also provides an InfluxDB/OpenTSDB compatible data ingestion interface, allowing InfluxDB/OpenTSDB applications to be seamlessly ported to TDengine." sidebar_label: "taosAdapter" --- @@ -10,46 +10,46 @@ import StatsD from "./_statsd.mdx" import Icinga2 from "./_icinga2.mdx" import Tcollector from "./_tcollector.mdx" -taosAdapter 是一个 TDengine 的配套工具,是 TDengine 集群和应用程序之间的桥梁和适配器。它提供了一种易于使用和高效的方式来直接从数据收集代理软件(如 Telegraf、StatsD、collectd 等)摄取数据。它还提供了 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine。 +taosAdapter is a TDengine companion tool that acts as a bridge and adapter between TDengine clusters and applications. It provides an easy-to-use and efficient way to ingest data directly from data collection agent software such as Telegraf, StatsD, collectd, etc. It also provides an InfluxDB/OpenTSDB compatible data ingestion interface that allows InfluxDB/OpenTSDB applications to be seamlessly ported to TDengine. -taosAdapter 提供以下功能: +taosAdapter provides the following features. -- RESTful 接口 -- 兼容 InfluxDB v1 写接口 -- 兼容 OpenTSDB JSON 和 telnet 格式写入 -- 无缝连接到 Telegraf -- 无缝连接到 collectd -- 无缝连接到 StatsD -- 支持 Prometheus remote_read 和 remote_write +- RESTful interface +- InfluxDB v1 compliant write interface +- OpenTSDB JSON and telnet format writes compatible +- Seamless connection to Telegraf +- Seamless connection to collectd +- Seamless connection to StatsD +- Supports Prometheus remote_read and remote_write -## taosAdapter 架构图 +## taosAdapter architecture diagram ![taosAdapter Architecture](taosAdapter-architecture.png) -## taosAdapter 部署方法 +## taosAdapter Deployment Method -### 安装 taosAdapter +### Install taosAdapter -taosAdapter 从 TDengine v2.4.0.0 版本开始成为 TDengine 服务端软件 的一部分,如果您使用 TDengine server 您不需要任何额外的步骤来安装 taosAdapter。您可以从[涛思数据官方网站](https://taosdata.com/cn/all-downloads/)下载 TDengine server(taosAdapter 包含在 v2.4.0.0 及以上版本)安装包。如果需要将 taosAdapter 分离部署在 TDengine server 之外的服务器上,则应该在该服务器上安装完整的 TDengine 来安装 taosAdapter。如果您需要使用源代码编译生成 taosAdapter,您可以参考[构建 taosAdapter](https://github.com/taosdata/taosadapter/blob/develop/BUILD-CN.md)文档。 +taosAdapter has been part of TDengine server software since TDengine v2.4.0.0. If you use the TDengine server, you don't need additional steps to install taosAdapter. You can download taosAdapter from [Taos Data official website](https://taosdata. com/cn/all-downloads/) to download the TDengine server (taosAdapter is included in v2.4.0.0 and above) installation package. If you need to deploy taosAdapter separately on a server other than the TDengine server, you should install the full TDengine on that server to install taosAdapter. If you need to generate taosAdapter using source code compilation, you can refer to the [Building taosAdapter]( https://github.com/taosdata/taosadapter/blob/develop/BUILD-CN.md) documentation. ### start/stop taosAdapter -在 Linux 系统上 taosAdapter 服务默认由 systemd 管理。使用命令 `systemctl start taosadapter` 可以启动 taosAdapter 服务。使用命令 `systemctl stop taosadapter` 可以停止 taosAdapter 服务。 +On Linux systems, the taosAdapter service is managed by systemd by default. You can use the command `systemctl start taosadapter` to start the taosAdapter service and use the command `systemctl stop taosadapter` to stop the taosAdapter service. -### 移除 taosAdapter +### Remove taosAdapter -使用命令 rmtaos 可以移除包括 taosAdapter 在内的 TDengine server 软件。 +Use the command `rmtaos` to remove the TDengine server software, including taosAdapter. -### 升级 taosAdapter +### Upgrade taosAdapter -taosAdapter 和 TDengine server 需要使用相同版本。请通过升级 TDengine server 来升级 taosAdapter。 -与 taosd 分离部署的 taosAdapter 必须通过升级其所在服务器的 TDengine server 才能得到升级。 +taosAdapter and TDengine server need to use the same version. Please upgrade the taosAdapter by upgrading the TDengine server. +You need to upgrade the taosAdapter deployed separately from taosd by upgrading the TDengine server of the deployed server. -## taosAdapter 参数列表 +## taosAdapter parameter list -taosAdapter 支持通过命令行参数、环境变量和配置文件来进行配置。默认配置文件是 /etc/taos/taosadapter.toml。 +taosAdapter supports configuration via command-line arguments, environment variables and configuration files. The default configuration file is /etc/taos/taosadapter.toml. -命令行参数优先于环境变量优先于配置文件,命令行用法是 arg=val,如 taosadapter -p=30000 --debug=true,详细列表如下: +Command-line arguments take precedence over environment variables over configuration files. The command line usage is arg=val, e.g., taosadapter -p=30000 --debug=true. The detailed list is as follows: ```shell Usage of taosAdapter: @@ -133,8 +133,8 @@ Usage of taosAdapter: --version Print the version and exit ``` -备注: -使用浏览器进行接口调用请根据实际情况设置如下跨源资源共享(CORS)参数: +Note: +Please set the following Cross-Origin Resource Sharing (CORS) parameters according to the actual situation when using a browser for interface calls. ```text AllowAllOrigins @@ -145,39 +145,39 @@ AllowCredentials AllowWebSockets ``` -如果不通过浏览器进行接口调用无需关心这几项配置。 +You do not need to care about these configurations if you do not make interface calls through the browser. -关于 CORS 协议细节请参考:[https://www.w3.org/wiki/CORS_Enabled](https://www.w3.org/wiki/CORS_Enabled) 或 [https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS)。 +For details on the CORS protocol, please refer to: [https://www.w3.org/wiki/CORS_Enabled](https://www.w3.org/wiki/CORS_Enabled) or [https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS). -示例配置文件参见 [example/config/taosadapter.toml](https://github.com/taosdata/taosadapter/blob/develop/example/config/taosadapter.toml)。 +See [example/config/taosadapter.toml](https://github.com/taosdata/taosadapter/blob/develop/example/config/taosadapter.toml) for sample configuration files. -## 功能列表 +## Feature List -- 与 RESTful 接口兼容 +- Compatible with RESTful interfaces [https://www.taosdata.com/cn/documentation/connector#restful](https://www.taosdata.com/cn/documentation/connector#restful) -- 兼容 InfluxDB v1 写接口 - [https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/write/](https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/write/) -- 兼容 OpenTSDB JSON 和 telnet 格式写入 +- Compatible with InfluxDB v1 write interface + [https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/write/](https://docs.influxdata.com/influxdb/v2.0/reference/ api/influxdb-1x/write/) +- Compatible with OpenTSDB JSON and telnet format writes - - -- 与 collectd 无缝连接 - collectd 是一个系统统计收集守护程序,请访问 [https://collectd.org/](https://collectd.org/) 了解更多信息。 +- Seamless connection to collectd + collectd is a system statistics collection daemon, please visit [https://collectd.org/](https://collectd.org/) for more information. - Seamless connection with StatsD - StatsD 是一个简单而强大的统计信息汇总的守护程序。请访问 [https://github.com/statsd/statsd](https://github.com/statsd/statsd) 了解更多信息。 -- 与 icinga2 的无缝连接 - icinga2 是一个收集检查结果指标和性能数据的软件。请访问 [https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer](https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer) 了解更多信息。 -- 与 tcollector 无缝连接 - TCollector 是一个客户端进程,从本地收集器收集数据,并将数据推送到 OpenTSDB。请访问 [http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html](http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html) 了解更多信息。 -- 无缝连接 node_exporter - node_export 是一个机器指标的导出器。请访问 [https://github.com/prometheus/node_exporter](https://github.com/prometheus/node_exporter) 了解更多信息。 -- 支持 Prometheus remote_read 和 remote_write - remote_read 和 remote_write 是 Prometheus 数据读写分离的集群方案。请访问[https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/#remote-apis](https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/#remote-apis) 了解更多信息。 + StatsD is a simple yet powerful daemon for aggregating statistical information. Please visit [https://github.com/statsd/statsd](https://github.com/statsd/statsd) for more information. +- Seamless connection with icinga2 + icinga2 is a software that collects inspection result metrics and performance data. Please visit [https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer](https://icinga.com/docs/icinga-2/latest/doc/14- features/#opentsdb-writer) for more information. +- Seamless connection to tcollector + TCollector is a client process that collects data from a local collector and pushes the data to OpenTSDB. Please visit [http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html](http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html) for more information. +- Seamless connection to node_exporter + node_export is an exporter for machine metrics. Please visit [https://github.com/prometheus/node_exporter](https://github.com/prometheus/node_exporter) for more information. +- Support for Prometheus remote_read and remote_write + remote_read and remote_write are clustering solutions for Prometheus data read and write separation. Please visit [https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/#remote-apis](https://prometheus.io/blog/2019/10/10/remote- read-meets-streaming/#remote-apis) for more information. -## 接口 +## Interfaces -### TDengine RESTful 接口 +### TDengine RESTful interface -您可以使用任何支持 http 协议的客户端通过访问 RESTful 接口地址 `http://:6041/` 来写入数据到 TDengine 或从 TDengine 中查询数据。细节请参考[官方文档](/reference/connector#restful)。支持如下 EndPoint : +You can use any client that supports the http protocol to write data to or query data from TDengine by accessing the RESTful interface address `http://:6041/`. See the [official documentation](/reference/connector#restful) for details. The following EndPoint is supported. ```text /rest/sql @@ -187,24 +187,24 @@ AllowWebSockets ### InfluxDB -您可以使用任何支持 http 协议的客户端访问 Restful 接口地址 `http://:6041/` 来写入 InfluxDB 兼容格式的数据到 TDengine。EndPoint 如下: +You can use any client that supports the http protocol to access the Restful interface address `http://:6041/` to write data in InfluxDB compatible format to TDengine. The EndPoint is as follows: ```text /influxdb/v1/write ``` -支持 InfluxDB 查询参数如下: +Support InfluxDB query parameters as follows. -- `db` 指定 TDengine 使用的数据库名 -- `precision` TDengine 使用的时间精度 -- `u` TDengine 用户名 -- `p` TDengine 密码 +- `db` Specifies the database name used by TDengine +- `precision` The time precision used by TDengine +- `u` TDengine user name +- `p` TDengine password -注意: 目前不支持 InfluxDB 的 token 验证方式只支持 Basic 验证和查询参数验证。 +Note: InfluxDB token verification is not supported at present. Only Basic verification and query parameter validation are supported. ### OpenTSDB -您可以使用任何支持 http 协议的客户端访问 Restful 接口地址 `http://:6041/` 来写入 OpenTSDB 兼容格式的数据到 TDengine。EndPoint 如下: +You can use any client that supports the http protocol to access the Restful interface address `http://:6041/` to write data in OpenTSDB compatible format to TDengine. ```text /opentsdb/v1/put/json/:db @@ -229,110 +229,110 @@ AllowWebSockets ### node_exporter -Prometheus 使用的由\*NIX 内核暴露的硬件和操作系统指标的输出器 +Exporter of hardware and OS metrics exposed by the \*NIX kernel used by Prometheus -- 启用 taosAdapter 的配置 node_exporter.enable -- 设置 node_exporter 的相关配置 -- 重新启动 taosAdapter +- Enable the taosAdapter configuration node_exporter.enable +- Set the configuration of the node_exporter +- Restart taosAdapter ### prometheus -## 内存使用优化方法 +## Memory usage optimization methods -taosAdapter 将监测自身运行过程中内存使用率并通过两个阈值进行调节。有效值范围为 -1 到 100 的整数,单位为系统物理内存的百分比。 +taosAdapter will monitor its memory usage during operation and adjust it with two thresholds. Valid values range from -1 to 100 integers in percent of the system's physical memory. - pauseQueryMemoryThreshold - pauseAllMemoryThreshold -当超过 pauseQueryMemoryThreshold 阈值时时停止处理查询请求。 +Stops processing query requests when the pauseQueryMemoryThreshold threshold is exceeded. -http 返回内容: +http response content. - code 503 - body "query memory exceeds threshold" -当超过 pauseAllMemoryThreshold 阈值时停止处理所有写入和查询请求。 +Stops processing all write and query requests when the pauseAllMemoryThreshold threshold is exceeded. -http 返回内容: +http response: code 503 - code 503 - body "memory exceeds threshold" -当内存回落到阈值之下时恢复对应功能。 +Resume the corresponding function when the memory falls back below the threshold. -状态检查接口 `http://:6041/-/ping` +Status check interface `http://:6041/-/ping` -- 正常返回 `code 200` -- 无参数 如果内存超过 pauseAllMemoryThreshold 将返回 `code 503` -- 请求参数 `action=query` 如果内存超过 pauseQueryMemoryThreshold 或 pauseAllMemoryThreshold 将返回 `code 503` +- Normal returns `code 200` +- No parameter If memory exceeds pauseAllMemoryThreshold returns `code 503` +- Request parameter `action=query` returns `code 503` if memory exceeds pauseQueryMemoryThreshold or pauseAllMemoryThreshold -对应配置参数 +Corresponding configuration parameter -```text - monitor.collectDuration 监测间隔 环境变量 "TAOS_MONITOR_COLLECT_DURATION" (默认值 3s) - monitor.incgroup 是否是cgroup中运行(容器中运行设置为 true) 环境变量 "TAOS_MONITOR_INCGROUP" - monitor.pauseAllMemoryThreshold 不再进行插入和查询的内存阈值 环境变量 "TAOS_MONITOR_PAUSE_ALL_MEMORY_THRESHOLD" (默认值 80) - monitor.pauseQueryMemoryThreshold 不再进行查询的内存阈值 环境变量 "TAOS_MONITOR_PAUSE_QUERY_MEMORY_THRESHOLD" (默认值 70) +``text + monitor.collectDuration monitoring interval environment variable "TAOS_MONITOR_COLLECT_DURATION" (default value 3s) + monitor.incgroup whether to run in cgroup (set to true for running in container) environment variable "TAOS_MONITOR_INCGROUP" + monitor.pauseAllMemoryThreshold memory threshold for no more inserts and queries environment variable "TAOS_MONITOR_PAUSE_ALL_MEMORY_THRESHOLD" (default 80) + monitor.pauseQueryMemoryThreshold memory threshold for no more queries Environment variable "TAOS_MONITOR_PAUSE_QUERY_MEMORY_THRESHOLD" (default 70) ``` -您可以根据具体项目应用场景和运营策略进行相应调整,并建议使用运营监控软件及时进行系统内存状态监控。负载均衡器也可以通过这个接口检查 taosAdapter 运行状态。 +You can adjust it according to the specific project application scenario and operation strategy, and it is recommended to use operation monitoring software for timely system memory status monitoring. The load balancer can also check the taosAdapter running status through this interface. -## taosAdapter 监控指标 +## taosAdapter Monitoring Metrics -taosAdapter 采集 http 相关指标、cpu 百分比和内存百分比。 +taosAdapter collects http-related metrics, CPU percentage, and memory percentage. -### http 接口 +### http interface -提供符合 [OpenMetrics](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md) 接口: +Provides an interface conforming to [OpenMetrics](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md). ```text http://:6041/metrics ``` -### 写入 TDengine +### Write to TDengine -taosAdapter 支持将 http 监控、cpu 百分比和内存百分比写入 TDengine。 +taosAdapter supports writing http monitoring, CPU percentage, and memory percentage to TDengine. -有关配置参数 +For configuration parameters -| **配置项** | **描述** | **默认值** | +| **Configuration items** | **Description** | **Default values** | | ----------------------- | --------------------------------------------------------- | ---------- | -| monitor.collectDuration | cpu 和内存采集间隔 | 3s | -| monitor.identity | 当前 taosadapter 的标识符如果不设置将使用 'hostname:port' | | -| monitor.incgroup | 是否是 cgroup 中运行(容器中运行设置为 true) | false | -| monitor.writeToTD | 是否写入到 TDengine | true | -| monitor.user | TDengine 连接用户名 | root | -| monitor.password | TDengine 连接密码 | taosdata | -| monitor.writeInterval | 写入 TDengine 间隔 | 30s | +| monitor.collectDuration | CPU and memory collection interval | 3s | +| monitor.identity | The current taosadapter identifier will be used if not set to 'hostname:port' | | +| monitor.incgroup | whether it is running in a cgroup (set to true for running in a container) | false | +| monitor.writeToTD | Whether to write to TDengine | true | +| monitor.user | TDengine connection username | root | +| monitor.password | TDengine connection password | taosdata | +| monitor.writeInterval | Write to TDengine interval | 30s | -## 结果返回条数限制 +## Limit the number of results returned -taosAdapter 通过参数 `restfulRowLimit` 来控制结果的返回条数,-1 代表无限制,默认无限制。 +taosAdapter controls the number of results returned by the parameter `restfulRowLimit`, -1 means no limit, default is no limit. -该参数控制以下接口返回 +This parameter controls the number of results returned by the following interfaces: - `http://:6041/rest/sql` - `http://:6041/rest/sqlt` - `http://:6041/rest/sqlutc` -- `http://:6041/prometheus/v1/remote_read/:db` +- ` http://:6041/prometheus/v1/remote_read/:db` -## 故障解决 +## Troubleshooting -您可以通过命令 `systemctl status taosadapter` 来检查 taosAdapter 运行状态。 +You can check the taosAdapter running status with the` systemctl status taosadapter` command. -您也可以通过设置 --logLevel 参数或者环境变量 TAOS_ADAPTER_LOG_LEVEL 来调节 taosAdapter 日志输出详细程度。有效值包括: panic、fatal、error、warn、warning、info、debug 以及 trace。 +You can also adjust the level of the taosAdapter log output by setting the --logLevel parameter or the environment variable TAOS_ADAPTER_LOG_LEVEL. Valid values are: panic, fatal, error, warn, warning, info, debug and trace. -## 如何从旧版本 TDengine 迁移到 taosAdapter +## How to migrate from older TDengine versions to taosAdapter -在 TDengine server 2.2.x.x 或更早期版本中,taosd 进程包含一个内嵌的 http 服务。如前面所述,taosAdapter 是一个使用 systemd 管理的独立软件,拥有自己的进程。并且两者有一些配置参数和行为是不同的,请见下表: +In TDengine server 2.2.x.x or earlier, the taosd process contains an embedded http service. As mentioned earlier, taosAdapter is a standalone software managed using systemd and has its process. And there are some configuration parameters and behaviors that are different between the two. See the following table. -| **#** | **embedded httpd** | **taosAdapter** | **comment** | -| ----- | ------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | -| 1 | httpEnableRecordSql | --logLevel=debug | | -| 2 | httpMaxThreads | n/a | taosAdapter 自动管理线程池,无需此参数 | -| 3 | telegrafUseFieldNum | 请参考 taosAdapter telegraf 配置方法 | | -| 4 | restfulRowLimit | restfulRowLimit | 内嵌 httpd 默认输出 10240 行数据,最大允许值为 102400。taosAdapter 也提供 restfulRowLimit 但是默认不做限制。您可以根据实际场景需求进行配置 | -| 5 | httpDebugFlag | 不适用 | httpdDebugFlag 对 taosAdapter 不起作用 | -| 6 | httpDBNameMandatory | 不适用 | taosAdapter 要求 URL 中必须指定数据库名 | +| **#** | **embedded httpd** | **taosAdapter** | **comment** | +| ----- | ------------------- | ------------------------------------ | ------------------------------------------------------------------ ------------------------------------------------------------------------ | +| 1 | httpEnableRecordSql | --logLevel=debug | | +| 2 | httpMaxThreads | n/a | taosAdapter Automatically manages thread pools without this parameter | +| 3 | telegrafUseFieldNum | See the taosAdapter telegraf configuration method | | +| 4 | restfulRowLimit | restfulRowLimit | Embedded httpd outputs 10240 rows of data by default, the maximum allowed is 102400. taosAdapter also provides restfulRowLimit but it is not limited by default. You can configure it according to the actual scenario. +| 5 | httpDebugFlag | Not applicable | httpdDebugFlag does not work for taosAdapter | +| 6 | httpDBNameMandatory | N/A | taosAdapter requires the database name to be specified in the URL | diff --git a/docs-en/14-reference/05-taosbenchmark.md b/docs-en/14-reference/05-taosbenchmark.md index 0ccd25cf3a93f0496458e061d095f58fe3eac4ca..7091f409baf2df5135c00fda42e8fff766c619f7 100644 --- a/docs-en/14-reference/05-taosbenchmark.md +++ b/docs-en/14-reference/05-taosbenchmark.md @@ -2,64 +2,64 @@ title: taosBenchmark sidebar_label: taosBenchmark toc_max_heading_level: 4 -description: "taosBenchmark (曾用名 taosdemo ) 是一个用于测试 TDengine 产品性能的工具" +description: "taosBenchmark (once called taosdemo ) is a tool for testing the performance of TDengine." --- -## 简介 +## Introduction -taosBenchmark (曾用名 taosdemo ) 是一个用于测试 TDengine 产品性能的工具。taosBenchmark 可以测试 TDengine 的插入、查询和订阅等功能的性能,它可以模拟由大量设备产生的大量数据,还可以灵活地控制数据库、超级表、标签列的数量和类型、数据列的数量和类型、子表的数量、每张子表的数据量、插入数据的时间间隔、taosBenchmark 的工作线程数量、是否以及如何插入乱序数据等。为了兼容过往用户的使用习惯,安装包提供 了 taosdemo 作为 taosBenchmark 的软链接。 +taosBenchmark (formerly taosdemo ) is a tool for testing the performance of TDengine products. taosBenchmark can test the performance of TDengine's insert, query, and subscription functions and simulate large amounts of data generated by many devices. taosBenchmark can flexibly control the number and type of databases, supertables, tag columns, number and type of data columns, and sub-tables, and types of databases, super tables, the number and types of data columns, the number of sub-tables, the amount of data per sub-table, the time interval for inserting data, the number of working threads, whether and how to insert disordered data, and so on. The installer provides taosdemo as a soft link to taosBenchmark for compatibility with past users. -## 安装 +## Installation -taosBenchmark 有两种安装方式: +There are two ways to install taosBenchmark: -- 安装 TDengine 官方安装包的同时会自动安装 taosBenchmark, 详情请参考[ TDengine 安装](/operation/pkg-install)。 +- Installing the official TDengine installer will automatically install taosBenchmark. Please refer to [TDengine installation](/operation/pkg-install) for details. -- 单独编译 taos-tools 并安装, 详情请参考 [taos-tools](https://github.com/taosdata/taos-tools) 仓库。 +- Compile taos-tools separately and install them. Please refer to the [taos-tools](https://github.com/taosdata/taos-tools) repository for details. -## 运行 +## Run -### 配置和运行方式 +### Configuration and running methods -taosBenchmark 支持两种配置方式:[命令行参数](#命令行参数详解) 和 [JSON 配置文件](#配置文件参数详解)。这两种方式是互斥的,在使用配置文件时只能使用一个命令行参数 `-f ` 指定配置文件。在使用命令行参数运行 taosBenchmark 并控制其行为时则不能使用 `-f` 参数而要用其它参数来进行配置。除此之外,taosBenchmark 还提供了一种特殊的运行方式,即无参数运行。 +taosBenchmark supports two configuration methods: [command line arguments](# command line arguments detailed) and [JSON configuration file](# configuration file arguments detailed). These two methods are mutually exclusive, and with only one command line parameter, users can use `-f ` to specify a configuration file when using a configuration file. When running taosBenchmark with command-line arguments and controlling its behavior, users should use other parameters for configuration rather than `-f` parameter. In addition, taosBenchmark offers a special way of running without parameters. -taosBenchmark 支持对 TDengine 做完备的性能测试,其所支持的 TDengine 功能分为三大类:写入、查询和订阅。这三种功能之间是互斥的,每次运行 taosBenchmark 只能选择其中之一。值得注意的是,所要测试的功能类型在使用命令行配置方式时是不可配置的,命令行配置方式只能测试写入性能。若要测试 TDegnine 的查询和订阅性能,必须使用配置文件的方式,通过配置文件中的参数 `filetype` 指定所要测试的功能类型。 +taosBenchmark supports complete performance testing of TDengine. taosBenchmark supports the TDengine functions in three categories: write, query, and subscribe. These three functions are mutually exclusive, and users can select only one of them each time taosBenchmark runs. It is important to note that the type of functionality to be tested is not configurable when using the command line configuration method, which can only test writing performance. To test the query and subscription performance of the TDengine, you must use the configuration file method and specify the function type to test via the parameter `filetype` in the configuration file. -**在运行 taosBenchmark 之前要确保 TDengine 集群已经在正确运行。** +**Make sure that the TDengine cluster is running correctly before running taosBenchmark. ** -### 无命令行参数运行 +### Run without command-line arguments -执行下列命令即可快速体验 taosBenchmark 对 TDengine 进行基于默认配置的写入性能测试。 +Execute the following commands to quickly experience taosBenchmark's default configuration-based write performance testing of TDengine. ```bash taosBenchmark ``` -在无参数运行时,taosBenchmark 默认连接 `/etc/taos` 下指定的 TDengine 集群,并在 TDengine 中创建一个名为 test 的数据库,test 数据库下创建名为 meters 的一张超级表,超级表下创建 10000 张表,每张表中写入 10000 条记录。注意,如果已有 test 数据库,这个命令会先删除该数据库后建立一个全新的 test 数据库。 +When run without parameters, taosBenchmark connects to the TDengine cluster specified in `/etc/taos` by default and creates a database named test in TDengine, a super table named `meters` under the test database, and 10,000 tables under the super table with 10,000 records written to each table. Note that if there is already a test database, this table is not used. Note that if there is already a test database, this command will delete it first and create a new test database. -### 使用命令行配置参数运行 +### Run with command line configuration parameters -在使用命令行参数运行 taosBenchmark 并控制其行为时,`-f ` 参数不能使用。所有配置参数都必须通过命令行指定。以下是使用命令行方式测试 taosBenchmark 写入性能的一个示例。 +The `-f ` argument cannot be used when running taosBenchmark with command-line parameters and controlling its behavior. Users must specify all configuration parameters from the command line. The following is an example of testing taosBenchmark writing performance using the command line approach. ```bash taosBenchmark -I stmt -n 200 -t 100 ``` -上面的命令 `taosBenchmark` 将创建一个名为`test`的数据库,在其中建立一张超级表`meters`,在该超级表中建立 100 张子表并使用参数绑定的方式为每张子表插入 200 条记录。 +The above command, `taosBenchmark` will create a database named `test`, create a super table `meters` in it, create 100 sub-tables in the super table and insert 200 records for each sub-table using parameter binding. -### 使用配置文件运行 +### Run with the configuration file -taosBenchmark 安装包中提供了配置文件的示例,位于 `/examples/taosbenchmark-json` 下 +A sample configuration file is provided in the taosBenchmark installation package under `/examples/taosbenchmark-json`. -使用如下命令行即可运行 taosBenchmark 并通过配置文件控制其行为。 +Use the following command line to run taosBenchmark and control its behavior via a configuration file. ```bash taosBenchmark -f ``` -**下面是几个配置文件的示例:** +**Here are a few examples of configuration files:** -#### 插入场景 JSON 配置文件示例 +#### Example of inserting a scenario JSON configuration file
insert.json @@ -70,7 +70,7 @@ taosBenchmark -f
-#### 查询场景 JSON 配置文件示例 +#### Query Scenario JSON Profile Example
query.json @@ -92,343 +92,343 @@ taosBenchmark -f
-## 命令行参数详解 +## Command Line Parameters Explained - **-f/--file ** : - 要使用的 JSON 配置文件,由该文件指定所有参数,本参数与命令行其他参数不能同时使用。没有默认值。 + specify the configuration file to use. This file includes All parameters. And users should not use this parameter with other parameters on the command line. There is no default value. - **-c/--config-dir ** : - TDengine 集群配置文件所在的目录,默认路径是 /etc/taos 。 + specify the directory where the TDengine cluster configuration file. the default path is `/etc/taos`. - **-h/--host ** : - 指定要连接的 TDengine 服务端的 FQDN,默认值为 localhost 。 + Specify the FQDN of the TDengine server to connect to. The default value is localhost. - **-P/--port ** : - 要连接的 TDengine 服务器的端口号,默认值为 6030 。 + The port number of the TDengine server to connect to, the default value is 6030. - **-I/--interface ** : - 插入模式,可选项有 taosc, rest, stmt, sml, sml-rest, 分别对应普通写入、restful 接口写入、参数绑定接口写入、schemaless 接口写入、restful schemaless 接口写入 (由 taosAdapter 提供)。默认值为 taosc。 + Insert mode. Options are taosc, rest, stmt, sml, sml-rest, corresponding to normal write, restful interface writing, parameter binding interface writing, schemaless interface writing, RESTful schemaless interface writing (provided by taosAdapter). The default value is taosc. - **-u/--user ** : - 用于连接 TDengine 服务端的用户名,默认为 root 。 + User name to connect to the TDengine server. Default is root. - **-p/--password ** : - 用于连接 TDengine 服务端的密码,默认值为 taosdata。 + The default password to connect to the TDengine server is `taosdata`. - **-o/--output ** : - 结果输出文件的路径,默认值为 ./output.txt。 + specify the path of the result output file, the default value is `. /output.txt`. - **-T/--thread ** : - 插入数据的线程数量,默认为 8 。 + The number of threads to insert data. Default is 8. - **-B/--interlace-rows ** : - 启用交错插入模式并同时指定向每个子表每次插入的数据行数。交错插入模式是指依次向每张子表插入由本参数所指定的行数并重复这个过程,直到所有子表的数据都插入完成。默认值为 0, 即向一张子表完成数据插入后才会向下一张子表进行数据插入。 + Enables interleaved insertion mode and specifies the number of rows of data to be inserted into each child table. Interleaved insertion mode means inserting the number of rows specified by this parameter into each sub-table and repeating the process until all sub-tables have been inserted. The default value is 0, i.e., data is inserted into one sub-table before the next sub-table is inserted. - **-i/--insert-interval ** : - 指定交错插入模式的插入间隔,单位为 ms,默认值为 0。 只有当 `-B/--interlace-rows` 大于 0 时才起作用。意味着数据插入线程在为每个子表插入隔行扫描记录后,会等待该值指定的时间间隔后再进行下一轮写入。 + Specify the insert interval in `ms` for interleaved insert mode. The default value is 0. It only works if `-B/--interlace-rows` is greater than 0. That means that after inserting interlaced rows for each child table, the data insertion with multiple threads will wait for the interval specified by this value before proceeding to the next round of writes. - **-r/--rec-per-req ** : - 每次向 TDegnine 请求写入的数据行数,默认值为 30000 。 + Writing the number of rows of records per request to TDengine, the default value is 30000. - **-t/--tables ** : - 指定子表的数量,默认为 10000 。 + Specify the number of sub-tables. The default is 10000. - **-S/--timestampstep ** : - 每个子表中插入数据的时间戳步长,单位是 ms,默认值是 1。 + Timestamp step for inserting data in each child table in ms, default is 1. - **-n/--records ** : - 每个子表插入的记录数,默认值为 10000 。 + The default value of the number of records inserted in each sub-table is 10000. - **-d/--database ** : - 所使用的数据库的名称,默认值为 test 。 + The name of the database used, the default value is `test`. - **-b/--data-type ** : - 超级表的数据列的类型。如果不使用则默认为有三个数据列,其类型分别为 FLOAT, INT, FLOAT 。 + specify the type of the data columns of the super table. It defaults to three columns of type FLOAT, INT, and FLOAT if not used. - **-l/--columns ** : - 超级表的数据列的总数量。如果同时设置了该参数和 `-b/--data-type`,则最后的结果列数为两者取大。如果本参数指定的数量大于 `-b/--data-type` 指定的列数,则未指定的列类型默认为 INT, 例如: `-l 5 -b float,double`, 那么最后的列为 `FLOAT,DOUBLE,INT,INT,INT`。如果 columns 指定的数量小于或等于 `-b/--data-type` 指定的列数,则结果为 `-b/--data-type` 指定的列和类型,例如: `-l 3 -b float,double,float,bigint`,那么最后的列为 `FLOAT,DOUBLE,FLOAT,BIGINT` 。 + specify the number of columns in the super table. If both this parameter and `-b/--data-type` is set, the final result number of columns is the greater of the two. If the number specified by this parameter is greater than the number of columns specified by `-b/--data-type`, the unspecified column type defaults to INT, for example: `-l 5 -b float,double`, then the final column is `FLOAT,DOUBLE,INT,INT,INT`. If the number of columns specified is less than or equal to the number of columns specified by `-b/--data-type`, then the result is the column and type specified by `-b/--data-type`, e.g.: `-l 3 -b float,double,float,bigint`. The last column is `FLOAT,DOUBLE, FLOAT,BIGINT`. - **-A/--tag-type ** : - 超级表的标签列类型。nchar 和 binary 类型可以同时设置长度,例如: + The tag column type of the super table. nchar and binary types can both set the length, for example: ``` taosBenchmark -A INT,DOUBLE,NCHAR,BINARY(16) ``` -如果没有设置标签类型,默认是两个标签,其类型分别为 INT 和 BINARY(16)。 -注意:在有的 shell 比如 bash 命令里面 “()” 需要转义,则上述指令应为: +If users did not set tag type, the default is two tags, whose types are INT and BINARY(16). +Note: In some shells, such as bash, "()" needs to be escaped, so the above command should be ``` taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\) ``` - **-w/--binwidth **: - nchar 和 binary 类型的默认长度,默认值为 64。 + specify the default length for nchar and binary types. The default value is 64. - **-m/--table-prefix ** : - 子表名称的前缀,默认值为 "d"。 + The prefix of the sub-table name, the default value is "d". - **-E/--escape-character** : - 开关参数,指定在超级表和子表名称中是否使用转义字符。默认值为不使用。 + Switch parameter specifying whether to use escape characters in the super table and sub-table names. By default is not used. - **-C/--chinese** : - 开关参数,指定 nchar 和 binary 是否使用 Unicode 中文字符。默认值为不使用。 + Switch specifying whether to use Unicode Chinese characters in nchar and binary. By default is not used. - **-N/--normal-table** : - 开关参数,指定只创建普通表,不创建超级表。默认值为 false。仅当插入模式为 taosc, stmt, rest 模式下可以使用。 + This parameter indicates that taosBenchmark will create only normal tables instead of super tables. The default value is false. It can be used if the insert mode is taosc, stmt, and rest. - **-M/--random** : - 开关参数,插入数据为生成的随机值。默认值为 false。若配置此参数,则随机生成要插入的数据。对于数值类型的 标签列/数据列,其值为该类型取值范围内的随机值。对于 NCHAR 和 BINARY 类型的 标签列/数据列,其值为指定长度范围内的随机字符串。 + This parameter indicates writing data with random values. The default is false. If users use this parameter, taosBenchmark will generate the random values. For tag/data columns of numeric type, the value is a random value within the range of values of that type. For NCHAR and BINARY type tag columns/data columns, the value is the random string within the specified length range. - **-x/--aggr-func** : - 开关参数,指示插入后查询聚合函数。默认值为 false。 + Switch parameter to indicate query aggregation function after insertion. The default value is false. - **-y/--answer-yes** : - 开关参数,要求用户在提示后确认才能继续。默认值为 false 。 + Switch parameter that requires the user to confirm at the prompt to continue. The default value is false. - **-O/--disorder ** : - 指定乱序数据的百分比概率,其值域为 [0,50]。默认为 0,即没有乱序数据。 + Specify the percentage probability of disordered data, with a value range of [0,50]. The default is 0, i.e., there is no disordered data. - **-R/--disorder-range ** : - 指定乱序数据的时间戳回退范围。所生成的乱序时间戳为非乱序情况下应该使用的时间戳减去这个范围内的一个随机值。仅在 `-O/--disorder` 指定的乱序数据百分比大于 0 时有效。 + Specify the timestamp range for the disordered data. It leads the resulting disorder timestamp as the ordered timestamp minus a random value in this range. Valid only if the percentage of disordered data specified by `-O/--disorder` is greater than 0. - **-F/--prepare_rand ** : - 生成的随机数据中唯一值的数量。若为 1 则表示所有数据都相同。默认值为 10000 。 + Specify the number of unique values in the generated random data. A value of 1 means that all data are equal. The default value is 10000. - **-a/--replica ** : - 创建数据库时指定其副本数,默认值为 1 。 + Specify the number of replicas when creating the database. The default value is 1. - **-V/--version** : - 显示版本信息并退出。不能与其它参数混用。 + Show version information only. Users should not use it with other parameters. -- **-?/--help** : - 显示帮助信息并退出。不能与其它参数混用。 +- **-? /--help** : + Show help information and exit. Users should not use it with other parameters. -## 配置文件参数详解 +## Configuration file parameters in detail -### 通用配置参数 +### General configuration parameters -本节所列参数适用于所有功能模式。 +The parameters listed in this section apply to all function modes. -- **filetype** : 要测试的功能,可选值为 `insert`, `query` 和 `subscribe`。分别对应插入、查询和订阅功能。每个配置文件中只能指定其中之一。 -- **cfgdir** : TDengine 集群配置文件所在的目录,默认路径是 /etc/taos 。 +- **filetype** : The function to be tested, with optional values `insert`, `query` and `subscribe`. These correspond to the insert, query, and subscribe functions, respectively. Users can specify only one of these in each configuration file. +**cfgdir**: specify the TDengine cluster configuration file's directory. The default path is /etc/taos. -- **host** : 指定要连接的 TDengine 服务端的 FQDN,默认值为 localhost。 +- **host**: Specify the FQDN of the TDengine server to connect. The default value is `localhost`. -- **port** : 要连接的 TDengine 服务器的端口号,默认值为 6030。 +- **port**: The port number of the TDengine server to connect to, the default value is `6030`. -- **user** : 用于连接 TDengine 服务端的用户名,默认为 root。 +- **user**: The user name of the TDengine server to connect to, the default is `root`. -- **password** : 用于连接 TDengine 服务端的密码,默认值为 taosdata。 +- **password**: The password to connect to the TDengine server, the default value is `taosdata`. -### 插入场景配置参数 +### Insert scenario configuration parameters -插入场景下 `filetype` 必须设置为 `insert`,该参数及其它通用参数详见[通用配置参数](#通用配置参数) +`filetype` must be set to `insert` in the insertion scenario. See [General Configuration Parameters](#General Configuration Parameters) -#### 数据库相关配置参数 +#### Database related configuration parameters -创建数据库时的相关参数在 json 配置文件中的 `dbinfo` 中配置,具体参数如下。这些参数与 TDengine 中 `create database` 时所指定的数据库参数相对应。 +The parameters related to database creation are configured in `dbinfo` in the json configuration file, as follows. These parameters correspond to the database parameters specified when `create database` in TDengine. -- **name** : 数据库名。 +- **name**: specify the name of the database. -- **drop** : 插入前是否删除数据库,默认为 true。 +- **drop**: indicate whether to delete the database before inserting. The default is true. -- **replica** : 创建数据库时指定的副本数。 +- **replica**: specify the number of replicas when creating the database. -- **days** : 单个数据文件中存储数据的时间跨度,默认值为 10。 +- **days**: specify the time span for storing data in a single data file. The default is 10. -- **cache** : 缓存块的大小,单位是 MB,默认值是 16。 +- **cache**: specify the size of the cache blocks in MB. The default value is 16. -- **blocks** : 每个 vnode 中缓存块的数量,默认为 6。 +- **blocks**: specify the number of cache blocks in each vnode. The default is 6. -- **precision** : 数据库时间精度,默认值为 "ms"。 +- **precision**: specify the database time precision. The default value is "ms". -- **keep** : 保留数据的天数,默认值为 3650。 +- **keep**: specify the number of days to keep the data. The default value is 3650. -- **minRows** : 文件块中的最小记录数,默认值为 100。 +- **minRows**: specify the minimum number of records in the file block. The default value is 100. -- **maxRows** : 文件块中的最大记录数,默认值为 4096。 +- **maxRows**: specify the maximum number of records in the file block. The default value is 4096. -- **comp** : 文件压缩标志,默认值为 2。 +- **comp**: specify the file compression level. The default value is 2. -- **walLevel** : WAL 级别,默认为 1。 +- **walLevel** : specify WAL level, default is 1. -- **cacheLast** : 是否允许将每个表的最后一条记录保留在内存中,默认值为 0,可选值为 0,1,2,3。 +- **cacheLast**: indicate whether to allow the last record of each table to be kept in memory. The default value is 0. The value can be 0, 1, 2, or 3. -- **quorum** : 多副本模式下的写确认数量,默认值为 1。 +- **quorum**: specify the number of writing acknowledgments in multi-replica mode. The default value is 1. -- **fsync** : 当 wal 设置为 2 时,fsync 的间隔时间,单位为 ms,默认值为 3000。 +- **fsync**: specify the interval of fsync in ms when users set WAL to 2. The default value is 3000. -- **update** : 是否支持数据更新,默认值为 0, 可选值为 0, 1, 2。 +- **update** : indicate whether to support data update, default value is 0, optional values are 0, 1, 2. -#### 超级表相关配置参数 +#### Super table related configuration parameters -创建超级表时的相关参数在 json 配置文件中的 `super_tables` 中配置,具体参数如下表。 +The parameters for creating super tables are configured in `super_tables` in the json configuration file, as shown below. -- **name**: 超级表名,必须配置,没有默认值。 -- **child_table_exists** : 子表是否已经存在,默认值为 "no",可选值为 "yes" 或 "no"。 +- **name**: Super table name, mandatory, no default value. +- **child_table_exists** : whether the child table already exists, default value is "no", optional value is "yes" or "no". -- **child_table_count** : 子表的数量,默认值为 10。 +- **child_table_count** : The number of child tables, the default value is 10. -- **child_table_prefix** : 子表名称的前缀,必选配置项,没有默认值。 +- **child_table_prefix** : The prefix of the child table name, mandatory configuration item, no default value. -- **escape_character** : 超级表和子表名称中是否包含转义字符,默认值为 "no",可选值为 "yes" 或 "no"。 +- **escape_character**: specify the super table and child table names containing escape characters. By default is "no". The value can be "yes" or "no". -- **auto_create_table** : 仅当 insert_mode 为 taosc, rest, stmt 并且 childtable_exists 为 "no" 时生效,该参数为 "yes" 表示 taosBenchmark 在插入数据时会自动创建不存在的表;为 "no" 则表示先提前建好所有表再进行插入。 +- **auto_create_table**: only when insert_mode is taosc, rest, stmt, and childtable_exists is "no". "yes" means taosBenchmark will automatically create non-existent tables when inserting data; "no" means that taosBenchmark will create all tables before inserting. -- **batch_create_tbl_num** : 创建子表时每批次的建表数量,默认为 10。注:实际的批数不一定与该值相同,当执行的 SQL 语句大于支持的最大长度时,会自动截断再执行,继续创建。 +- **batch_create_tbl_num** : the number of tables per batch when creating sub-tables, default is 10. Note: the actual number of batches may not be the same as this value when the executed SQL statement is larger than the maximum length supported, it will be automatically truncated and re-executed to continue creating. -- **data_source** : 数据的来源,默认为 taosBenchmark 随机产生,可以配置为 "rand" 和 "sample"。为 "sample" 时使用 sample_file 参数指定的文件内的数据。 +- **data_source**: specify the source of data-generating. Default is taosBenchmark randomly generated. Users can configure it as "rand" and "sample". When "sample" is used, taosBenchmark will use the data in the file specified by the `sample_file` parameter. -- **insert_mode** : 插入模式,可选项有 taosc, rest, stmt, sml, sml-rest, 分别对应普通写入、restful 接口写入、参数绑定接口写入、schemaless 接口写入、restful schemaless 接口写入 (由 taosAdapter 提供)。默认值为 taosc 。 +- **insert_mode**: insertion mode with options taosc, rest, stmt, sml, sml-rest, corresponding to normal write, restful interface write, parameter binding interface write, schemaless interface write, restful schemaless interface write (provided by taosAdapter). The default value is taosc. -- **non_stop_mode** : 指定是否持续写入,若为 "yes" 则 insert_rows 失效,直到 Ctrl + C 停止程序,写入才会停止。默认值为 "no",即写入指定数量的记录后停止。注:即使在持续写入模式下 insert_rows 失效,但其也必须被配置为一个非零正整数。 +- **non_stop_mode**: Specify whether to keep writing. If "yes", insert_rows will be disabled, and writing will not stop until Ctrl + C stops the program. The default value is "no", i.e., taosBenchmark will stop the writing after the specified number of rows are written. Note: insert_rows must be configured as a non-zero positive integer even if it fails in continuous write mode. -- **line_protocol** : 使用行协议插入数据,仅当 insert_mode 为 sml 或 sml-rest 时生效,可选项为 line, telnet, json。 +- **line_protocol**: Insert data using line protocol. Only works when insert_mode is sml or sml-rest. The value can be `line`, `telnet`, or `json`. -- **tcp_transfer** : telnet 模式下的通信协议,仅当 insert_mode 为 sml-rest 并且 line_protocol 为 telnet 时生效。如果不配置,则默认为 http 协议。 +- **tcp_transfer**: Communication protocol in telnet mode only takes effect when insert_mode is sml-rest, and line_protocol is telnet. If not configured, the default protocol is http. -- **insert_rows** : 每个子表插入的记录数,默认为 0 。 +- **insert_rows** : The number of inserted rows per child table, default is 0. -- **childtable_offset** : 仅当 childtable_exists 为 yes 时生效,指定从超级表获取子表列表时的偏移量,即从第几个子表开始。 +- **childtable_offset**: Effective only if childtable_exists is yes, specifies the offset when fetching the list of child tables from the super table, i.e., starting from the first child table. -- **childtable_limit** : 仅当 childtable_exists 为 yes 时生效,指定从超级表获取子表列表的上限。 +- **childtable_limit**: Effective only when childtable_exists is yes, specifies the upper limit for fetching the list of child tables from the super table. -- **interlace_rows** : 启用交错插入模式并同时指定向每个子表每次插入的数据行数。交错插入模式是指依次向每张子表插入由本参数所指定的行数并重复这个过程,直到所有子表的数据都插入完成。默认值为 0, 即向一张子表完成数据插入后才会向下一张子表进行数据插入。 +- **interlace_rows**: Enables interleaved insertion mode and specifies the number of rows of data to be inserted into each child table at a time. Staggered insertion mode means inserting the number of rows specified by this parameter into each sub-table and repeating the process until all sub-tables have been inserted. The default value is 0, i.e., data is inserted into one sub-table before the next sub-table is inserted. -- **insert_interval** : 指定交错插入模式的插入间隔,单位为 ms,默认值为 0。 只有当 `-B/--interlace-rows` 大于 0 时才起作用。意味着数据插入线程在为每个子表插入隔行扫描记录后,会等待该值指定的时间间隔后再进行下一轮写入。 +- **insert_interval** : Specifies the insertion interval in ms for interleaved insertion mode. The default value is 0. It only works if `-B/--interlace-rows` is greater than 0. After inserting interlaced rows for each child table, the data insertion thread will wait for the interval specified by this value before proceeding to the next round of writes. -- **partial_col_num** : 若该值为正数 n 时, 则仅向前 n 列写入,仅当 insert_mode 为 taosc 和 rest 时生效,如果 n 为 0 则是向全部列写入。 +- **partial_col_num**: If this value is a positive number n, only the first n columns are written to, only if insert_mode is taosc and rest, or all columns if n is 0. -- **disorder_ratio** : 指定乱序数据的百分比概率,其值域为 [0,50]。默认为 0,即没有乱序数据。 +- **disorder_ratio** : Specifies the percentage probability of disordered data in the value range [0,50]. The default is 0, which means there is no disorder data. -- **disorder_range** : 指定乱序数据的时间戳回退范围。所生成的乱序时间戳为非乱序情况下应该使用的时间戳减去这个范围内的一个随机值。仅在 `-O/--disorder` 指定的乱序数据百分比大于 0 时有效。 +- **disorder_range** : Specifies the timestamp fallback range for the disordered data. The generated disorder timestamp is the timestamp that should be used in the non-disorder case minus a random value in this range. Valid only if the percentage of disordered data specified by `-O/--disorder` is greater than 0. -- **timestamp_step** : 每个子表中插入数据的时间戳步长,单位与数据库的 `precision` 一致,默认值是 1。 +- **timestamp_step**: The timestamp step for inserting data in each child table, in units consistent with the `precision` of the database, the default value is 1. -- **start_timestamp** : 每个子表的时间戳起始值,默认值是 now。 +- **start_timestamp** : The timestamp start value of each sub-table, the default value is now. -- **sample_format** : 样本数据文件的类型,现在只支持 "csv" 。 +- **sample_format**: The type of the sample data file, now only "csv" is supported. -- **sample_file** : 指定 csv 格式的文件作为数据源,仅当 data_source 为 sample 时生效。若 csv 文件内的数据行数小于等于 prepared_rand,那么会循环读取 csv 文件数据直到与 prepared_rand 相同;否则则会只读取 prepared_rand 个数的行的数据。也即最终生成的数据行数为二者取小。 +- **sample_file**: Specify a CSV format file as the data source. It only works when data_source is a sample. If the number of rows in the CSV file is less than or equal to prepared_rand, then taosBenchmark will read the CSV file data cyclically until it is the same as prepared_rand; otherwise, taosBenchmark will read only the rows with the number of prepared_rand. The final number of rows of data generated is the smaller of the two. -- **use_sample_ts** : 仅当 data_source 为 sample 时生效,表示 sample_file 指定的 csv 文件内是否包含第一列时间戳,默认为 no。 若设置为 yes, 则使用 csv 文件第一列作为时间戳,由于同一子表时间戳不能重复,生成的数据量取决于 csv 文件内的数据行数相同,此时 insert_rows 失效。 +- **use_sample_ts**: effective only when data_source is `sample`, indicates whether the CSV file specified by sample_file contains the first timestamp column. Default is no. If set to yes, the first column of the CSV file is used as `timestamp`. Since the timestamp of the same sub-table cannot be repeated, the amount of data generated depends on the same number of rows of data in the CSV file, and insert_rows will be invalidated. -- **tags_file** : 仅当 insert_mode 为 taosc, rest 的模式下生效。 最终的 tag 的数值与 childtable_count 有关,如果 csv 文件内的 tag 数据行小于给定的子表数量,那么会循环读取 csv 文件数据直到生成 childtable_count 指定的子表数量;否则则只会读取 childtable_count 行 tag 数据。也即最终生成的子表数量为二者取小。 +- **tags_file** : only works when insert_mode is taosc, rest. The final tag value is related to the childtable_count. Suppose the tag data rows in the CSV file are smaller than the given number of child tables. In that case, taosBenchmark will read the CSV file data cyclically until the number of child tables specified by childtable_count is generated. Otherwise, taosBenchmark will read the childtable_count rows of tag data only. The final number of child tables generated is the smaller of the two. -#### 标签列与数据列配置参数 +#### Tag and Data Column Configuration Parameters -指定超级表标签列与数据列的配置参数分别在 `super_tables` 中的 `columns` 和 `tag` 中。 +The configuration parameters for specifying super table tag columns and data columns are in `columns` and `tag` in `super_tables`, respectively. -- **type** : 指定列类型,可选值请参考 TDengine 支持的数据类型。 - 注:JSON 数据类型比较特殊,只能用于标签,当使用 JSON 类型作为 tag 时有且只能有这一个标签,此时 count 和 len 代表的意义分别是 JSON tag 内的 key-value pair 的个数和每个 KV pair 的 value 的值的长度,value 默认为 string。 +- **type**: Specify the column type. For optional values, please refer to the data types supported by TDengine. + Note: JSON data type is unique and can only be used for tags. When using JSON type as a tag, there is and can only be this one tag. At this time, `count` and `len` represent the meaning of the number of key-value pairs within the JSON tag and the length of the value of each KV pair. Respectively, the value is a string by default. -- **len** : 指定该数据类型的长度,对 NCHAR,BINARY 和 JSON 数据类型有效。如果对其他数据类型配置了该参数,若为 0 , 则代表该列始终都是以 null 值写入;如果不为 0 则被忽略。 +- **len**: Specifies the length of this data type, valid for NCHAR, BINARY, and JSON data types. If this parameter is configured for other data types, a value of 0 means that the column is always written with a null value; if it is not 0, it is ignored. -- **count** : 指定该类型列连续出现的数量,例如 "count": 4096 即可生成 4096 个指定类型的列。 +- **count**: Specifies the number of consecutive occurrences of the column type, e.g., "count": 4096 generates 4096 columns of the specified type. -- **name** : 列的名字,若与 count 同时使用,比如 "name":"current", "count":3, 则 3 个列的名字分别为 current, current_2. current_3。 +- **name** : The name of the column, if used together with count, e.g. "name": "current", "count":3, then the names of the 3 columns are current, current_2. current_3. -- **min** : 数据类型的 列/标签 的最小值。 +- **min**: The minimum value of the column/label of the data type. -- **max** : 数据类型的 列/标签 的最大值。 +- **max**: The maximum value of the column/label of the data type. -- **values** : nchar/binary 列/标签的值域,将从值中随机选择。 +- **values**: The value field of the nchar/binary column/label, which will be chosen randomly from the values. -#### 插入行为配置参数 +#### insertion behavior configuration parameters -- **thread_count** : 插入数据的线程数量,默认为 8。 +- **thread_count**: specify the number of threads to insert data. Default is 8. -- **create_table_thread_count** : 建表的线程数量,默认为 8。 +- **create_table_thread_count** : The number of threads to build the table, default is 8. -- **connection_pool_size** : 预先建立的与 TDengine 服务端之间的连接的数量。若不配置,则与所指定的线程数相同。 +- **connection_pool_size** : The number of pre-established connections to the TDengine server. If not configured, it is the same number of threads specified. -- **result_file** : 结果输出文件的路径,默认值为 ./output.txt。 +- **result_file** : The path to the result output file, the default value is . /output.txt. -- **confirm_parameter_prompt** : 开关参数,要求用户在提示后确认才能继续。默认值为 false 。 +- **confirm_parameter_prompt**: The switch parameter requires the user to confirm after the prompt to continue. The default value is false. -- **interlace_rows** : 启用交错插入模式并同时指定向每个子表每次插入的数据行数。交错插入模式是指依次向每张子表插入由本参数所指定的行数并重复这个过程,直到所有子表的数据都插入完成。默认值为 0, 即向一张子表完成数据插入后才会向下一张子表进行数据插入。 - 在 `super_tables` 中也可以配置该参数,若配置则以 `super_tables` 中的配置为高优先级,覆盖全局设置。 +- **interlace_rows**: Enables interleaved insertion mode and specifies the number of rows of data to be inserted into each child table at a time. Interleaved insertion mode means inserting the number of rows specified by this parameter into each sub-table and repeating the process until all sub-tables are inserted. The default value is 0, which means that data will be inserted into the following child table only after data is inserted into one child table. + This parameter can also be configured in `super_tables`, and if so, the configuration in `super_tables` takes precedence and overrides the global setting. - **insert_interval** : - 指定交错插入模式的插入间隔,单位为 ms,默认值为 0。 只有当 `-B/--interlace-rows` 大于 0 时才起作用。意味着数据插入线程在为每个子表插入隔行扫描记录后,会等待该值指定的时间间隔后再进行下一轮写入。 - 在 `super_tables` 中也可以配置该参数,若配置则以 `super_tables` 中的配置为高优先级,覆盖全局设置。 + Specifies the insertion interval in ms for interleaved insertion mode. The default value is 0. Only works if `-B/--interlace-rows` is greater than 0. It means that after inserting interlace rows for each child table, the data insertion thread will wait for the interval specified by this value before proceeding to the next round of writes. + This parameter can also be configured in `super_tables`, and if configured, the configuration in `super_tables` takes high priority, overriding the global setting. - **num_of_records_per_req** : - 每次向 TDegnine 请求写入的数据行数,默认值为 30000 。当其设置过大时,TDegnine 客户端驱动会返回相应的错误信息,此时需要调低这个参数的设置以满足写入要求。 + The number of rows of data to be written per request to TDengine, the default value is 30000. When it is set too large, the TDengine client driver will return the corresponding error message, so you need to lower the setting of this parameter to meet the writing requirements. -- **prepare_rand** : 生成的随机数据中唯一值的数量。若为 1 则表示所有数据都相同。默认值为 10000 。 +- **prepare_rand**: The number of unique values in the generated random data. A value of 1 means that all data are the same. The default value is 10000. -### 查询场景配置参数 +### Query scenario configuration parameters -查询场景下 `filetype` 必须设置为 `qeury`,该参数及其它通用参数详见[通用配置参数](#通用配置参数) +`filetype` must be set to `query` in the query scenario. See [General Configuration Parameters](#General Configuration Parameters) for details of this parameter and other general parameters -#### 执行指定查询语句的配置参数 +#### Configuration parameters for executing the specified query statement -查询子表或者普通表的配置参数在 `specified_table_query` 中设置。 +The configuration parameters for querying the sub-tables or the normal tables are set in `specified_table_query`. -- **query_interval** : 查询时间间隔,单位是秒,默认值为 0。 +- **query_interval** : The query interval in seconds, the default value is 0. -- **threads** : 执行查询 SQL 的线程数,默认值为 1。 +- **threads**: The number of threads to execute the query SQL, the default value is 1. -- **sqls**: - - **sql**: 执行的 SQL 命令,必填。 - - **result**: 保存查询结果的文件,未指定则不保存。 +- **sqls**. + - **sql**: the SQL command to be executed. + - **result**: the file to save the query result. If it is unspecified, taosBenchark will not save the result. -#### 查询超级表的配置参数 +#### Configuration parameters of query super table -查询超级表的配置参数在 `super_table_query` 中设置。 +The configuration parameters of the super table query are set in `super_table_query`. -- **stblname** : 指定要查询的超级表的名称,必填。 +- **stblname**: Specify the name of the super table to be queried, required. -- **query_interval** : 查询时间间隔,单位是秒,默认值为 0。 +- **query_interval** : The query interval in seconds, the default value is 0. -- **threads** : 执行查询 SQL 的线程数,默认值为 1。 +- **threads**: The number of threads to execute the query SQL, the default value is 1. -- **sqls** : - - **sql** : 执行的 SQL 命令,必填;对于超级表的查询 SQL,在 SQL 命令中保留 "xxxx",程序会自动将其替换为超级表的所有子表名。 - 替换为超级表中所有的子表名。 - - **result** : 保存查询结果的文件,未指定则不保存。 +- **sqls** : The default value is 1. + - **sql**: The SQL command to be executed. For the query SQL of super table, keep "xxxx" in the SQL command. The program will automatically replace it with all the sub-table names of the super table. + Replace it with all the sub-table names in the super table. + - **result**: The file to save the query result. If not specified, taosBenchmark will not save result. -### 订阅场景配置参数 +### Subscription scenario configuration parameters -订阅场景下 `filetype` 必须设置为 `subscribe`,该参数及其它通用参数详见[通用配置参数](#通用配置参数) +`filetype` must be set to `subscribe` in the subscription scenario. See [General Configuration Parameters](#General Configuration Parameters) for details of this and other general parameters -#### 执行指定订阅语句的配置参数 +#### Configuration parameters for executing the specified subscription statement -订阅子表或者普通表的配置参数在 `specified_table_query` 中设置。 +The configuration parameters for subscribing to a sub-table or a generic table are set in `specified_table_query`. -- **threads** : 执行 SQL 的线程数,默认为 1。 +- **threads**: The number of threads to execute SQL, default is 1. -- **interva** : 执行订阅的时间间隔,单位为秒,默认为 0。 +- **interval**: The time interval to execute the subscription, in seconds, default is 0. -- **restart** : "yes" 表示开始新的订阅,"no" 表示继续之前的订阅,默认值为 "no"。 +- **restart** : "yes" means start a new subscription, "no" means continue the previous subscription, the default value is "no". -- **keepProgress** : "yes" 表示保留订阅进度,"no" 表示不保留,默认值为 "no"。 +- **keepProgress**: "yes" means keep the progress of the subscription, "no" means don't keep it, and the default value is "no". -- **resubAfterConsume** : "yes" 表示取消之前的订阅然后再次订阅, "no" 表示继续之前的订阅,默认值为 "no"。 +- **resubAfterConsume**: "yes" means cancel the previous subscription and then subscribe again, "no" means continue the previous subscription, and the default value is "no". -- **sqls** : - - **sql** : 执行的 SQL 命令,必填。 - - **result** : 保存查询结果的文件,未指定则不保存。 +- **sqls** : The default value is "no". + - **sql** : The SQL command to be executed, required. + - **result** : The file to save the query result, unspecified is not saved. -#### 订阅超级表的配置参数 +#### Configuration parameters for subscribing to supertables -订阅超级表的配置参数在 `super_table_query` 中设置。 +The configuration parameters for subscribing to a super table are set in `super_table_query`. -- **stblname** : 要订阅的超级表名称,必填。 +- **stblname**: The name of the super table to subscribe. -- **threads** : 执行 SQL 的线程数,默认为 1。 +- **threads**: The number of threads to execute SQL, default is 1. -- **interva** : 执行订阅的时间间隔,单位为秒,默认为 0。 +- **interval**: The time interval to execute the subscription, in seconds, default is 0. -- **restart** : "yes" 表示开始新的订阅,"no" 表示继续之前的订阅,默认值为 "no"。 +- **restart** : "yes" means start a new subscription, "no" means continue the previous subscription, the default value is "no". -- **keepProgress** : "yes" 表示保留订阅进度,"no" 表示不保留,默认值为 "no"。 +- **keepProgress**: "yes" means keep the progress of the subscription, "no" means don't keep it, and the default value is "no". -- **resubAfterConsume** : "yes" 表示取消之前的订阅然后再次订阅, "no" 表示继续之前的订阅,默认值为 "no"。 +- **resubAfterConsume**: "yes" means cancel the previous subscription and then subscribe again, "no" means continue the previous subscription, and the default value is "no". -- **sqls** : - - **sql** : 执行的 SQL 命令,必填;对于超级表的查询 SQL,在 SQL 命令中保留 "xxxx",程序会自动将其替换为超级表的所有子表名。 - 替换为超级表中所有的子表名。 - - **result** : 保存查询结果的文件,未指定则不保存。 +- **sqls** : The default value is "no". + - **sql**: SQL command to be executed, required; for the query SQL of the super table, keep "xxxx" in the SQL command, and the program will replace it with all the sub-table names of the super table automatically. + Replace it with all the sub-table names in the super table. + - **result**: The file to save the query result, if not specified, it will not be saved. diff --git a/docs-en/14-reference/06-taosdump.md b/docs-en/14-reference/06-taosdump.md index 7131493ec9439225d8047288ed86026c887f0aac..aa88beb5bbd79d7ffcd50ba7669bc0cf68fd8afa 100644 --- a/docs-en/14-reference/06-taosdump.md +++ b/docs-en/14-reference/06-taosdump.md @@ -1,59 +1,56 @@ --- title: taosdump -description: "taosdump 是一个支持从运行中的 TDengine 集群备份数据并将备份的数据恢复到相同或另一个运行中的 TDengine 集群中的工具应用程序" +description: "taosdump is a tool application that supports backing up data from a running TDengine cluster and restoring the backed up data to the same or another running TDengine cluster." --- -## 简介 +## Introduction -taosdump 是一个支持从运行中的 TDengine 集群备份数据并将备份的数据恢复到相同或另一个运行中的 TDengine 集群中的工具应用程序。 +taosdump is a tool application that supports backing up data from a running TDengine cluster and restoring the backed up data to the same or another running TDengine cluster. -taosdump 可以用数据库、超级表或普通表作为逻辑数据单元进行备份,也可以对数据库、超级 -表和普通表中指定时间段内的数据记录进行备份。使用时可以指定数据备份的目录路径,如果 -不指定位置,taosdump 默认会将数据备份到当前目录。 +taosdump can back up a database, a super table, or a normal table as a logical data unit or backup data records in the database, super tables, and normal tables. When using taosdump, you can specify the directory path for data backup. If you do not specify a directory, taosdump will back up the data to the current directory by default. -如果指定的位置已经有数据文件,taosdump 会提示用户并立即退出,避免数据被覆盖。这意味着同一路径只能被用于一次备份。 -如果看到相关提示,请小心操作。 +Suppose the specified location already has data files. In that case, taosdump will prompt the user and exit immediately to avoid data overwriting which means that the same path can only be used for one backup. +Please be careful if you see a prompt for this. -taosdump 是一个逻辑备份工具,它不应被用于备份任何原始数据、环境设置、 -硬件信息、服务端配置或集群的拓扑结构。taosdump 使用 -[ Apache AVRO ](https://avro.apache.org/)作为数据文件格式来存储备份数据。 +taosdump is a logical backup tool and should not be used to back up any raw data, environment settings, +Users should not use taosdump to back up raw data, environment settings, hardware information, server configuration, or cluster topology. taosdump uses [Apache AVRO](https://avro.apache.org/) as the data file format to store backup data. -## 安装 +## Installation -taosdump 有两种安装方式: +There are two ways to install taosdump: -- 安装 taosTools 官方安装包, 请从[所有下载链接](https://www.taosdata.com/all-downloads)页面找到 taosTools 并下载安装。 +- Install the taosTools official installer. Please find taosTools from [All download links](https://www.taosdata.com/all-downloads) page and download and install it. -- 单独编译 taos-tools 并安装, 详情请参考 [taos-tools](https://github.com/taosdata/taos-tools) 仓库。 +- Compile taos-tools separately and install it. Please refer to the [taos-tools](https://github.com/taosdata/taos-tools) repository for details. -## 常用使用场景 +## Common usage scenarios -### taosdump 备份数据 +### taosdump backup data -1. 备份所有数据库:指定 `-A` 或 `--all-databases` 参数; -2. 备份多个指定数据库:使用 `-D db1,db2,...` 参数; -3. 备份指定数据库中的某些超级表或普通表:使用 `dbname stbname1 stbname2 tbname1 tbname2 ...` 参数,注意这种输入序列第一个参数为数据库名称,且只支持一个数据库,第二个和之后的参数为该数据库中的超级表或普通表名称,中间以空格分隔; -4. 备份系统 log 库:TDengine 集群通常会包含一个系统数据库,名为 `log`,这个数据库内的数据为 TDengine 自我运行的数据,taosdump 默认不会对 log 库进行备份。如果有特定需求对 log 库进行备份,可以使用 `-a` 或 `--allow-sys` 命令行参数。 -5. “宽容”模式备份:taosdump 1.4.1 之后的版本提供 `-n` 参数和 `-L` 参数,用于备份数据时不使用转义字符和“宽容”模式,可以在表名、列名、标签名没使用转义字符的情况下减少备份数据时间和备份数据占用空间。如果不确定符合使用 `-n` 和 `-L` 条件时请使用默认参数进行“严格”模式进行备份。转义字符的说明请参考[官方文档](/taos-sql/escape)。 +1. backing up all databases: specify `-A` or `-all-databases` parameter. +2. backup multiple specified databases: use `-D db1,db2,... ` parameters; 3. +3. back up some super or normal tables in the specified database: use `-dbname stbname1 stbname2 tbname1 tbname2 ... ` parameters. Note that the first parameter of this input sequence is the database name, and only one database is supported. The second and subsequent parameters are the names of super or normal tables in that database, separated by spaces. +4. back up the system log database: TDengine clusters usually contain a system database named `log`. The data in this database is the data that TDengine runs itself, and the taosdump will not back up the log database by default. If users need to back up the log database, users can use the `-a` or `-allow-sys` command line parameter. +5. Loose mode backup: taosdump version 1.4.1 onwards provides `-n` and `-L` parameters for backing up data without using escape characters and "loose" mode, which can reduce the number of backups if table names, column names, tag names do not use This can reduce the backup data time and backup data footprint if table names, column names, and tag names do not use `escape character`. If you are unsure about using `-n` and `-L` conditions, please use the default parameters for "strict" mode backup. See the [official documentation](/taos-sql/escape) for a description of escaped characters. :::tip -- taosdump 1.4.1 之后的版本提供 `-I` 参数,用于解析 avro 文件 schema 和数据,如果指定 `-s` 参数将只解析 schema。 -- taosdump 1.4.2 之后的备份使用 `-B` 参数指定的批次数,默认值为 16384,如果在某些环境下由于网络速度或磁盘性能不足导致 "Error actual dump .. batch .." 可以通过 `-B` 参数挑战为更小的值进行尝试。 +- taosdump versions after 1.4.1 provide the `-I` argument for parsing Avro file schema and data. If users specify `-s` then only taosdump will parse schema. +- Backups after taosdump 1.4.2 use the batch count specified by the `-B` parameter. The default value is 16384. If, in some environments, low network speed or disk performance causes "Error actual dump ... batch ..." can be tried by challenging the `-B` parameter to a smaller value. ::: -### taosdump 恢复数据 +### taosdump recover data -恢复指定路径下的数据文件:使用 `-i` 参数加上数据文件所在路径。如前面提及,不应该使用同一个目录备份不同数据集合,也不应该在同一路径多次备份同一数据集,否则备份数据会造成覆盖或多次备份。 +Restore the data file in the specified path: use the `-i` parameter plus the path to the data file. You should not use the same directory to backup different data sets, and you should not backup the same data set multiple times in the same path. Otherwise, the backup data will cause overwriting or multiple backups. :::tip -taosdump 内部使用 TDengine stmt binding API 进行恢复数据的写入,为提高数据恢复性能,目前使用 16384 为一次写入批次。如果备份数据中有比较多列数据,可能会导致产生 "WAL size exceeds limit" 错误,此时可以通过使用 `-B` 参数调整为一个更小的值进行尝试。 +taosdump internally uses TDengine stmt binding API for writing recovery data and currently uses 16384 as one write batch for better data recovery performance. If there are more columns in the backup data, it may cause a "WAL size exceeds limit" error. You can try to adjust to a smaller value by using the `-B` parameter. ::: -## 详细命令行参数列表 +## Detailed command line parameter list -以下为 taosdump 详细命令行参数列表: +The following is a detailed list of taosdump command line arguments. ``` Usage: taosdump [OPTION...] dbname [tbname ...] diff --git a/docs-en/14-reference/08-taos-shell.md b/docs-en/14-reference/08-taos-shell.md index c9167fcf2643954981925fb5ef67a60cbad97a6d..5b8aafc204a6f598f128e02294fdb724dcac4559 100644 --- a/docs-en/14-reference/08-taos-shell.md +++ b/docs-en/14-reference/08-taos-shell.md @@ -1,85 +1,85 @@ --- -title: TDengine 命令行(CLI) +title: TDengine Command Line (CLI) sidebar_label: TDengine CLI -description: TDengine CLI 的使用说明和技巧 +description: Instructions and tips for using the TDengine CLI --- -TDengine 命令行程序(以下简称 TDengine CLI)是用户操作 TDengine 实例并与之交互的最简洁最常用的方式。 +The TDengine command-line application (hereafter referred to as TDengine CLI) is the cleanest and most common way for users to manipulate and interact with TDengine instances. -## 安装 +## Installation -如果在 TDengine 服务器端执行,无需任何安装,已经自动安装好。如果要在非 TDengine 服务器端运行,需要安装 TDengine 客户端驱动,具体安装,请参考 [连接器](/reference/connector/)。 +If executed on the TDengine server-side, there is no need for additional installation as it is already installed automatically. To run on the non-TDengine server-side, the TDengine client driver needs to be installed. For details, please refer to [connector](/reference/connector/). -## 执行 +## Execution -要进入 TDengine CLI,您只要在 Linux 终端或Windos 终端执行 `taos` 即可。 +To access the TDengine CLI, you can execute `taos` from a Linux terminal or Windows terminal. ```bash taos ``` -如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-faq/faq) 来解决终端连接服务端失败的问题)。TDengine CLI 的提示符号如下: +TDengine will display a welcome message and version information if the connection to the service is successful. If it fails, TDengine will print an error message (see [FAQ](/train-faq/faq) to solve the problem of terminal connection failure to the server.) The TDengine CLI prompt symbols are as follows: ```cmd taos> ``` -进入CLI后,你可执行各种SQL语句,包括插入、查询以及各种管理命令。 +After entering the CLI, you can execute various SQL statements, including inserts, queries, and administrative commands. -## 执行 SQL 脚本 +## Execute SQL scripts -在 TDengine CLI 里可以通过 `source` 命令来运行 SQL 命令脚本。 +Run SQL command scripts in the TDengine CLI via the `source` command. ```sql taos> source ; ``` -## 在线修改显示字符宽度 +## Modify display character width online -可以在 TDengine CLI 里使用如下命令调整字符显示宽度 +Users can adjust the character display width in TDengine CLI with the following command: ```sql taos> SET MAX_BINARY_DISPLAY_WIDTH ; ``` -如显示的内容后面以...结尾时,表示该内容已被截断,可通过本命令修改显示字符宽度以显示完整的内容。 +If the displayed content is followed by `...` you can use this command to change the display width to display the full content. -## 命令行参数 +## Command Line Parameters -您可通过配置命令行参数来改变 TDengine CLI 的行为。以下为常用的几个命令行参数: +You can change the behavior of TDengine CLI by configuring command-line parameters. The following command-line arguments are commonly used. -- -h, --host=HOST: 要连接的 TDengine 服务端所在服务器的 FQDN, 默认为连接本地服务 -- -P, --port=PORT: 指定服务端所用端口号 -- -u, --user=USER: 连接时使用的用户名 -- -p, --password=PASSWORD: 连接服务端时使用的密码 -- -?, --help: 打印出所有命令行参数 +-h, --host=HOST: FQDN of the server where the TDengine server is to be connected. Default is to connect to the local service +-P, --port=PORT: Specify the port number to be used by the server +-u, --user=USER: the user name to use when connecting +-p, --password=PASSWORD: the password to use when connecting to the server +--?, --help: print out all command-line arguments -还有更多其他参数: +And many more parameters. -- -c, --config-dir: 指定配置文件目录,默认为 `/etc/taos`,该目录下的配置文件默认名称为 taos.cfg -- -C, --dump-config: 打印 -c 指定的目录中 taos.cfg 的配置参数 -- -d, --database=DATABASE: 指定连接到服务端时使用的数据库 -- -D, --directory=DIRECTORY: 导入指定路径中的 SQL 脚本文件 -- -f, --file=FILE: 以非交互模式执行 SQL 脚本文件 -- -k, --check=CHECK: 指定要检查的表 -- -l, --pktlen=PKTLEN: 网络测试时使用的测试包大小 -- -n, --netrole=NETROLE: 网络连接测试时的测试范围,默认为 startup, 可选值为 client, server, rpc, startup, sync, speed, fqdn -- -r, --raw-time: 将时间输出出 uint64_t -- -s, --commands=COMMAND: 以非交互模式执行的 SQL 命令 -- -S, --pkttype=PKTTYPE: 指定网络测试所用的包类型,默认为 TCP。只有 netrole 为 speed 时既可以指定为 TCP 也可以指定为 UDP -- -T, --thread=THREADNUM: 以多线程模式导入数据时的线程数 -- -s, --commands: 在不进入终端的情况下运行 TDengine 命令 -- -z, --timezone=TIMEZONE: 指定时区,默认为本地 -- -V, --version: 打印出当前版本号 +-c, --config-dir: Specify the configuration file directory. The default is `/etc/taos`, and the default name of the configuration file in this directory is taos.cfg +-C, --dump-config: Print the configuration parameters of taos.cfg in the directory specified by -c +-d, --database=DATABASE: Specify the database to use when connecting to the server +-D, --directory=DIRECTORY: Import the SQL script file in the specified path +-f, --file=FILE: Execute the SQL script file in non-interactive mode +-k, --check=CHECK: Specify the table to be checked +-l, --pktlen=PKTLEN: Test package size to be used for network testing +-n, --netrole=NETROLE: test scope for network connection test, default is `startup`, The value can be `client`, `server`, `rpc`, `startup`, `sync`, `speed`, or `fqdn`. +-r, --raw-time: output the time to uint64_t +-s, --commands=COMMAND: execute SQL commands in non-interactive mode +-S, --pkttype=PKTTYPE: Specify the packet type used for network testing. The default is TCP. only `netrole` can be specified as either TCP or UDP when speed is specified +-T, --thread=THREADNUM: The number of threads to import data in multi-threaded mode +-s, --commands: Run TDengine commands without entering the terminal +-z, --timezone=TIMEZONE: Specify time zone. Default is local +-V, --version: Print out the current version number -示例: +Example. ```bash taos -h h1.taos.com -s "use db; show tables;" ``` -## TDengine CLI 小技巧 - -- 可以使用上下光标键查看历史输入的指令 -- 修改用户密码:在 shell 中使用 `alter user` 命令,缺省密码为 taosdata -- ctrl+c 中止正在进行中的查询 -- 执行 `RESET QUERY CACHE` 可清除本地缓存的表 schema -- 批量执行 SQL 语句。可以将一系列的 shell 命令(以英文 ; 结尾,每个 SQL 语句为一行)按行存放在文件里,在 shell 里执行命令 `source ` 自动执行该文件里所有的 SQL 语句 -- 输入 q 回车,退出 taos shell +## TDengine CLI tips + +- You can use the up and down cursor keys to see the history of commands entered +- Change user password: use `alter user` command in TDengine CLI. The default password is `taosdata`. +- ctrl+c to stop a query in progress +- Execute `RESET QUERY CACHE` to clear the local cache of the table schema +- Execute SQL statements in batches. You can store a series of shell commands (ending with ;, one line for each SQL statement) in a file and execute the command `source ` in the shell to execute all SQL statements in that file automatically +- Enter `q` to exit taos shell diff --git a/docs-en/14-reference/12-config/_category_.yml b/docs-en/14-reference/12-config/_category_.yml index 8d3cfcc8d0d8966bf1354f9ece83faea105f9c7a..94aa9438729449e6e0d13b20019514dbbbc3a384 100644 --- a/docs-en/14-reference/12-config/_category_.yml +++ b/docs-en/14-reference/12-config/_category_.yml @@ -1 +1 @@ -label: 配置参数 \ No newline at end of file +label: Configuration \ No newline at end of file diff --git a/docs-en/14-reference/12-config/index.md b/docs-en/14-reference/12-config/index.md index 9fff685ee6bfe9ef77b3a83d8b49ccc13216e0ce..108863ac58837d9bd617a7725d0c60a28182678c 100644 --- a/docs-en/14-reference/12-config/index.md +++ b/docs-en/14-reference/12-config/index.md @@ -1,27 +1,30 @@ --- -title: 配置参数 -description: "TDengine 客户端和服务配置列表" +sidebar_label: Configuration +title: Configuration Parameters +description: "Configuration parameters for client and server in TDengine" --- -## 为服务端指定配置文件 +In this chapter, all the configuration parameters on both server and client side are described thoroughly. -TDengine 系统后台服务由 taosd 提供,可以在配置文件 taos.cfg 里修改配置参数,以满足不同场景的需求。配置文件的缺省位置在/etc/taos 目录,可以通过 taosd 命令行执行参数 -c 指定配置文件目录。比如,指定配置文件位于`/home/user` 这个目录: +## Configuration File on Server Side -``` +On the server side, the actual service of TDengine is provided by an executable `taosd` whose parameters can be configured in file `taos.cfg` to meet the requirements of different use cases. The default location of `taos.cfg` is `/etc/taos`, but can be changed by using `-c` parameter on the CLI of `taosd`. For example, the configuration file can be put under `/home/user` and used like below + +```bash taosd -c /home/user ``` -另外可以使用 `-C` 显示当前服务器配置参数: +Parameter `-C` can be used on the CLI of `taosd` to show its configuration, like below: ``` taosd -C ``` -## 为客户端指定配置文件 +## Configuration File on Client Side -TDengine 系统的前台交互客户端应用程序为 taos,以及应用驱动,它可以与 taosd 共享同一个配置文件 taos.cfg,也可以使用单独指定配置文件。运行 taos 时,使用参数-c 指定配置文件目录,如 taos -c /home/cfg,表示使用/home/cfg/目录下的 taos.cfg 配置文件中的参数,缺省目录是/etc/taos。更多 taos 的使用方法请见帮助信息 `taos --help`。 +TDengine CLI `taos` is the tool for users to interact with TDengine. It can share same configuration file as `taosd` or use a separate configuration file. When launching `taos`, parameter `-c` can be used to specify the location where its configuration file is. For example `taos -c /home/cfg` means `/home/cfg/taos.cfg` will be used. If `-c` is not used, the default location of the configuration file is `/etc/taos`. For more details please use `taos --help` to get. -**2.0.10.0 之后版本支持命令行以下参数显示当前客户端参数的配置** +From version 2.0.10.0 below commands can be used to show the configuration parameters of the client side. ```bash taos -C @@ -31,1096 +34,1087 @@ taos -C taos --dump-config ``` -# 配置参数详细列表 - -:::note -本节内容覆盖产品的配置参数,适用于服务端的参数按其对产品行为的影响进行分类,这其中有部分参数也同时适用于客户端;但有少量参数仅适用于客户端,这部分参数进行了单独归类。 - -::: - +# Configuration Parameters :::note -配置文件参数修改后,需要重启*taosd*服务,或客户端应用才能生效。 +`taosd` needs to be restarted for the parameters changed in the configuration file to take effect. ::: -## 连接相关 +## Connection Parameters ### firstEp -| 属性 | 说明 | -| -------- | ----------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | taosd 或者 taos 启动时,主动连接的集群中首个 dnode 的 end point | -| 缺省值 | localhost:6030 | +| Attribute | Description | +| ------------- | ---------------------------------------------------------------------------------------------------- | +| Applicable | Server and Client | +| Meaning | The end point of the first dnode in the cluster to be connected to when `taosd` or `taos` is started | +| Default Value | localhost:6030 | ### secondEp -| 属性 | 说明 | -| -------- | ---------------------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | taosd 或者 taos 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 end point | -| 缺省值 | 无 | +| Attribute | Description | +| ------------- | ---------------------------------------------------------------------------------------------------------------------- | +| Applicable | Server and Client | +| Meaning | The end point of the second dnode to be connected to if the firstEp is not available when `taosd` or `taos` is started | +| Default Value | None | ### fqdn -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 数据节点的 FQDN。如果习惯 IP 地址访问,可设置为该节点的 IP 地址。 | -| 缺省值 | 缺省为操作系统配置的第一个 hostname。 | -| 补充说明 | 这个参数值的长度需要控制在 96 个字符以内。 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------ | +| Applicable | Server Only | +| Meaning | The FQDN of the host where `taosd` will be started. It can be IP address | +| Default Value | The first hostname configured for the hos | +| Note | It should be within 96 bytes | ### serverPort -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | taosd 启动后,对外服务的端口号 | -| 缺省值 | 6030 | -| 补充说明 | RESTful 服务在2.4.0.0之前(不含)由taosd提供,默认端口为 6041; 在2.4.0.0 及后续版本由 taosAdapter,默认端口为6041 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The port for external access after `taosd` is started 号 | +| Default Value | 6030 | +| Note | REST service is provided by `taosd` before 2.4.0.0 but by `taosAdapter` after 2.4.0.0, the default port of REST service is 6041 | :::note -对于端口,TDengine 会使用从 serverPort 起 13 个连续的 TCP 和 UDP 端口号,请务必在防火墙打开。因此如果是缺省配置,需要打开从 6030 到 6042 共 13 个端口,而且必须 TCP 和 UDP 都打开。(详细的端口情况请参见下表) +TDengine uses continuous 13 ports, both TCP and TCP, from the port specified by `serverPort`. These ports need to be kept as open if firewall is enabled. Below table describes the ports used by TDengine in details. + ::: -| 协议 | 默认端口 | 用途说明 | 修改方法 | -| :--- | :-------- | :---------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- | -| TCP | 6030 | 客户端与服务端之间通讯。 | 由配置文件设置 serverPort 决定。 | -| TCP | 6035 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | -| TCP | 6040 | 多节点集群的节点间数据同步。 | 随 serverPort 端口变化。 | -| TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | -| TCP | 6042 | Arbitrator 的服务端口。 | 随 Arbitrator 启动参数设置变化。 | -| TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 | -| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | -| UDP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | -| TCP | 6060 | 企业版内 Monitor 服务的网络端口。 | | -| UDP | 6030-6034 | 客户端与服务端之间通讯。 | 随 serverPort 端口变化。 | -| UDP | 6035-6039 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 + +| Protocol | Default Port | Description | How to configure | +| :------- | :----------- | :----------------------------------------------- | :--------------------------------------------------------------------------------------------- | +| TCP | 6030 | Communication between client and server | serverPort | +| TCP | 6035 | Communication among server nodes in cluster | serverPort+5 | +| TCP | 6040 | Data syncup among server nodes in cluster | serverPort+10 | +| TCP | 6041 | REST connection between client and server | Prior to 2.4.0.0: serverPort+11; After 2.4.0.0 refer to [taosAdapter](/reference/taosadapter/) | +| TCP | 6042 | Service Port of Arbitrator | The parameter of Arbitrator | +| TCP | 6043 | Service Port of TaosKeeper | The parameter of TaosKeeper | +| TCP | 6044 | Data access port for StatsD | efer to [taosAdapter](/reference/taosadapter/) | +| UDP | 6045 | Data access for statsd | efer to [taosAdapter](/reference/taosadapter/) | +| TCP | 6060 | Port of Monitoring Service in Enterprise version | | +| UDP | 6030-6034 | Communication between client and server | serverPort | +| UDP | 6035-6039 | Communication among server nodes in cluster | serverPort | ### maxShellConns -| 属性 | 说明 | -| -------- | ----------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 一个 dnode 容许的连接数 | -| 取值范围 | 10-50000000 | -| 缺省值 | 5000 | +| Attribute | Description | +| ------------- | ---------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The maximum number of connections a dnode can accept | +| Value Range | 10-50000000 | +| Default Value | 5000 | ### maxConnections -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 一个数据库连接所容许的 dnode 连接数 | -| 取值范围 | 1-100000 | -| 缺省值 | 5000 | -| 补充说明 | 实际测试下来,如果默认没有配,选 50 个 worker thread 会产生 Network unavailable | +| Attribute | Description | +| ------------- | ----------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The maximum number of connections allowed by a database | +| Value Range | 1-100000 | +| Default Value | 5000 | +| Note | The maximum number of worker threads on the client side is maxConnections/100 | ### rpcForceTcp -| 属性 | 说明 | -| -------- | --------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 强制使用 TCP 传输 | -| 取值范围 | 0: 不开启 1: 开启 | -| 缺省值 | 0 | -| 补充说明 | 在网络比较差的环境中,建议开启。
2.0 版本新增。 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------- | +| Applicable | Server and Client | +| Meaning | TCP is used forcely | +| Value Range | 0: disabled 1: enabled | +| Default Value | 0 | +| Note | It's suggested to configure to enable if network is not good enough | -## 监控相关 +## Monitoring Parameters ### monitor -| 属性 | 说明 | -| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 服务器内部的系统监控开关。监控主要负责收集物理节点的负载状况,包括 CPU、内存、硬盘、网络带宽、HTTP 请求量的监控记录,记录信息存储在`LOG`库中。 | -| 取值范围 | 0:关闭监控服务, 1:激活监控服务。 | -| 缺省值 | 0 | +| Attribute | Description | +| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The switch for monitoring inside server. The workload of the hosts, including CPU, memory, disk, network, TTP requests, are collected and stored in a system builtin database `LOG` | +| Value Range | 0: monitoring disabled, 1: monitoring enabled 务. | +| Default Value | 0 | ### monitorInterval -| 属性 | 说明 | -| -------- | -------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 监控数据库记录系统参数(CPU/内存)的时间间隔 | -| 单位 | 秒 | -| 取值范围 | 1-600 | -| 缺省值 | 30 | - +| Attribute | Description | +| ------------- | ------------------------------------------ | +| Applicable | Server Only | +| Meaning | The interval of collecting system workload | +| Unit | second | +| Value Range | 1-600 | +| Default Value | 30 | ### telemetryReporting -| 属性 | 说明 | -| -------- | ---------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否允许 TDengine 采集和上报基本使用信息 | -| 取值范围 | 0:不允许 1:允许 | -| 缺省值 | 1 | +| Attribute | Description | +| ------------- | ---------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Switch for allowing TDengine to collect and report service usage information | +| Value Range | 0: Not allowed; 1: Allowed | +| Default Value | 1 | -## 查询相关 +## Query Parameters ### queryBufferSize -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 为所有并发查询占用保留的内存大小。 | -| 单位 | MB | -| 缺省值 | 无 | -| 补充说明 | 计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。
(2.0.15 以前的版本中,此参数的单位是字节) | +| Attribute | Description | +| ------------- | --------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The total memory size reserved for all queries | +| Unit | MB | +| Default Value | 无 | +| Note | It can be estimated by "maximum number of concurrent quries" _ "number of tables" _ 170 | ### ratioOfQueryCores -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | -| 适用范围 | 仅服务端适用 | -| 含义 | 设置查询线程的最大数量。 | -| 缺省值 | 1 | -| 补充说明 | 最小值 0 表示只有 1 个查询线程
最大值 2 表示最大建立 2 倍 CPU 核数的查询线程。
默认为 1,表示最大和 CPU 核数相等的查询线程。
该值可以为小数,即 0.5 表示最大建立 CPU 核数一半的查询线程。 | +| Attribute | Description | +| ------------- | ----------------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Maximum number of query threads | +| Default Value | 1 | +| Note | value range: float number between [0, 2] 0: only 1 query thread; >0: the times of the number of cores | ### maxNumOfDistinctRes -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 允许返回的 distinct 结果最大行数 | -| 取值范围 | 默认值为 10 万,最大值 1 亿 | -| 缺省值 | 10 万 | -| 补充说明 | 2.3 版本新增。 | | +| Attribute | Description | +| ------------- | -------------------------------------------- | +| Applicable | Server Only | +| Meaning | The maximum number of distinct rows returned | +| Value Range | [100,000 - 100, 000, 000] | +| Default Value | 100, 000 | +| Note | After version 2.3.0.0 | -## 区域相关 +## Locale Parameters ### timezone -| 属性 | 说明 | -| -------- | ------------------------------ | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 时区 | -| 缺省值 | 从系统中动态获取当前的时区设置 | +| Attribute | Description | +| ------------- | ------------------------------- | +| Applicable | Server and Client | +| Meaning | TimeZone | +| Default Value | TimeZone configured in the host | :::info -为应对多时区的数据写入和查询问题,TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区,产生的时间戳均一致。需要注意的是,Unix 时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。 +To handle the data insertion and data query from multiple timezones, Unix Timestamp is used and stored TDengie. The timestamp generated from any timezones at same time is same in Unix timestamp. To make sure the time on client side can be converted to Unix timestamp correctly, the timezone must be set properly. - 在 Linux 系统中,客户端会自动读取系统设置的时区信息。用户也可以采用多种方式在配置文件设置时区。例如: +On Linux system, TDengine clients automatically obtain timezone from the host. Alternatively, the timezone can be configured explicitly in configuration file `taos.cfg` like below. - ``` - timezone UTC-8 - timezone GMT-8 - timezone Asia/Shanghai - ``` +``` +timezone UTC-8 +timezone GMT-8 +timezone Asia/Shanghai +``` - 均是合法的设置东八区时区的格式。但需注意,Windows 下并不支持 `timezone Asia/Shanghai` 这样的写法,而必须写成 `timezone UTC-8`。 +The above examples are all proper configuration for the timezone of UTC+8. On Windows system, however, `timezone Asia/Shanghai` is not supported, it must be set as `timezone UTC-8`. - 时区的设置对于查询和写入 SQL 语句中非 Unix 时间戳的内容(时间戳字符串、关键词 now 的解析)产生影响。例如: +The setting for timezone impacts the strings not in Unix timestamp, keywords or functions related to date/time, for example - ```sql - SELECT count(*) FROM table_name WHERE TS<'2019-04-11 12:01:08'; - ``` +```sql +SELECT count(*) FROM table_name WHERE TS<'2019-04-11 12:01:08'; +``` - 在东八区,SQL 语句等效于 +If the timezone is UTC+8, the above SQL statement is equal to: - ```sql - SELECT count(*) FROM table_name WHERE TS<1554955268000; - ``` +```sql +SELECT count(*) FROM table_name WHERE TS<1554955268000; +``` - 在 UTC 时区,SQL 语句等效于 +If the timezone is UTC, it's equal to - ```sql - SELECT count(*) FROM table_name WHERE TS<1554984068000; - ``` +```sql +SELECT count(*) FROM table_name WHERE TS<1554984068000; +``` - 为了避免使用字符串时间格式带来的不确定性,也可以直接使用 Unix 时间戳。此外,还可以在 SQL 语句中使用带有时区的时间戳字符串,例如:RFC3339 格式的时间戳字符串,2013-04-12T15:52:01.123+08:00 或者 ISO-8601 格式时间戳字符串 2013-04-12T15:52:01.123+0800。上述两个字符串转化为 Unix 时间戳不受系统所在时区的影响。 +To avoid the problems of using time strings, Unix timestamp can be used directly. Furthermore, time strings with timezone can be used in SQL statement, for example "2013-04-12T15:52:01.123+08:00" in RFC3339 format or "2013-04-12T15:52:01.123+0800" in ISO-8601 format, they are not influenced by timezone setting when converted to Unix timestamp. ::: ### locale -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 系统区位信息及编码格式 | -| 缺省值 | 系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置 | +| Attribute | Description | +| ------------- | ------------------------- | +| Applicable | Server and Client | +| Meaning | Location code | +| Default Value | Locale configured in host | :::info - TDengine 为存储中文、日文、韩文等非 ASCII 编码的宽字符,提供一种专门的字段类型 nchar。写入 nchar 字段的数据将统一采用 UCS4-LE 格式进行编码并发送到服务器。需要注意的是,编码正确性是客户端来保证。因此,如果用户想要正常使用 nchar 字段来存储诸如中文、日文、韩文等非 ASCII 字符,需要正确设置客户端的编码格式。 +A specific type "nchar" is provied in TDengine to store non-ASCII characters such as Chinese, Japanese, Korean. The characters to be stored in nchar type are firstly encoded in UCS4-LE before sending to server side. To store non-ASCII characters correctly, the encoding format of the client side needs to be set properly. - 客户端的输入的字符均采用操作系统当前默认的编码格式,在 Linux 系统上多为 UTF-8,部分中文系统编码则可能是 GB18030 或 GBK 等。在 docker 环境中默认的编码是 POSIX。在中文版 Windows 系统中,编码则是 CP936。客户端需要确保正确设置自己所使用的字符集,即客户端运行的操作系统当前编码字符集,才能保证 nchar 中的数据正确转换为 UCS4-LE 编码格式。 +The characters input on the client side are encoded using the default system encoding, which is UTF-8 on Linux, or GB18030 or GBK on some systems in Chinese, POSIX in docker, CP936 on Windows in Chinese. The encoding of the operating system in use must be set correctly so that the characters in nchar type can be converted to UCS4-LE. - 在 Linux 中 locale 的命名规则为: <语言>\_<地区>.<字符集编码> 如:zh_CN.UTF-8,zh 代表中文,CN 代表大陆地区,UTF-8 表示字符集。字符集编码为客户端正确解析本地字符串提供编码转换的说明。Linux 系统与 Mac OSX 系统可以通过设置 locale 来确定系统的字符编码,由于 Windows 使用的 locale 中不是 POSIX 标准的 locale 格式,因此在 Windows 下需要采用另一个配置参数 charset 来指定字符编码。在 Linux 系统中也可以使用 charset 来指定字符编码。 +The locale definition standard on Linux is: \_., for example, in "zh_CN.UTF-8", "zh" means Chinese, "CN" means China mainland, "UTF-8" means charset. On Linux andMac OSX, the charset can be set by locale in the system. On Windows system another configuration parameter `charset` must be used to configure charset because the locale used on Windows is not POSIX standard. Of course, `charset` can also be used on Linux to specify the charset. ::: ### charset -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 字符集编码 | -| 缺省值 | 系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置 | +| Attribute | Description | +| ------------- | ---------------------------- | +| Applicable | Server and Client | +| Meaning | Character | +| Default Value | charset set in the system 系 | :::info -如果配置文件中不设置 charset,在 Linux 系统中,taos 在启动时候,自动读取系统当前的 locale 信息,并从 locale 信息中解析提取 charset 编码格式。如果自动读取 locale 信息失败,则尝试读取 charset 配置,如果读取 charset 配置也失败,则中断启动过程。 +On Linux, if `charset` is not set in `taos.cfg`, when `taos` is started, the charset is obtained from system locale. If obtaining charset from system locale fails, `taos` would fail to start. So on Linux system, if system locale is set properly, it's not necessary to set `charset` in `taos.cfg`. For example: - 在 Linux 系统中,locale 信息包含了字符编码信息,因此正确设置了 Linux 系统 locale 以后可以不用再单独设置 charset。例如: - - ``` - locale zh_CN.UTF-8 - ``` - - 在 Windows 系统中,无法从 locale 获取系统当前编码。如果无法从配置文件中读取字符串编码信息,taos 默认设置为字符编码为 CP936。其等效在配置文件中添加如下配置: - - ``` - charset CP936 - ``` - - 如果需要调整字符编码,请查阅当前操作系统使用的编码,并在配置文件中正确设置。 +``` +locale zh_CN.UTF-8 +``` - 在 Linux 系统中,如果用户同时设置了 locale 和字符集编码 charset,并且 locale 和 charset 的不一致,后设置的值将覆盖前面设置的值。 +Besides, on Linux system, if the charset contained in `locale` is not consistent with that set by `charset`, the one who comes later in the configuration file is used. - ``` - locale zh_CN.UTF-8 - charset GBK - ``` +```title="Effective charset is GBK" +locale zh_CN.UTF-8 +charset GBK +``` - 则 charset 的有效值是 GBK。 +```title="Effective charset is UTF-8" +charset GBK +locale zh_CN.UTF-8 +``` - ``` - charset GBK - locale zh_CN.UTF-8 - ``` +On Windows system, it's not possible to obtain charset from system locale. If it's not set in configuration file `taos.cfg`, it would be default to CP936, same as set as below in `taos.cfg`. For example - charset 的有效值是 UTF-8。 +``` +charset CP936 +``` ::: -## 存储相关 +## Storage Parameters ### dataDir -| 属性 | 说明 | -| -------- | ------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 数据文件目录,所有的数据文件都将写入该目录 | -| 缺省值 | /var/lib/taos | +| Attribute | Description | +| ------------- | ------------------------------------------- | +| Applicable | Server Only | +| Meaning | All data files are stored in this directory | +| Default Value | /var/lib/taos | ### cache -| 属性 | 说明 | -| -------- | ------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 内存块的大小 | -| 单位 | MB | -| 缺省值 | 16 | +| Attribute | Description | +| ------------- | ----------------------------- | +| Applicable | Server Only | +| Meaning | The size of each memory block | +| Unit | MB | +| Default Value | 16 | ### blocks -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 vnode(tsdb)中有多少 cache 大小的内存块。因此一个 vnode 的用的内存大小粗略为(cache \* blocks) | -| 缺省值 | 6 | +| Attribute | Description | +| ------------- | -------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The number of memory blocks of size `cache` used by each vnode | +| Default Value | 6 | ### days -| 属性 | 说明 | -| -------- | -------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 数据文件存储数据的时间跨度 | -| 单位 | 天 | -| 缺省值 | 10 | +| Attribute | Description | +| ------------- | ----------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The time range of the data stored in single data file | +| Unit | day | +| Default Value | 10 | ### keep -| 属性 | 说明 | -| -------- | -------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 数据保留的天数 | -| 单位 | 天 | -| 缺省值 | 3650 | +| Attribute | Description | +| ------------- | -------------------------------------- | +| Applicable | Server Only | +| Meaning | The number of days for data to be kept | +| Unit | day | +| Default Value | 3650 | ### minRows -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 文件块中记录的最小条数 | -| 缺省值 | 100 | +| Attribute | Description | +| ------------- | ------------------------------------------ | +| Applicable | Server Only | +| Meaning | minimum number of rows in single data file | +| Default Value | 100 | ### maxRows -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 文件块中记录的最大条数 | -| 缺省值 | 4096 | +| Attribute | Description | +| ------------- | ------------------------------------------ | +| Applicable | Server Only | +| Meaning | maximum number of rows in single data file | +| Default Value | 4096 | ### walLevel -| 属性 | 说明 | -| -------- | --------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | WAL 级别 | -| 取值范围 | 1:写 wal, 但不执行 fsync
2:写 wal, 而且执行 fsync | -| 缺省值 | 1 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------ | +| Applicable | Server Only | +| Meaning | WAL level | +| Value Range | 1: wal enabled without fsync
2: wal enabled with fsync | +| Default Value | 1 | ### fsync -| 属性 | 说明 | -| -------- | -------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 当 wal 设置为 2 时,执行 fsync 的周期 | -| 单位 | 毫秒 | -| 取值范围 | 最小为 0,表示每次写入,立即执行 fsync
最大为 180000(三分钟) | -| 缺省值 | 3000 | +| Attribute | Description | +| ------------- | --------------------------------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The waiting time for invoking fsync when walLevel is 2 | +| Unit | millisecond | +| Value Range | 0: no waiting time, fsync is performed immediately once WAL is written;
maximum value is 180000, i.e. 3 minutes | +| Default Value | 3000 | ### update -| 属性 | 说明 | -| -------- | ---------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 允许更新已存在的数据行 | -| 取值范围 | 0:不允许更新
1:允许整行更新
2:允许部分列更新。(2.1.7.0 版本开始此参数支持设为 2,在此之前取值只能是 [0, 1]) | -| 缺省值 | 0 | -| 补充说明 | 2.0.8.0 版本之前,不支持此参数。 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------------------------------------ | +| Applicable | Server Only | +| Meaning | If it's allowed to update existing data | +| Value Range | 0: not allowed
1: a row can only be updated as a whole
2: a part of columns can be updated | +| Default Value | 0 | +| Note | Not available from version 2.0.8.0 | ### cacheLast -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否在内存中缓存子表的最近数据 | -| 取值范围 | 0:关闭
1:缓存子表最近一行数据
2:缓存子表每一列的最近的非 NULL 值
3:同时打开缓存最近行和列功能。(2.1.2.0 版本开始此参数支持 0 ~ 3 的取值范围,在此之前取值只能是 [0, 1]) | -| 缺省值 | 0 | -| 补充说明 | 2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。 +| Attribute | Description | +| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Whether to cache the latest rows of each sub table in memory | +| Value Range | 0: not cached
1: the last row of each sub table is cached
2: the last non-null value of each column is cached
3: identical to both 1 and 2 are set | +| Default Value | 0 | ### minimalTmpDirGB -| 属性 | 说明 | -| -------- | ------------------------------------------------ | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 当日志文件夹的磁盘大小小于该值时,停止写临时文件 | -| 单位 | GB | -| 缺省值 | 1.0 | +| Attribute | Description | +| ------------- | ----------------------------------------------------------------------------------------------- | +| Applicable | Server and Client | +| Meaning | When the available disk space in tmpDir is below this threshold, writing to tmpDir is suspended | +| Unit | GB | +| Default Value | 1.0 | ### minimalDataDirGB -| 属性 | 说明 | -| -------- | ------------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 当日志文件夹的磁盘大小小于该值时,停止写时序数据 | -| 单位 | GB | -| 缺省值 | 2.0 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------------------------------ | +| Applicable | Server Only | +| Meaning | hen the available disk space in dataDir is below this threshold, writing to dataDir is suspended | +| Unit | GB | +| Default Value | 2.0 | ### vnodeBak -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 删除 vnode 时是否备份 vnode 目录 | -| 取值范围 | 0:否,1:是 | -| 缺省值 | 1 | +| Attribute | Description | +| ------------- | --------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Whether to backup the corresponding vnode directory when a vnode is deleted | +| Value Range | 0: not backed up, 1: backup | +| Default Value | 1 | -## 集群相关 +## Cluster Parameters ### numOfMnodes -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 系统中管理节点个数 | -| 缺省值 | 3 | +| Attribute | Description | +| ------------- | ------------------------------ | +| Applicable | Server Only | +| Meaning | The number of management nodes | +| Default Value | 3 | ### replica -| 属性 | 说明 | -| -------- | ------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 副本个数 | -| 取值范围 | 1-3 | -| 缺省值 | 1 | +| Attribute | Description | +| ------------- | -------------------------- | +| Applicable | Server Only | +| Meaning | The number of replications | +| Value Range | 1-3 | +| Default Value | 1 | ### quorum -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 多副本环境下指令执行的确认数要求 | -| 取值范围 | 1,2 | -| 缺省值 | 1 | +| Attribute | Description | +| ------------- | --------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The number of required confirmations for data replication in case of multiple replications 多 | +| Value Range | 1,2 | +| Default Value | 1 | ### role -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | dnode 的可选角色 | -| 取值范围 | 0:any(既可作为 mnode,也可分配 vnode)
1:mgmt(只能作为 mnode,不能分配 vnode)
2:dnode(不能作为 mnode,只能分配 vnode) | -| 缺省值 | 0 | +| Attribute | Description | +| ------------- | --------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The role of the dnode | +| Value Range | 0: both mnode and vnode
1: mnode only
2: dnode only | +| Default Value | 0 | + ### balance -| 属性 | 说明 | -| -------- | ---------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否启动负载均衡 | -| 取值范围 | 0,1 | -| 缺省值 | 1 | +| Attribute | Description | +| ------------- | ------------------------ | +| Applicable | Server Only | +| Meaning | Automatic load balancing | +| Value Range | 0: disabled, 1: enabled | +| Default Value | 1 | ### balanceInterval -| 属性 | 说明 | -| -------- | ------------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 管理节点在正常运行状态下,检查负载均衡的时间间隔 | -| 单位 | 秒 | -| 取值范围 | 1-30000 | -| 缺省值 | 300 | +| Attribute | Description | +| ------------- | ----------------------------------------------- | +| Applicable | Server Only | +| Meaning | The interval for checking load balance by mnode | +| Unit | second | +| Value Range | 1-30000 | +| Default Value | 300 | ### arbitrator -| 属性 | 说明 | -| -------- | ------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 系统中裁决器的 end point,其格式如firstEp | -| 缺省值 | 空 | +| Attribute | Description | +| ------------- | -------------------------------------------------- | +| Applicable | Server Only | +| Meaning | End point of arbitrator, format is same as firstEp | +| Default Value | None | + +## Time Parameters -## 时间相关 +### precision + +| Attribute | Description | +| ------------- | ------------------------------------------------- | +| Applicable | Server only | +| Meaning | Time precision used for each database | +| Value Range | ms: millisecond; us: microsecond ; ns: nanosecond | +| Default Value | ms | ### rpcTimer -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | rpc 重试时长 | -| 单位 | 毫秒 | -| 取值范围 | 100-3000 | -| 缺省值 | 300 | +| Attribute | Description | +| ------------- | ------------------ | +| Applicable | Server and Client | +| Meaning | rpc retry interval | +| Unit | milliseconds | +| Value Range | 100-3000 | +| Default Value | 300 | ### rpcMaxTime -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | rpc 等待应答最大时长 | -| 单位 | 秒 | -| 取值范围 | 100-7200 | -| 缺省值 | 600 | +| Attribute | Description | +| ------------- | ---------------------------------- | +| Applicable | Server and Client | +| Meaning | maximum wait time for rpc response | +| Unit | second | +| Value Range | 100-7200 | +| Default Value | 600 | ### statusInterval -| 属性 | 说明 | -| -------- | --------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | dnode 向 mnode 报告状态间隔 | -| 单位 | 秒 | -| 取值范围 | 1-10 | -| 缺省值 | 1 | +| Attribute | Description | +| ------------- | ----------------------------------------------- | +| Applicable | Server Only | +| Meaning | the interval of dnode reporting status to mnode | +| Unit | second | +| Value Range | 1-10 | +| Default Value | 1 | ### shellActivityTimer -| 属性 | 说明 | -| -------- | --------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | shell 客户端向 mnode 发送心跳间隔 | -| 单位 | 秒 | -| 取值范围 | 1-120 | -| 缺省值 | 3 | +| Attribute | Description | +| ------------- | ------------------------------------------------------ | +| Applicable | Server and Client | +| Meaning | The interval for taos shell to send heartbeat to mnode | +| Unit | second | +| Value Range | 1-120 | +| Default Value | 3 | ### tableMetaKeepTimer -| 属性 | 说明 | -| -------- | --------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 表的元数据 cache 时长 | -| 单位 | 秒 | -| 取值范围 | 1-8640000 | -| 缺省值 | 7200 | +| Attribute | Description | +| ------------- | -------------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The expiration time for metadata in cache, once it's reached the client would refresh the metadata | +| Unit | second | +| Value Range | 1-8640000 | +| Default Value | 7200 | ### maxTmrCtrl -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 定时器个数 | -| 单位 | 个 | -| 取值范围 | 8-2048 | -| 缺省值 | 512 | +| Attribute | Description | +| ------------- | ------------------------ | +| Applicable | Server and Client | +| Meaning | Maximum number of timers | +| Unit | None | +| Value Range | 8-2048 | +| Default Value | 512 | ### offlineThreshold -| 属性 | 说明 | -| -------- | ------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | dnode 离线阈值,超过该时间将导致 dnode 离线 | -| 单位 | 秒 | -| 取值范围 | 5-7200000 | -| 缺省值 | 86400\*10(10 天) | - +| Attribute | Description | +| ------------- | ----------------------------------------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The expiration time for dnode online status, once it's reached before receiving status from a node, the dnode becomes offline | +| Unit | second | +| Value Range | 5-7200000 | +| Default Value | 86400\*10(10 天) | -## 性能调优 +## Performance Optimization Parameters ### numOfThreadsPerCore -| 属性 | 说明 | -| -------- | ----------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 每个 CPU 核生成的队列消费者线程数量 | -| 缺省值 | 1.0 | +| Attribute | Description | +| ------------- | ------------------------------------------- | +| Applicable | Server and Client | +| Meaning | The number of consumer threads per CPU core | +| Default Value | 1.0 | ### ratioOfQueryThreads -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 设置查询线程的最大数量 | -| 取值范围 | 0:表示只有 1 个查询线程
1:表示最大和 CPU 核数相等的查询线程
2:表示最大建立 2 倍 CPU 核数的查询线程。 | -| 缺省值 | 1 | -| 补充说明 | 该值可以为小数,即 0.5 表示最大建立 CPU 核数一半的查询线程。 | +| Attribute | Description | +| ------------- | --------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Maximum number of query threads 量 | +| Value Range | 0: Only one query thread
1: Same as number of CPU cores
2: two times of CPU cores | +| Default Value | 1 | +| Note | This value can be a float number, 0.5 means half of the CPU cores | ### maxVgroupsPerDb -| 属性 | 说明 | -| -------- | ------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 DB 中 能够使用的最大 vnode 个数 | -| 取值范围 | 0-8192 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------------------------ | +| Applicable | Server Only | +| Meaning | Maximum number of vnodes for each DB | +| Value Range | 0-8192 | +| Default Value | | ### maxTablesPerVnode -| 属性 | 说明 | -| -------- | --------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 vnode 中能够创建的最大表个数 | -| 缺省值 | 1000000 | +| Attribute | Description | +| ------------- | -------------------------------------- | +| Applicable | Server Only | +| Meaning | Maximum number of tables in each vnode | +| Default Value | 1000000 | ### minTablesPerVnode -| 属性 | 说明 | -| -------- | --------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 vnode 中必须创建表的最小数量 | -| 缺省值 | 1000 | +| Attribute | Description | +| ------------- | -------------------------------------- | +| Applicable | Server Only | +| Meaning | Minimum number of tables in each vnode | +| Default Value | 1000 | ### tableIncStepPerVnode -| 属性 | 说明 | -| -------- | ----------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 vnode 中超过最小表数,i.e. minTablesPerVnode, 后递增步长 | -| 缺省值 | 1000 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | When minTablesPerVnode is reached, the number of tables are allocated for a vnode each time | +| Default Value | 1000 | ### maxNumOfOrderedRes -| 属性 | 说明 | -| -------- | -------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 支持超级表时间排序允许的最多记录数限制 | -| 缺省值 | 10 万 | - +| Attribute | Description | +| ------------- | ------------------------------------------- | +| Applicable | Server and Client | +| Meaning | Maximum number of rows ordered for a STable | +| Default Value | 100,000 | ### mnodeEqualVnodeNum -| 属性 | 说明 | -| -------- | ---------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 将一个 mnode 等同于 vnode 消耗的个数 | -| 缺省值 | 4 | +| Attribute | Description | +| ------------- | ----------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The number of vnodes whose system resources consumption are considered as equal to single mnode | +| Default Value | 4 | ### numOfCommitThreads -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 设置写入线程的最大数量 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ----------------------------------------- | +| Applicable | Server Only | +| Meaning | Maximum of threads for committing to disk | +| Default Value | | -## 压缩相关 +## Compression Parameters ### comp -| 属性 | 说明 | -| -------- | ----------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 文件压缩标志位 | -| 取值范围 | 0:关闭,1:一阶段压缩,2:两阶段压缩 | -| 缺省值 | 2 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Whether data is compressed | +| Value Range | 0: uncompressed, 1: One phase compression, 2: Two phase compression | +| Default Value | 2 | ### tsdbMetaCompactRatio -| 属性 | 说明 | -| -------- | -------------------------------------------------------------- | -| 含义 | tsdb meta 文件中冗余数据超过多少阈值,开启 meta 文件的压缩功能 | -| 取值范围 | 0:不开启,[1-100]:冗余数据比例 | -| 缺省值 | 0 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------------------------- | +| Meaning | The threshold for percentage of redundant in meta file to trigger compression for meta file | +| Value Range | 0: no compression forever, [1-100]: The threshold percentage | +| Default Value | 0 | ### compressMsgSize -| 属性 | 说明 | -| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 客户端与服务器之间进行消息通讯过程中,对通讯的消息进行压缩的阈值。如果要压缩消息,建议设置为 64330 字节,即大于 64330 字节的消息体才进行压缩。 | -| 单位 | bytes | -| 取值范围 | `0 `表示对所有的消息均进行压缩 >0: 超过该值的消息才进行压缩 -1: 不压缩 | -| 缺省值 | -1 | +| Attribute | Description | +| ------------- | -------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The threshold for message size to compress the message.. | +| Unit | bytes | +| Value Range | 0: already compress; >0: compress when message exceeds it; -1: always uncompress | +| Default Value | -1 | ### compressColData -| 属性 | 说明 | -| -------- | --------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 客户端与服务器之间进行消息通讯过程中,对服务器端查询结果进行列压缩的阈值。 | -| 单位 | bytes | -| 取值范围 | 0: 对所有查询结果均进行压缩 >0: 查询结果中任意列大小超过该值的消息才进行压缩 -1: 不压缩 | -| 缺省值 | -1 | -| 补充说明 | 2.3.0.0 版本新增。 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The threshold for size of column data to trigger compression for the query result | +| Unit | bytes | +| Value Range | 0: always compress; >0: only compress when the size of any column data exceeds the threshold; -1: always uncompress | +| Default Value | -1 | +| Note | available from version 2.3.0.0 | ### lossyColumns -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| 适用范围 | 服务器端 | -| 含义 | 配置要进行有损压缩的浮点数据类型 | -| 取值范围 | 空字符串:关闭有损压缩
float:只对 float 类型进行有损压缩
double:只对 double 类型进行有损压缩
float \| double:float double 都进行有损压缩 | -| 缺省值 | 空字符串 | -| 补充说明 | 有损压缩默认为关闭状态,只有配置后才生效 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | The floating number types for lossy compression | +| Value Range | "": lossy compression is disabled
float: only for float
double: only for double
float \| double: for both float and double | +| Default Value | "" , i.e. disabled | ### fPrecision -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 服务器端 | -| 含义 | 设置 float 类型浮点数压缩精度 | -| 取值范围 | 0.1 ~ 0.00000001 | -| 缺省值 | 0.00000001 | -| 补充说明 | 小于此值的浮点数尾数部分将被截取 | +| Attribute | Description | +| ------------- | ----------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Compression precision for float type | +| Value Range | 0.1 ~ 0.00000001 | +| Default Value | 0.00000001 | +| Note | The fractional part lower than this value will be discarded | ### dPrecision -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 服务器端 | -| 含义 | 设置 double 类型浮点数压缩精度 | -| 取值范围 | 0.1 ~ 0.0000000000000001 | -| 缺省值 | 0.0000000000000001 | -| 补充说明 | 小于此值的浮点数尾数部分将被截取 | +| Attribute | Description | +| ------------- | ----------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Compression precision for double type | +| Value Range | 0.1 ~ 0.0000000000000001 | +| Default Value | 0.0000000000000001 | +| Note | The fractional part lower than this value will be discarded | -## 连续查询相关 +## Continuous Query Prameters ### stream -| 属性 | 说明 | -| -------- | ------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否启用连续查询(流计算功能) | -| 取值范围 | 0:不允许
1:允许 | -| 缺省值 | 1 | +| Attribute | Description | +| ------------- | ---------------------------------- | +| Applicable | Server Only | +| Meaning | Whether to enable continuous query | +| Value Range | 0: disabled
1: enabled | +| Default Value | 1 | ### minSlidingTime -| 属性 | 说明 | -| -------- | ----------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 最小滑动窗口时长 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000 | -| 缺省值 | 10 | -| 补充说明 | 支持 us 补值后,这个值就是 1us 了。 | +| Attribute | Description | +| ------------- | -------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Minimum sliding time of time window | +| Unit | millisecond or microsecond , depending on time precision | +| Value Range | 10-1000000 | +| Default Value | 10 | ### minIntervalTime -| 属性 | 说明 | -| -------- | -------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 时间窗口最小值 | -| 单位 | 毫秒 | -| 取值范围 | 1-1000000 | -| 缺省值 | 10 | +| Attribute | Description | +| ------------- | --------------------------- | +| Applicable | Server Only | +| Meaning | Minimum size of time window | +| Unit | millisecond | +| Value Range | 1-1000000 | +| Default Value | 10 | ### maxStreamCompDelay -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 连续查询启动最大延迟 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000000 | -| 缺省值 | 20000 | +| Attribute | Description | +| ------------- | ------------------------------------------------ | +| Applicable | Server Only | +| Meaning | Maximum delay before starting a continuous query | +| Unit | millisecond | +| Value Range | 10-1000000000 | +| Default Value | 20000 | ### maxFirstStreamCompDelay -| 属性 | 说明 | -| -------- | -------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 第一次连续查询启动最大延迟 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000000 | -| 缺省值 | 10000 | +| Attribute | Description | +| ------------- | -------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Maximum delay time before starting a continuous query the first time | +| Unit | millisecond | +| Value Range | 10-1000000000 | +| Default Value | 10000 | ### retryStreamCompDelay -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 连续查询重试等待间隔 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000000 | -| 缺省值 | 10 | +| Attribute | Description | +| ------------- | --------------------------------------------- | +| Applicable | Server Only | +| Meaning | Delay time before retrying a continuous query | +| Unit | millisecond | +| Value Range | 10-1000000000 | +| Default Value | 10 | ### streamCompDelayRatio -| 属性 | 说明 | -| -------- | -------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 连续查询的延迟时间计算系数,实际延迟时间为本参数乘以计算时间窗口 | -| 取值范围 | 0.1-0.9 | -| 缺省值 | 0.1 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------ | +| Applicable | Server Only | +| Meaning | The delay ratio, with time window size as the base, for continuous query | +| Value Range | 0.1-0.9 | +| Default Value | 0.1 | :::info -为避免多个 stream 同时执行占用太多系统资源,程序中对 stream 的执行时间人为增加了一些随机的延时。
maxFirstStreamCompDelay 是 stream 第一次执行前最少要等待的时间。
streamCompDelayRatio 是延迟时间的计算系数,它乘以查询的 interval 后为延迟时间基准。
maxStreamCompDelay 是延迟时间基准的上限。
实际延迟时间为一个不超过延迟时间基准的随机值。
stream 某次计算失败后需要重试,retryStreamCompDelay 是重试的等待时间基准。
实际重试等待时间为不超过等待时间基准的随机值。 +To prevent system resource from being exhausted by multiple concurrent streams, a random delay is applied on each stream automatically. `maxFirstStreamCompDelay` is the maximum delay time before a continuous query is started the first time. `streamCompDelayRatio` is the ratio for calculating delay time, with the size of the time window as base. `maxStreamCompDelay` is the maximum delay time. The actual delay time is a random time not bigger than `maxStreamCompDelay`. If a continuous query fails, `retryStreamComDelay` is the delay time before retrying it, also not bigger than `maxStreamCompDelay`. ::: -## HTTP 相关 +## HTTP Parameters :::note -HTTP服务在2.4.0.0(不含)以前的版本中由taosd提供,在2.4.0.0以后(含)由taosAdapter提供。 -本节的配置参数仅在2.4.0.0(不含)以前的版本中生效。如果您使用的是2.4.0.0(含)及以后的版本请参考[文档](/reference/taosadapter/)。 +HTTP server had been provided by `taosd` prior to version 2.4.0.0, now is provided by `taosAdapter` after version 2.4.0.0. +The parameters described in this section are only application in versions prior to 2.4.0.0. If you are using any version from 2.4.0.0, please refer to [taosAdapter]](/reference/taosadapter/). ::: ### http -| 属性 | 说明 | -| -------- | --------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 服务器内部的 http 服务开关。 | -| 取值范围 | 0:关闭 http 服务, 1:激活 http 服务。 | -| 缺省值 | 1 | +| Attribute | Description | +| ------------- | ------------------------------ | +| Applicable | Server Only | +| Meaning | Whether to enable http service | +| Value Range | 0: disabled, 1: enabled | +| Default Value | 1 | ### httpEnableRecordSql -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 记录通过 RESTFul 接口,产生的 SQL 调用。 | -| 缺省值 | 0 | -| 补充说明 | 生成的文件(httpnote.0/httpnote.1),与服务端日志所在目录相同。 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------- | +| Applicable | Server Only | +| Meaning | Whether to record the SQL invocation through REST interface | +| Default Value | 0: false; 1: true | +| Note | The resulting files, i.e. httpnote.0/httpnote.1, are located under logDir | ### httpMaxThreads -| 属性 | 说明 | -| -------- | --------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | RESTFul 接口的线程数。taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | -| 缺省值 | 2 | +| Attribute | Description | +| ------------- | -------------------------------------------- | +| Applicable | Server Only | +| Meaning | The number of threads for RESTFul interface. | +| Default Value | 2 | ### restfulRowLimit -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | RESTFul 接口单次返回的记录条数。taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | -| 缺省值 | 10240 | -| 补充说明 | 最大 10,000,000 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------ | +| Applicable | Server Only | +| Meaning | Maximum number of rows returned each time by REST interface. | +| Default Value | 10240 | +| Note | Maximum value is 10,000,000 | ### httpDBNameMandatory -| 属性 | 说明 | -| -------- | ---------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否在 URL 中输入 数据库名称 | -| 取值范围 | 0:不开启,1:开启 | -| 缺省值 | 0 | -| 补充说明 | 2.3 版本新增。 | +| Attribute | Description | +| ------------- | ---------------------------------------- | +| Applicable | Server Only | +| Meaning | Whether database name is required in URL | +| Value Range | 0:not required, 1: required | +| Default Value | 0 | +| Note | From version 2.3.0.0 | -## 日志相关 +## Log Parameters ### logDir -| 属性 | 说明 | -| -------- | -------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 日志文件目录,客户端和服务器的运行日志将写入该目录 | -| 缺省值 | /var/log/taos | +| Attribute | Description | +| ------------- | ----------------------------------- | +| Applicable | Server and Client | +| Meaning | The directory for writing log files | +| Default Value | /var/log/taos | ### minimalLogDirGB -| 属性 | 说明 | -| -------- | -------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 当日志文件夹的磁盘大小小于该值时,停止写日志 | -| 单位 | GB | -| 缺省值 | 1.0 | - +| Attribute | Description | +| ------------- | -------------------------------------------------------------------------------------------------- | +| Applicable | Server and Client | +| Meaning | When the available disk space in logDir is below this threshold, writing to log files is suspended | +| Unit | GB | +| Default Value | 1.0 | ### numOfLogLines -| 属性 | 说明 | -| -------- | ---------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 单个日志文件允许的最大行数。 | -| 缺省值 | 10,000,000 | +| Attribute | Description | +| ------------- | ------------------------------------------ | +| Applicable | Server and Client | +| Meaning | Maximum number of lines in single log file | +| Default Value | 10,000,000 | ### asyncLog -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 日志写入模式 | -| 取值范围 | 0:同步、1:异步 | -| 缺省值 | 1 | +| Attribute | Description | +| ------------- | ---------------------------- | +| Applicable | Server and Client | +| Meaning | The mode of writing log file | +| Value Range | 0: sync way; 1: async way | +| Default Value | 1 | ### logKeepDays -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 日志文件的最长保存时间 | -| 单位 | 天 | -| 缺省值 | 0 | -| 补充说明 | 大于 0 时,日志文件会被重命名为 taosdlog.xxx,其中 xxx 为日志文件最后修改的时间戳。 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | +| Applicable | Server and Client | +| Meaning | The number of days for log files to be kept | +| Unit | day | +| Default Value | 0 | +| Note | When it's bigger than 0, the log file would be renamed to "taosdlog.xxx" in which "xxx" is the timestamp when the file is changed last time | ### debugFlag -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 运行日志开关 | -| 取值范围 | 131(输出错误和警告日志),135(输出错误、警告和调试日志),143(输出错误、警告、调试和跟踪日志) | -| 缺省值 | 131 或 135(不同模块有不同的默认值) | +| Attribute | Description | +| ------------- | --------------------------------------------------------- | +| Applicable | Server and Client | +| Meaning | Log level | +| Value Range | 131: INFO/WARNING/ERROR; 135: plus DEBUG; 143: plus TRACE | +| Default Value | 131 or 135, depending on the module | ### mDebugFlag -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 管理模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | +| Attribute | Description | +| ------------- | ------------------ | +| Applicable | Server Only | +| Meaning | Log level of mnode | +| Value Range | same as debugFlag | +| Default Value | 135 | ### dDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | dnode 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | +| Attribute | Description | +| ------------- | ------------------ | +| Applicable | Server and Client | +| Meaning | Log level of dnode | +| Value Range | same as debugFlag | +| Default Value | 135 | ### sDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | sync 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | +| Attribute | Description | +| ------------- | ------------------------ | +| Applicable | Server and Client | +| Meaning | Log level of sync module | +| Value Range | same as debugFlag | +| Default Value | 135 | ### wDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | wal 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | +| Attribute | Description | +| ------------- | ----------------------- | +| Applicable | Server and Client | +| Meaning | Log level of WAL module | +| Value Range | same as debugFlag | +| Default Value | 135 | ### sdbDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | sdb 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | +| Attribute | Description | +| ------------- | ---------------------- | +| Applicable | Server and Client | +| Meaning | logLevel of sdb module | +| Value Range | same as debugFlag | +| Default Value | 135 | ### rpcDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | rpc 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ----------------------- | +| Applicable | Server and Client | +| Meaning | Log level of rpc module | +| Value Range | Same as debugFlag | +| Default Value | | ### tmrDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 定时器模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------------- | +| Applicable | Server and Client | +| Meaning | Log level of timer module | +| Value Range | Same as debugFlag | +| Default Value | | ### cDebugFlag -| 属性 | 说明 | -| -------- | --------------------- | -| 适用范围 | 仅客户端适用 | -| 含义 | client 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------- | +| Applicable | Client Only | +| Meaning | Log level of Client | +| Value Range | Same as debugFlag | +| Default Value | | ### jniDebugFlag -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅客户端适用 | -| 含义 | jni 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ----------------------- | +| Applicable | Client Only | +| Meaning | Log level of jni module | +| Value Range | 同上 | +| Default Value | | ### odbcDebugFlag -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅客户端适用 | -| 含义 | odbc 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------------ | +| Applicable | Client Only | +| Meaning | Log level of odbc module | +| Value Range | Same as debugFlag | +| Default Value | | ### uDebugFlag -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 共用功能模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | -------------------------- | +| Applicable | Server and Client | +| Meaning | Log level of common module | +| Value Range | Same as debugFlag | +| Default Value | | ### httpDebugFlag -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | http 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------------------------------- | +| Applicable | Server Only | +| Meaning | Log level of http module (prior to 2.4.0.0) | +| Value Range | Same as debugFlag | +| Default Value | | ### mqttDebugFlag -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | mqtt 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------------ | +| Applicable | Server Only | +| Meaning | Log level of mqtt module | +| Value Range | Same as debugFlag | +| Default Value | | ### monitorDebugFlag -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 监控模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------------------ | +| Applicable | Server Only | +| Meaning | Log level of monitoring module | +| Value Range | Same as debugFlag | +| Default Value | | ### qDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 查询模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------------- | +| Applicable | Server and Client | +| Meaning | Log level of query module | +| Value Range | Same as debugFlag | +| Default Value | | ### vDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | vnode 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------ | +| Applicable | Server and Client | +| Meaning | Log level of vnode | +| Value Range | Same as debugFlag | +| Default Value | | ### tsdbDebugFlag -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | TSDB 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------------ | +| Applicable | Server Only | +| Meaning | Log level of TSDB module | +| Value Range | Same as debugFlag | +| Default Value | | ### cqDebugFlag -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 连续查询模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| Attribute | Description | +| ------------- | ------------------------------------ | +| Applicable | Server and Client | +| Meaning | Log level of continuous query module | +| Value Range | Same as debugFlag | +| Default Value | | -## 仅客户端适用 +## Client Only ### maxSQLLength -| 属性 | 说明 | -| -------- | --------------------------- | -| 适用范围 | 仅客户端适用 | -| 含义 | 单条 SQL 语句允许的最长限制 | -| 单位 | bytes | -| 取值范围 | 65480-1048576 | -| 缺省值 | 1048576 | +| Attribute | Description | +| ------------- | -------------------------------------- | +| Applicable | Client Only | +| Meaning | Maximum length of single SQL statement | +| Unit | bytes | +| Value Range | 65480-1048576 | +| Default Value | 1048576 | ### tscEnableRecordSql -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------- | -| 含义 | 是否记录客户端 sql 语句到文件 | -| 取值范围 | 0:否,1:是 | -| 缺省值 | 0 | -| 补充说明 | 生成的文件(tscnote-xxxx.0/tscnote-xxx.1,xxxx 是 pid),与客户端日志所在目录相同。 | +| Attribute | Description | +| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| Meaning | Whether to record SQL statements in file | +| Value Range | 0: false, 1: true | +| Default Value | 0 | +| Note | The generated files are named as "tscnote-xxxx.0/tscnote-xxx.1" in which "xxxx" is the pid of the client, and located at same place as client log | ### maxBinaryDisplayWidth -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 含义 | Taos shell 中 binary 和 nchar 字段的显示宽度上限,超过此限制的部分将被隐藏 | -| 取值范围 | 5 - | -| 缺省值 | 30 | +| Attribute | Description | +| ------------- | --------------------------------------------------------------------------------------------------- | +| Meaning | Maximum display width of binary and nchar in taos shell. Anything beyond this limit would be hidden | +| Value Range | 5 - | +| Default Value | 30 | :::info -实际上限按以下规则计算:如果字段值的长度大于 maxBinaryDisplayWidth,则显示上限为 **字段名长度** 和 **maxBinaryDisplayWidth** 的较大者。
否则,上限为 **字段名长度** 和 **字段值长度** 的较大者。
可在 shell 中通过命令 set max_binary_display_width nn 动态修改此选项 +If the length of value exceeds `maxBinaryDisplayWidth`, then the actual display width is max(column name, maxBinaryDisplayLength); otherwise the actual display width is max(length of column name, length of column value). This parameter can also be changed dynamically using `set max_binary_display_width ` in TDengine CLI `taos`. ::: ### maxWildCardsLength -| 属性 | 说明 | -| -------- | ------------------------------------------ | -| 含义 | 设定 LIKE 算子的通配符字符串允许的最大长度 | -| 单位 | bytes | -| 取值范围 | 0-16384 | -| 缺省值 | 100 | -| 补充说明 | 2.1.6.1 版本新增。 | +| Attribute | Description | +| ------------- | ----------------------------------------------------- | +| Meaning | The maximum length for wildcard string used with LIKE | +| Unit | bytes | +| Value Range | 0-16384 | +| Default Value | 100 | +| Note | From version 2.1.6.1 | ### clientMerge -| 属性 | 说明 | -| -------- | ---------------------------- | -| 含义 | 是否允许客户端对写入数据去重 | -| 取值范围 | 0:不开启,1:开启 | -| 缺省值 | 0 | -| 补充说明 | 2.3 版本新增。 | +| Attribute | Description | +| ------------- | --------------------------------------------------- | +| Meaning | Whether to filter out duplicate data on client side | +| Value Range | 0: false; 1: true | +| Default Value | 0 | +| Note | From version 2.3.0.0 | ### maxRegexStringLen -| 属性 | 说明 | -| -------- | -------------------------- | -| 含义 | 正则表达式最大允许长度 | -| 取值范围 | 默认值 128,最大长度 16384 | -| 缺省值 | 128 | -| 补充说明 | 2.3 版本新增。 | +| Attribute | Description | +| ------------- | ----------------------------------------------------------- | +| Meaning | Maximum length of regular expression 正则表达式最大允许长度 | +| Value Range | [128, 16384] | +| Default Value | 128 | +| Note | From version 2.3.0.0 | -## 其他 +## Other Parameters ### enableCoreFile -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 是否开启服务 crash 时生成 core 文件 | -| 取值范围 | 0:否,1:是 | -| 缺省值 | 1 | -| 补充说明 | 不同的启动方式,生成 core 文件的目录如下:1、systemctl start taosd 启动:生成的 core 在根目录下
2、手动启动,就在 taosd 执行目录下。 | +| Attribute | Description | +| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Applicable | Server and Client | +| Meaning | Whether to generate core file when server crashes | +| Value Range | 0: false, 1: true | +| Default Value | 1 | +| Note | The core file is generated under root directory `systemctl start taosd` is used to start, or under the working directory if `taosd` is started directly on Linux Shell. | diff --git a/docs-en/14-reference/12-directory.md b/docs-en/14-reference/12-directory.md index f8c8cb4a082f691cf75db9bed3b42d0d6e1bc8a3..e033d0227d8405f61f3bd9e04837d9739928ca7c 100644 --- a/docs-en/14-reference/12-directory.md +++ b/docs-en/14-reference/12-directory.md @@ -1,42 +1,42 @@ --- -title: 文件目录结构 -description: "TDengine 安装目录说明" +title: File directory structure +description: "TDengine installation directory description" --- -安装 TDengine 后,默认会在操作系统中生成下列目录或文件: +When TDengine is installed, the following directories or files will be created in the operating system by default. -| 目录/文件 | 说明 | +| directory/file | description | | ------------------------- | -------------------------------------------------------------------- | -| /usr/local/taos/bin | TDengine 可执行文件目录。其中的执行文件都会软链接到/usr/bin 目录下。 | -| /usr/local/taos/driver | TDengine 动态链接库目录。会软链接到/usr/lib 目录下。 | -| /usr/local/taos/examples | TDengine 各种语言应用示例目录。 | -| /usr/local/taos/include | TDengine 对外提供的 C 语言接口的头文件。 | -| /etc/taos/taos.cfg | TDengine 默认[配置文件] | -| /var/lib/taos | TDengine 默认数据文件目录。可通过[配置文件]修改位置。 | -| /var/log/taos | TDengine 默认日志文件目录。可通过[配置文件]修改位置。 | - -## 可执行文件 - -TDengine 的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下。其中包括: - -- _taosd_:TDengine 服务端可执行文件 -- _taos_:TDengine Shell 可执行文件 -- _taosdump_:数据导入导出工具 -- _taosBenchmark_:TDengine 测试工具 -- _remove.sh_:卸载 TDengine 的脚本,请谨慎执行,链接到/usr/bin 目录下的**rmtaos**命令。会删除 TDengine 的安装目录/usr/local/taos,但会保留/etc/taos、/var/lib/taos、/var/log/taos -- _taosadapter_: 提供 RESTful 服务和接受其他多种软件写入请求的服务端可执行文件 -- _tarbitrator_: 提供双节点集群部署的仲裁功能 -- _run_taosd_and_taosadapter.sh_:同时启动 taosd 和 taosAdapter 的脚本 -- _TDinsight.sh_:用于下载 TDinsight 并安装的脚本 -- _set_core.sh_:用于方便调试设置系统生成 core dump 文件的脚本 -- _taosd-dump-cfg.gdb_:用于方便调试 taosd 的 gdb 执行脚本。 +| /usr/local/taos/bin | The TDengine executable directory. The executable files are soft-linked to the /usr/bin directory. | +| /usr/local/taos/driver | The TDengine dynamic link library directory. It is soft-linked to the /usr/lib directory. | +| /usr/local/taos/examples | The TDengine various language application examples directory. | +| /usr/local/taos/include | The header files for TDengine's external C interface. | +| /etc/taos/taos.cfg | TDengine default [configuration file] | +| /var/lib/taos | TDengine's default data file directory. The location can be changed via [configuration file]. | +| /var/log/taos | TDengine default log file directory. The location can be changed via [configure file]. | + +## Executable files + +All executable files of TDengine are stored in the _/usr/local/taos/bin_ directory by default. These include. + +- _taosd_: TDengine server-side executable files +- _taos_: TDengine shell executable +- _taosdump_: data import and export tool +- _taosBenchmark_: TDengine testing tool +- _remove.sh_: script to uninstall TDengine, please execute it carefully, link to the **rmtaos** command in the /usr/bin directory. Will remove the TDengine installation directory /usr/local/taos, but will keep /etc/taos, /var/lib/taos, /var/log/taos +- _taosadapter_: server-side executable that provides RESTful services and accepts writing requests from a variety of other software +- _tarbitrator_: provides arbitration for two-node cluster deployments +- _run_taosd_and_taosadapter.sh_: script to start both taosd and taosAdapter +- _TDinsight.sh_: script to download TDinsight and install it +- _set_core.sh_: script for setting up the system to generate core dump files for easy debugging +- _taosd-dump-cfg.gdb_: script to facilitate debugging of taosd's gdb execution. :::note -2.4.0.0 版本之后的 taosBenchmark 和 taosdump 需要安装独立安装包 taosTools。 +taosBenchmark and taosdump after version 2.4.0.0 require taosTools as a standalone installation. ::: :::tip -您可以通过修改系统配置文件 taos.cfg 来配置不同的数据目录和日志目录。 +You can configure different data directories and log directories by modifying the system configuration file taos.cfg. ::: diff --git a/docs-en/14-reference/_category_.yml b/docs-en/14-reference/_category_.yml index 079c784e6512109661afe08c12b398e8c4fab720..5f5466532be79153d42da0907df6336439593601 100644 --- a/docs-en/14-reference/_category_.yml +++ b/docs-en/14-reference/_category_.yml @@ -1,5 +1 @@ -label: 参考指南 -link: - slug: /reference/ - type: generated-index - description: "参考指南是对 TDengine 本身、 TDengine 各语言连接器及自带的工具最详细的介绍。" +label: Reference diff --git a/docs-en/14-reference/_collectd.mdx b/docs-en/14-reference/_collectd.mdx index 1853769bf926a081a80cdf72b8e822e58cefb1e9..af3dd7564a58fb71f1a6c8a1cc6169ab6b3bb3a6 100644 --- a/docs-en/14-reference/_collectd.mdx +++ b/docs-en/14-reference/_collectd.mdx @@ -1,8 +1,8 @@ -### 配置 taosAdapter +### Configuring taosAdapter -配置 taosAdapter 接收 collectd 数据的方法: +To configure taosAdapter to receive collectd data. -- 在 taosAdapter 配置文件(默认位置为 /etc/taos/taosadapter.toml)中使能配置项 +- Enable the configuration item in the taosAdapter configuration file (default location is /etc/taos/taosadapter.toml) ``` ... @@ -17,17 +17,17 @@ password = "taosdata" ... ``` -其中 taosAdapter 默认写入的数据库名称为 `collectd`,也可以修改 taosAdapter 配置文件 dbs 项来指定不同的名称。user 和 password 填写实际 TDengine 配置的值。修改过配置文件 taosAdapter 需重新启动。 +The default database name written by taosAdapter is `collectd`. You can also modify the taosAdapter configuration file dbs entry to specify a different name. user and password are the values configured by the actual TDengine. After changing the configuration file, you need to restart the taosAdapter. -- 也可以使用 taosAdapter 命令行参数或设置环境变量启动的方式,使能 taosAdapter 接收 collectd 数据功能,具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) +- You can also enable the taosAdapter to receive collectd data by using the taosAdapter command line parameters or by setting environment variables. -### 配置 collectd -# -collectd 使用插件机制可以以多种形式将采集到的监控数据写入到不同的数据存储软件。TDengine 支持直接采集插件和 write_tsdb 插件。 +### Configure collectd +#collectd +collectd uses a plugin mechanism to write the collected monitoring data to different data storage software in various forms. tdengine supports both direct collection plugins and write_tsdb plugins. -#### 配置接收直接采集插件数据 +#### is configured to receive data from the direct collection plugin -修改 collectd 配置文件(默认位置 /etc/collectd/collectd.conf)相关配置项。 +Modify the relevant configuration items in the collectd configuration file (default location /etc/collectd/collectd.conf). ```text LoadPlugin network @@ -36,20 +36,20 @@ LoadPlugin network ``` -其中 填写运行 taosAdapter 的服务器域名或 IP 地址。 填写 taosAdapter 用于接收 collectd 数据的端口(默认为 6045)。 +where fills in the server's domain name or IP address running taosAdapter. fills in the port that taosAdapter uses to receive collectd data (default is 6045). -实例如下: +An example is as follows. ```text LoadPlugin network - + ``` -#### 配置 write_tsdb 插件数据 +#### Configure write_tsdb plugin data -修改 collectd 配置文件(默认位置 /etc/collectd/collectd.conf)相关配置项。 +Modify the relevant configuration items in the collectd configuration file (default location /etc/collectd/collectd.conf). ```text LoadPlugin write_tsdb @@ -62,7 +62,7 @@ LoadPlugin write_tsdb ``` -其中 填写运行 taosAdapter 的服务器域名或 IP 地址。 填写 taosAdapter 用于接收 collectd write_tsdb 插件的数据(默认为 6047)。 +Where fills in the server's domain name or IP address running taosAdapter. Fill in the data that taosAdapter uses to receive the collectd write_tsdb plugin (default is 6047). ```text LoadPlugin write_tsdb @@ -73,13 +73,12 @@ LoadPlugin write_tsdb HostTags "status=production" StoreRates false AlwaysAppendDS false - + ``` -然后重启 collectd: +Then restart collectd. ``` systemctl restart collectd ``` - diff --git a/docs-en/14-reference/_icinga2.mdx b/docs-en/14-reference/_icinga2.mdx index 0ed5023f953a6d879cc553def3aa0eaa9098afd5..a462a765e493acc1a276e99ee1c237a67bf4f5e2 100644 --- a/docs-en/14-reference/_icinga2.mdx +++ b/docs-en/14-reference/_icinga2.mdx @@ -1,8 +1,10 @@ -### 配置 taosAdapter -配置 taosAdapter 接收 icinga2 数据的方法: -- 在 taosAdapter 配置文件(默认位置 /etc/taos/taosadapter.toml)中使能配置项 +### Configuring taosAdapter + +To configure taosAdapter to receive icinga2 data. + +- Enable the configuration item in the taosAdapter configuration file (default location /etc/taos/taosadapter.toml) ``` ... @@ -17,14 +19,14 @@ password = "taosdata" ... ``` -其中 taosAdapter 默认写入的数据库名称为 `icinga2`,也可以修改 taosAdapter 配置文件 dbs 项来指定不同的名称。user 和 password 填写实际 TDengine 配置的值。修改过 taosAdapter 需重新启动。 +The default database name written by the taosAdapter is `icinga2`. You can also modify the taosAdapter configuration file dbs entry to specify a different name. user and password are the values configured by the actual TDengine. You need to restart the taosAdapter after modification. -- 也可以使用 taosAdapter 命令行参数或设置环境变量启动的方式,使能 taosAdapter 接收 icinga2 数据功能,具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) +- You can also enable taosAdapter to receive icinga2 data by using the taosAdapter command line parameters or setting environment variables. -### 配置 icinga2 +### Configure icinga3 -- 使能 icinga2 的 opentsdb-writer(参考链接 https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer) -- 修改配置文件 `/etc/icinga2/features-enabled/opentsdb.conf` 填写 为运行 taosAdapter 的服务器的域名或 IP 地址, 填写 taosAdapter 支持接收 icinga2 数据的相应端口(默认为 6048) +- Enable opentsdb-writer for icinga2 (refer to the link https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer) +- Modify the configuration file `/etc/icinga2/features-enabled/opentsdb.conf` by filling in as the domain name or IP address of the server running taosAdapter and as the corresponding port on which taosAdapter supports receiving icinga2 data (default is 6048) ``` object OpenTsdbWriter "opentsdb" { @@ -33,7 +35,7 @@ object OpenTsdbWriter "opentsdb" { } ``` -实例文件: +Example file: ``` object OpenTsdbWriter "opentsdb" { diff --git a/docs-en/14-reference/_prometheus.mdx b/docs-en/14-reference/_prometheus.mdx index be73d95cbc001727ee1ea60759f37e0a836643c2..0059fe53fcbb766f43d2f2580e2ab299f3a79cf8 100644 --- a/docs-en/14-reference/_prometheus.mdx +++ b/docs-en/14-reference/_prometheus.mdx @@ -1,18 +1,18 @@ -配置 Prometheus 是通过编辑 Prometheus 配置文件 prometheus.yml (默认位置 /etc/prometheus/prometheus.yml)完成的。 +Configuring Prometheus is done by editing the Prometheus configuration file prometheus.yml (default location /etc/prometheus/prometheus.yml). -### 配置第三方数据库地址 +### Configuring third-party database addresses -将其中的 remote_read url 和 remote_write url 指向运行 taosAdapter 服务的服务器域名或 IP 地址,REST 服务端口(taosAdapter 默认使用 6041),以及希望写入 TDengine 的数据库名称,并确保相应的 URL 形式如下: +Point the `remote_read url` and `remote_write url` to the domain name or IP address of the server running the taosAdapter service, the REST service port (taosAdapter uses 6041 by default), and the name of the database you want to write to TDengine, and ensure that the corresponding URL form as follows. - remote_read url : `http://:/prometheus/v1/remote_read/` - remote_write url : `http://:/prometheus/v1/remote_write/` -### 配置 Basic 验证 +### Configure Basic authentication -- username: -- password: +- username: +- password: -### prometheus.yml 文件中 remote_write 和 remote_read 相关部分配置示例 +### Example configuration of remote_write and remote_read related sections in prometheus.yml file ```yaml remote_write: diff --git a/docs-en/14-reference/_statsd.mdx b/docs-en/14-reference/_statsd.mdx index b225c44267d7ae32e3845972f683f664e11e9cae..403aff297c22958e0717381676f74ed8822c02ea 100644 --- a/docs-en/14-reference/_statsd.mdx +++ b/docs-en/14-reference/_statsd.mdx @@ -1,8 +1,8 @@ -### 配置 taosAdapter +### Configuring taosAdapter -配置 taosAdapter 接收 StatsD 数据的方法: +To configure taosAdapter to receive StatsD data. -- 在 taosAdapter 配置文件(默认位置 /etc/taos/taosadapter.toml)中使能配置项 +- Enable the configuration item in the taosAdapter configuration file (default location /etc/taos/taosadapter.toml) ``` ... @@ -25,30 +25,30 @@ deleteTimings = true ... ``` -其中 taosAdapter 默认写入的数据库名称为 `statsd`,也可以修改 taosAdapter 配置文件 db 项来指定不同的名称。user 和 password 填写实际 TDengine 配置的值。修改过配置文件 taosAdapter 需重新启动。 +The default database name written by taosAdapter is `statsd`. To specify a different name, you can also modify the taosAdapter configuration file db entry. user and password fill in the actual TDengine configuration values. After changing the configuration file, you need to restart the taosAdapter. -- 也可以使用 taosAdapter 命令行参数或设置环境变量启动的方式,使能 taosAdapter 接收 StatsD 数据功能,具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) +- You can also enable taosAdapter to receive StatsD data by using the taosAdapter command line parameters or setting environment variables. -### 配置 StatsD +### Configuring StatsD -使用 StatsD 需要下载其[源代码](https://github.com/statsd/statsd)。其配置文件请参考其源代码下载到本地的根目录下的示例文件 `exampleConfig.js` 进行修改。其中 填写运行 taosAdapter 的服务器域名或 IP 地址,请填写 taosAdapter 接收 StatsD 数据的端口(默认为 6044)。 +To use StatsD, you need to download its [source code](https://github.com/statsd/statsd). Please refer to the example file `exampleConfig.js` in the root directory of the source download to modify the configuration file. In , please fill in the domain name or IP address of the server running taosAdapter, and , please fill in the port where taosAdapter receives StatsD data (default is 6044). ``` -backends 部分添加 "./backends/repeater" -repeater 部分添加 { host:'', port: } +backends section add ". /backends/repeater" +Add { host:'', port: } to repeater section ``` -示例配置文件: +Example configuration file. ``` { port: 8125 -, backends: ["./backends/repeater"] +, backends: [". /backends/repeater"] , repeater: [{ host: '127.0.0.1', port: 6044}] } ``` -增加如下内容后启动 StatsD(假设配置文件修改为 config.js)。 +Start StatsD after adding the following (assuming the config file is modified to config.js) ``` node stats.js config.js & diff --git a/docs-en/14-reference/_tcollector.mdx b/docs-en/14-reference/_tcollector.mdx index 8e51975b512d658e27a53b469d981e1c85a871dc..b96c981b4294c15d3fe0afde9e0642f619413637 100644 --- a/docs-en/14-reference/_tcollector.mdx +++ b/docs-en/14-reference/_tcollector.mdx @@ -1,9 +1,8 @@ +### Configuring taosAdapter -### 配置 taosAdapter +To configure taosAdapter to receive TCollector data. -配置 taosAdapter 接收 TCollector 数据的方法: - -- 在 taosAdapter 配置文件(默认位置 /etc/taos/taosadapter.toml)中使能配置项 +- Enable the configuration item in the taosAdapter configuration file (default location /etc/taos/taosadapter.toml) ``` ... @@ -18,17 +17,17 @@ password = "taosdata" ... ``` -其中 taosAdapter 默认写入的数据库名称为 `tcollector`,也可以修改 taosAdapter 配置文件 dbs 项来指定不同的名称。user 和 password 填写实际 TDengine 配置的值。修改过配置文件 taosAdapter 需重新启动。 +The taosAdapter writes to the database with the default name `tcollector`. You can also modify the taosAdapter configuration file dbs entry to specify a different name. user and password fill in the actual TDengine configuration values. After changing the configuration file, you need to restart the taosAdapter. -- 也可以使用 taosAdapter 命令行参数或设置环境变量启动的方式,使能 taosAdapter 接收 tcollector 数据功能,具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) +- You can also enable taosAdapter to receive tcollector data by using the taosAdapter command line parameters or setting environment variables. -### 配置 TCollector +### Configuring TCollector -使用 TCollector 需下载其[源代码](https://github.com/OpenTSDB/tcollector)。其配置项在其源代码中。注意:TCollector 各个版本区别较大,这里仅以当前 master 分支最新代码 (git commit: 37ae920) 为例。 +To use TCollector, you need to download its [source code](https://github.com/OpenTSDB/tcollector). Its configuration items are in its source code. Note: TCollector differs significantly from version to version, so here is an example of the latest code for the current master branch (git commit: 37ae920). -修改 `collectors/etc/config.py` 和 `tcollector.py` 两个文件中相应内容。将原指向 OpenTSDB 宿主机的地址修改为 taosAdapter 被部署的服务器域名或 IP 地址,修改端口为 taosAdapter 支持 TCollector 使用的相应端口(默认为 6049)。 +Modify the contents of the `collectors/etc/config.py` and `tcollector.py` files. Change the address of the OpenTSDB host to the domain name or IP address of the server where taosAdapter is deployed, and change the port to the port that taosAdapter supports TCollector on (default is 6049). -示例为源代码修改内容的 git diff 输出: +Example of git diff output of source code changes. ``` index e7e7a1c..ec3e23c 100644 diff --git a/docs-en/14-reference/_telegraf.mdx b/docs-en/14-reference/_telegraf.mdx index bae46d66062ad7d5bfc2487900c02bd7a19ce4f6..423e9c6b835e99eb0582e82c5903b8eb399e0832 100644 --- a/docs-en/14-reference/_telegraf.mdx +++ b/docs-en/14-reference/_telegraf.mdx @@ -1,5 +1,5 @@ -在 Telegraf 配置文件(默认位置 /etc/telegraf/telegraf.conf) 增加 outputs.http 输出模块配置: +In the Telegraf configuration file (default location /etc/telegraf/telegraf.conf) add the outputs.http output module configuration. ``` [[outputs.http]] @@ -10,9 +10,9 @@ ... ``` -其中 请填写运行 taosAdapter 服务的服务器域名或 IP 地址, 请填写 REST 服务的端口(默认为 6041), 请填写当前运行的 TDengine 实际配置, 请填写希望在 TDengine 保存 Telegraf 数据的数据库名。 +Where please fill in the server's domain name or IP address running the taosAdapter service. please fill in the port of the REST service (default is 6041). and please fill in the actual configuration of the currently running TDengine. And please fill in the database name where you want to store Telegraf data in TDengine. -示例如下: +An example is as follows. ``` [[outputs.http]] diff --git a/docs-en/14-reference/index.md b/docs-en/14-reference/index.md new file mode 100644 index 0000000000000000000000000000000000000000..788f83efe4aa84da3d1fc1cc6cb450110f2198c7 --- /dev/null +++ b/docs-en/14-reference/index.md @@ -0,0 +1,12 @@ +--- +title: Reference +--- + +参考指南是对 TDengine 本身、 TDengine 各语言连接器及自带的工具最详细的介绍。 + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-en/20-third-party/01-grafana.mdx b/docs-en/20-third-party/01-grafana.mdx index 569cd750475447c9c6d107949c99b9405867916e..c1bfd4a96a4576df8570d8b480d5c2afe47e20b8 100644 --- a/docs-en/20-third-party/01-grafana.mdx +++ b/docs-en/20-third-party/01-grafana.mdx @@ -3,93 +3,101 @@ sidebar_label: Grafana title: Grafana --- -TDengine 能够与开源数据可视化系统 [Grafana](https://www.grafana.com/) 快速集成搭建数据监测报警系统,整个过程无需任何代码开发,TDengine 中数据表的内容可以在仪表盘(DashBoard)上进行可视化展现。关于 TDengine 插件的使用您可以在[GitHub](https://github.com/taosdata/grafanaplugin/blob/master/README.md)中了解更多。 +TDengine can be quickly integrated with the open-source data visualization system [Grafana](https://www.grafana.com/) to build a data monitoring and alerting system. The whole process does not require any code development. And you can visualize the contents of the data tables in TDengine on a DashBoard. -## 安装 Grafana +You can learn more about using the TDengine plugin on [GitHub](https://github.com/taosdata/grafanaplugin/blob/master/README.md). -目前 TDengine 支持 Grafana 7.0 以上的版本。用户可以根据当前的操作系统,到 Grafana 官网下载安装包,并执行安装。下载地址如下:。 +## Prerequisites -## 配置 Grafana +In order for Grafana to add the TDengine data source successfully, the following preparations are required: +1. The TDengine cluster is deployed and functioning properly +2. taosAdapter is installed and running properly. Please refer to the taosAdapter manual for details. -TDengine 的 Grafana 插件托管在 GitHub,可从 下载,当前最新版本为 3.1.4。 +## Installing Grafana -推荐使用 [`grafana-cli` 命令行工具](https://grafana.com/docs/grafana/latest/administration/cli/) 进行插件安装。 +TDengine currently supports Grafana versions 7.0 and above. Users can go to the Grafana official website to download the installation package and execute the installation according to the current operating system. The download address is as follows: . -```bash +## Configuring Grafana + +You can download The Grafana plugin for TDengine from . The current latest version is 3.1.4. + +Recommend using the [``grafana-cli`` command-line tool](https://grafana.com/docs/grafana/latest/administration/cli/) for plugin installation. + +``bash sudo -u grafana grafana-cli \ --pluginUrl https://github.com/taosdata/grafanaplugin/releases/download/v3.1.4/tdengine-datasource-3.1.4.zip \ plugins install tdengine-datasource ``` -或者下载到本地并解压到 Grafana 插件目录。 +Or download it locally and extract it to the Grafana plugin directory. ```bash GF_VERSION=3.1.4 wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip ``` -以 CentOS 7.2 操作系统为例,将插件包解压到 /var/lib/grafana/plugins 目录下,重新启动 grafana 即可。 +Take CentOS 7.2 for example, extract the plugin package to /var/lib/grafana/plugins directory, and restart grafana. ```bash sudo unzip tdengine-datasource-$GF_VERSION.zip -d /var/lib/grafana/plugins/ ``` -Grafana 7.3+ / 8.x 版本会对插件进行签名检查,因此还需要在 grafana.ini 文件中增加如下行,才能正确使用插件: +Grafana versions 7.3+ / 8.x do signature checks on plugins, so you also need to add the following line to the grafana.ini file to use the plugin correctly. ```ini [plugins] allow_loading_unsigned_plugins = tdengine-datasource ``` -在 Docker 环境下,可以使用如下的环境变量设置自动安装并设置 TDengine 插件: +The TDengine plugin can be automatically installed and set up using the following environment variable settings in a Docker environment. ```bash -GF_INSTALL_PLUGINS=https://github.com/taosdata/grafanaplugin/releases/download/v3.1.4/tdengine-datasource-3.1.4.zip;tdengine-datasource +GF_INSTALL_PLUGINS=https://github.com/taosdata/grafanaplugin/releases/download/v3.1.4/tdengine-datasource-3.1.4.zip;tdengine- datasource GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=tdengine-datasource ``` -## 使用 Grafana +## Using Grafana -### 配置数据源 +### Configuring Data Sources -用户可以直接通过 http://localhost:3000 的网址,登录 Grafana 服务器(用户名/密码:admin/admin),通过左侧 `Configuration -> Data Sources` 可以添加数据源,如下图所示: +Users can log in to the Grafana server (username/password: admin/admin) directly through the URL `http://localhost:3000` and add a datasource through `Configuration -> Data Sources` on the left side, as shown in the following figure. -![img](/img/connections/add_datasource1.jpg) +![img](./grafana/add_datasource1.jpg) -点击 `Add data source` 可进入新增数据源页面,在查询框中输入 TDengine 可选择添加,如下图所示: +Click `Add data source` to enter the Add data source page, and enter TDengine in the query box to add it, as shown in the following figure. -![img](/img/connections/add_datasource2.jpg) +![img](./grafana/add_datasource2.jpg) -进入数据源配置页面,按照默认提示修改相应配置即可: +Enter the datasource configuration page, and follow the default prompts to modify the corresponding configuration. -![img](/img/connections/add_datasource3.jpg) +![img](./grafana/add_datasource3.jpg) -- Host: TDengine 集群中提供 REST 服务 (在 2.4 之前由 taosd 提供, 从 2.4 开始由 taosAdapter 提供)的组件所在服务器的 IP 地址与 TDengine REST 服务的端口号(6041),默认 http://localhost:6041。 -- User:TDengine 用户名。 -- Password:TDengine 用户密码。 +- Host: IP address of the server where the components of the TDengine cluster provide REST service (offered by taosd before 2.4 and by taosAdapter since 2.4) and the port number of the TDengine REST service (6041), by default use `http://localhost:6041`. +- User: TDengine user name. +- Password: TDengine user password. -点击 `Save & Test` 进行测试,成功会有如下提示: +Click `Save & Test` to test. Follows are a success. -![img](/img/connections/add_datasource4.jpg) +![img](./grafana/add_datasource4.jpg) -### 创建 Dashboard +### Create Dashboard -回到主界面创建 Dashboard,点击 Add Query 进入面板查询页面: +Go back to the main interface to create the Dashboard, click Add Query to enter the panel query page: -![img](/img/connections/create_dashboard1.jpg) +![img](./grafana/create_dashboard1.jpg) -如上图所示,在 Query 中选中 `TDengine` 数据源,在下方查询框可输入相应 sql 进行查询,具体说明如下: +As shown above, select the `TDengine` data source in the `Query` and enter the corresponding SQL in the query box below for query. -- INPUT SQL:输入要查询的语句(该 SQL 语句的结果集应为两列多行),例如:`select avg(mem_system) from log.dn where ts >= $from and ts < $to interval($interval)` ,其中,from、to 和 interval 为 TDengine 插件的内置变量,表示从 Grafana 插件面板获取的查询范围和时间间隔。除了内置变量外,`也支持可以使用自定义模板变量`。 -- ALIAS BY:可设置当前查询别名。 -- GENERATE SQL: 点击该按钮会自动替换相应变量,并生成最终执行的语句。 +- INPUT SQL: enter the statement to be queried (the result set of the SQL statement should be two columns and multiple rows), for example: `select avg(mem_system) from log.dn where ts >= $from and ts < $to interval($interval)`, where, from, to and interval are built-in variables of the TDengine plugin, indicating the range and time interval of queries fetched from the Grafana plugin panel. In addition to the built-in variables, ` custom template variables are also supported. +- ALIAS BY: This allows you to set the current query alias. +- GENERATE SQL: Clicking this button will automatically replace the corresponding variables and generate the final executed statement. -按照默认提示查询当前 TDengine 部署所在服务器指定间隔系统内存平均使用量如下: +Follow the default prompt to query the average system memory usage for the specified interval on the server where the current TDengine deployment is located as follows. -![img](/img/connections/create_dashboard2.jpg) +![img](./grafana/create_dashboard2.jpg) -> 关于如何使用 Grafana 创建相应的监测界面以及更多有关使用 Grafana 的信息,请参考 Grafana 官方的[文档](https://grafana.com/docs/)。 +> For more information on how to use Grafana to create the appropriate monitoring interface and for more details on using Grafana, refer to the official Grafana [documentation](https://grafana.com/docs/). -### 导入 Dashboard +### Importing the Dashboard -在 2.3.3.0 及以上版本,您可以导入 TDinsight Dashboard (Grafana Dashboard ID: [15167](https://grafana.com/grafana/dashboards/15167)) 作为 TDengine 集群的监控可视化工具。安装和使用说明请见 [TDinsight 用户手册](/reference/tdinsight/)。 +In version 2.3.3.0 and above, you can import the TDinsight Dashboard (Grafana Dashboard ID: [15168](https://grafana.com/grafana/dashboards/15167)) as a monitoring visualization tool for TDengine clusters. You can find installation and usage instructions in the TDinsight User Manual (/reference/tdinsight/). diff --git a/docs-en/20-third-party/02-prometheus.md b/docs-en/20-third-party/02-prometheus.md index 0fe534b8df263064e5269e1732b69893efd7a79a..0fb41a169632a9d2775dfb3f48ea7254cf9a8558 100644 --- a/docs-en/20-third-party/02-prometheus.md +++ b/docs-en/20-third-party/02-prometheus.md @@ -1,31 +1,33 @@ --- sidebar_label: Prometheus -title: Prometheus +title: Prometheus writing and reading --- import Prometheus from "../14-reference/_prometheus.mdx" -Prometheus 是一款流行的开源监控告警系统。Prometheus 于2016年加入了 Cloud Native Computing Foundation (云原生云计算基金会,简称 CNCF),成为继 Kubernetes 之后的第二个托管项目,该项目拥有非常活跃的开发人员和用户社区。 +Prometheus is a widespread open-source monitoring and alerting system. Prometheus joined the Cloud Native Computing Foundation (CNCF) in 2016 as the second incubated project after Kubernetes, which has a very active developer and user community. -Prometheus 提供了 `remote_write` 和 `remote_read` 接口来利用其它数据库产品作为它的存储引擎。为了让 Prometheus 生态圈的用户能够利用 TDengine 的高效写入和查询,TDengine 也提供了对这两个接口的支持。 +Prometheus provides `remote_write` and `remote_read` interfaces to leverage other database products as its storage engine. To enable users of the Prometheus ecosystem to take advantage of TDengine's efficient writing and querying, TDengine also provides support for these two interfaces. -通过适当的配置, Prometheus 的数据可以通过 `remote_write` 接口存储到 TDengine 中,也可以通过 `remote_read` 接口来查询存储在 TDengine 中的数据,充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 +Prometheus data can be stored in TDengine via the `remote_write` interface with proper configuration. Data stored in TDengine can be queried via the `remote_read` interface, taking full advantage of TDengine's efficient storage query performance and clustering capabilities for time-series data. -## 前置条件 +## Prerequisites -要将 Prometheus 数据写入 TDengine 需要以下几方面的准备工作。 -- TDengine 集群已经部署并正常运行 -- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) -- Prometheus 已经安装。安装 Prometheus 请参考[官方文档](https://prometheus.io/docs/prometheus/latest/installation/) +To write Prometheus data to TDengine requires the following preparations. +- The TDengine cluster is deployed and functioning properly +- taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details. +- Prometheus has been installed. Please refer to the [official documentation](https://prometheus.io/docs/prometheus/latest/installation/) for installing Prometheus + +## Configuration steps -## 配置步骤 -## 验证方法 +## Verification method + +After restarting Prometheus, you can refer to the following example to verify that data is written from Prometheus to TDengine and can read out correctly. -重启 Prometheus 后可参考以下示例验证从 Prometheus 向 TDengine 写入数据并能够正确读出。 +### Query and write data using TDengine CLI -### 使用 TDengine CLI 查询写入数据 ``` taos> show databases; name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | @@ -61,15 +63,15 @@ taos> select * from metrics limit 10; Query OK, 10 row(s) in set (0.011146s) ``` -### 使用 promql-cli 通过 remote_read 从 TDengine 读取数据 +### Use promql-cli to read data from TDengine via remote_read -安装 promql-cli +Install promql-cli ``` go install github.com/nalbury/promql-cli@latest ``` -在 TDengine 和 taosAdapter 服务运行状态对 Prometheus 数据进行查询 +Query Prometheus data in the running state of TDengine and taosAdapter services ``` ubuntu@shuduo-1804 ~ $ promql-cli --host "http://127.0.0.1:9090" "sum(up) by (job)" @@ -78,7 +80,7 @@ prometheus 1 2022-04-20T08:05:26Z node 1 2022-04-20T08:05:26Z ``` -暂停 taosAdapter 服务后对 Prometheus 数据进行查询 +Stop taosAdapter service and query Prometheus data to verify ``` ubuntu@shuduo-1804 ~ $ sudo systemctl stop taosadapter.service diff --git a/docs-en/20-third-party/03-telegraf.md b/docs-en/20-third-party/03-telegraf.md index 88a69211c0592940d7f75d34c03bcc0593cd74d6..0d563c9ff36268ac27e18e21fefed789789dc1a7 100644 --- a/docs-en/20-third-party/03-telegraf.md +++ b/docs-en/20-third-party/03-telegraf.md @@ -1,33 +1,33 @@ --- sidebar_label: Telegraf -title: Telegraf 写入 +title: Telegraf writing --- import Telegraf from "../14-reference/_telegraf.mdx" -Telegraf 是一款十分流行的指标采集开源软件。在数据采集和平台监控系统中,Telegraf 可以采集多种组件的运行信息,而不需要自己手写脚本定时采集,降低数据获取的难度。 +Telegraf is a viral metrics collection open-source software. Telegraf can collect the operation information of various components without writing any scripts to collect regularly, reducing the difficulty of data acquisition. -只需要将 Telegraf 的输出配置增加指向 taosAdapter 对应的 url 并修改若干配置项即可将 Telegraf 的数据写入到 TDengine 中。将 Telegraf 的数据存在到 TDengine 中可以充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 +Telegraf's data can be written to TDengine by simply adding the output configuration of Telegraf to the URL corresponding to taosAdapter and modifying several configuration items. The presence of Telegraf data in TDengine can take advantage of TDengine's efficient storage query performance and clustering capabilities for time-series data. -## 前置条件 +## Prerequisites -要将 Telegraf 数据写入 TDengine 需要以下几方面的准备工作。 -- TDengine 集群已经部署并正常运行 -- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) -- Telegraf 已经安装。安装 Telegraf 请参考[官方文档](https://docs.influxdata.com/telegraf/v1.22/install/) +To write Telegraf data to TDengine requires the following preparations. +- The TDengine cluster is deployed and functioning properly +- taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details. +- Telegraf has been installed. Please refer to the [official documentation](https://docs.influxdata.com/telegraf/v1.22/install/) for Telegraf installation. -## 配置步骤 +## Configuration steps -## 验证方法 +## Verification method -重启 Telegraf 服务: +Restart Telegraf service: ``` sudo systemctl restart telegraf ``` -使用 TDengine CLI 验证从 Telegraf 向 TDengine 写入数据并能够正确读出: +Use TDengine CLI to verify Telegraf correctly writing data to TDengine and read out: ``` taos> show databases; diff --git a/docs-en/20-third-party/05-collectd.md b/docs-en/20-third-party/05-collectd.md index 04892fd42e92e962fcccadf626f67c432e78d286..609e55842ab35cdc2d394663f5450f908e49f7f7 100644 --- a/docs-en/20-third-party/05-collectd.md +++ b/docs-en/20-third-party/05-collectd.md @@ -1,33 +1,34 @@ --- sidebar_label: collectd -title: collectd 写入 +title: collectd writing --- import CollectD from "../14-reference/_collectd.mdx" -collectd 是一个用来收集系统性能的守护进程。collectd 提供各种存储方式来存储不同值的机制。它会在系统运行和存储信息时周期性的统计系统的相关统计信息。利用这些信息有助于查找当前系统性能瓶颈和预测系统未来的负载等。 -只需要将 collectd 的配置指向运行 taosAdapter 的服务器域名(或 IP 地址)和相应端口即可将 collectd 采集的数据写入到 TDengine,可以充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 +collectd is a daemon used to collect system performance metric data. collectd provides various storage mechanisms to store different values. It periodically counts system performance statistics number while the system is running and storing information. You can use this information to help identify current system performance bottlenecks and predict future system load. -## 前置条件 +You can write the data collected by collectd to TDengine by simply modifying the configuration of collectd to the domain name (or IP address) and corresponding port of the server running taosAdapter. It can take full advantage of TDengine's efficient storage query performance and clustering capability for time-series data. -要将 collectd 数据写入 TDengine,需要几方面的准备工作。 -- TDengine 集群已经部署并正常运行 -- taosAdapter 已经安装并正常运行,具体细节请参考[ taosAdapter 的使用手册](/reference/taosadapter) -- collectd 已经安装。安装 collectd 请参考[官方文档](https://collectd.org/download.shtml) +## Prerequisites -## 配置步骤 +Writing collectd data to the TDengine requires several preparations. +- The TDengine cluster is deployed and running properly +- taosAdapter is installed and running, please refer to [taosAdapter's manual](/reference/taosadapter) for details +- collectd has been installed. Please refer to the [official documentation](https://collectd.org/download.shtml) to install collectd + +## Configuration steps -## 验证方法 +## Verification method -重启 collectd +Restart collectd ``` sudo systemctl restart collectd ``` -使用 TDengine CLI 验证从 collectd 向 TDengine 写入数据并能够正确读出: +Use the TDengine CLI to verify that collectd's data is written to TDengine and can read out correctly. ``` taos> show databases; diff --git a/docs-en/20-third-party/06-statsd.md b/docs-en/20-third-party/06-statsd.md index bcbd6c42ae5dd1c83be428797544d254e11a0238..bf4b6c7ab5dac4114cad0d650b2aeb026a67581c 100644 --- a/docs-en/20-third-party/06-statsd.md +++ b/docs-en/20-third-party/06-statsd.md @@ -1,27 +1,27 @@ --- sidebar_label: StatsD -title: StatsD 直接写入 +title: StatsD writing --- import StatsD from "../14-reference/_statsd.mdx" -StatsD 是汇总和总结应用指标的一个简单的守护进程,近些年来发展迅速,已经变成了一个用于收集应用性能指标的统一的协议。 +StatsD is a simple daemon for aggregating application metrics, which has evolved rapidly in recent years into a unified protocol for collecting application performance metrics. -只需要在 StatsD 的配置文件中填写运行 taosAdapter 的服务器域名(或 IP 地址)和相应端口即可将 StatsD 的数据写入到 TDengine 中,可以充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 +You can write StatsD data to TDengine by simply modifying in the configuration file of StatsD with the domain name (or IP address) of the server running taosAdapter and the corresponding port. It can take full advantage of TDengine's efficient storage query performance and clustering capabilities for time-series data. -## 前置条件 +## Prerequisites -要将 StatsD 数据写入 TDengine 需要以下几方面的准备工作。 -- TDengine 集群已经部署并正常运行 -- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) -- StatsD 已经安装。安装 StatsD 请参考[官方文档](https://github.com/statsd/statsd) +To write StatsD data to TDengine requires the following preparations. +- The TDengine cluster has been deployed and is working properly +- taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details. +- StatsD has been installed. To install StatsD, please refer to [official documentation](https://github.com/statsd/statsd) -## 配置步骤 +## Configuration steps -## 验证方法 +## Verification method -运行 StatsD: +Start StatsD: ``` $ node stats.js config.js & @@ -30,13 +30,13 @@ $ 20 Apr 09:54:41 - [8546] reading config file: exampleConfig.js 20 Apr 09:54:41 - server is up INFO ``` -使用 nc 写入测试数据: +Using the utility software `nc` to write data for test: ``` $ echo "foo:1|c" | nc -u -w0 127.0.0.1 8125 ``` -使用 TDengine CLI 验证从 StatsD 向 TDengine 写入数据并能够正确读出: +Use the TDengine CLI to verify that StatsD data is written to TDengine and can read out correctly. ``` Welcome to the TDengine shell from Linux, Client Version:2.4.0.0 diff --git a/docs-en/20-third-party/07-icinga2.md b/docs-en/20-third-party/07-icinga2.md index ed1f1404a730eca5f51e2ff9bbcd54949018f8ea..ba9cde8cea7504ac9df871d5f6aa42cc5c94d895 100644 --- a/docs-en/20-third-party/07-icinga2.md +++ b/docs-en/20-third-party/07-icinga2.md @@ -1,38 +1,38 @@ --- sidebar_label: icinga2 -title: icinga2 写入 +title: icinga2 writing --- import Icinga2 from "../14-reference/_icinga2.mdx" -icinga2 是一款开源主机、网络监控软件,最初由 Nagios 网络监控应用发展而来。目前,icinga2 遵从 GNU GPL v2 许可协议发行。 +icinga2 is an open-source software monitoring host and network initially developed from the Nagios network monitoring application. Currently, icinga2 is distributed under the GNU GPL v2 license. -只需要将 icinga2 的配置修改指向 taosAdapter 对应的服务器和相应端口即可将 icinga2 采集的数据存在到 TDengine 中,可以充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 +You can write the data collected by icinga2 to TDengine by simply modifying the icinga2 configuration to point to the taosAdapter server and the corresponding port, taking advantage of TDengine's efficient storage and query performance and clustering capabilities for time-series data. -## 前置条件 +## Prerequisites -要将 icinga2 数据写入 TDengine 需要以下几方面的准备工作。 -- TDengine 集群已经部署并正常运行 -- taosAdapter 已经安装并正常运行。具体细节请参考[ taosAdapter 的使用手册](/reference/taosadapter) -- icinga2 已经安装。安装 icinga2 请参考[官方文档](https://icinga.com/docs/icinga-2/latest/doc/02-installation/) +To write icinga2 data to TDengine requires the following preparations. +- The TDengine cluster is deployed and working properly +- taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details. +- icinga2 has been installed. Please refer to the [official documentation](https://icinga.com/docs/icinga-2/latest/doc/02-installation/) for icinga2 installation -## 配置步骤 +## Configuration steps -## 验证方法 +## Verification method -重启 taosAdapter: +Restart taosAdapter: ``` sudo systemctl restart taosadapter ``` -重启 icinga2: +Restart icinga2: ``` sudo systemctl restart icinga2 ``` -等待 10 秒左右后,使用 TDengine CLI 查询 TDengine 验证是否创建相应数据库并写入数据: +After waiting about 10 seconds, use the TDengine CLI to query TDengine to verify that the appropriate database has been created and data are written. ``` taos> show databases; diff --git a/docs-en/20-third-party/08-tcollector.md b/docs-en/20-third-party/08-tcollector.md index 5fbf001fa093f978dfdcd0f3f344a131d56ed9f9..dc14772c183c826297fed7997fd0aa88b4deaf48 100644 --- a/docs-en/20-third-party/08-tcollector.md +++ b/docs-en/20-third-party/08-tcollector.md @@ -1,35 +1,35 @@ --- sidebar_label: TCollector -title: TCollector 写入 +title: TCollector writing --- import Tcollector from "../14-reference/_tcollector.mdx" -TCollector 是 openTSDB 的一部分,它用来采集客户端日志发送给数据库。 +TCollector is part of openTSDB and collects client computer's logs to send to the database. -只需要将 TCollector 的配置修改指向运行 taosAdapter 的服务器域名(或 IP 地址)和相应端口即可将 TCollector 采集的数据存在到 TDengine 中,可以充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 +You can write the data collected by TCollector to TDengine by simply changing the configuration of TCollector to point to the domain name (or IP address) and corresponding port of the server running taosAdapter. It can take full advantage of TDengine's efficient storage query performance and clustering capability for time-series data. -## 前置条件 +## Prerequisites -要将 TCollector 数据写入 TDengine 需要以下几方面的准备工作。 -- TDengine 集群已经部署并正常运行 -- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) -- TCollector 已经安装。安装 TCollector 请参考[官方文档](http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html#installation-of-tcollector) +To write data to the TDengine via TCollector requires the following preparations. +- The TDengine cluster has been deployed and is working properly +- taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details. +- TCollector has been installed. Please refer to [official documentation](http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html#installation-of-tcollector) for TCollector installation -## 配置步骤 +## Configuration steps -## 验证方法 +## Verification method -重启 taosAdapter: +Restart taosAdapter: ``` sudo systemctl restart taosadapter ``` -手动执行 `sudo ./tcollector.py` +Run `sudo ./tcollector.py`: -等待数秒后使用 TDengine CLI 查询 TDengine 是否创建相应数据库并写入数据。 +Wait for a few seconds and then use the TDengine CLI to query whether the corresponding database has been created and data are written in TDengine. ``` taos> show databases; diff --git a/docs-en/20-third-party/09-emq-broder.md b/docs-en/20-third-party/09-emq-broder.md deleted file mode 100644 index a661943088e2b478ff9940b6679a47c1bbb039ed..0000000000000000000000000000000000000000 --- a/docs-en/20-third-party/09-emq-broder.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -sidebar_label: EMQ Broker -title: EMQ Broker 写入 ---- - -MQTT 是流行的物联网数据传输协议,[EMQ](https://github.com/emqx/emqx)是一开源的 MQTT Broker 软件,无需任何代码,只需要在 EMQ Dashboard 里使用“规则”做简单配置,即可将 MQTT 的数据直接写入 TDengine。EMQ X 支持通过 发送到 Web 服务的方式保存数据到 TDEngine,也在企业版上提供原生的 TDEngine 驱动实现直接保存。详细使用方法请参考 [EMQ 官方文档](https://docs.emqx.io/broker/latest/cn/rule/rule-example.html#%E4%BF%9D%E5%AD%98%E6%95%B0%E6%8D%AE%E5%88%B0-tdengine)。 diff --git a/docs-en/20-third-party/09-emq-broker.md b/docs-en/20-third-party/09-emq-broker.md new file mode 100644 index 0000000000000000000000000000000000000000..dc3ef4f43f4e153dbe3a729a36196509a6f7964c --- /dev/null +++ b/docs-en/20-third-party/09-emq-broker.md @@ -0,0 +1,190 @@ +--- +sidebar_label: EMQ Broker +title: EMQ Broker writing +--- + +MQTT is a popular IoT data transfer protocol, [EMQ](https://github.com/emqx/emqx) is an open-source MQTT Broker software, without any code, only need to use "rules" in EMQ Dashboard to do simple configuration. You can write MQTT data directly to TDengine. EMQ X supports saving data to TDengine by sending it to web services and provides a native TDengine driver for direct saving in the Enterprise Edition. Please refer to the [EMQ official documentation](https://www.emqx.io/docs/en/v4.4/rule/rule-engine.html) for details on how to use it. tdengine). + +## Prerequisites + +The following preparations are required for EMQX to add TDengine data sources correctly. +- The TDengine cluster is deployed and working properly +- taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details. +- If you use the emulated writers described later, you need to install the appropriate version of Node.js. V12 is recommended. + +## Install and start EMQX + +Depending on the current operating system, users can download the installation package from the [EMQX official website](https://www.emqx.io/downloads) and execute the installation. After installation, use `sudo emqx start` or `sudo systemctl start emqx` to start the EMQX service. + +## Create the appropriate database and table schema in TDengine for receiving MQTT data + +### Take the Docker installation of TDengine as an example + +```bash + docker exec -it tdengine bash + taos +``` + +### Create Database and Table + +```sql + CREATE DATABASE test; + USE test; + + CREATE TABLE sensor_data (ts timestamp, temperature float, humidity float, volume float, PM10 float, pm25 float, SO2 float, NO2 float, CO float, sensor_id NCHAR(255), area TINYINT, coll_time timestamp); +``` + +Note: The table schema is based on the blog [(In Chinese) Data Transfer, Storage, Presentation, EMQ X + TDengine Build MQTT IoT Data Visualization Platform](https://www.taosdata.com/blog/2020/08/04/1722.html) as an example. Subsequent operations are carried out with this blog scenario too. Please modify it according to your actual application scenario. + +## Configuring EMQX Rules + +Since the configuration interface of EMQX differs from version to version, here is v4.4.3 as an example. For other versions, please refer to the corresponding official documentation. + +### Login EMQX Dashboard + +Use your browser to open the URL `http://IP:18083` and log in to EMQX Dashboard. The initial installation username is `admin` and the password is: `public`. + +![img](./emqx/login-dashboard.png) + +### Creating Rule + +Select "Rule" in the "Rule Engine" on the left and click the "Create" button: ! + +![img](./emqx/rule-engine.png) + +### Edit SQL fields + +![img](./emqx/create-rule.png) + +### Add "action handler" + +![img](./emqx/add-action-handler.png) + +### Add "Resource" + +![img](./emqx/create-resource.png) + +Select "Data to Web Service" and click the "New Resource" button. + +### Edit "Resource" + +Select "Data to Web Service" and fill in the request URL as the address and port of the server running taosAdapter (default is 6041). Leave the other properties at their default values. + +![img](./emqx/edit-resource.png) + +### Edit "action" + +Edit the resource configuration to add the key/value pairing for Authorization. Please refer to the [ TDengine REST API documentation ](https://docs.taosdata.com/reference/rest-api/) for the authorization in details. Enter the rule engine replacement template in the message body. + +![img](./emqx/edit-action.png) + +## Compose program to mock data + +```javascript + // mock.js + const mqtt = require('mqtt') + const Mock = require('mockjs') + const EMQX_SERVER = 'mqtt://localhost:1883' + const CLIENT_NUM = 10 + const STEP = 5000 // Data interval in ms + const AWAIT = 5000 // Sleep time after data be written once to avoid data writing too fast + const CLIENT_POOL = [] + startMock() + function sleep(timer = 100) { + return new Promise(resolve => { + setTimeout(resolve, timer) + }) + } + async function startMock() { + const now = Date.now() + for (let i = 0; i < CLIENT_NUM; i++) { + const client = await createClient(`mock_client_${i}`) + CLIENT_POOL.push(client) + } + // last 24h every 5s + const last = 24 * 3600 * 1000 + for (let ts = now - last; ts <= now; ts += STEP) { + for (const client of CLIENT_POOL) { + const mockData = generateMockData() + const data = { + ...mockData, + id: client.clientId, + area: 0, + ts, + } + client.publish('sensor/data', JSON.stringify(data)) + } + const dateStr = new Date(ts).toLocaleTimeString() + console.log(`${dateStr} send success.`) + await sleep(AWAIT) + } + console.log(`Done, use ${(Date.now() - now) / 1000}s`) + } + /** + * Init a virtual mqtt client + * @param {string} clientId ClientID + */ + function createClient(clientId) { + return new Promise((resolve, reject) => { + const client = mqtt.connect(EMQX_SERVER, { + clientId, + }) + client.on('connect', () => { + console.log(`client ${clientId} connected`) + resolve(client) + }) + client.on('reconnect', () => { + console.log('reconnect') + }) + client.on('error', (e) => { + console.error(e) + reject(e) + }) + }) + } + /** + * Generate mock data + */ + function generateMockData() { + return { + "temperature": parseFloat(Mock.Random.float(22, 100).toFixed(2)), + "humidity": parseFloat(Mock.Random.float(12, 86).toFixed(2)), + "volume": parseFloat(Mock.Random.float(20, 200).toFixed(2)), + "PM10": parseFloat(Mock.Random.float(0, 300).toFixed(2)), + "pm25": parseFloat(Mock.Random.float(0, 300).toFixed(2)), + "SO2": parseFloat(Mock.Random.float(0, 50).toFixed(2)), + "NO2": parseFloat(Mock.Random.float(0, 50).toFixed(2)), + "CO": parseFloat(Mock.Random.float(0, 50).toFixed(2)), + "area": Mock.Random.integer(0, 20), + "ts": 1596157444170, + } + } +``` + +Note: `CLIENT_NUM` in the code can be set to a smaller value at the beginning of the test to avoid hardware performance be not capable to handle a more significant number of concurrent clients. + +![img](./emqx/client-num.png) + +## Execute tests to simulate sending MQTT data + +``` +npm install mqtt mockjs --save ---registry=https://registry.npm.taobao.org +node mock.js +``` + +![img](./emqx/run-mock.png) + +## Verify that EMQX is receiving data + +Refresh the EMQX Dashboard rules engine interface to see how many records were received correctly: + +![img](./emqx/check-rule-matched.png) + +## Verify that data writing to TDengine + +Use the TDengine CLI program to log in and query the appropriate databases and tables to verify that the data is being written to TDengine correctly: + +![img](./emqx/check-result-in-taos.png) + +Please refer to the [TDengine official documentation](https://docs.taosdata.com/) for more details on how to use TDengine. +EMQX Please refer to the [EMQ official documentation](https://www.emqx.io/docs/en/v4.4/rule/rule-engine.html) for details on how to use EMQX. diff --git a/docs-en/20-third-party/10-hive-mq-broker.md b/docs-en/20-third-party/10-hive-mq-broker.md index f75ed793d6272ae27f92676e2096ef455f638aa6..333e00fa0e9b724ffbb067a83ad07d0b846b1a23 100644 --- a/docs-en/20-third-party/10-hive-mq-broker.md +++ b/docs-en/20-third-party/10-hive-mq-broker.md @@ -1,6 +1,6 @@ --- sidebar_label: HiveMQ Broker -title: HiveMQ Broker 写入 +title: HiveMQ Broker writing --- -[HiveMQ](https://www.hivemq.com/) 是一个提供免费个人版和企业版的 MQTT 代理,主要用于企业和新兴的机器到机器 M2M 通讯和内部传输,满足可伸缩性、易管理和安全特性。HiveMQ 提供了开源的插件开发包。可以通过 HiveMQ extension - TDengine 保存数据到 TDengine。详细使用方法请参考 [HiveMQ extension - TDengine 说明文档](https://github.com/huskar-t/hivemq-tdengine-extension/blob/b62a26ecc164a310104df57691691b237e091c89/README.md)。 +[HiveMQ](https://www.hivemq.com/) is an MQTT broker that provides community and enterprise editions. HiveMQ is mainly for enterprise emerging machine-to-machine M2M communication and internal transport, meeting scalability, ease of management, and security features. HiveMQ provides an open-source plug-in development kit. MQTT data can be saved to TDengine via TDengine extension for HiveMQ. Please refer to the [HiveMQ extension - TDengine documentation](https://github.com/huskar-t/hivemq-tdengine-extension/blob/b62a26ecc164a310104df57691691b237e091c89/README_EN.md) for details on how to use it. \ No newline at end of file diff --git a/docs-en/20-third-party/_category_.yml b/docs-en/20-third-party/_category_.yml index cf9d95e5f9e0941f64159ffa17619839fdafbf05..e71e65a6a365df63603c3878375c034b4b24db77 100644 --- a/docs-en/20-third-party/_category_.yml +++ b/docs-en/20-third-party/_category_.yml @@ -1,6 +1,2 @@ -label: 第三方工具 -link: - type: generated-index - slug: /third-party/ - description: TDengine 通过对标准 SQL 命令、常用数据库连接器标准(例如 JDBC)、ORM 以及其他流行时序数据库写入协议(例如 InfluxDB Line Protocol、OpenTSDB JSON、OpenTSDB Telnet 等)的支持可以使 TDengine 非常容易和第三方工具共同使用。 - +label: Third Party Tools + diff --git a/docs-en/20-third-party/_deploytaosadapter.mdx b/docs-en/20-third-party/_deploytaosadapter.mdx index ec40744c9a4620801e59aadd49996a0b6381f1bc..840ca7640ab3f95143c92ae61c293e5407a07b14 100644 --- a/docs-en/20-third-party/_deploytaosadapter.mdx +++ b/docs-en/20-third-party/_deploytaosadapter.mdx @@ -1,18 +1,17 @@ -### 部署taosAdapter +### Deploying taosAdapter -taosAdapter 可以和 TDengine 部署在同一个系统中,也可以分离部署。 +taosAdapter can be deployed on the same system as TDengine, or separately. -启动 taosAdapter: +To start taosAdapter. ``` systemctl start taosadapter ``` -检查 taosAdapter 的运行状态: +Check the running status of taosAdapter. ``` systemctl status taosadapter ``` -taosAdapter 详细的配置参数和使用请参考 `taosadapter --help` 命令输出以及 [参考文档](/reference/taosadapter) 。 - +taosAdapter Please refer to the `taosadapter --help` command output and [reference documentation](/reference/taosadapter) for detailed configuration parameters and usage of taosAdapter. diff --git a/docs-en/20-third-party/emqx/add-action-handler.png b/docs-en/20-third-party/emqx/add-action-handler.png new file mode 100644 index 0000000000000000000000000000000000000000..97a1f933ecfadfcab399938806d73c5a5ecc6427 Binary files /dev/null and b/docs-en/20-third-party/emqx/add-action-handler.png differ diff --git a/docs-en/20-third-party/emqx/check-result-in-taos.png b/docs-en/20-third-party/emqx/check-result-in-taos.png new file mode 100644 index 0000000000000000000000000000000000000000..c17a5c1ea2b9bbd49263056c8bf09c9aabab07d5 Binary files /dev/null and b/docs-en/20-third-party/emqx/check-result-in-taos.png differ diff --git a/docs-en/20-third-party/emqx/check-rule-matched.png b/docs-en/20-third-party/emqx/check-rule-matched.png new file mode 100644 index 0000000000000000000000000000000000000000..9e9a466946a1afa857e2bbc07b14956dd0f984b6 Binary files /dev/null and b/docs-en/20-third-party/emqx/check-rule-matched.png differ diff --git a/docs-en/20-third-party/emqx/client-num.png b/docs-en/20-third-party/emqx/client-num.png new file mode 100644 index 0000000000000000000000000000000000000000..fff48cbf3b271c367079ddde425b3f9b014062f7 Binary files /dev/null and b/docs-en/20-third-party/emqx/client-num.png differ diff --git a/docs-en/20-third-party/emqx/create-resource.png b/docs-en/20-third-party/emqx/create-resource.png new file mode 100644 index 0000000000000000000000000000000000000000..58da4c391a3692b9f5fa348d952701eab8bcb746 Binary files /dev/null and b/docs-en/20-third-party/emqx/create-resource.png differ diff --git a/docs-en/20-third-party/emqx/create-rule.png b/docs-en/20-third-party/emqx/create-rule.png new file mode 100644 index 0000000000000000000000000000000000000000..73b0b6ee3e6065a142df98abe8c0dbb32b34f89d Binary files /dev/null and b/docs-en/20-third-party/emqx/create-rule.png differ diff --git a/docs-en/20-third-party/emqx/edit-action.png b/docs-en/20-third-party/emqx/edit-action.png new file mode 100644 index 0000000000000000000000000000000000000000..2a43ee369a439cf11cee23c11f25d6a84b26d7dc Binary files /dev/null and b/docs-en/20-third-party/emqx/edit-action.png differ diff --git a/docs-en/20-third-party/emqx/edit-resource.png b/docs-en/20-third-party/emqx/edit-resource.png new file mode 100644 index 0000000000000000000000000000000000000000..0a0b3560044f4ed6e0a8f040b74085a7e8948b1f Binary files /dev/null and b/docs-en/20-third-party/emqx/edit-resource.png differ diff --git a/docs-en/20-third-party/emqx/login-dashboard.png b/docs-en/20-third-party/emqx/login-dashboard.png new file mode 100644 index 0000000000000000000000000000000000000000..d6c5035c98d860faf639ef6611c6719adf80c47b Binary files /dev/null and b/docs-en/20-third-party/emqx/login-dashboard.png differ diff --git a/docs-en/20-third-party/emqx/rule-engine.png b/docs-en/20-third-party/emqx/rule-engine.png new file mode 100644 index 0000000000000000000000000000000000000000..db110a837b024c82ee9d22f02dcd3a9d06abdd55 Binary files /dev/null and b/docs-en/20-third-party/emqx/rule-engine.png differ diff --git a/docs-en/20-third-party/emqx/rule-header-key-value.png b/docs-en/20-third-party/emqx/rule-header-key-value.png new file mode 100644 index 0000000000000000000000000000000000000000..b81b9a9684aa2f98d00b7ec21e5de411fb450312 Binary files /dev/null and b/docs-en/20-third-party/emqx/rule-header-key-value.png differ diff --git a/docs-en/20-third-party/emqx/run-mock.png b/docs-en/20-third-party/emqx/run-mock.png new file mode 100644 index 0000000000000000000000000000000000000000..0da25818575247732d5d3a783aa52cf7ce24662c Binary files /dev/null and b/docs-en/20-third-party/emqx/run-mock.png differ diff --git a/docs-en/20-third-party/grafana/add_datasource1.jpg b/docs-en/20-third-party/grafana/add_datasource1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1f0f5110f312c57f3ec1788bbc02f04fac6ac142 Binary files /dev/null and b/docs-en/20-third-party/grafana/add_datasource1.jpg differ diff --git a/docs-en/20-third-party/grafana/add_datasource2.jpg b/docs-en/20-third-party/grafana/add_datasource2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fa7a83e00e96fae649910dff4edf5f5bdadd7850 Binary files /dev/null and b/docs-en/20-third-party/grafana/add_datasource2.jpg differ diff --git a/docs-en/20-third-party/grafana/add_datasource3.jpg b/docs-en/20-third-party/grafana/add_datasource3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fc850ad08ff1174de972906842e0d5ee64e6e5cb Binary files /dev/null and b/docs-en/20-third-party/grafana/add_datasource3.jpg differ diff --git a/docs-en/20-third-party/grafana/add_datasource4.jpg b/docs-en/20-third-party/grafana/add_datasource4.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3ba73e50d455111f8621f4165746078554c2d790 Binary files /dev/null and b/docs-en/20-third-party/grafana/add_datasource4.jpg differ diff --git a/docs-en/20-third-party/grafana/create_dashboard1.jpg b/docs-en/20-third-party/grafana/create_dashboard1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3b83c3a1714e9e7540e0b06239ef7c1c4f63fe2c Binary files /dev/null and b/docs-en/20-third-party/grafana/create_dashboard1.jpg differ diff --git a/docs-en/20-third-party/grafana/create_dashboard2.jpg b/docs-en/20-third-party/grafana/create_dashboard2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fe5d768ac55254251e0290bf257178f5ff28f5a5 Binary files /dev/null and b/docs-en/20-third-party/grafana/create_dashboard2.jpg differ diff --git a/docs-en/20-third-party/index.md b/docs-en/20-third-party/index.md new file mode 100644 index 0000000000000000000000000000000000000000..45f70abc844eb3022e786fbf023b82fc06f22367 --- /dev/null +++ b/docs-en/20-third-party/index.md @@ -0,0 +1,12 @@ +--- +title: Third Party Tools +--- + +TDengine's support for standard SQL commands, common database connector standards (e.g., JDBC), ORM, and other popular time-series database writing protocols (e.g., InfluxDB Line Protocol, OpenTSDB JSON, OpenTSDB Telnet, etc.) makes TDengine very easy to use with third-party tools. + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-en/21-tdinternal/01-arch.md b/docs-en/21-tdinternal/01-arch.md index 84f6d239dd9fb347a4850966d391cb0b629a7944..2d4aa6c3dcc07e1d95c13560d04844eceb4b9dd8 100644 --- a/docs-en/21-tdinternal/01-arch.md +++ b/docs-en/21-tdinternal/01-arch.md @@ -1,302 +1,285 @@ --- -sidebar_label: 整体架构 -title: 整体架构 +sidebar_label: Architecture +title: Architecture --- -## 集群与基本逻辑单元 +## Cluster and Primary Logic Unit -TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何单台计算机都无法提供足够计算能力和存储能力处理海量数据的假设进行设计的。因此 TDengine 从研发的第一天起,就按照分布式高可靠架构进行设计,是支持水平扩展的,这样任何单台或多台服务器发生硬件故障或软件错误都不影响系统的可用性和可靠性。同时,通过节点虚拟化并辅以自动化负载均衡技术,TDengine 能最高效率地利用异构集群中的计算和存储资源降低硬件投资。 +The design of TDengine is based on the assumption that any hardware or software system is not 100% reliable and that no single node can provide sufficient computing and storage resources to process massive data. Therefore, TDengine has been designed in a distributed and high-reliability architecture since day one of the development, so that hardware failure or software failure of any single even multiple servers will not affect the availability and reliability of the system. At the same time, through node virtualization and automatic load-balancing technology, TDengine can make the most efficient use of computing and storage resources in heterogeneous clusters to reduce hardware resources significantly. -### 主要逻辑单元 +### Primary Logic Unit -TDengine 分布式架构的逻辑结构图如下: +Logical structure diagram of TDengine distributed architecture as following: -![TDengine架构示意图](/img/architecture/structure.png) +![TDengine architecture diagram](structure.png) +
Figure 1: TDengine architecture diagram
-
图 1 TDengine架构示意图
+A complete TDengine system runs on one or more physical nodes. Logically, it includes data node (dnode), TDengine application driver (TAOSC) and application (app). There are one or more data nodes in the system, which form a cluster. The application interacts with the TDengine cluster through TAOSC's API. The following is a brief introduction to each logical unit. -一个完整的 TDengine 系统是运行在一到多个物理节点上的,逻辑上,它包含数据节点(dnode)、TDengine 应用驱动(taosc)以及应用(app)。系统中存在一到多个数据节点,这些数据节点组成一个集群(cluster)。应用通过 taosc 的 API 与 TDengine 集群进行互动。下面对每个逻辑单元进行简要介绍。 +**Physical node (pnode)**: A pnode is a computer that runs independently and has its own computing, storage and network capabilities. It can be a physical machine, virtual machine, or Docker container installed with OS. The physical node is identified by its configured FQDN (Fully Qualified Domain Name). TDengine relies entirely on FQDN for network communication. If you don't know about FQDN, please check [wikipedia](https://en.wikipedia.org/wiki/Fully_qualified_domain_name). -**物理节点(pnode):** pnode 是一独立运行、拥有自己的计算、存储和网络能力的计算机,可以是安装有 OS 的物理机、虚拟机或 Docker 容器。物理节点由其配置的 FQDN(Fully Qualified Domain Name)来标识。TDengine 完全依赖 FQDN 来进行网络通讯,如果不了解 FQDN,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。 +**Data node (dnode):** A dnode is a running instance of the TDengine server-side execution code taosd on a physical node. A working system must have at least one data node. A dnode contains zero to multiple logical virtual nodes (VNODE), zero or at most one logical management node (mnode). The unique identification of a dnode in the system is determined by the instance's End Point (EP). EP is a combination of FQDN (Fully Qualified Domain Name) of the physical node where the dnode is located and the network port number (Port) configured by the system. By configuring different ports, a physical node (a physical machine, virtual machine or container) can run multiple instances or have multiple data nodes. -**数据节点(dnode):** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例,一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点(vnode),零或者至多一个逻辑的管理节点(mnode)。dnode 在系统中的唯一标识由实例的 End Point(EP)决定。EP 是 dnode 所在物理节点的 FQDN(Fully Qualified Domain Name)和系统所配置的网络端口号(Port)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。 +**Virtual node (vnode)**: To better support data sharding, load balancing and prevent data from overheating or skewing, data nodes are virtualized into multiple virtual nodes (vnode, V2, V3, V4, etc. in the figure). Each vnode is a relatively independent work unit, which is the basic unit of time-series data storage and has independent running threads, memory space and persistent storage path. A vnode contains a certain number of tables (data collection points). When a new table is created, the system checks whether a new vnode needs to be created. The number of vnodes that can be created on a data node depends on the hardware capacities of the physical node where the data node is located. A vnode belongs to only one DB, but a DB can have multiple vnodes. In addition to the stored time-series data, a vnode also stores the schema and tag values of the included tables. A virtual node is uniquely identified in the system by the EP of the data node and the VGroup ID to which it belongs and is created and managed by the management node. -**虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2,V3,V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一张新表时,系统会检查是否需要创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 +**Management node (mnode)**: A virtual logical unit responsible for monitoring and maintaining the running status of all data nodes and load balancing among nodes (M in the figure). At the same time, the management node is also responsible for the storage and management of metadata (including users, databases, tables, static tags, etc.), so it is also called Meta Node. Multiple (up to 5) mnodes can be configured in a TDengine cluster, and they are automatically constructed into a virtual management node group (M0, M1, M2 in the figure). The master/slave mechanism is adopted for the mnode group and the data synchronization is carried out in a strongly consistent way. Any data update operation can only be executed on the master. The creation of mnode cluster is completed automatically by the system without manual intervention. There is at most one mnode on each dnode, which is uniquely identified by the EP of the data node to which it belongs. Each dnode automatically obtains the EP of the dnode where all mnodes in the whole cluster are located through internal messaging interaction. -**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(开源版最多不超过 3 个)mnode,它们自动构建成为一个虚拟管理节点组(图中 M0,M1,M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步,任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 +**Virtual node group (VGroup)**: Vnodes on different data nodes can form a virtual node group to ensure the high availability of the system. The virtual node group is managed in a master/slave mechanism. Write operations can only be performed on the master vnode, and then replicated to slave vnodes, thus ensuring that one single replica of data is copied on multiple physical nodes. The number of virtual nodes in a vgroup equals the number of data replicas. If the number of replicas of a DB is N, the system must have at least N data nodes. The number of replicas can be specified by the parameter `“replica”` when creating DB, and the default is 1. Using the multi-replication feature of TDengine, the same high data reliability can be achieved without the need for expensive storage devices such as disk arrays. Virtual node group is created and managed by the management node, and the management node assigns a system unique ID, aka VGroup ID. If two virtual nodes have the same vnode group ID, means that they belong to the same group and the data is backed up to each other. The number of virtual nodes in a virtual node group can be dynamically changed, allowing only one, that is, no data replication. VGroup ID is never changed. Even if a virtual node group is deleted, its ID will not be reused. -**虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vgroup)来保证系统的高可靠。虚拟节点组内采取 master/slave 的方式进行管理。写操作只能在 master vnode 上进行,系统采用异步复制的方式将数据同步到 slave vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 VGroup ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。 +**TAOSC**: TAOSC is the driver provided by TDengine to applications, which is responsible for dealing with the interaction between application and cluster, and provides the native interface of C/C++ language, which is embedded in JDBC, C #, Python, Go, Node.js language connection libraries. Applications interact with the whole cluster through TAOSC instead of directly connecting to data nodes in the cluster. This module is responsible for obtaining and caching metadata; forwarding requests for insertion, query, etc. to the correct data node; when returning the results to the application, TAOSC also needs to be responsible for the final level of aggregation, sorting, filtering and other operations. For JDBC, C/C++/C #/Python/Go/Node.js interfaces, this module runs on the physical node where the application is located. At the same time, in order to support the fully distributed RESTful interface, TAOSC has a running instance on each dnode of TDengine cluster. -**Taosc** taosc 是 TDengine 给应用提供的驱动程序(driver),负责处理应用与集群的接口交互,提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言,这个模块是在应用所处的物理节点上运行。同时,为支持全分布式的 RESTful 接口,taosc 在 TDengine 集群的每个 dnode 上都有一运行实例。 +### Node Communication -### 节点之间的通讯 +**Communication mode**: The communication among each data node of TDengine system, and among the application driver and each data node is carried out through TCP/UDP. Considering an IoT scenario, the data writing packets are generally not large, so TDengine uses UDP in addition to TCP for transmission, because UDP is more efficient and is not limited by the number of connections. TDengine implements its own timeout, retransmission, confirmation and other mechanisms to ensure reliable transmission of UDP. For packets with a data volume of less than 15K, UDP is adopted for transmission, and TCP is automatically adopted for transmission of packets with a data volume of more than 15K or query operations. At the same time, TDengine will automatically compress/decompress the data, digital sign/authenticate the data according to the configuration and data packet. For data replication among data nodes, only TCP is used for data transportation. -**通讯方式:**TDengine 系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过 TCP/UDP 进行的。因为考虑到物联网场景,数据写入的包一般不大,因此 TDengine 除采用 TCP 做传输之外,还采用 UDP 方式,因为 UDP 更加高效,而且不受连接数的限制。TDengine 实现了自己的超时、重传、确认等机制,以确保 UDP 的可靠传输。对于数据量不到 15K 的数据包,采取 UDP 的方式进行传输,超过 15K 的,或者是查询类的操作,自动采取 TCP 的方式进行传输。同时,TDengine 根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用 TCP 方式进行数据传输。 +**FQDN configuration:** A data node has one or more FQDNs, which can be specified in the system configuration file taos.cfg with the parameter “fqdn”. If it is not specified, the system will automatically use the hostname of the computer as its FQDN. If the node is not configured with FQDN, you can directly set the configuration parameter “fqdn” of the node to its IP address. However, IP is not recommended because IP address may be changed, and once it changes, the cluster will not work properly. The EP (End Point) of a data node consists of FQDN + Port. With FQDN, it is necessary to ensure the DNS service is running, or hosts files on nodes are configured properly. -**FQDN 配置:**一个数据节点有一个或多个 FQDN,可以在系统配置文件 taos.cfg 通过参数“fqdn”进行指定,如果没有指定,系统将自动获取计算机的 hostname 作为其 FQDN。如果节点没有配置 FQDN,可以直接将该节点的配置参数 fqdn 设置为它的 IP 地址。但不建议使用 IP,因为 IP 地址可变,一旦变化,将让集群无法正常工作。一个数据节点的 EP(End Point)由 FQDN + Port 组成。采用 FQDN,需要保证 DNS 服务正常工作,或者在节点以及应用所在的节点配置好 hosts 文件。另外,这个参数值的长度需要控制在 96 个字符以内。 +**Port configuration**: The external port of a data node is determined by the system configuration parameter “serverPort” in TDengine, and the port for internal communication of cluster is serverPort+5. The data replication operation among data nodes in the cluster also occupies a TCP port, which is serverPort+10. In order to support multithreading and efficient processing of UDP data, each internal and external UDP connection needs to occupy 5 consecutive ports. Therefore, the total port range of a data node will be serverPort to serverPort + 10, for a total of 11 TCP/UDP ports. To run the system, make sure that the firewall keeps these ports open. Each data node can be configured with a different serverPort. -**端口配置:**一个数据节点对外的端口由 TDengine 的系统配置参数 serverPort 决定,对集群内部通讯的端口是 serverPort+5。为支持多线程高效的处理 UDP 数据,每个对内和对外的 UDP 连接,都需要占用 5 个连续的端口。 +**Cluster external connection**: TDengine cluster can accommodate one single, multiple or even thousands of data nodes. The application only needs to initiate a connection to any data node in the cluster. The network parameter required for connection is the End Point (FQDN plus configured port number) of a data node. When starting the application taos through CLI, the FQDN of the data node can be specified through the option `-h`, and the configured port number can be specified through `-p`. If the port is not configured, the system configuration parameter “serverPort” of TDengine will be adopted. -- 集群内数据节点之间的数据复制操作占用一个 TCP 端口,是 serverPort+10。 -- 集群数据节点对外提供 RESTful 服务占用一个 TCP 端口,是 serverPort+11。 -- 集群内数据节点与 Arbitrator 节点之间通讯占用一个 TCP 端口,是 serverPort+12。 +**Inter-cluster communication**: Data nodes connect with each other through TCP/UDP. When a data node starts, it will obtain the EP information of the dnode where the mnode is located, and then establish a connection with the mnode in the system to exchange information. There are three steps to obtain EP information of the mnode: -因此一个数据节点总的端口范围为 serverPort 到 serverPort+12,总共 13 个 TCP/UDP 端口。使用时,需要确保防火墙将这些端口打开。每个数据节点可以配置不同的 serverPort。详细的端口情况请参见 [TDengine 2.0 端口说明](/train-faq/faq#port) +1. Check whether the mnodeEpList file exists, if it does not exist or cannot be opened normally to obtain EP information of the mnode, skip to the second step; +2. Check the system configuration file taos.cfg to obtain node configuration parameters “firstEp” and “secondEp” (the node specified by these two parameters can be a normal node without mnode, in this case, the node will try to redirect to the mnode node when connected). If these two configuration parameters do not exist or do not exist in taos.cfg, or are invalid, skip to the third step; +3. Set your own EP as a mnode EP and run it independently. After obtaining the mnode EP list, the data node initiates the connection. It will successfully join the working cluster after connection. If not successful, it will try the next item in the mnode EP list. If all attempts are made, but the connection still fails, sleep for a few seconds before trying again. -**集群对外连接:**TDengine 集群可以容纳单个、多个甚至几千个数据节点。应用只需要向集群中任何一个数据节点发起连接即可,连接需要提供的网络参数是一数据节点的 End Point(FQDN 加配置的端口号)。通过命令行 CLI 启动应用 taos 时,可以通过选项-h 来指定数据节点的 FQDN,-P 来指定其配置的端口号,如果端口不配置,将采用 TDengine 的系统配置参数 serverPort。 +**The choice of MNODE**: TDengine logically has a management node, but there is no separated execution code. The server-side only has a set of execution code taosd. So which data node will be the management node? This is determined automatically by the system without any manual intervention. The principle is as follows: when a data node starts, it will check its End Point and compare it with the obtained mnode EP List. If its EP exists in it, the data node shall start the mnode module and become a mnode. If your own EP is not in the mnode EP List, the mnode module will not start. During the system operation, due to load balancing, downtime and other reasons, mnode may migrate to the new dnode, while totally transparent without manual intervention. The modification of configuration parameters is the decision made by mnode itself according to resources usage. -**集群内部通讯:**各个数据节点之间通过 TCP/UDP 进行连接。一个数据节点启动时,将获取 mnode 所在的 dnode 的 EP 信息,然后与系统中的 mnode 建立起连接,交换信息。获取 mnode 的 EP 信息有三步: +**Add new data nodes:** After the system has a data node, it has become a working system. There are two steps to add a new node into the cluster. Step1: Connect to the existing working data node using TDengine CLI, and then add the End Point of the new data node with the command "create dnode"; Step 2: In the system configuration parameter file taos.cfg of the new data node, set the “firstEp” and “secondEp” parameters to the EP of any two data nodes in the existing cluster. Please refer to the detailed user tutorial for detailed steps. In this way, the cluster will be established step by step. -1. 检查 mnodeEpSet.json 文件是否存在,如果不存在或不能正常打开获得 mnode EP 信息,进入第二步; -2. 检查系统配置文件 taos.cfg,获取节点配置参数 firstEp、secondEp(这两个参数指定的节点可以是不带 mnode 的普通节点,这样的话,节点被连接时会尝试重定向到 mnode 节点),如果不存在或者 taos.cfg 里没有这两个配置参数,或无效,进入第三步; -3. 将自己的 EP 设为 mnode EP,并独立运行起来。 +**Redirection**: No matter about dnode or TAOSC, the connection to the mnode shall be initiated first, but the mnode is automatically created and maintained by the system, so the user does not know which dnode is running the mnode. TDengine only requires a connection to any working dnode in the system. Because any running dnode maintains the currently running mnode EP List, when receiving a connecting request from the newly started dnode or TAOSC, if it’s not a mnode by self, it will reply to the mnode EP List back. After receiving this list, TAOSC or the newly started dnode will try to establish the connection again. When the mnode EP List changes, each data node quickly obtains the latest list and notifies TAOSC through messaging interaction among nodes. -获取 mnode EP 列表后,数据节点发起连接,如果连接成功,则成功加入进工作的集群,如果不成功,则尝试 mnode EP 列表中的下一个。如果都尝试了,但连接都仍然失败,则休眠几秒后,再进行尝试。 +### A Typical Data Writing Process -**Mnode 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢?这是系统自动决定的,无需任何人工干预。原则如下:一个数据节点启动时,会检查自己的 End Point,并与获取的 mnode EP List 进行比对,如果在其中,该数据节点认为自己应该启动 mnode 模块,成为 mnode。如果自己的 EP 不在 mnode EP List 里,则不启动 mnode 模块。在系统的运行过程中,由于负载均衡、宕机等原因,mnode 有可能迁移至新的 dnode,但一切都是透明的,无需人工干预,配置参数的修改,是 mnode 自己根据资源做出的决定。 +To explain the relationship between vnode, mnode, TAOSC and application and their respective roles, the following is an analysis of a typical data writing process. -**新数据节点的加入:**系统有了一个数据节点后,就已经成为一个工作的系统。添加新的节点进集群时,有两个步骤,第一步:使用 TDengine CLI 连接到现有工作的数据节点,然后用命令“CREATE DNODE”将新的数据节点的 End Point 添加进去;第二步:在新的数据节点的系统配置参数文件 taos.cfg 里,将 firstEp,secondEp 参数设置为现有集群中任意两个数据节点的 EP 即可。具体添加的详细步骤请见详细的用户手册。这样就把集群一步一步的建立起来。 +![typical process of TDengine](message.png) +
Figure 2: Typical process of TDengine
-**重定向:**无论是 dnode 还是 taosc,最先都是要发起与 mnode 的连接,但 mnode 是系统自动创建并维护的,因此对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode,都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode,则将 mnode EP List 回复给对方,taosc 或新启动的 dnode 收到这个 list,就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。 +1. Application initiates a request to insert data through JDBC, ODBC, or other APIs. +2. TAOSC checks if meta data existing for the table in the cache. If so, go straight to Step 4. If not, TAOSC sends a get meta-data request to mnode. +3. Mnode returns the meta-data of the table to TAOSC. Meta-data contains the schema of the table, and also the vgroup information to which the table belongs (the vnode ID and the End Point of the dnode where the table belongs. If the number of replicas is N, there will be N groups of End Points). If TAOSC does not receive a response from the mnode for a long time, and there are multiple mnodes, TAOSC will send a request to the next mnode. +4. TAOSC initiates an insert request to master vnode. +5. After vnode inserts the data, it gives a reply to TAOSC, indicating that the insertion is successful. If TAOSC doesn't get a response from vnode for a long time, TAOSC will treat this node as offline. In this case, if there are multiple replicas of the inserted database, TAOSC will issue an insert request to the next vnode in vgroup. +6. TAOSC notifies APP that writing is successful. -### 一个典型的消息流程 +For Step 2 and 3, when TAOSC starts, it does not know the End Point of mnode, so it will directly initiate a request to the configured serving End Point of the cluster. If the dnode that receives the request does not have a mnode configured, it will inform the mnode EP list in a reply message, so that TAOSC will re-issue a request to obtain meta-data to the EP of another new mnode. -为解释 vnode、mnode、taosc 和应用之间的关系以及各自扮演的角色,下面对写入数据这个典型操作的流程进行剖析。 +For Step 4 and 5, without caching, TAOSC can't recognize the master in the virtual node group, so assumes that the first vnode is the master and sends a request to it. If this vnode is not the master, it will reply to the actual master as a new target where TAOSC shall send a request to. Once the reply of successful insertion is obtained, TAOSC will cache the information of master node. -![TDengine典型的操作流程](/img/architecture/message.png) +The above is the process of inserting data, and the processes of querying and computing are the same. TAOSC encapsulates and hides all these complicated processes, and it is transparent to applications. -
图 2 TDengine 典型的操作流程
+Through TAOSC caching mechanism, mnode needs to be accessed only when a table is accessed for the first time, so mnode will not become a system bottleneck. However, because schema and vgroup may change (such as load balancing), TAOSC will interact with mnode regularly to automatically update the cache. -1. 应用通过 JDBC 或其他 API 接口发起插入数据的请求。 -2. taosc 会检查缓存,看是否保存有该表的 meta data。如果有,直接到第 4 步。如果没有,taosc 将向 mnode 发出 get meta-data 请求。 -3. mnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema,而且还有该表所属的 vgroup 信息(vnode ID 以及所在的 dnode 的 End Point,如果副本数为 N,就有 N 组 End Point)。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnode,taosc 将向下一个 mnode 发出请求。 -4. taosc 向 master vnode 发起插入请求。 -5. vnode 插入数据后,给 taosc 一个应答,表示插入成功。如果 taosc 迟迟得不到 vnode 的回应,taosc 会认为该节点已经离线。这种情况下,如果被插入的数据库有多个副本,taosc 将向 vgroup 里下一个 vnode 发出插入请求。 -6. taosc 通知 APP,写入成功。 +## Storage Model and Data Partitioning/Sharding -对于第二和第三步,taosc 启动时,并不知道 mnode 的 End Point,因此会直接向配置的集群对外服务的 End Point 发起请求。如果接收到该请求的 dnode 并没有配置 mnode,该 dnode 会在回复的消息中告知 mnode EP 列表,这样 taosc 会重新向新的 mnode 的 EP 发出获取 meta-data 的请求。 +### Storage Model -对于第四和第五步,没有缓存的情况下,taosc 无法知道虚拟节点组里谁是 master,就假设第一个 vnodeID 就是 master,向它发出请求。如果接收到请求的 vnode 并不是 master,它会在回复中告知谁是 master,这样 taosc 就向建议的 master vnode 发出请求。一旦得到插入成功的回复,taosc 会缓存 master 节点的信息。 +The data stored by TDengine include collected time-series data, metadata related to database and tables, tag data, etc. These data are specifically divided into three parts: -上述是插入数据的流程,查询、计算的流程也完全一致。taosc 把这些复杂的流程全部封装屏蔽了,对于应用来说无感知也无需任何特别处理。 +- Time-series data: stored in vnode and composed of data, head and last files. The amount of data is large and query amount depends on the application scenario. Out-of-order writing is allowed, but delete operation is not supported for the time being, and update operation is only allowed when database “update” parameter is set to 1. By adopting the model with **one table for each data collection point**, the data of a given time period is continuously stored, and the writing against one single table is a simple appending operation. Multiple records can be read at one time, thus ensuring the insert and query operation of a single data collection point with the best performance. +- Tag data: meta files stored in vnode. Four standard operations of create, read, update and delete are supported. The amount of data is not large. If there are N tables, there are N records, so all can be stored in memory. To make tag filtering efficient, TDengine supports multi-core and multi-threaded concurrent queries. As long as the computing resources are sufficient, even in face of millions of tables, the tag filtering results will return in milliseconds. +- Metadata: stored in mnode, including system node, user, DB, Table Schema and other information. Four standard operations of create, delete, update and read are supported. The amount of these data are not large and can be stored in memory, moreover, the query amount is not large because of the client cache. Therefore, TDengine uses centralized storage management, however, there will be no performance bottleneck. -通过 taosc 缓存机制,只有在第一次对一张表操作时,才需要访问 mnode,因此 mnode 不会成为系统瓶颈。但因为 schema 有可能变化,而且 vgroup 有可能发生改变(比如负载均衡发生),因此 taosc 会定时和 mnode 交互,自动更新缓存。 +Compared with the typical NoSQL storage model, TDengine stores tag data and time-series data completely separately, which has two major advantages: -## 存储模型与数据分区、分片 +- Reduce the redundancy of tag data storage significantly: general NoSQL database or time-series database adopts K-V storage, in which Key includes a timestamp, a device ID and various tags. Each record carries these duplicated tags, so storage space is wasted. Moreover, if the application needs to add, modify or delete tags on historical data, it has to traverse the data and rewrite them again, which is extremely expensive to operate. +- Aggregate data efficiently between multiple tables: when aggregating data between multiple tables, it first finds out the tables which satisfy the filtering conditions, and then find out the corresponding data blocks of these tables to greatly reduce the data sets to be scanned, thus greatly improving the aggregation efficiency. Moreover, tag data is managed and maintained in a full-memory structure, and tag data queries in tens of millions can return in milliseconds. -### 存储模型 +### Data Sharding -TDengine 存储的数据包括采集的时序数据以及库、表相关的元数据、标签数据等,这些数据具体分为三部分: +For large-scale data management, to achieve scale-out, it is generally necessary to adopt the Partitioning or Sharding strategy. TDengine implements data sharding via vnode, and time-series data partitioning via one data file for a time range. -- 时序数据:存放于 vnode 里,由 data、head 和 last 三个文件组成,数据量大,查询量取决于应用场景。容许乱序写入,但暂时不支持删除操作,并且仅在 update 参数设置为 1 时允许更新操作。通过采用一个采集点一张表的模型,一个时间段的数据是连续存储,对单张表的写入是简单的追加操作,一次读,可以读到多条记录,这样保证对单个采集点的插入和查询操作,性能达到最优。 -- 标签数据:存放于 vnode 里的 meta 文件,支持增删改查四个标准操作。数据量不大,有 N 张表,就有 N 条记录,因此可以全内存存储。如果标签过滤操作很多,查询将十分频繁,因此 TDengine 支持多核多线程并发查询。只要计算资源足够,即使有数千万张表,过滤结果能毫秒级返回。 -- 元数据:存放于 mnode 里,包含系统节点、用户、DB、Table Schema 等信息,支持增删改查四个标准操作。这部分数据的量不大,可以全内存保存,而且由于客户端有缓存,查询量也不大。因此目前的设计虽是集中式存储管理,但不会构成性能瓶颈。 +VNode (Virtual Data Node) is responsible for providing writing, query and computing functions for collected time-series data. To facilitate load balancing, data recovery and support heterogeneous environments, TDengine splits a data node into multiple vnodes according to its computing and storage resources. The management of these vnodes is done automatically by TDengine and is completely transparent to the application. -与典型的 NoSQL 存储模型相比,TDengine 将标签数据与时序数据完全分离存储,它具有两大优势: +For a single data collection point, regardless of the amount of data, a vnode (or vnode group, if the number of replicas is greater than 1) has enough computing resource and storage resource to process (if a 16-byte record is generated per second, the original data generated in one year will be less than 0.5 G), so TDengine stores all the data of a table (a data collection point) in one vnode instead of distributing the data to two or more dnodes. Moreover, a vnode can store data from multiple data collection points (tables), and the upper limit of the tables’ quantity for a vnode is one million. By design, all tables in a vnode belong to the same DB. On a data node, unless specially configured, the number of vnodes owned by a DB will not exceed the number of system cores. -- 能够极大地降低标签数据存储的冗余度:一般的 NoSQL 数据库或时序数据库,采用的 K-V 存储,其中的 Key 包含时间戳、设备 ID、各种标签。每条记录都带有这些重复的内容,浪费存储空间。而且如果应用要在历史数据上增加、修改或删除标签,需要遍历数据,重写一遍,操作成本极其昂贵。 -- 能够实现极为高效的多表之间的聚合查询:做多表之间聚合查询时,先把符合标签过滤条件的表查找出来,然后再查找这些表相应的数据块,这样大幅减少要扫描的数据集,从而大幅提高查询效率。而且标签数据采用全内存的结构进行管理和维护,千万级别规模的标签数据查询可以在毫秒级别返回。 +When creating a DB, the system does not allocate resources immediately. However, when creating a table, the system will check if there is an allocated vnode with free tablespace. If so, the table will be created in the vacant vnode immediately. If not, the system will create a new vnode on a dnode from the cluster according to the current workload, and then a table. If there are multiple replicas of a DB, the system does not create only one vnode, but a vgroup (virtual data node group). The system has no limit on the number of vnodes, which is just limited by the computing and storage resources of physical nodes. -### 数据分片 +The meta data of each table (including schema, tags, etc.) is also stored in vnode instead of centralized storage in mnode. In fact, this means sharding of meta data, which is good for efficient and parallel tag filtering operations. -对于海量的数据管理,为实现水平扩展,一般都需要采取分片(Sharding)分区(Partitioning)策略。TDengine 是通过 vnode 来实现数据分片的,通过一个时间段一个数据文件来实现时序数据分区的。 +### Data Partitioning -vnode(虚拟数据节点)负责为采集的时序数据提供写入、查询和计算功能。为便于负载均衡、数据恢复、支持异构环境,TDengine 将一个数据节点根据其计算和存储资源切分为多个 vnode。这些 vnode 的管理是 TDengine 自动完成的,对应用完全透明。 +In addition to vnode sharding, TDengine partitions the time-series data by time range. Each data file contains only one time range of time-series data, and the length of the time range is determined by DB's configuration parameter `“days”`. This method of partitioning by time rang is also convenient to efficiently implement the data retention policy. As long as the data file exceeds the specified number of days (system configuration parameter `“keep”`), it will be automatically deleted. Moreover, different time ranges can be stored in different paths and storage media, so as to facilitate the tiered-storage. Cold/hot data can be stored in different storage media to reduce the storage cost. -对于单独一个数据采集点,无论其数据量多大,一个 vnode(或 vgroup,如果副本数大于 1)有足够的计算资源和存储资源来处理(如果每秒生成一条 16 字节的记录,一年产生的原始数据不到 0.5G),因此 TDengine 将一张表(一个数据采集点)的所有数据都存放在一个 vnode 里,而不会让同一个采集点的数据分布到两个或多个 dnode 上。而且一个 vnode 可存储多个数据采集点(表)的数据,一个 vnode 可容纳的表的数目的上限为一百万。设计上,一个 vnode 里所有的表都属于同一个 DB。一个数据节点上,除非特殊配置,一个 DB 拥有的 vnode 数目不会超过系统核的数目。 +In general, **TDengine splits big data by vnode and time range in two dimensions** to manage the data efficiently with horizontal scalability. -创建 DB 时,系统并不会马上分配资源。但当创建一张表时,系统将看是否有已经分配的 vnode,且该 vnode 是否有空余的表空间,如果有,立即在该有空位的 vnode 创建表。如果没有,系统将从集群中,根据当前的负载情况,在一个 dnode 上创建一新的 vnode,然后创建表。如果 DB 有多个副本,系统不是只创建一个 vnode,而是一个 vgroup(虚拟数据节点组)。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。 +### Load Balancing -每张表的 meta data(包含 schema,标签等)也存放于 vnode 里,而不是集中存放于 mnode,实际上这是对 Meta 数据的分片,这样便于高效并行的进行标签过滤操作。 +Each dnode regularly reports its status (including hard disk space, memory size, CPU, network, number of virtual nodes, etc.) to the mnode (virtual management node), so mnode knows the status of the entire cluster. Based on the overall status, when the mnode finds a dnode is overloaded, it will migrate one or more vnodes to other dnodes. During the process, TDengine services keep running and the data insertion, query and computing operations are not affected. -### 数据分区 +If the mnode has not received the dnode status for a period of time, the dnode will be treated as offline. When offline lasts a certain period of time (configured by parameter `“offlineThreshold”`), the dnode will be forcibly removed from the cluster by mnode. If the number of replicas of vnodes on this dnode is greater than one, the system will automatically create new replicas on other dnodes to ensure the replica number. If there are other mnodes on this dnode and the number of mnodes replicas is greater than one, the system will automatically create new mnodes on other dnodes to ensure the replica number. -TDengine 除 vnode 分片之外,还对时序数据按照时间段进行分区。每个数据文件只包含一个时间段的时序数据,时间段的长度由 DB 的配置参数 days 决定。这种按时间段分区的方法还便于高效实现数据的保留策略,只要数据文件超过规定的天数(系统配置参数 keep),将被自动删除。而且不同的时间段可以存放于不同的路径和存储介质,以便于大数据的冷热管理,实现多级存储。 +When new data nodes are added to the cluster, with new computing and storage resources are added, the system will automatically start the load balancing process. -总的来说,**TDengine 是通过 vnode 以及时间两个维度,对大数据进行切分**,便于并行高效的管理,实现水平扩展。 +The load balancing process does not require any manual intervention, and it is transparent to the application. **Note: load balancing is controlled by parameter “balance”, which determines to turn on/off automatic load balancing.** -### 负载均衡 +## Data Writing and Replication Process -每个 dnode 都定时向 mnode(虚拟管理节点)报告其状态(包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等),因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中,对外服务继续进行,数据插入、查询和计算操作都不受影响。 +If a database has N replicas, thus a virtual node group has N virtual nodes, but only one as Master and all others are slaves. When the application writes a new record to system, only the Master vnode can accept the writing request. If a slave vnode receives a writing request, the system will notifies TAOSC to redirect. -如果 mnode 一段时间没有收到 dnode 的状态报告,mnode 会认为这个 dnode 已经离线。如果离线时间超过一定时长(时长由配置参数 offlineThreshold 决定),该 dnode 将被 mnode 强制剔除出集群。该 dnode 上的 vnodes 如果副本数大于 1,系统将自动在其他 dnode 上创建新的副本,以保证数据的副本数。如果该 dnode 上还有 mnode,而且 mnode 的副本数大于 1,系统也将自动在其他 dnode 上创建新的 mnode,以保证 mnode 的副本数。 +### Master vnode Writing Process -当新的数据节点被添加进集群,因为新的计算和存储被添加进来,系统也将自动启动负载均衡流程。 +Master Vnode uses a writing process as follows: -负载均衡过程无需任何人工干预,应用也无需重启,将自动连接新的节点,完全透明。 +![TDengine Master Writing Process](write_master.png) +
Figure 3: TDengine Master writing process
-**提示:负载均衡由参数 balance 控制,决定开启/关闭自动负载均衡。** +1. Master vnode receives the application data insertion request, verifies, and moves to next step; +2. If the system configuration parameter `“walLevel”` is greater than 0, vnode will write the original request packet into database log file WAL. If walLevel is set to 2 and fsync is set to 0, TDengine will make WAL data written immediately to ensure that even system goes down, all data can be recovered from database log file; +3. If there are multiple replicas, vnode will forward data packet to slave vnodes in the same virtual node group, and the forwarded packet has a version number with data; +4. Write into memory and add the record to “skip list”; +5. Master vnode returns a confirmation message to the application, indicating a successful writing. +6. If any of Step 2, 3 or 4 fails, the error will directly return to the application. -## 数据写入与复制流程 +### Slave vnode Writing Process -如果一个数据库有 N 个副本,那一个虚拟节点组就有 N 个虚拟节点,但是只有一个是 master,其他都是 slave。当应用将新的记录写入系统时,只有 master vnode 能接受写的请求。如果 slave vnode 收到写的请求,系统将通知 taosc 需要重新定向。 +For a slave vnode, the write process as follows: -### Master Vnode 写入流程 +![TDengine Slave Writing Process](write_slave.png) +
Figure 4: TDengine Slave Writing Process
-Master Vnode 遵循下面的写入流程: +1. Slave vnode receives a data insertion request forwarded by Master vnode; +2. If the system configuration parameter `“walLevel”` is greater than 0, vnode will write the original request packet into database log file WAL. If walLevel is set to 2 and fsync is set to 0, TDengine will make WAL data written immediately to ensure that even system goes down, all data can be recovered from database log file; +3. Write into memory and add the record to “skip list”. -![TDengine Master写入流程](/img/architecture/write_master.png) +Compared with Master vnode, slave vnode has no forwarding or reply confirmation step, means two steps less. But writing into memory and WAL is exactly the same. -
图 3 TDengine Master 写入流程
+### Remote Disaster Recovery and IDC Migration -1. master vnode 收到应用的数据插入请求,验证 OK,进入下一步; -2. 如果系统配置参数 walLevel 大于 0,vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; -3. 如果有多个副本,vnode 将把数据包转发给同一虚拟节点组内的 slave vnodes,该转发包带有数据的版本号(version); -4. 写入内存,并将记录加入到 skip list; -5. master vnode 返回确认信息给应用,表示写入成功; -6. 如果第 2、3、4 步中任何一步失败,将直接返回错误给应用。 +As above Master and Slave processes discussed, TDengine adopts asynchronous replication for data synchronization. This method can greatly improve the writing performance, with no obvious impact from network delay. By configuring IDC and rack number for each physical node, it can be ensured that for a virtual node group, virtual nodes are composed of physical nodes from different IDC and different racks, thus implementing remote disaster recovery without other tools. -### Slave Vnode 写入流程 +On the other hand, TDengine supports dynamic modification of the replicas number. Once the number of replicas increases, the newly added virtual nodes will immediately enter the data synchronization process. After synchronization completed, added virtual nodes can provide services. In the synchronization process, master and other synchronized virtual nodes keep serving. With this feature, TDengine can provide IDC migration without service interruption. It is only necessary to add new physical nodes to the existing IDC cluster, and then remove old physical nodes after the data synchronization is completed. -对于 slave vnode,写入流程是: +However, the asynchronous replication has a tiny time window where data can be lost. The specific scenario is as follows: -![TDengine Slave 写入流程](/img/architecture/write_slave.png) +1. Master vnode has finished its 5-step operations, confirmed the success of writing to APP, and then went down; +2. Slave vnode receives the write request, then processing fails before writing to the log in Step 2; +3. Slave vnode will become the new master, thus losing one record. -
图 4 TDengine Slave 写入流程
+In theory, for asynchronous replication, there is no guarantee to prevent data loss. However, this window is extremely small, only if mater and slave fail at the same time, and just confirm the successful write to the application before. -1. slave vnode 收到 Master vnode 转发了的数据插入请求。检查 last version 是否与 master 一致,如果一致,进入下一步。如果不一致,需要进入同步状态。 -2. 如果系统配置参数 walLevel 大于 0,vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。 -3. 写入内存,更新内存中的 skip list。 +Note: Remote disaster recovery and no-downtime IDC migration are only supported by Enterprise Edition. **Hint: This function is not available yet** -与 master vnode 相比,slave vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。 +### Master/slave Selection -### 主从选择 +Vnode maintains a version number. When memory data is persisted, the version number will also be persisted. For each data update operation, whether it is time-series data or metadata, this version number will be increased by one. -Vnode 会保持一个数据版本号(version),对内存数据进行持久化存储时,对该版本号也进行持久化存储。每个数据更新操作,无论是采集的时序数据还是元数据,这个版本号将增加 1。 +When a vnode starts, the roles (master, slave) are uncertain, and the data is in an unsynchronized state. It’s necessary to establish TCP connections with other nodes in the virtual node group and exchange status, including version and its own roles. Through the exchange, the system implements a master-selection process. The rules are as follows: -一个 vnode 启动时,角色(master、slave)是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status,其中包括 version 和自己的角色。通过 status 的交换,系统进入选主流程,规则如下: +1. If there’s only one replica, it’s always master +2. When all replicas are online, the one with latest version is master +3. Over half of online nodes are virtual nodes, and some virtual node is slave, it will automatically become master +4. For 2 and 3, if multiple virtual nodes meet the requirement, the first vnode in virtual node group list will be selected as master -1. 如果只有一个副本,该副本永远就是 master -2. 所有副本都在线时,版本最高的被选为 master -3. 在线的虚拟节点数过半,而且有虚拟节点是 slave 的话,该虚拟节点自动成为 master -4. 对于 2 和 3,如果多个虚拟节点满足成为 master 的要求,那么虚拟节点组的节点列表里,最前面的选为 master +### Synchronous Replication -更多的关于数据复制的流程,请见[《TDengine 2.0 数据复制模块设计》](/tdinternal/replica/)。 +For scenarios with strong data consistency requirements, asynchronous data replication is not applicable, because there is a small probability of data loss. So, TDengine provides a synchronous replication mechanism for users. When creating a database, in addition to specifying the number of replicas, user also needs to specify a new parameter “quorum”. If quorum is greater than one, it means that every time the Master forwards a message to the replica, it needs to wait for “quorum-1” reply confirms before informing the application that data has been successfully written in slave. If “quorum-1” reply confirms are not received within a certain period of time, the master vnode will return an error to the application. -### 同步复制 +With synchronous replication, performance of system will decrease and latency will increase. Because metadata needs strong consistent, the default for data synchronization between mnodes is synchronous replication. -对于数据一致性要求更高的场景,异步数据复制无法满足要求,因为有极小的概率丢失数据,因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 replica 之外,用户还需要指定新的参数 quorum。如果 quorum 大于 1,它表示每次 master 转发给副本时,需要等待 quorum-1 个回复确认,才能通知应用,数据在 slave 已经写入成功。如果在一定的时间内,得不到 quorum-1 个回复确认,master vnode 将返回错误给应用。 +## Caching and Persistence -采用同步复制,系统的性能会有所下降,而且 latency 会增加。因为元数据要强一致,mnode 之间的数据同步缺省就是采用的同步复制。 +### Caching -## 缓存与持久化 +TDengine adopts a time-driven cache management strategy (First-In-First-Out, FIFO), also known as a Write-driven Cache Management Mechanism. This strategy is different from the read-driven data caching mode (Least-Recent-Used, LRU), which directly put the most recently written data in the system buffer. When the buffer reaches a threshold, the earliest data are written to disk in batches. Generally speaking, for the use of IoT data, users are most concerned about the newly generated data, that is, the current status. TDengine takes full advantage of this feature to put the most recently arrived (current state) data in the buffer. -### 缓存 +TDengine provides millisecond-level data collecting capability to users through query functions. Putting the recently arrived data directly in the buffer can respond to users' analysis query for the latest piece or batch of data more quickly, and provide faster database query response capability as a whole. In this sense, **TDengine can be used as a data cache by setting appropriate configuration parameters without deploying Redis or other additional cache systems**, which can effectively simplify the system architecture and reduce the operation costs. It should be noted that after the TDengine is restarted, the buffer of the system will be emptied, the previously cached data will be written to disk in batches, and the previously cached data will not be reloaded into the buffer as so in a proprietary key-value cache system. -TDengine 采用时间驱动缓存管理策略(First-In-First-Out,FIFO),又称为写驱动的缓存管理机制。这种策略有别于读驱动的数据缓存模式(Least-Recent-Used,LRU),直接将最近写入的数据保存在系统的缓存中。当缓存达到临界值的时候,将最早的数据批量写入磁盘。一般意义上来说,对于物联网数据的使用,用户最为关心的是刚产生的数据,即当前状态。TDengine 充分利用这一特性,将最近到达的(当前状态)数据保存在缓存中。 +Each vnode has its own independent memory, and it is composed of multiple memory blocks of fixed size, and different vnodes are completely isolated. When writing data, similar to the writing of logs, data is sequentially added to memory, but each vnode maintains its own skip list for quick search. When more than one third of the memory block are used, the disk writing operation will start, and the subsequent writing operation is carried out in a new memory block. By this design, one third of the memory blocks in a vnode keep the latest data, so as to achieve the purpose of caching and quick search. The number of memory blocks of a vnode is determined by the configuration parameter “blocks”, and the size of memory blocks is determined by the configuration parameter “cache”. -TDengine 通过查询函数向用户提供毫秒级的数据获取能力。直接将最近到达的数据保存在缓存中,可以更加快速地响应用户针对最近一条或一批数据的查询分析,整体上提供更快的数据库查询响应能力。从这个意义上来说,**可通过设置合适的配置参数将 TDengine 作为数据缓存来使用,而不需要再部署 Redis 或其他额外的缓存系统**,可有效地简化系统架构,降低运维的成本。需要注意的是,TDengine 重启以后系统的缓存将被清空,之前缓存的数据均会被批量写入磁盘,缓存的数据将不会像专门的 key-value 缓存系统再将之前缓存的数据重新加载到缓存中。 +### Persistent Storage -每个 vnode 有自己独立的内存,而且由多个固定大小的内存块组成,不同 vnode 之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个 vnode 维护有自己的 skip list,便于迅速查找。当三分之一以上的内存块写满时,启动落盘操作,而且后续写的操作在新的内存块进行。这样,一个 vnode 里有三分之一内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个 vnode 的内存块的个数由配置参数 blocks 决定,内存块的大小由配置参数 cache 决定。 +TDengine uses a data-driven method to write the data from buffer into hard disk for persistent storage. When the cached data in vnode reaches a certain volume, TDengine will also pull up the disk-writing thread to write the cached data into persistent storage in order not to block subsequent data writing. TDengine will open a new database log file when the data is written, and delete the old database log file after written successfully to avoid unlimited log growth. -### 持久化存储 +To make full use of the characteristics of time-series data, TDengine splits the data stored in persistent storage by a vnode into multiple files, each file only saves data for a fixed number of days, which is determined by the system configuration parameter `“days”`. By so, for the given start and end date of a query, you can locate the data files to open immediately without any index, thus greatly speeding up reading operations. -TDengine 采用数据驱动的方式让缓存中的数据写入硬盘进行持久化存储。当 vnode 中缓存的数据达到一定规模时,为了不阻塞后续数据的写入,TDengine 也会拉起落盘线程将缓存的数据写入持久化存储。TDengine 在数据落盘时会打开新的数据库日志文件,在落盘成功后则会删除老的数据库日志文件,避免日志文件无限制地增长。 +For time-series data, there is generally a retention policy, which is determined by the system configuration parameter `“keep”`. Data files exceeding this set number of days will be automatically deleted by the system to free up storage space. -为充分利用时序数据特点,TDengine 将一个 vnode 保存在持久化存储的数据切分成多个文件,每个文件只保存固定天数的数据,这个天数由系统配置参数 days 决定。切分成多个文件后,给定查询的起止日期,无需任何索引,就可以立即定位需要打开哪些数据文件,大大加快读取速度。 +Given “days” and “keep” parameters, the total number of data files in a vnode is: keep/days. The total number of data files should not be too large or too small. 10 to 100 is appropriate. Based on this principle, reasonable days can be set. In the current version, parameter “keep” can be modified, but parameter “days” cannot be modified once it is set. -对于采集的数据,一般有保留时长,这个时长由系统配置参数 keep 决定。超过这个设置天数的数据文件,将被系统自动删除,释放存储空间。 +In each data file, the data of a table is stored by blocks. A table can have one or more data file blocks. In a file block, data is stored in columns, occupying a continuous storage space, thus greatly improving the reading speed. The size of file block is determined by the system parameter `“maxRows”` (the maximum number of records per block), and the default value is 4096. This value should not be too large or too small. If it is too large, the data locating in search will cost longer; if too small, the index of data block is too large, and the compression efficiency will be low with slower reading speed. -给定 days 与 keep 两个参数,一个典型工作状态的 vnode 中总的数据文件数为:向上取整 `(keep/days)+1` 个。总的数据文件个数不宜过大,也不宜过小。10 到 100 以内合适。基于这个原则,可以设置合理的 days。目前的版本,参数 keep 可以修改,但对于参数 days,一旦设置后,不可修改。 +Each data file (with a .data postfix) has a corresponding index file (with a .head postfix). The index file has summary information of a data block for each table, recording the offset of each data block in the data file, start and end time of data and other information, so as to lead system quickly locate the data to be found. Each data file also has a corresponding last file (with a .last postfix), which is designed to prevent data block fragmentation when written in disk. If the number of written records from a table does not reach the system configuration parameter `“minRows”` (minimum number of records per block), it will be stored in the last file first. When write to disk next time, the newly written records will be merged with the records in last file and then written into data file. -在每个数据文件里,一张表的数据是一块一块存储的。一张表可以有一到多个数据文件块。在一个文件块里,数据是列式存储的,占用的是一片连续的存储空间,这样大大提高读取速度。文件块的大小由系统参数 maxRows (每块最大记录条数)决定,缺省值为 4096。这个值不宜过大,也不宜过小。过大,定位具体时间段的数据的搜索时间会变长,影响读取速度;过小,数据块的索引太大,压缩效率偏低,也影响读取速度。 +When data is written to disk, it is decided whether to compress the data according to system configuration parameter `“comp”`. TDengine provides three compression options: no compression, one-stage compression and two-stage compression, corresponding to comp values of 0, 1 and 2 respectively. One-stage compression is carried out according to the type of data. Compression algorithms include delta-delta coding, simple 8B method, zig-zag coding, LZ4 and other algorithms. Two-stage compression is based on one-stage compression and compressed by general compression algorithm, which has higher compression ratio. -每个数据文件(.data 结尾)都有一个对应的索引文件(.head 结尾),该索引文件对每张表都有一数据块的摘要信息,记录了每个数据块在数据文件中的偏移量,数据的起止时间等信息,以帮助系统迅速定位需要查找的数据。每个数据文件还有一对应的 last 文件(.last 结尾),该文件是为防止落盘时数据块碎片化而设计的。如果一张表落盘的记录条数没有达到系统配置参数 minRows(每块最小记录条数),将被先存储到 last 文件,等下次落盘时,新落盘的记录将与 last 文件的记录进行合并,再写入数据文件。 +### Tiered Storage -数据写入磁盘时,根据系统配置参数 comp 决定是否压缩数据。TDengine 提供了三种压缩选项:无压缩、一阶段压缩和两阶段压缩,分别对应 comp 值为 0、1 和 2 的情况。一阶段压缩根据数据的类型进行了相应的压缩,压缩算法包括 delta-delta 编码、simple 8B 方法、zig-zag 编码、LZ4 等算法。二阶段压缩在一阶段压缩的基础上又用通用压缩算法进行了压缩,压缩率更高。 - -### 多级存储 - -说明:多级存储功能仅企业版支持,从 2.0.16.0 版本开始提供。 - -在默认配置下,TDengine 会将所有数据保存在 /var/lib/taos 目录下,而且每个 vnode 的数据文件保存在该目录下的不同目录。为扩大存储空间,尽量减少文件读取的瓶颈,提高数据吞吐率 TDengine 可通过配置系统参数 dataDir 让多个挂载的硬盘被系统同时使用。 - -除此之外,TDengine 也提供了数据分级存储的功能,将不同时间段的数据存储在挂载的不同介质上的目录里,从而实现不同“热度”的数据存储在不同的存储介质上,充分利用存储,节约成本。比如,最新采集的数据需要经常访问,对硬盘的读取性能要求高,那么用户可以配置将这些数据存储在 SSD 盘上。超过一定期限的数据,查询需求量没有那么高,那么可以存储在相对便宜的 HDD 盘上。 - -多级存储支持 3 级,每级最多可配置 16 个挂载点。 - -TDengine 多级存储配置方式如下(在配置文件/etc/taos/taos.cfg 中): +By default, TDengine saves all data in /var/lib/taos directory, and the data files of each vnode are saved in a different directory under this directory. In order to expand the storage space, minimize the bottleneck of file reading and improve the data throughput rate, TDengine can configure the system parameter “dataDir” to allow multiple mounted hard disks to be used by system at the same time. In addition, TDengine also provides the function of tiered data storage, i.e. storage on different storage media according to the time stamps of data files. For example, the latest data is stored on SSD, the data for more than one week is stored on local hard disk, and the data for more than four weeks is stored on network storage device, thus reducing the storage cost and ensuring efficient data access. The movement of data on different storage media is automatically done by the system and completely transparent to applications. Tiered storage of data is also configured through the system parameter “dataDir”. +dataDir format is as follows: ``` -dataDir [path] +dataDir data_path [tier_level] ``` -- path: 挂载点的文件夹路径 -- level: 介质存储等级,取值为 0,1,2。 - 0 级存储最新的数据,1 级存储次新的数据,2 级存储最老的数据,省略默认为 0。 - 各级存储之间的数据流向:0 级存储 -> 1 级存储 -> 2 级存储。 - 同一存储等级可挂载多个硬盘,同一存储等级上的数据文件分布在该存储等级的所有硬盘上。 - 需要说明的是,数据在不同级别的存储介质上的移动,是由系统自动完成的,用户无需干预。 -- primary: 是否为主挂载点,0(否)或 1(是),省略默认为 1。 +Where data_path is the folder path of mount point and tier_level is the media storage-tier. The higher the media storage-tier, means the older the data file. Multiple hard disks can be mounted at the same storage-tier, and data files on the same storage-tier are distributed on all hard disks within the tier. TDengine supports up to 3 tiers of storage, so tier_level values are 0, 1, and 2. When configuring dataDir, there must be only one mount path without specifying tier_level, which is called special mount disk (path). The mount path defaults to level 0 storage media and contains special file links, which cannot be removed, otherwise it will have a devastating impact on the written data. -在配置中,只允许一个主挂载点的存在(level=0,primary=1),例如采用如下的配置方式: +Suppose a physical node with six mountable hard disks/mnt/disk1,/mnt/disk2, …,/mnt/disk6, where disk1 and disk2 need to be designated as level 0 storage media, disk3 and disk4 are level 1 storage media, and disk5 and disk6 are level 2 storage media. Disk1 is a special mount disk, you can configure it in/etc/taos/taos.cfg as follows: ``` -dataDir /mnt/data1 0 1 -dataDir /mnt/data2 0 0 -dataDir /mnt/data3 1 0 -dataDir /mnt/data4 1 0 -dataDir /mnt/data5 2 0 -dataDir /mnt/data6 2 0 +dataDir /mnt/disk1/taos +dataDir /mnt/disk2/taos 0 +dataDir /mnt/disk3/taos 1 +dataDir /mnt/disk4/taos 1 +dataDir /mnt/disk5/taos 2 +dataDir /mnt/disk6/taos 2 ``` -:::note - -1. 多级存储不允许跨级配置,合法的配置方案有:仅 0 级,仅 0 级+ 1 级,以及 0 级+ 1 级+ 2 级。而不允许只配置 level=0 和 level=2,而不配置 level=1。 -2. 禁止手动移除使用中的挂载盘,挂载盘目前不支持非本地的网络盘。 -3. 多级存储目前不支持删除已经挂载的硬盘的功能。 +Mounted disks can also be a non-local network disk, as long as the system can access it. -::: +Note: Tiered Storage is only supported in Enterprise Edition -## 数据查询 +## Data Query -TDengine 提供了多种多样针对表和超级表的查询处理功能,除了常规的聚合查询之外,还提供针对时序数据的窗口查询、统计聚合等功能。TDengine 的查询处理需要客户端、vnode、mnode 节点协同完成。 +TDengine provides a variety of query processing functions for tables and STables. In addition to common aggregation queries, TDengine also provides window queries and statistical aggregation functions for time-series data. The query processing of TDengine needs the collaboration of client, vnode and mnode. -### 单表查询 +### Single Table Query -SQL 语句的解析和校验工作在客户端完成。解析 SQL 语句并生成抽象语法树(Abstract Syntax Tree,AST),然后对其进行校验和检查。以及向管理节点(mnode)请求查询中指定表的元数据信息(table metadata)。 +The parsing and verification of SQL statements are completed on the client side. SQL statements are parsed and generate an Abstract Syntax Tree (AST), which is then checksummed. Then request metadata information (table metadata) for the table specified in the query from management node (mnode). -根据元数据信息中的 End Point 信息,将查询请求序列化后发送到该表所在的数据节点(dnode)。dnode 接收到查询请求后,识别出该查询请求指向的虚拟节点(vnode),将消息转发到 vnode 的查询执行队列。vnode 的查询执行线程建立基础的查询执行环境,并立即返回该查询请求,同时开始执行该查询。 +According to the End Point information in metadata information, the query request is serialized and sent to the data node (dnode) where the table is located. After receiving the query, the dnode identifies the virtual node (vnode) pointed to and forwards the message to the query execution queue of the vnode. The query execution thread of vnode establishes the basic query execution environment, immediately returns the query request and starts executing the query at the same time. -客户端在获取查询结果的时候,dnode 的查询执行队列中的工作线程会等待 vnode 执行线程执行完成,才能将查询结果返回到请求的客户端。 +When client obtains query result, the worker thread in query execution queue of dnode will wait for the execution of vnode execution thread to complete before returning the query result to the requesting client. -### 按时间轴聚合、降采样、插值 +### Aggregation by Time Axis, Downsampling, Interpolation -时序数据有别于普通数据的显著特征是每条记录均具有时间戳,因此针对具有时间戳的数据在时间轴上进行聚合是不同于普通数据库的重要功能。从这点上来看,与流计算引擎的窗口查询有相似的地方。 +The remarkable feature that time-series data is different from ordinary data is that each record has a timestamp, so aggregating data with timestamps on the time axis is an important and distinct feature from common databases. From this point of view, it is similar to the window query of stream computing engine. -在 TDengine 中引入关键词 interval 来进行时间轴上固定长度时间窗口的切分,并按照时间窗口对数据进行聚合,对窗口范围内的数据按需进行聚合。例如: +The keyword `interval` is introduced into TDengine to split fixed length time windows on time axis, and the data are aggregated based on time windows, and the data within window range are aggregated as needed. For example: -```sql -SELECT COUNT(*) FROM d1001 INTERVAL(1h); +```mysql +select count(*) from d1001 interval(1h); ``` -针对 d1001 设备采集的数据,按照 1 小时的时间窗口返回每小时存储的记录数量。 +For the data collected by device D1001, the number of records stored per hour is returned by a 1-hour time window. -在需要连续获得查询结果的应用场景下,如果给定的时间区间存在数据缺失,会导致该区间数据结果也丢失。TDengine 提供策略针对时间轴聚合计算的结果进行插值,通过使用关键词 fill 就能够对时间轴聚合结果进行插值。例如: +In application scenarios where query results need to be obtained continuously, if there is data missing in a given time interval, the data results in this interval will also be lost. TDengine provides a strategy to interpolate the results of timeline aggregation calculation. The results of time axis aggregation can be interpolated by using keyword Fill. For example: -```sql -SELECT COUNT(*) FROM d1001 WHERE ts >= '2017-7-14 00:00:00' AND ts < '2017-7-14 23:59:59' INTERVAL(1h) FILL(PREV); +```mysql +select count(*) from d1001 interval(1h) fill(prev); ``` -针对 d1001 设备采集数据统计每小时记录数,如果某一个小时不存在数据,则返回之前一个小时的统计数据。TDengine 提供前向插值(prev)、线性插值(linear)、空值填充(NULL)、特定值填充(value)。 +For the data collected by device D1001, the number of records per hour is counted. If there is no data in a certain hour, statistical data of the previous hour is returned. TDengine provides forward interpolation (prev), linear interpolation (linear), NULL value populating (NULL), and specific value populating (value). -### 多表聚合查询 +### Multi-table Aggregation Query -TDengine 对每个数据采集点单独建表,但在实际应用中经常需要对不同的采集点数据进行聚合。为高效的进行聚合操作,TDengine 引入超级表(STable)的概念。超级表用来代表一特定类型的数据采集点,它是包含多张表的表集合,集合里每张表的模式(schema)完全一致,但每张表都带有自己的静态标签,标签可以有多个,可以随时增加、删除和修改。应用可通过指定标签的过滤条件,对一个 STable 下的全部或部分表进行聚合或统计操作,这样大大简化应用的开发。其具体流程如下图所示: +TDengine creates a separate table for each data collection point, but in practical applications, it is often necessary to aggregate data from different data collection points. In order to perform aggregation operations efficiently, TDengine introduces the concept of STable. STable is used to represent a specific type of data collection point. It is a table set containing multiple tables. The schema of each table in the set is the same, but each table has its own static tag. The tags can be multiple and be added, deleted and modified at any time. Applications can aggregate or statistically operate all or a subset of tables under a STABLE by specifying tag filters, thus greatly simplifying the development of applications. The process is shown in the following figure: -![多表聚合查询原理图](/img/architecture/multi_tables.png) +![Diagram of multi-table aggregation query](multi_tables.png) +
Figure 5: Diagram of multi-table aggregation query
-
图 5 多表聚合查询原理图
+1. Application sends a query condition to system; +2. TAOSC sends the STable name to Meta Node(management node); +3. Management node sends the vnode list owned by the STable back to TAOSC; +4. TAOSC sends the computing request together with tag filters to multiple data nodes corresponding to these vnodes; +5. Each vnode first finds out the set of tables within its own node that meet the tag filters from memory, then scans the stored time-series data, completes corresponding aggregation calculations, and returns result to TAOSC; +6. TAOSC finally aggregates the results returned by multiple data nodes and send them back to application. -1. 应用将一个查询条件发往系统; -2. taosc 将超级表的名字发往 meta node(管理节点); -3. 管理节点将超级表所拥有的 vnode 列表发回 taosc; -4. taosc 将计算的请求连同标签过滤条件发往这些 vnode 对应的多个数据节点; -5. 每个 vnode 先在内存里查找出自己节点里符合标签过滤条件的表的集合,然后扫描存储的时序数据,完成相应的聚合计算,将结果返回给 taosc; -6. taosc 将多个数据节点返回的结果做最后的聚合,将其返回给应用。 +Since TDengine stores tag data and time-series data separately in vnode, by filtering tag data in memory, the set of tables that need to participate in aggregation operation is first found, which greatly reduces the volume of data scanned and improves aggregation speed. At the same time, because the data is distributed in multiple vnodes/dnodes, the aggregation operation is carried out concurrently in multiple vnodes, which further improves the aggregation speed. Aggregation functions for ordinary tables and most operations are applicable to STables. The syntax is exactly the same. Please see TAOS SQL for details. -由于 TDengine 在 vnode 内将标签数据与时序数据分离存储,通过在内存里过滤标签数据,先找到需要参与聚合操作的表的集合,将需要扫描的数据集大幅减少,大幅提升聚合计算速度。同时,由于数据分布在多个 vnode/dnode,聚合计算操作在多个 vnode 里并发进行,又进一步提升了聚合的速度。 对普通表的聚合函数以及绝大部分操作都适用于超级表,语法完全一样,细节请看 TAOS SQL。 +### Precomputation -### 预计算 +In order to effectively improve the performance of query processing, based-on the unchangeable feature of IoT data, statistical information of data stored in data block is recorded in the head of data block, including max value, min value, and sum. We call it a precomputing unit. If the query processing involves all the data of a whole data block, the pre-calculated results are directly used, and no need to read the data block contents at all. Since the amount of pre-calculated data is much smaller than the actual size of data block stored on disk, for query processing with disk IO as bottleneck, the use of pre-calculated results can greatly reduce the pressure of reading IO and accelerate the query process. The precomputation mechanism is similar to the index BRIN (Block Range Index) of PostgreSQL. -为有效提升查询处理的性能,针对物联网数据的不可更改的特点,在数据块头部记录该数据块中存储数据的统计信息:包括最大值、最小值、和。我们称之为预计算单元。如果查询处理涉及整个数据块的全部数据,直接使用预计算结果,完全不需要读取数据块的内容。由于预计算数据量远小于磁盘上存储的数据块数据的大小,对于磁盘 I/O 为瓶颈的查询处理,使用预计算结果可以极大地减小读取 I/O 压力,加速查询处理的流程。预计算机制与 Postgre SQL 的索引 BRIN(block range index)有异曲同工之妙。 diff --git a/docs-en/21-tdinternal/02-replica.md b/docs-en/21-tdinternal/02-replica.md deleted file mode 100644 index 6a384b982d22956dd514d8df05dc827ca6f8b729..0000000000000000000000000000000000000000 --- a/docs-en/21-tdinternal/02-replica.md +++ /dev/null @@ -1,256 +0,0 @@ ---- -sidebar_label: 数据复制模块设计 -title: 数据复制模块设计 ---- - -## 数据复制概述 - -数据复制(Replication)是指同一份数据在多个物理地点保存。它的目的是防止数据丢失,提高系统的高可用性(High Availability),而且通过应用访问多个副本,提升数据查询性能。 - -在高可靠的大数据系统里,数据复制是必不可少的一大功能。数据复制又分为实时复制与非实时复制。实时复制是指任何数据的更新(包括数据的增加、删除、修改)操作,会被实时的复制到所有副本,这样任何一台机器宕机或网络出现故障,整个系统还能提供最新的数据,保证系统的正常工作。而非实时复制,是指传统的数据备份操作,按照固定的时间周期,将一份数据全量或增量复制到其他地方。如果主节点宕机,副本是很大可能没有最新数据,因此在有些场景是无法满足要求的。 - -TDengine面向的是物联网场景,需要支持数据的实时复制,来最大程度保证系统的可靠性。实时复制有两种方式,一种是异步复制,一种是同步复制。异步复制(Asynchronous Replication)是指数据由Master转发给Slave后,Master并不需要等待Slave回复确认,这种方式效率高,但有极小的概率会丢失数据。同步复制是指Master将数据转发给Slave后,需要等待Slave的回复确认,才会通知应用写入成功,这种方式效率偏低,但能保证数据绝不丢失。 - -数据复制是与数据存储(写入、读取)密切相关的,但两者又是相对独立,可以完全脱耦的。在TDengine系统中,有两种不同类型的数据,一种是时序数据,由TSDB模块负责;一种是元数据(Meta Data), 由MNODE负责。这两种性质不同的数据都需要同步功能。数据复制模块通过不同的实例启动配置参数,为这两种类型数据都提供同步功能。 - -在阅读本文之前,请先阅读《[TDengine 2.0 整体架构](/tdinternal/arch/)》,了解TDengine的集群设计和基本概念 - -特别注明:本文中提到数据更新操作包括数据的增加、删除与修改。 - -## 基本概念和定义 - -TDengine里存在vnode, mnode, vnode用来存储时序数据,mnode用来存储元数据。但从同步数据复制的模块来看,两者没有本质的区别,因此本文里的虚拟节点不仅包括vnode, 也包括mnode, vgroup也指mnode group, 除非特别注明。 - -**版本(version)**: - -一个虚拟节点组里多个虚拟节点互为备份,来保证数据的有效与可靠,是依靠虚拟节点组的数据版本号来维持的。TDengine2.0设计里,对于版本的定义如下:客户端发起增加、删除、修改的流程,无论是一条记录还是多条,只要是在一个请求里,这个数据更新请求被TDengine的一个虚拟节点收到后,经过合法性检查后,可以被写入系统时,就会被分配一个版本号。这个版本号在一个虚拟节点里从1开始,是单调连续递增的。无论这条记录是采集的时序数据还是meta data, 一样处理。当Master转发一个写入请求到slave时,必须带上版本号。一个虚拟节点将一数据更新请求写入WAL时,需要带上版本号。 - -不同虚拟节点组的数据版本号是完全独立的,互不相干的。版本号本质上是数据更新记录的transaction ID,但用来标识数据集的版本。 - -**角色(role):** - -一个虚拟节点可以是master, slave, unsynced或offline状态。 - -- master: 具有最新的数据,容许客户端往里写入数据,一个虚拟节点组,至多一个master. -- slave:与master是同步的,但不容许客户端往里写入数据,根据配置,可以容许客户端对其进行查询。 -- unsynced: 节点处于非同步状态,比如虚拟节点刚启动、或与其他虚拟节点的连接出现故障等。处于该状态时,该虚拟节点既不能提供写入,也不能提供查询服务。 -- offline: 由于宕机或网络原因,无法访问到某虚拟节点时,其他虚拟节点将该虚拟节点标为离线。但请注意,该虚拟节点本身的状态可能是unsynced或其他,但不会是离线。 - -**Quorum:** - -指数据写入成功所需要的确认数。对于异步复制,quorum设为1,具有master角色的虚拟节点自己确认即可。对于同步复制,需要至少大于等于2。原则上,Quorum >=1 并且 Quorum <= replication(副本数)。这个参数在启动一个同步模块实例时需要提供。 - -**WAL:** - -TDengine的WAL(Write Ahead Log)与cassandra的commit log, mySQL的bin log, Postgres的WAL没本质区别。没有写入数据库文件,还保存在内存的数据都会先存在WAL。当数据已经成功写入数据库数据文件,相应的WAL会被删除。但需要特别指明的是,在TDengine系统里,有几点: - -- 每个虚拟节点有自己独立的wal -- WAL里包含而且仅仅包含来自客户端的数据更新操作,每个更新操作都会被打上一个版本号 - -**复制实例:** - -复制模块只是一可执行的代码,复制实例是指正在运行的复制模块的一个实例,一个节点里,可以存在多个实例。原则上,一个节点有多少虚拟节点,就可以启动多少实例。对于副本数为1的场景,应用可以决定是否需要启动同步实例。应用启动一个同步模块的实例时,需要提供的就是虚拟节点组的配置信息,包括: - -- 虚拟节点个数,即replication number -- 各虚拟节点所在节点的信息,包括node的end point -- quorum, 需要的数据写入成功的确认数 -- 虚拟节点的初始版本号 - -## 数据复制模块的基本工作原理 - -TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性算法比较一致。总结下来,有几点: - -1. 一个vgroup里有一到多个虚拟节点,每个虚拟节点都有自己的角色 -2. 客户端只能向角色是master的虚拟节点发起数据更新操作,因为master具有最新版本的数据,如果向非Master发起数据更新操作,会直接收到错误 -3. 客户端可以向master, 也可以向角色是Slave的虚拟节点发起查询操作,但不能对unsynced的虚拟节点发起任何操作 -4. 如果master不存在,这个vgroup是不能对外提供数据更新和查询服务的 -5. master收到客户端的数据更新操作时,会将其转发给slave节点 -6. 一个虚拟节点的版本号比master低的时候,会发起数据恢复流程,成功后,才会成为slave - -数据实时复制有三个主要流程:选主、数据转发、数据恢复。后续做详细讨论。 - -## 虚拟节点之间的网络连接 - -虚拟节点之间通过TCP进行连接,节点之间的状态交换、数据包的转发都是通过这个TCP连接(peerFd)进行。为避免竞争,两个虚拟节点之间的TCP连接,总是由IP地址(UINT32)小的节点作为TCP客户端发起。一旦TCP连接被中断,虚拟节点能通过TCP socket自动检测到,将对方标为offline。如果监测到任何错误(比如数据恢复流程),虚拟节点将主动重置该连接。 - -一旦作为客户端的节点连接不成或中断,它将周期性的每隔一秒钟去试图去连接一次。因为TCP本身有心跳机制,虚拟节点之间不再另行提供心跳。 - -如果一个unsynced节点要发起数据恢复流程,它与Master将建立起专有的TCP连接(syncFd)。数据恢复完成后,该连接会被关闭。而且为限制资源的使用,系统只容许一定数量(配置参数tsMaxSyncNum)的数据恢复的socket存在。如果超过这个数字,系统会将新的数据恢复请求延后处理。 - -任意一个节点,无论有多少虚拟节点,都会启动而且只会启动一个TCP server, 来接受来自其他虚拟节点的上述两类TCP的连接请求。当TCP socket建立起来,客户端侧发送的消息体里会带有vgId(全局唯一的vgroup ID), TCP 服务器侧会检查该vgId是否已经在该节点启动运行。如果已经启动运行,就接受其请求。如果不存在,就直接将连接请求关闭。在TDengine代码里,mnode group的vgId设置为1。 - -## 选主流程 - -当同一组的两个虚拟节点之间(vnode A, vnode B)建立连接后,他们互换status消息。status消息里包含本地存储的同一虚拟节点组内所有虚拟节点的role和version。 - -如果一个虚拟节点(vnode A)检测到与同一虚拟节点组内另外一虚拟节点(vnode B)的连接中断,vnode A将立即把vnode B的role设置为offline。无论是接收到另外一虚拟节点发来的status消息,还是检测与另外一虚拟节点的连接中断,该虚拟节点都将进入状态处理流程。状态处理流程的规则如下: - -1. 如果检测到在线的节点数没有超过一半,则将自己的状态设置为unsynced. -2. 如果在线的虚拟节点数超过一半,会检查master节点是否存在,如果存在,则会决定是否将自己状态改为slave或启动数据恢复流程。 -3. 如果master不存在,则会检查自己保存的各虚拟节点的状态信息与从另一节点接收到的是否一致,如果一致,说明节点组里状态已经稳定一致,则会触发选举流程。如果不一致,说明状态还没趋于一致,即使master不存在,也不进行选主。由于要求状态信息一致才进行选举,每个虚拟节点根据同样的信息,会选出同一个虚拟节点做master,无需投票表决。 -4. 自己的状态是根据规则自己决定并修改的,并不需要其他节点同意,包括成为master。一个节点无权修改其他节点的状态。 -5. 如果一个虚拟节点检测到自己或其他虚拟节点的role发生改变,该节点会广播它自己保存的各个虚拟节点的状态信息(role和version)。 - -具体的流程图如下: - -![replica-master.png](/img/architecture/replica-master.png) - -选择Master的具体规则如下: - -1. 如果只有一个副本,该副本永远就是master -2. 所有副本都在线时,版本最高的被选为master -3. 在线的虚拟节点数过半,而且有虚拟节点是slave的话,该虚拟节点自动成为master -4. 对于2和3,如果多个虚拟节点满足成为master的要求,那么虚拟节点组的节点列表里,最前面的选为master - -按照上面的规则,如果所有虚拟节点都是unsynced(比如全部重启),只有所有虚拟节点上线,才能选出master,该虚拟节点组才能开始对外提供服务。当一个虚拟节点的role发生改变时,sync模块回通过回调函数notifyRole通知应用。 - -## 数据转发流程 - -如果vnode A是master, vnode B是slave, vnode A能接受客户端的写请求,而vnode B不能。当vnode A收到写的请求后,遵循下面的流程: - -![replica-forward.png](/img/architecture/replica-forward.png) - -1. 应用对写请求做基本的合法性检查,通过,则给该请求包打上一个版本号(version, 单调递增) -2. 应用将打上版本号的写请求封装一个WAL Head, 写入WAL(Write Ahead Log) -3. 应用调用API syncForwardToPeer,如果vnode B是slave状态,sync模块将包含WAL Head的数据包通过Forward消息发送给vnode B,否则就不转发。 -4. vnode B收到Forward消息后,调用回调函数writeToCache, 交给应用处理 -5. vnode B应用在写入成功后,都需要调用syncConfirmForward通知sync模块已经写入成功。 -6. 如果quorum大于1,vnode B需要等待应用的回复确认,收到确认后,vnode B发送Forward Response消息给node A。 -7. 如果quorum大于1,vnode A需要等待vnode B或其他副本对Forward消息的确认。 -8. 如果quorum大于1,vnode A收到quorum-1条确认消息后,调用回调函数confirmForward,通知应用写入成功。 -9. 如果quorum为1,上述6,7,8步不会发生。 -10. 如果要等待slave的确认,master会启动2秒的定时器(可配置),如果超时,则认为失败。 - -对于回复确认,sync模块提供的是异步回调函数,因此APP在调用syncForwardToPeer之后,无需等待,可以处理下一个操作。在Master与Slave的TCP连接管道里,可能有多个Forward消息,这些消息是严格按照应用提供的顺序排好的。对于Forward Response也是一样,TCP管道里存在多个,但都是排序好的。这个顺序,SYNC模块并没有做特别的事情,是由APP单线程顺序写来保证的(TDengine里每个vnode的写数据,都是单线程)。 - -## 数据恢复流程 - -如果一虚拟节点(vnode B) 处于unsynced状态,master存在(vnode A),而且其版本号比master的低,它将立即启动数据恢复流程。在理解恢复流程时,需要澄清几个关于文件的概念和处理规则。 - -1. 每个文件(无论是archived data的file还是wal)都有一个index, 这需要应用来维护(vnode里,该index就是fileId*3 + 0/1/2, 对应data, head与last三个文件)。如果index为0,表示系统里最老的数据文件。对于mode里的文件,数量是固定的,对应于acct, user, db, table等文件。 -2. 任何一个数据文件(file)有名字、大小,还有一个magic number。只有文件名、大小与magic number一致时,两个文件才判断是一样的,无需同步。Magic number可以是checksum, 也可以是简单的文件大小。怎么计算magic,换句话说,如何检测数据文件是否有效,完全由应用决定。 -3. 文件名的处理有点复杂,因为每台服务器的路径可能不一致。比如node A的TDengine的数据文件存放在 /etc/taos目录下,而node B的数据存放在 /home/jhtao目录下。因此同步模块需要应用在启动一个同步实例时提供一个path,这样两台服务器的绝对路径可以不一样,但仍然可以做对比,做同步。 -4. 当sync模块调用回调函数getFileInfo获得数据文件信息时,有如下的规则 - * index 为0,表示获取最老的文件,同时修改index返回给sync模块。如果index不为0,表示获取指定位置的文件。 - * 如果name为空,表示sync想获取位于index位置的文件信息,包括magic, size。Master节点会这么调用 - * 如果name不为空,表示sync想获取指定文件名和index的信息,slave节点会这么调用 - * 如果某个index的文件不存在,magic返回0,表示文件已经是最后一个。因此整个系统里,文件的index必须是连续的一段整数。 -5. 当sync模块调用回调函数getWalInfo获得wal信息时,有如下规则 - * index为0,表示获得最老的WAL文件, 返回时,index更新为具体的数字 - * 如果返回0,表示这是最新的一个WAL文件,如果返回值是1,表示后面还有更新的WAL文件 - * 返回的文件名为空,那表示没有WAL文件 -6. 无论是getFileInfo, 还是getWalInfo, 只要获取出错(不是文件不存在),返回-1即可,系统会报错,停止同步 - -整个数据恢复流程分为两大步骤,第一步,先恢复archived data(file), 然后恢复wal。具体流程如下: - -![replica-restore.png](/img/architecture/replica-restore.png) - -1. 通过已经建立的TCP连接,发送sync req给master节点 -2. master收到sync req后,以client的身份,向vnode B主动建立一新的专用于同步的TCP连接(syncFd) -3. 新的TCP连接建立成功后,master将开始retrieve流程,对应的,vnode B将同步启动restore流程 -4. Retrieve/Restore流程里,先处理所有archived data (vnode里的data, head, last文件),后处理WAL data。 -5. 对于archived data,master将通过回调函数getFileInfo获取数据文件的基本信息,包括文件名、magic以及文件大小。 -6. master 将获得的文件名、magic以及文件大小发给vnode B -7. vnode B将回调函数getFile获得magic和文件大小,如果两者一致,就认为无需同步,如果两者不一致 ,就认为需要同步。vnode B将结果通过消息FileAck发回master -8. 如果文件需要同步,master就调用sendfile把整个文件发往vnode B -9. 如果文件不需要同步,master(vnode A)就重复5,6,7,8,直到所有文件被处理完 - -对于WAL同步,流程如下: - -1. master节点调用回调函数getWalInfo,获取WAL的文件名。 -2. 如果getWalInfo返回值大于0,表示该文件还不是最后一个WAL,因此master调用sendfile一下把该文件发送给vnode B -3. 如果getWalInfo返回时为0,表示该文件是最后一个WAL,因为文件可能还处于写的状态中,sync模块要根据WAL Head的定义逐条读出记录,然后发往vnode B。 -4. vnode A读取TCP连接传来的数据,按照WAL Head,逐条读取,如果版本号比现有的大,调用回调函数writeToCache,交给应用处理。如果小,直接扔掉。 -5. 上述流程循环,直到所有WAL文件都被处理完。处理完后,master就会将新来的数据包通过Forward消息转发给slave。 - -从同步文件启动起,sync模块会通过inotify监控所有处理过的file以及wal。一旦发现被处理过的文件有更新变化,同步流程将中止,会重新启动。因为有可能落盘操作正在进行(比如历史数据导入,内存数据落盘),把已经处理过的文件进行了修改,需要重新同步才行。 - -对于最后一个WAL (LastWal)的处理逻辑有点复杂,因为这个文件往往是打开写的状态,有很多场景需要考虑,比如: - -- LastWal文件size在增长,需要重新读; -- LastWal文件虽然已经打开写,但内容为空; -- LastWal文件已经被关闭,应用生成了新的Last WAL文件; -- LastWal文件没有被关闭,但数据落盘的原因,没有读到完整的一条记录; -- LastWal文件没有被关闭,但数据落盘的原因,还有部分记录暂时读取不到; - -sync模块通过inotify监控LastWal文件的更新和关闭操作。而且在确认已经尽可能读完LastWal的数据后,会将对方同步状态设置为SYNC_CACHE。该状态下,master节点会将新的记录转发给vnode B,而此时vnode B并没有完成同步,需要把这些转发包先存在recv buffer里,等WAL处理完后,vnode A再把recv buffer里的数据包通过回调writeToCache交给应用处理。 - -等vnode B把这些buffered forwards处理完,同步流程才算结束,vnode B正式变为slave。 - -## Master分布均匀性问题 - -因为Master负责写、转发,消耗的资源会更多,因此Master在整个集群里分布均匀比较理想。 - -但在TDengine的设计里,如果多个虚拟节点都符合master条件,TDengine选在列表中最前面的做Master, 这样是否导致在集群里,Master数量的分布不均匀问题呢?这取决于应用的设计。 - -给一个具体例子,系统里仅仅有三个节点,IP地址分别为IP1, IP2, IP3. 在各个节点上,TDengine创建了多个虚拟节点组,每个虚拟节点组都有三个副本。如果三个副本的顺序在所有虚拟节点组里都是IP1, IP2, IP3, 那毫无疑问,master将集中在IP1这个节点,这是我们不想看到的。 - -但是,如果在创建虚拟节点组时,增加随机性,这个问题就不存在了。比如在vgroup 1, 顺序是IP1, IP2, IP3, 在vgroup 2里,顺序是IP2, IP3, IP1, 在vgroup 3里,顺序是IP3, IP1, IP2。最后master的分布会是均匀的。 - -因此在创建一个虚拟节点组时,应用需要保证节点的顺序是round robin或完全随机。 - -## 少数虚拟节点写入成功的问题 - -在某种情况下,写入成功的确认数大于0,但小于配置的Quorum, 虽然有虚拟节点数据更新成功,master仍然会认为数据更新失败,并通知客户端写入失败。 - -这个时候,系统存在数据不一致的问题,因为有的虚拟节点已经写入成功,而有的写入失败。一个处理方式是,Master重置(reset)与其他虚拟节点的连接,该虚拟节点组将自动进入选举流程。按照规则,已经成功写入数据的虚拟节点将成为新的master,组内的其他虚拟节点将从master那里恢复数据。 - -因为写入失败,客户端会重新写入数据。但对于TDengine而言,是OK的。因为时序数据都是有时间戳的,时间戳相同的数据更新操作,第一次会执行,但第二次会自动扔掉。对于Meta Data(增加、删除库、表等等)的操作,也是OK的。一张表、库已经被创建或删除,再创建或删除,不会被执行的。 - -在TDengine的设计里,虚拟节点与虚拟节点之间,是一个TCP连接,是一个pipeline,数据块一个接一个按顺序在这个pipeline里等待处理。一旦某个数据块的处理失败,这个连接会被重置,后续的数据块的处理都会失败。因此不会存在Pipeline里一个数据块更新失败,但下一个数据块成功的可能。 - -## Split Brain的问题 - -选举流程中,有个强制要求,那就是一定有超过半数的虚拟节点在线。但是如果replication正好是偶数,这个时候,完全可能存在splt brain问题。 - -为解决这个问题,TDengine提供Arbitrator的解决方法。Arbitrator是一个节点,它的任务就是接受任何虚拟节点的连接请求,并保持它。 - -在启动复制模块实例时,在配置参数中,应用可以提供Arbitrator的IP地址。如果是奇数个副本,复制模块不会与这个arbitrator去建立连接,但如果是偶数个副本,就会主动去建立连接。 - -Arbitrator的程序tarbitrator.c在复制模块的同一目录, 编译整个系统时,会在bin目录生成。命令行参数“-?”查看可以配置的参数,比如绑定的IP地址,监听的端口号。 - -## 与RAFT相比的异同 - -数据一致性协议流行的有两种,Paxos与Raft. 本设计的实现与Raft有很多类同之处,下面做一些比较 - -相同之处: - -- 三大流程一致:Raft里有Leader election, replication, safety,完全对应TDengine的选举、数据转发、数据恢复三个流程。 -- 节点状态定义一致:Raft里每个节点有Leader, Follower, Candidate三个状态,TDengine里是Master, Slave, Unsynced, Offline。多了一个offlince, 但本质上是一样的,因为offline是外界看一个节点的状态,但该节点本身是处于master, slave 或unsynced的。 -- 数据转发流程完全一样,Master(leader)需要等待回复确认。 -- 数据恢复流程几乎一样,Raft没有涉及历史数据同步问题,只考虑了WAL数据同步。 - -不同之处: - -- 选举流程不一样:Raft里任何一个节点是candidate时,主动向其他节点发出vote request,如果超过半数回答Yes,这个candidate就成为Leader,开始一个新的term。而TDengine的实现里,节点上线、离线或角色改变都会触发状态消息在节点组内传播,等节点组里状态稳定一致之后才触发选举流程,因为状态稳定一致,基于同样的状态信息,每个节点做出的决定会是一致的,一旦某个节点符合成为master的条件,无需其他节点认可,它会自动将自己设为master。TDengine里,任何一个节点检测到其他节点或自己的角色发生改变,就会向节点组内其他节点进行广播。Raft里不存在这样的机制,因此需要投票来解决。 -- 对WAL的一条记录,Raft用term + index来做唯一标识。但TDengine只用version(类似index),在TDengine实现里,仅仅用version是完全可行的, 因为TDengine的选举机制,没有term的概念。 - -如果整个虚拟节点组全部宕机,重启,但不是所有虚拟节点都上线,这个时候TDengine是不会选出master的,因为未上线的节点有可能有最高version的数据。而RAFT协议,只要超过半数上线,就会选出Leader。 - -## Meta Data的数据复制 - -TDengine里存在时序数据,也存在Meta Data。Meta Data对数据的可靠性要求更高,那么TDengine设计能否满足要求呢?下面做个仔细分析。 - -TDengine里Meta Data包括以下: - -- account 信息 -- 一个account下面,可以有多个user, 多个DB -- 一个DB下面有多个vgroup -- 一个DB下面有多个stable -- 一个vgroup下面有多个table -- 整个系统有多个mnode, dnode -- 一个dnode可以有多个vnode - -上述的account, user, DB, vgroup, table, stable, mnode, dnode都有自己的属性,这些属性是TDengine自己定义的,不会开放给用户进行修改。这些Meta Data的查询都比较简单,都可以采用key-value模型进行存储。这些Meta Data还具有几个特点: - -1. 上述的Meta Data之间有一定的层级关系,比如必须先创建DB,才能创建table, stable。只有先创建dnode,才可能创建vnode, 才可能创建vgroup。因此他们创建的顺序是绝对不能错的。 -2. 在客户端应用的数据更新操作得到TDengine服务器侧确认后,所执行的数据更新操作绝对不能丢失。否则会造成客户端应用与服务器的数据不一致。 -3. 上述的Meta Data是容许重复操作的。比如插入新记录后,再插入一次,删除一次后,再删除一次,更新一次后,再更新一次,不会对系统产生任何影响,不会改变系统任何状态。 - -对于特点1,本设计里,数据的写入是单线程的,按照到达的先后顺序,给每个数据更新操作打上版本号,版本号大的记录一定是晚于版本号小的写入系统,数据写入顺序是100%保证的,绝对不会让版本号大的记录先写入。复制过程中,数据块的转发也是严格按照顺序进行的,因此TDengine的数据复制设计是能保证Meta Data的创建顺序的。 - -对于特点2,只要Quorum数设置等于replica,那么一定能保证回复确认过的数据更新操作不会在服务器侧丢失。即使某节点永不起来,只要超过一半的节点还是online, 查询服务不会受到任何影响。这时,如果某个节点离线超过一定时长,系统可以自动补充新的节点,以保证在线的节点数在绝大部分时间是100%的。 - -对于特点3,完全可能发生,服务器确实持久化存储了某一数据更新操作,但客户端应用出了问题,认为操作不成功,它会重新发起操作。但对于Meta Data而言,没有关系,客户端可以再次发起同样的操作,不会有任何影响。 - -总结来看,只要quorum设置大于一,本数据复制的设计是能满足Meta Data的需求的。目前,还没有发现漏洞。 diff --git a/docs-en/21-tdinternal/03-taosd.md b/docs-en/21-tdinternal/03-taosd.md deleted file mode 100644 index f0f50e03e277524fc37f44a2207b43e87898937e..0000000000000000000000000000000000000000 --- a/docs-en/21-tdinternal/03-taosd.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -sidebar_label: taosd 的设计 -title: taosd的设计 ---- - - -逻辑上,TDengine 系统包含 dnode,taosc 和 App,dnode 是服务器侧执行代码 taosd 的一个运行实例,因此 taosd 是 TDengine 的核心,本文对 taosd 的设计做一简单的介绍,模块内的实现细节请见其他文档。 - -## 系统模块图 - -taosd 包含 rpc,dnode,vnode,tsdb,query,cq,sync,wal,mnode,http,monitor 等模块,具体如下图: - -![modules.png](/img/architecture/modules.png) - -taosd 的启动入口是 dnode 模块,dnode 然后启动其他模块,包括可选配置的 http,monitor 模块。taosc 或 dnode 之间交互的消息都是通过 rpc 模块进行,dnode 模块根据接收到的消息类型,将消息分发到 vnode 或 mnode 的消息队列,或由 dnode 模块自己消费。dnode 的工作线程(worker)消费消息队列里的消息,交给 mnode 或 vnode 进行处理。下面对各个模块做简要说明。 - -## RPC模块 - -该模块负责 taosd 与 taosc,以及其他数据节点之间的通讯。TDengine 没有采取标准的 HTTP 或 gRPC 等第三方工具,而是实现了自己的通讯模块 RPC。 - -考虑到物联网场景下,数据写入的包一般不大,因此除支持 TCP 连接之外,RPC 还支持 UDP 连接。当数据包小于 15K 时,RPC 将采用 UDP 方式进行连接,否则将采用 TCP 连接。对于查询类的消息,RPC 不管包的大小,总是采取 TCP 连接。对于 UDP 连接,RPC 实现了自己的超时、重传、顺序检查等机制,以保证数据可靠传输。 - -RPC 模块还提供数据压缩功能,如果数据包的字节数超过系统配置参数 compressMsgSize,RPC 在传输中将自动压缩数据,以节省带宽。 - -为保证数据的安全和数据的 integrity,RPC 模块采用 MD5 做数字签名,对数据的真实性和完整性进行认证。 - -## DNODE模块 - -该模块是整个 taosd 的入口,它具体负责如下任务: - -- 系统的初始化,包括 - - 从文件 taos.cfg 读取系统配置参数,从文件 dnodeCfg.json 读取数据节点的配置参数; - - 启动 RPC 模块,并建立起与 taosc 通讯的 server 连接,与其他数据节点通讯的 server 连接; - - 启动并初始化 dnode 的内部管理,该模块将扫描该数据节点已有的 vnode ,并打开它们; - - 初始化可配置的模块,如 mnode,http,monitor 等。 -- 数据节点的管理,包括 - - 定时的向 mnode 发送 status 消息,报告自己的状态; - - 根据 mnode 的指示,创建、改变、删除 vnode; - - 根据 mnode 的指示,修改自己的配置参数; -- 消息的分发、消费,包括 - - 为每一个 vnode 和 mnode 的创建并维护一个读队列、一个写队列; - - 将从 taosc 或其他数据节点来的消息,根据消息类型,将其直接分发到不同的消息队列,或由自己的管理模块直接消费; - - 维护一个读的线程池,消费读队列的消息,交给 vnode 或 mnode 处理。为支持高并发,一个读线程(worker)可以消费多个队列的消息,一个读队列可以由多个 worker 消费; - - 维护一个写的线程池,消费写队列的消息,交给 vnode 或 mnode 处理。为保证写操作的序列化,一个写队列只能由一个写线程负责,但一个写线程可以负责多个写队列。 - -taosd 的消息消费由 dnode 通过读写线程池进行控制,是系统的中枢。该模块内的结构体图如下: - -![dnode.png](/img/architecture/dnode.png) - -## VNODE模块 - -vnode 是一独立的数据存储查询逻辑单元,但因为一个 vnode 只能容许一个 DB ,因此 vnode 内部没有 account,DB,user 等概念。为实现更好的模块化、封装以及未来的扩展,它有很多子模块,包括负责存储的 TSDB,负责查询的 query,负责数据复制的 sync,负责数据库日志的的 wal,负责连续查询的 cq(continuous query),负责事件触发的流计算的 event 等模块,这些子模块只与 vnode 模块发生关系,与其他模块没有任何调用关系。模块图如下: - -![vnode.png](/img/architecture/vnode.png) - -vnode 模块向下,与 dnodeVRead,dnodeVWrite 发生互动,向上,与子模块发生互动。它主要的功能有: - -- 协调各个子模块的互动。各个子模块之间都不直接调用,都需要通过 vnode 模块进行; -- 对于来自 taosc 或 mnode 的写操作,vnode 模块将其分解为写日志(wal),转发(sync),本地存储(TSDB)子模块的操作; -- 对于查询操作,分发到 query 模块进行。 - -一个数据节点里有多个 vnode,因此 vnode 模块是有多个运行实例的。每个运行实例是完全独立的。 - -vnode 与其子模块是通过 API 直接调用,而不是通过消息队列传递。而且各个子模块只与 vnode 模块有交互,不与 dnode,rpc 等模块发生任何直接关联。 - -## MNODE模块 - -mnode 是整个系统的大脑,负责整个系统的资源调度,负责 meta data 的管理与存储。 - -一个运行的系统里,只有一个 mnode,但它有多个副本(由系统配置参数 numOfMnodes 控制)。这些副本分布在不同的 dnode 里,目的是保证系统的高可靠运行。副本之间的数据复制是采用同步而非异步的方式,以确保数据的一致性,确保数据不会丢失。这些副本会自动选举一个 Master,其他副本是 slave。所有数据更新类的操作,都只能在 master 上进行,而查询类的可以在 slave 节点上进行。代码实现上,同步模块与 vnode 共享,但 mnode 被分配一个特殊的 vgroup ID: 1,而且 quorum 大于1。整个集群系统是由多个 dnode 组成的,运行的 mnode 的副本数不可能超过 dnode 的个数,但不会超过配置的副本数。如果某个 mnode 副本宕机一段时间,只要超过半数的 mnode 副本仍在运行,运行的 mnode 会自动根据整个系统的资源情况,在其他 dnode 里再启动一个 mnode,以保证运行的副本数。 - -各个 dnode 通过信息交换,保存有 mnode 各个副本的 End Point 列表,并向其中的 master 节点定时(间隔由系统配置参数 statusInterval 控制)发送 status 消息,消息体里包含该 dnode 的 CPU、内存、剩余存储空间、vnode 个数,以及各个 vnode 的状态(存储空间、原始数据大小、记录条数、角色等)。这样 mnode 就了解整个系统的资源情况,如果用户创建新的表,就可以决定需要在哪个 dnode 创建;如果增加或删除 dnode,或者监测到某 dnode 数据过热、或离线太长,就可以决定需要挪动那些 vnode,以实现负载均衡。 - -mnode 里还负责 account,user,DB,stable,table,vgroup,dnode 的创建、删除与更新。mnode 不仅把这些 entity 的 meta data 保存在内存,还做持久化存储。但为节省内存,各个表的标签值不保存在 mnode(保存在 vnode),而且子表不维护自己的 schema,而是与 stable 共享。为减小 mnode 的查询压力,taosc 会缓存 table、stable 的 schema。对于查询类的操作,各个 slave mnode 也可以提供,以减轻 master 压力。 - -## TSDB模块 - -TSDB 模块是 vnode 中的负责快速高并发地存储和读取属于该 vnode 的表的元数据及采集的时序数据的引擎。除此之外,TSDB 还提供了表结构的修改、表标签值的修改等功能。TSDB 提供 API 供 vnode 和 query 等模块调用。TSDB 中存储了两类数据,1:元数据信息;2:时序数据 - -### 元数据信息 - -TSDB 中存储的元数据包含属于其所在的 vnode 中表的类型,schema 的定义等。对于超级表和超级表下的子表而言,又包含了 tag 的 schema 定义以及子表的 tag 值等。对于元数据信息而言,TSDB 就相当于一个全内存的KV型数据库,属于该 vnode 的表对象全部在内存中,方便快速查询表的信息。除此之外,TSDB 还对其中的子表,按照 tag 的第一列取值做了全内存的索引,大大加快了对于标签的过滤查询。TSDB 中的元数据的最新状态在落盘时,会以追加(append-only)的形式,写入到 meta 文件中。meta 文件只进行追加操作,即便是元数据的删除,也会以一条记录的形式写入到文件末尾。TSDB 也提供了对于元数据的修改操作,如表 schema 的修改,tag schema 的修改以及 tag 值的修改等。 - -### 时序数据 - -每个 TSDB 在创建时,都会事先分配一定量的内存缓冲区,且内存缓冲区的大小可配可修改。表采集的时序数据,在写入 TSDB 时,首先以追加的方式写入到分配的内存缓冲区中,同时建立基于时间戳的内存索引,方便快速查询。当内存缓冲区的数据积累到一定的程度时(达到内存缓冲区总大小的 1/3),则会触发落盘操作,将缓冲区中的数据持久化到硬盘文件上。时序数据在内存缓冲区中是以行(row)的形式存储的。 - -而时序数据在写入到 TSDB 的数据文件时,是以列(column)的形式存储的。TSDB 中的数据文件包含多个数据文件组,每个数据文件组中又包含 .head、.data 和 .last 三个文件,如(v2f1801.head、v2f1801.data、v2f1801.last)数据文件组。TSDB 中的数据文件组是按照时间跨度进行分片的,默认是 10 天一个文件组,且可通过配置文件及建库选项进行配置。分片的数据文件组又按照编号递增排列,方便快速定位某一时间段的时序数据,高效定位数据文件组。时序数据在 TSDB 的数据文件中是以块的形式进行列式存储的,每个块中只包含一张表的数据,且数据在一个块中是按照时间顺序递增排列的。在一个数据文件组中,.head 文件负责存储数据块的索引及统计信息,如每个块的位置,压缩算法,时间戳范围等。存储在 .head 文件中一张表的索引信息是按照数据块中存储的数据的时间递增排列的,方便进行折半查找等工作。.head 和 .last文件是存储真实数据块的文件,若数据块中的数据累计到一定程度,则会写入 .data 文件中,否则,会写入 .last 文件中,等待下次落盘时合并数据写入 .data 文件中,从而大大减少文件中块的个数,避免数据的过度碎片化。 - -## Query模块 - -该模块负责整体系统的查询处理。客户端调用该该模块进行 SQL 语法解析,并将查询或写入请求发送到 vnode ,同时负责针对超级表的查询进行二阶段的聚合操作。在 vnode 端,该模块调用 TSDB 模块读取系统中存储的数据进行查询处理。query 模块还定义了系统能够支持的全部查询函数,查询函数的实现机制与查询框架无耦合,可以在不修改查询流程的情况下动态增加查询函数。详细的设计请参见《TDengine 2.0 查询模块设计》。 - -## SYNC模块 - -该模块实现数据的多副本复制,包括vnode与mnode的数据复制,支持异步和同步两种复制方式,以满足meta data与时序数据不同复制的需求。因为它为mnode与vnode共享,系统为mnode副本预留了一个特殊的vgroup ID:1。因此vnode group的ID是从2开始的。 - -每个vnode/mnode模块实例会有一对应的sync模块实例,他们是一一对应的。详细设计请见[TDengine 2.0 数据复制模块设计](/tdinternal/replica/) - -## WAL模块 - -该模块负责将新插入的数据写入 write ahead log(WAL),为vnode,mnode共享。以保证服务器 crash 或其他故障,能从 WAL 中恢复数据。 - -每个 vnode/mnode 模块实例会有一对应的 wal 模块实例,是完全一一对应的。WAL 的落盘操作由两个参数 walLevel,fsync 控制。看具体场景,如果要 100% 保证数据不会丢失,需要将 walLevel 配置为 2,fsync 设置为 0,每条数据插入请求,都会实时落盘后,才会给应用确认 - -## HTTP模块 - -该模块负责处理系统对外的 RESTful 接口,可以通过配置,由 dnode 启动或停止 。(仅 2.2 及之前的版本中存在) - -该模块将接收到的 RESTful 请求,做了各种合法性检查后,将其变成标准的 SQL 语句,通过 taosc 的异步接口,将请求发往整个系统中的任一 dnode 。收到处理后的结果后,再翻译成 HTTP 协议,返回给应用。 - -如果HTTP模块启动,就意味着启动了一个taosc的实例。任一一个dnode都可以启动该模块,以实现对RESTful请求的分布式处理。 - -## Monitor模块 - -该模块负责检测一个 dnode 的运行状态,可以通过配置,由 dnode 启动或停止。原则上,每个 dnode 都应该启动一个 monitor 实例。 - -Monitor 采集 TDengine 里的关键操作,比如创建、删除、更新账号、表、库等,而且周期性的收集 CPU、内存、网络等资源的使用情况(采集周期由系统配置参数 monitorInterval 控制)。获得这些数据后,monitor 模块将采集的数据写入系统的日志库(DB 名字由系统配置参数 monitorDbName 控制)。 - -Monitor 模块使用 taosc 来将采集的数据写入系统,因此每个 monitor 实例,都有一个 taosc 运行实例。 - diff --git a/docs-en/21-tdinternal/12-tsz-compress.md b/docs-en/21-tdinternal/12-tsz-compress.md deleted file mode 100644 index baf5df15db3b44edc9e0bd6909e46fa84b676a0b..0000000000000000000000000000000000000000 --- a/docs-en/21-tdinternal/12-tsz-compress.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: TSZ 压缩算法 ---- - -TSZ 压缩算法是 TDengine 为浮点数据类型提供更加丰富的压缩功能,可以实现浮点数的有损至无损全状态压缩,相比原来在 TDengine 中原有压缩算法,TSZ 压缩算法压缩选项更丰富,压缩率更高,即使切到无损状态下对浮点数压缩,压缩率也会比原来的压缩算法高一倍。 - -## 适合场景 - -TSZ 压缩算法压缩率比原来的要高,但压缩时间会更长,即开启 TSZ 压缩算法写入速度会有一些下降,通常情况下会有 20% 左右的下降。影响写入速度是因为需要更多的 CPU 计算,所以从原始数据到压缩好数据的交付时间变长,导致写入速度变慢。如果您的服务器 CPU 配置很高的话,这个影响会变小甚至没有。 - -另外如果设备产生了大量的高精度浮点数,存储占用的空间非常庞大,但实际使用并不需要那么高的精度时,可以通过 TSZ 压缩的有损压缩功能,把精度压缩至指定的长度,节约存储空间。 - -总结:采集到了大量浮点数,存储时占用空间过大或出有存储空间不足,需要超高压缩率的场景。 - -## 使用步骤 - -- 检查版本支持,2.4.0.10 及之后 TDengine 的版本都支持此功能 - -- 配置选项开启功能,在 TDengine 的配置文件 taos.cfg 增加一行以下内容,打开 TSZ 功能 - -```TSZ -lossyColumns float|double -``` - -- 根据自己需要配置其它选项,如果不配置都会按默认值处理。 - -- 重启服务,配置生效。 -- 确认功能已开启,在服务启动过程中输出的信息如果有前面配置的内容,表明功能已生效: - -```TSZ Test -02/22 10:49:27.607990 00002933 UTL lossyColumns float|double -``` - -## 注意事项 - -- 确认版本是否支持 - -- 除了服务器启动时的输出的配置成功信息外,不再会有其它的信息输出是使用的哪种压缩算法,可以通过配置前后数据库文件大小来比较效果 - -- 如果浮点数类型列较少,看整体数据文件大小效果会不太明显 - -- 此压缩产生的数据文件中浮点数据部分将不能被 2.4.0.10 以下的版本解析,即不向下兼容,使用时避免更换回旧版本,以免数据不能被读取出来。 - -- 在使用过程中允许反复开启和关闭 TSZ 压缩选项的操作,前后两种压缩算法产生的数据都能正常读取。 diff --git a/docs-en/21-tdinternal/30-iot-big-data.md b/docs-en/21-tdinternal/30-iot-big-data.md index a234713f883056e3d1a0dcbfe8e2e47a82865f81..4bdf5cfba98234c9d843634b5210ca3dae94d870 100644 --- a/docs-en/21-tdinternal/30-iot-big-data.md +++ b/docs-en/21-tdinternal/30-iot-big-data.md @@ -1,9 +1,10 @@ --- -title: 物联网大数据 -description: "物联网、工业互联网大数据的特点;物联网大数据平台应具备的功能和特点;通用大数据架构为什么不适合处理物联网数据;物联网、车联网、工业互联网大数据平台,为什么推荐使用 TDengine" +title: IoT Big Data +description: "Characteristics of IoT Big Data, why general big data platform does not work well for IoT? The required features for an IoT Big Data Platform" --- -- [物联网、工业互联网大数据的特点](https://www.taosdata.com/blog/2019/07/09/105.html) -- [物联网大数据平台应具备的功能和特点](https://www.taosdata.com/blog/2019/07/29/542.html) -- [通用大数据架构为什么不适合处理物联网数据?](https://www.taosdata.com/blog/2019/07/09/107.html) -- [物联网、车联网、工业互联网大数据平台,为什么推荐使用 TDengine?](https://www.taosdata.com/blog/2019/07/09/109.html) +- [Characteristics of IoT Big Data](https://tdengine.com/2019/07/09/86.html) +- [Why don’t General Big Data Platforms Fit IoT Scenarios?](https://tdengine.com/2019/07/09/92.html) +- [Why TDengine is the Best Choice for IoT Big Data Processing?](https://tdengine.com/2019/07/09/94.html) +- [Why Redis, Kafka, Spark aren’t Needed if TDengine is Used in the IoT Platform?](https://tdengine.com/2019/07/09/96.html) + diff --git a/docs-en/21-tdinternal/_category_.yml b/docs-en/21-tdinternal/_category_.yml index 73c78f68a520fefecc145daaa24fe7e28c7c78e2..9d3df5ce3eb8e8ba3e1b01eb4a2c2ef89b631665 100644 --- a/docs-en/21-tdinternal/_category_.yml +++ b/docs-en/21-tdinternal/_category_.yml @@ -1,4 +1 @@ -label: 技术内幕 -link: - slug: /tdinternal/ - type: generated-index \ No newline at end of file +label: TDengine Inside \ No newline at end of file diff --git a/docs-en/21-tdinternal/dnode.png b/docs-en/21-tdinternal/dnode.png new file mode 100644 index 0000000000000000000000000000000000000000..cea87dcccba5d2761996e5dde998022d86487eb9 Binary files /dev/null and b/docs-en/21-tdinternal/dnode.png differ diff --git a/docs-en/21-tdinternal/index.md b/docs-en/21-tdinternal/index.md new file mode 100644 index 0000000000000000000000000000000000000000..999d6f89ff57164d6e0372620504c8ecc9de7c9b --- /dev/null +++ b/docs-en/21-tdinternal/index.md @@ -0,0 +1,10 @@ +--- +title: TDengine Inside +--- + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-en/21-tdinternal/message.png b/docs-en/21-tdinternal/message.png new file mode 100644 index 0000000000000000000000000000000000000000..715a8bd37ee9fe7e96eacce4e7ff563fedeefbee Binary files /dev/null and b/docs-en/21-tdinternal/message.png differ diff --git a/docs-en/21-tdinternal/modules.png b/docs-en/21-tdinternal/modules.png new file mode 100644 index 0000000000000000000000000000000000000000..10ae4703a6cbbf66afea325ce4c0f919f7769a07 Binary files /dev/null and b/docs-en/21-tdinternal/modules.png differ diff --git a/docs-en/21-tdinternal/multi_tables.png b/docs-en/21-tdinternal/multi_tables.png new file mode 100644 index 0000000000000000000000000000000000000000..0cefaab6a9a4cdd671c671f7c6186dea41415ff0 Binary files /dev/null and b/docs-en/21-tdinternal/multi_tables.png differ diff --git a/docs-en/21-tdinternal/replica-forward.png b/docs-en/21-tdinternal/replica-forward.png new file mode 100644 index 0000000000000000000000000000000000000000..bf616e030b130603eceb5dccfd30b4a1dfa68ea5 Binary files /dev/null and b/docs-en/21-tdinternal/replica-forward.png differ diff --git a/docs-en/21-tdinternal/replica-master.png b/docs-en/21-tdinternal/replica-master.png new file mode 100644 index 0000000000000000000000000000000000000000..cb33f1ce98661563693215d8fc73b003235c7668 Binary files /dev/null and b/docs-en/21-tdinternal/replica-master.png differ diff --git a/docs-en/21-tdinternal/replica-restore.png b/docs-en/21-tdinternal/replica-restore.png new file mode 100644 index 0000000000000000000000000000000000000000..1558e5ed0108d23efdc6b5d9ea0e44a1dff45d28 Binary files /dev/null and b/docs-en/21-tdinternal/replica-restore.png differ diff --git a/docs-en/21-tdinternal/structure.png b/docs-en/21-tdinternal/structure.png new file mode 100644 index 0000000000000000000000000000000000000000..4fc8f47ab0a30d95b85ba1d85105726ed981e56e Binary files /dev/null and b/docs-en/21-tdinternal/structure.png differ diff --git a/docs-en/21-tdinternal/vnode.png b/docs-en/21-tdinternal/vnode.png new file mode 100644 index 0000000000000000000000000000000000000000..e6148d4907cf9a18bc52251f712d5c685651b7f5 Binary files /dev/null and b/docs-en/21-tdinternal/vnode.png differ diff --git a/docs-en/21-tdinternal/write_master.png b/docs-en/21-tdinternal/write_master.png new file mode 100644 index 0000000000000000000000000000000000000000..ff2dfc20bfc2ecf956a2aab1a8965a7bbcae4387 Binary files /dev/null and b/docs-en/21-tdinternal/write_master.png differ diff --git a/docs-en/21-tdinternal/write_slave.png b/docs-en/21-tdinternal/write_slave.png new file mode 100644 index 0000000000000000000000000000000000000000..cacb2cb6bcc4f4d934e979862387e1345bbac078 Binary files /dev/null and b/docs-en/21-tdinternal/write_slave.png differ diff --git a/docs-en/25-application/01-telegraf.md b/docs-en/25-application/01-telegraf.md index 87f74fa67fbdbc3e4c5631b9cd393c4a78d3e25e..e3d8b90eb20cdc06b222bf5ed2c016cddf359901 100644 --- a/docs-en/25-application/01-telegraf.md +++ b/docs-en/25-application/01-telegraf.md @@ -1,44 +1,44 @@ --- sidebar_label: TDengine + Telegraf + Grafana -title: 使用 TDengine + Telegraf + Grafana 快速搭建 IT 运维展示系统 +title: Quickly Build IT DevOps Visualization System with TDengine + Telegraf + Grafana --- -## 背景介绍 +## Background -TDengine 是涛思数据专为物联网、车联网、工业互联网、IT 运维等设计和优化的大数据平台。自从 2019 年 7 月开源以来,凭借创新的数据建模设计、快捷的安装方式、易用的编程接口和强大的数据写入查询性能博得了大量时序数据开发者的青睐。 +TDengine is a big data platform designed and optimized for IoT (Internet of Things), Vehicle Telematics, Industrial Internet, IT DevOps, etc. by TAOSData. Since it opened its source code in July 2019, it has won the favor of a large number of time-series data developers with its innovative data modeling design, convenient installation, easy-to-use programming interface, and powerful data writing and query performance. -IT 运维监测数据通常都是对时间特性比较敏感的数据,例如: +IT DevOps metric data usually are time sensitive, for example: -- 系统资源指标:CPU、内存、IO、带宽等。 -- 软件系统指标:存活状态、连接数目、请求数目、超时数目、错误数目、响应时间、服务类型及其他与业务有关的指标。 +- System resource metrics: CPU, memory, IO, bandwidth, etc. +- Software system metrics: health status, number of connections, number of requests, number of timeouts, number of errors, response time, service type, and other business-related metrics. -当前主流的 IT 运维系统通常包含一个数据采集模块,一个数据存储模块,和一个可视化显示模块。Telegraf 和 Grafana 分别是当前最流行的数据采集模块和可视化显示模块之一。而数据存储模块可供选择的软件比较多,其中 OpenTSDB 或 InfluxDB 比较流行。而 TDengine 作为新兴的时序大数据平台,具备极强的高性能、高可靠、易管理、易维护的优势。 +Current mainstream IT DevOps system usually include a data collection module, a data persistent module, and a visualization module; Telegraf and Grafana are one of the most popular data collection modules and visualization modules, respectively. The data persistent module is available in a wide range of options, with OpenTSDB or InfluxDB being the most popular. TDengine, as an emerging time-series big data platform, has the advantages of high performance, high reliability, easy management and easy maintenance. -本文介绍不需要写一行代码,通过简单修改几行配置文件,就可以快速搭建一个基于 TDengine + Telegraf + Grafana 的 IT 运维系统。架构如下图: +This article introduces how to quickly build a TDengine + Telegraf + Grafana based IT DevOps visualization system without writing even a single line of code and by simply modifying a few lines of configuration files. The architecture is as follows. ![IT-DevOps-Solutions-Telegraf.png](/img/IT-DevOps-Solutions-Telegraf.png) -## 安装步骤 +## Installation steps -### 安装 Telegraf,Grafana 和 TDengine +### Installing Telegraf, Grafana and TDengine -安装 Telegraf、Grafana 和 TDengine 请参考相关官方文档。 +To install Telegraf, Grafana, and TDengine, please refer to the relevant official documentation. ### Telegraf -请参考[官方文档](https://portal.influxdata.com/downloads/)。 +Please refer to the [official documentation](https://portal.influxdata.com/downloads/). ### Grafana -请参考[官方文档](https://grafana.com/grafana/download)。 +Please refer to the [official documentation](https://grafana.com/grafana/download). ### TDengine -从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.3.0.0 或以上版本安装。 +Download the latest TDengine-server 2.4.0.x or above from the [Downloads](http://taosdata.com/cn/all-downloads/) page on the Taos Data website and install it. -## 数据链路设置 +## Data Connection Setup -### 下载 TDengine 插件到 grafana 插件目录 +### Download TDengine plug-in to grafana plug-in directory ```bash 1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip @@ -48,11 +48,11 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 5. sudo systemctl restart grafana-server.service ``` -### 修改 /etc/telegraf/telegraf.conf +### Modify /etc/telegraf/telegraf.conf -配置方法,在 /etc/telegraf/telegraf.conf 增加如下文字,其中 database name 请填写希望在 TDengine 保存 Telegraf 数据的数据库名,TDengine server/cluster host、username 和 password 填写 TDengine 实际值: +For the configuration method, add the following text to `/etc/telegraf/telegraf.conf`, where `database name` should be the name where you want to store Telegraf data in TDengine, `TDengine server/cluster host`, `username` and `password` please fill in the actual TDengine values. -``` +```text [[outputs.http]] url = "http://:6041/influxdb/v1/write?db=" method = "POST" @@ -63,20 +63,21 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 influx_max_line_bytes = 250 ``` -然后重启 telegraf: +Then restart telegraf: ```bash sudo systemctl start telegraf ``` -### 导入 Dashboard +### Importing the Dashboard -使用 Web 浏览器访问 IP:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。 -点击左侧齿轮图标并选择 Plugins,应该可以找到 TDengine data source 插件图标。 -点击左侧加号图标并选择 Import,从 `https://github.com/taosdata/grafanaplugin/blob/master/examples/telegraf/grafana/dashboards/telegraf-dashboard-v0.1.0.json` 下载 dashboard JSON 文件后导入。之后可以看到如下界面的仪表盘: +Log in to the Grafana interface using a web browser at `IP:3000`, with the system's initial username and password being `admin/admin`. +Click on the gear icon on the left and select `Plugins`, you should find the TDengine data source plugin icon. +Click on the plus icon on the left and select `Import` to get the data from `https://github.com/taosdata/grafanaplugin/blob/master/examples/telegraf/grafana/dashboards/telegraf-dashboard- v0.1.0.json`, download the dashboard JSON file and import it. You will then see the dashboard in the following screen. ![IT-DevOps-Solutions-telegraf-dashboard.png](/img/IT-DevOps-Solutions-telegraf-dashboard.png) -## 总结 +## Wrap-up -以上演示如何快速搭建一个完整的 IT 运维展示系统。得力于 TDengine 2.3.0.0 版本中新增的 schemaless 协议解析功能,以及强大的生态软件适配能力,用户可以短短数分钟就可以搭建一个高效易用的 IT 运维系统。TDengine 强大的数据写入查询性能和其他丰富功能请参考官方文档和产品落地案例。 +The above demonstrates how to quickly build a IT DevOps visualization system. Thanks to the new schemaless protocol parsing feature in TDengine version 2.4.0.0 and the powerful ecological software adaptation capability, users can build an efficient and easy-to-use IT DevOps visualization system in just a few minutes. +Please refer to the official documentation and product implementation cases for other features. diff --git a/docs-en/25-application/02-collectd.md b/docs-en/25-application/02-collectd.md index da055632837e74f4d863148843f1001cc3aa3e8b..2ac37618fafe11e71b215313e53f89b6c302f7cb 100644 --- a/docs-en/25-application/02-collectd.md +++ b/docs-en/25-application/02-collectd.md @@ -1,46 +1,47 @@ --- sidebar_label: TDengine + collectd/StatsD + Grafana -title: 使用 TDengine + collectd/StatsD + Grafana 快速搭建 IT 运维监控系统 +title: Quickly build an IT DevOps visualization system using TDengine + collectd/StatsD + Grafana --- -## 背景介绍 +## Background -TDengine 是涛思数据专为物联网、车联网、工业互联网、IT 运维等设计和优化的大数据平台。自从 2019 年 7 月开源以来,凭借创新的数据建模设计、快捷的安装方式、易用的编程接口和强大的数据写入查询性能博得了大量时序数据开发者的青睐。 +TDengine is a big data platform designed and optimized for IoT (Internet of Things), Vehicle Telematics, Industrial Internet, IT DevOps, etc. by TAOSData. Since it opened its source code in July 2019, it has won the favor of a large number of time-series data developers with its innovative data modeling design, convenient installation, easy-to-use programming interface, and powerful data writing and query performance. -IT 运维监测数据通常都是对时间特性比较敏感的数据,例如: +IT DevOps metric data usually are time sensitive, for example: -- 系统资源指标:CPU、内存、IO、带宽等。 -- 软件系统指标:存活状态、连接数目、请求数目、超时数目、错误数目、响应时间、服务类型及其他与业务有关的指标。 +- System resource metrics: CPU, memory, IO, bandwidth, etc. +- Software system metrics: health status, number of connections, number of requests, number of timeouts, number of errors, response time, service type, and other business-related metrics. -当前主流的 IT 运维系统通常包含一个数据采集模块,一个数据存储模块,和一个可视化显示模块。collectd / statsD 作为老牌开源数据采集工具,具有广泛的用户群。但是 collectd / StatsD 自身功能有限,往往需要配合 Telegraf、Grafana 以及时序数据库组合搭建成为完整的监控系统。而 TDengine 新版本支持多种数据协议接入,可以直接接受 collectd 和 statsD 的数据写入,并提供 Grafana dashboard 进行图形化展示。 +The current mainstream IT DevOps visualization system usually contains a data collection module, a data persistent module, and a visual display module. collectd/StatsD, as an old-fashion open source data collection tool, has a wide user base. However, collectd/StatsD has limited functionality, and often needs to be combined with Telegraf, Grafana, and a time-series database to build a complete monitoring system. +The new version of TDengine supports multiple data protocols and can accept data from collectd and StatsD directly, and provides Grafana dashboard for graphical display. -本文介绍不需要写一行代码,通过简单修改几行配置文件,就可以快速搭建一个基于 TDengine + collectd / statsD + Grafana 的 IT 运维系统。架构如下图: +This article introduces how to quickly build an IT DevOps visualization system based on TDengine + collectd / StatsD + Grafana without writing even a single line of code but by simply modifying a few lines of configuration files. The architecture is shown in the following figure. ![IT-DevOps-Solutions-Collectd-StatsD.png](/img/IT-DevOps-Solutions-Collectd-StatsD.png) -## 安装步骤 +## Installation Steps -安装 collectd, StatsD, Grafana 和 TDengine 请参考相关官方文档。 +To install collectd, StatsD, Grafana, and TDengine, please refer to the official documentation. -### 安装 collectd +### Installing collectd -请参考[官方文档](https://collectd.org/documentation.shtml)。 +Please refer to the [official documentation](https://collectd.org/documentation.shtml). -### 安装 StatsD +### Installing StatsD -请参考[官方文档](https://github.com/statsd/statsd)。 +Please refer to the [official documentation](https://github.com/statsd/statsd). -### 安装 Grafana +### Install Grafana -请参考[官方文档](https://grafana.com/grafana/download)。 +Please refer to the [official documentation](https://grafana.com/grafana/download). -### 安装 TDengine +### Install TDengine -从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.3.0.0 或以上版本安装。 +Download the latest TDengine-server 2.4.0.x or above from the [Downloads](http://taosdata.com/cn/all-downloads/) page on the TAOSData website and install it. -## 数据链路设置 +## Data Connection Setup -### 复制 TDengine 插件到 grafana 插件目录 +### Copy the TDengine plugin to the grafana plugin directory ```bash 1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip @@ -50,11 +51,11 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 5. sudo systemctl restart grafana-server.service ``` -### 配置 collectd +### Configure collectd -在 `/etc/collectd/collectd.conf` 文件中增加如下内容,其中 host 和 port 请填写 TDengine 和 taosAdapter 配置的实际值: +Add the following to the `/etc/collectd/collectd.conf` file, where the `host` and `port` should be the actual values of the TDengine and taosAdapter configurations. -``` +```text LoadPlugin network Server "" "" @@ -63,33 +64,41 @@ LoadPlugin network sudo systemctl start collectd ``` -### 配置 StatsD +### Configure StatsD -在 `config.js` 文件中增加如下内容后启动 StatsD,其中 host 和 port 请填写 TDengine 和 taosAdapter 配置的实际值: +Start StatsD after adding the following to the `config.js` file, where the `host` and `port` are the actual values of the TDengine and taosAdapter configurations. +```text +backends section add ". /backends/repeater" +Add { host:'', port: } to the repeater section ``` -backends 部分添加 "./backends/repeater" -repeater 部分添加 { host:'', port: } -``` -### 导入 Dashboard +### Importing the Dashboard + +Use a web browser to access the server running Grafana on port 3000 `host:3000` to log into the Grafana interface with the initial system username and password of `admin/admin`. +Click on the gear icon on the left and select `Plugins`, you should find the TDengine data source plugin icon. -使用 Web 浏览器访问运行 Grafana 的服务器的 3000 端口 host:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。 -点击左侧齿轮图标并选择 Plugins,应该可以找到 TDengine data source 插件图标。 +#### Importing the collectd dashboard + +Download the dashboard json from `https://github.com/taosdata/grafanaplugin/blob/master/examples/collectd/grafana/dashboards/collect-metrics-with-tdengine-v0.1.0.json`, click the plus icon on the left and select Import, follow the instructions to import the JSON file. After that, you can see +The dashboard can be seen in the following screen. + +![IT-DevOps-Solutions-collectd-dashboard.png](/img/IT-DevOps-Solutions-collectd-dashboard.png) -#### 导入 collectd 仪表盘 +#### import collectd dashboard -从 https://github.com/taosdata/grafanaplugin/blob/master/examples/collectd/grafana/dashboards/collect-metrics-with-tdengine-v0.1.0.json 下载 dashboard json 文件,点击左侧加号图标并选择 Import,按照界面提示选择 JSON 文件导入。之后可以看到如下界面的仪表盘: +Download the dashboard json file from `https://github.com/taosdata/grafanaplugin/blob/master/examples/collectd/grafana/dashboards/collect-metrics-with-tdengine-v0.1.0.json`. Download the dashboard json file, click the plus icon on the left side and select `Import`, and follow the interface prompts to select the JSON file to import. After that, you can see +dashboard with the following interface. ![IT-DevOps-Solutions-collectd-dashboard.png](/img/IT-DevOps-Solutions-collectd-dashboard.png) -#### 导入 StatsD 仪表盘 +#### Importing the StatsD dashboard -从 https://github.com/taosdata/grafanaplugin/blob/master/examples/statsd/dashboards/statsd-with-tdengine-v0.1.0.json 下载 dashboard json 文件,点击左侧加号图标并选择 Import,按照界面提示导入 JSON 文件。之后可以看到如下界面的仪表盘: +Download the dashboard json from `https://github.com/taosdata/grafanaplugin/blob/master/examples/statsd/dashboards/statsd-with-tdengine-v0.1.0.json`. Click on the plus icon on the left and select `Import`, and follow the interface prompts to import the JSON file. You will then see the dashboard in the following screen. ![IT-DevOps-Solutions-statsd-dashboard.png](/img/IT-DevOps-Solutions-statsd-dashboard.png) -## 总结 +## Wrap-up -TDengine 作为新兴的时序大数据平台,具备极强的高性能、高可靠、易管理、易维护的优势。得力于 TDengine 2.3.0.0 版本中新增的 schemaless 协议解析功能,以及强大的生态软件适配能力,用户可以短短数分钟就可以搭建一个高效易用的 IT 运维系统或者适配一个已存在的系统。 +TDengine, as an emerging time-series big data platform, has the advantages of high performance, high reliability, easy management and easy maintenance. Thanks to the new schemaless protocol parsing function in TDengine version 2.4.0.0 and the powerful ecological software adaptation capability, users can build an efficient and easy-to-use IT DevOps visualization system or adapt to an existing system in just a few minutes. -TDengine 强大的数据写入查询性能和其他丰富功能请参考官方文档和产品成功落地案例。 +For TDengine's powerful data writing and querying performance and other features, please refer to the official documentation and successful product implementation cases. diff --git a/docs-en/25-application/03-immigrate.md b/docs-en/25-application/03-immigrate.md index 9b2c04e96ecf5f7f43abc2a3e2c6fbce03840d9c..585761b699f30cfcc8a8232466421f6db7b5eeb8 100644 --- a/docs-en/25-application/03-immigrate.md +++ b/docs-en/25-application/03-immigrate.md @@ -1,55 +1,60 @@ --- -sidebar_label: OpenTSDB 迁移到 TDengine -title: OpenTSDB 应用迁移到 TDengine 的最佳实践 +sidebar_label: OpenTSDB Migration to TDengine +title: Best Practices for Migrating OpenTSDB Applications to TDengine --- -作为一个分布式、可伸缩、基于 HBase 的分布式时序数据库系统,得益于其先发优势,OpenTSDB 被 DevOps 领域的人员引入并广泛地应用在了运维监控领域。但最近几年,随着云计算、微服务、容器化等新技术快速落地发展,企业级服务种类变得越来越多,架构也越来越复杂,应用运行基础环境日益多样化,给系统和运行监控带来的压力也越来越大。从这一现状出发,使用 OpenTSDB 作为 DevOps 的监控后端存储,越来越受困于其性能问题以及迟缓的功能升级,以及由此而衍生出来的应用部署成本上升和运行效率降低等问题,这些问题随着系统规模的扩大日益严重。 +As a distributed, scalable, HBase-based distributed time-series database software, thanks to its first-mover advantage, OpenTSDB has been introduced and widely used in DevOps by people. However, using new technologies like cloud computing, microservices, and containerization technology with rapid development. Enterprise-level services are becoming more and more diverse. The architecture is becoming more complex. -在这一背景下,为满足高速增长的物联网大数据市场和技术需求,在吸取众多传统关系型数据库、NoSQL 数据库、流计算引擎、消息队列等软件的优点之后,涛思数据自主开发出创新型大数据处理产品 TDengine。在时序大数据处理上,TDengine 有着自己独特的优势。就 OpenTSDB 当前遇到的问题来说,TDengine 能够有效解决。 +From this situation, it increasingly plagues to use of OpenTSDB as a DevOps backend storage for monitoring by performance issues and delayed feature upgrades. The resulting increase in application deployment costs and reduced operational efficiency. +These problems are becoming increasingly severe as the system scales up. -相对于 OpenTSDB,TDengine 具有如下显著特点: +To meet the fast-growing IoT big data market and technical needs, TAOSData developed an innovative big-data processing product, **TDengine**. -- 数据写入和查询的性能远超 OpenTSDB; -- 针对时序数据的高效压缩机制,压缩后在磁盘上的存储空间不到 1/5; -- 安装部署非常简单,单一安装包完成安装部署,不依赖其他的第三方软件,整个安装部署过程秒级搞定; -- 提供的内建函数覆盖 OpenTSDB 支持的全部查询函数,还支持更多的时序数据查询函数、标量函数及聚合函数,支持多种时间窗口聚合、连接查询、表达式运算、多种分组聚合、用户定义排序、以及用户定义函数等高级查询功能。采用类 SQL 的语法规则,更加简单易学,基本上没有学习成本。 -- 支持多达 128 个标签,标签总长度可达到 16 KB; -- 除 HTTP 之外,还提供 Java、Python、C、Rust、Go 等多种语言的接口,支持 JDBC 等多种企业级标准连接器协议。 +After learning the advantages of many traditional relational databases and NoSQL databases, stream computing engines, and message queues, TDengine has its unique benefits in time-series big data processing. TDengine can effectively solve the problems currently encountered by OpenTSDB. -如果我们将原本运行在 OpenTSDB 上的应用迁移到 TDengine 上,不仅可以有效地降低计算和存储资源的占用、减少部署服务器的规模,还能够极大减少运行维护的成本的输出,让运维管理工作更简单、更轻松,大幅降低总拥有成本。与 OpenTSDB 一样,TDengine 也已经进行了开源,不同的是,除了单机版,后者还实现了集群版开源,被厂商绑定的顾虑一扫而空。 +Compared with OpenTSDB, TDengine has the following distinctive features. -在下文中我们将就“使用最典型并广泛应用的运维监控(DevOps)场景”来说明,如何在不编码的情况下将 OpenTSDB 的应用快速、安全、可靠地迁移到 TDengine 之上。后续的章节会做更深度的介绍,以便于进行非 DevOps 场景的迁移。 +- Performance of data writing and querying far exceeds that of OpenTSDB. +- Efficient compression mechanism for time-series data, which compresses less than 1/5 of the storage space on disk. +- The installation and deployment are straightforward. A single installation package can complete the installation and deployment and does not rely on other third-party software. The entire installation and deployment process in a few seconds; +- The built-in functions cover all of OpenTSDB's query functions. And support more time-series data query functions, scalar functions, and aggregation functions. And support advanced query functions such as multiple time-window aggregations, join query, expression operation, multiple group aggregation, user-defined sorting, and user-defined functions. Adopting SQL-like syntax rules is more straightforward and has no learning cost. +- Supports up to 128 tags, with a total tag length of 16 KB. +- In addition to the REST interface, it also provides interfaces to Java, Python, C, Rust, Go, C# and other languages. Its supports a variety of enterprise-class standard connector protocols such as JDBC. -## DevOps 应用快速迁移 +If we migrate the applications originally running on OpenTSDB to TDengine, we will effectively reduce the compute and storage resource consumption and the number of deployed servers. And will also significantly reduce the operation and maintenance costs, making operation and maintenance management more straightforward and more accessible, and considerably reducing the total cost of ownership. Like OpenTSDB, TDengine has also been open-sourced, including the stand-alone version and the cluster version source code. So there is no need to be concerned about the vendor-lock problem. -### 1、典型应用场景 +We will explain how to migrate OpenTSDB applications to TDengine quickly, securely, and reliably without coding, using the most typical DevOps scenarios. Subsequent chapters will go into more depth to facilitate migration for non-DevOps systems. -一个典型的 DevOps 应用场景的系统整体的架构如下图(图 1) 所示。 +## DevOps Application Quick Migration -**图 1. DevOps 场景中典型架构** -![IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch](/img/IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch.jpg "图1. DevOps 场景中典型架构") +### 1. Typical Application Scenarios -在该应用场景中,包含了部署在应用环境中负责收集机器度量(Metrics)、网络度量(Metrics)以及应用度量(Metrics)的 Agent 工具、汇聚 agent 收集信息的数据收集器,数据持久化存储和管理的系统以及监控数据可视化工具(例如:Grafana 等)。 +The following figure (Figure 1) shows the system's overall architecture for a typical DevOps application scenario. -其中,部署在应用节点的 Agents 负责向 collectd/Statsd 提供不同来源的运行指标,collectd/StatsD 则负责将汇聚的数据推送到 OpenTSDB 集群系统,然后使用可视化看板 Grafana 将数据可视化呈现出来。 +**Figure 1. Typical architecture in a DevOps scenario** +Figure 1. [IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch](/img/IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch.jpg "Figure 1. Typical architecture in a DevOps scenario") -### 2、迁移服务 +In this application scenario, there are Agent tools deployed in the application environment to collect machine metrics, network metrics, and application metrics. Data collectors to aggregate information collected by agents, systems for persistent data storage and management, and tools for monitoring data visualization (e.g., Grafana, etc.). -- **TDengine 安装部署** +The agents deployed in the application nodes are responsible for providing operational metrics from different sources to collectd/Statsd. And collectd/StatsD is accountable for pushing the aggregated data to the OpenTSDB cluster system and then visualizing the data using the visualization kanban board software, Grafana. -首先是 TDengine 的安装,从官网上下载 TDengine 最新稳定版,解压缩后运行 install.sh 进行安装。各种安装包的使用帮助请参见博客[《TDengine 多种安装包的安装和卸载》](https://www.taosdata.com/blog/2019/08/09/566.html)。 +### 2. Migration Services -注意,安装完成以后,不要立即启动 taosd 服务,在正确配置完成参数以后再启动。 +- **TDengine installation and deployment** -- **调整数据收集器配置** +First of all, please install TDengine. Download the latest stable version of TDengine from the official website and install it. For help with using various installation packages, please refer to the blog ["Installation and Uninstallation of TDengine Multiple Installation Packages"](https://www.taosdata.com/blog/2019/08/09/566.html). -在 TDengine 2.3 版本中,我们发布了 taosAdapter ,taosAdapter 是一个无状态、可快速弹性伸缩的组件,它可以兼容 Influxdb 的 Line Protocol 和 OpenTSDB 的 telnet/JSON 写入协议规范,提供了丰富的数据接入能力,有效的节省用户迁移成本,降低用户应用迁移的难度。 +Note that once the installation is complete, do not start the `taosd` service immediately, but after properly configuring the parameters. -用户可以根据需求弹性部署 taosAdapter 实例,结合场景的需要,快速提升数据写入的吞吐量,为不同应用场景下的数据写入提供保障。 +- **Adjusting the data collector configuration** -通过 taosAdapter,用户可以将 collectd 和 StatsD 收集的数据直接推送到 TDengine ,实现应用场景的无缝迁移,非常的轻松便捷。taosAdapter 还支持 Telegraf、Icinga、TCollector 、node_exporter 的数据接入,使用详情参考[taosAdapter](/reference/taosadapter/)。 +TDengine version 2.4 and later version includes `taosAdapter`. taosAdapter is a stateless, rapidly elastic, and scalable component. taosAdapter supports Influxdb's Line Protocol and OpenTSDB's telnet/JSON writing protocol specification, providing rich data access capabilities, effectively saving user migration costs and reducing the difficulty of user migration. -如果使用 collectd,修改其默认位置 `/etc/collectd/collectd.conf` 的配置文件为指向 taosAdapter 部署的节点 IP 地址和端口。假设 taosAdapter 的 IP 地址为 192.168.1.130,端口为 6046,配置如下: +Users can flexibly deploy taosAdapter instances according to their requirements to rapidly improve the throughput of data writes in conjunction with the needs of scenarios and provide guarantees for data writes in different application scenarios. + +Through taosAdapter, users can directly push the data collected by `collectd` or `StatsD` to TDengine to achieve seamless migration of application scenarios, which is very easy and convenient. taosAdapter also supports Telegraf, Icinga, TCollector, and node_exporter data. For more details, please refer to [taosAdapter](/reference/taosadapter/). + +If using collectd, modify the configuration file in its default location `/etc/collectd/collectd.conf` to point to the IP address and port of the node where to deploy taosAdapter. For example, assuming the taosAdapter IP address is 192.168.1.130 and port 6046, configure it as follows. ```html LoadPlugin write_tsdb @@ -61,340 +66,370 @@ LoadPlugin write_tsdb ``` -即可让 collectd 将数据使用推送到 OpenTSDB 的插件方式推送到 taosAdapter, taosAdapter 将调用 API 将数据写入到 taosd 中,从而完成数据的写入工作。如果你使用的是 StatsD 相应地调整配置文件信息。 +You can use collectd and push the data to taosAdapter utilizing the push to OpenTSDB plugin. taosAdapter will call the API to write the data to TDengine, thus completing the writing of the data. If you are using StatsD, adjust the profile information accordingly. -- **调整看板(Dashborad)系统** +- **Tuning the Dashboard system** -在数据能够正常写入 TDengine 后,可以调整适配 Grafana 将写入 TDengine 的数据可视化呈现出来。获取和使用 TDengine 提供的 Grafana 插件请参考[与其他工具的连接](/third-party/grafana)。 +After writing the data to TDengine properly, you can adapt Grafana to visualize the data written to TDengine. To obtain and use the Grafana plugin provided by TDengine, please refer to [Links to other tools](/third-party/grafana). -TDengine 提供了默认的两套 Dashboard 模板,用户只需要将 Grafana 目录下的模板导入到 Grafana 中即可激活使用。 +TDengine provides two sets of Dashboard templates by default, and users only need to import the templates from the Grafana directory into Grafana to activate their use. -**图 2. 导入 Grafana 模板** -![](/img/IT-DevOps-Solutions-Immigrate-OpenTSDB-Dashboard.jpg "图2. 导入 Grafana 模板") +**Importing Grafana Templates** Figure 2. +! [](/img/IT-DevOps-Solutions-Immigrate-OpenTSDB-Dashboard.jpg "Figure 2. Importing a Grafana Template") -操作完以上步骤后,就完成了将 OpenTSDB 替换成为 TDengine 的迁移工作。可以看到整个流程非常简单,不需要写代码,只需要对某些配置文件进行调整即可完成全部的迁移工作。 +After the above steps, you completed the migration to replace OpenTSDB with TDengine. You can see that the whole process is straightforward, there is no need to write any code, and only some configuration files need to be adjusted to meet the migration work. -### 3、迁移后架构 +### 3. Post-migration architecture -完成迁移以后,此时的系统整体的架构如下图(图 3)所示,而整个过程中采集端、数据写入端、以及监控呈现端均保持了稳定,除了极少的配置调整外,不涉及任何重要的更改和变动。OpenTSDB 大量的应用场景均为 DevOps ,这种场景下,简单的参数设置即可完成 OpenTSDB 到 TDengine 迁移动作,使用上 TDengine 更加强大的处理能力和查询性能。 +After completing the migration, the figure below (Figure 3) shows the system's overall architecture. The whole process of the acquisition side, the data writing, and the monitoring and presentation side are all kept stable, except for a few configuration adjustments, which do not involve any critical changes or alterations. OpenTSDB to TDengine migration action, using TDengine more powerful processing power and query performance. -在绝大多数的 DevOps 场景中,如果你拥有一个小规模的 OpenTSDB 集群(3 台及以下的节点)作为 DevOps 的存储端,依赖于 OpenTSDB 为系统持久化层提供数据存储和查询功能,那么你可以安全地将其替换为 TDengine,并节约更多的计算和存储资源。在同等计算资源配置情况下,单台 TDengine 即可满足 3 ~ 5 台 OpenTSDB 节点提供的服务能力。如果规模比较大,那便需要采用 TDengine 集群。 +In most DevOps scenarios, if you have a small OpenTSDB cluster (3 or fewer nodes) for providing the storage layer of DevOps and rely on OpenTSDB to give a data persistence layer and query capabilities, you can safely replace OpenTSDB with TDengine. TDengine will save more compute and storage resources. With the same compute resource allocation, a single TDengine can meet the service capacity provided by 3 to 5 OpenTSDB nodes. If the scale is more prominent, then TDengine clustering is required. -如果你的应用特别复杂,或者应用领域并不是 DevOps 场景,你可以继续阅读后续的章节,更加全面深入地了解将 OpenTSDB 的应用迁移到 TDengine 的高级话题。 +Suppose your application is particularly complex, or the application domain is not a DevOps scenario. You can continue reading subsequent chapters for a more comprehensive and in-depth look at the advanced topics of migrating an OpenTSDB application to TDengine. -**图 3. 迁移完成后的系统架构** -![IT-DevOps-Solutions-Immigrate-TDengine-Arch](/img/IT-DevOps-Solutions-Immigrate-TDengine-Arch.jpg "图 3. 迁移完成后的系统架构") +**Figure 3. System architecture after migration** +! [IT-DevOps-Solutions-Immigrate-TDengine-Arch](/img/IT-DevOps-Solutions-Immigrate-TDengine-Arch.jpg "Figure 3. System architecture after migration completion") -## 其他场景的迁移评估与策略 +## Migration evaluation and strategy for other scenarios -### 1、TDengine 与 OpenTSDB 的差异 +### 1. Differences between TDengine and OpenTSDB -本章将详细介绍 OpenTSDB 与 TDengine 在系统功能层面上存在的差异。阅读完本章的内容,你可以全面地评估是否能够将某些基于 OpenTSDB 的复杂应用迁移到 TDengine 上,以及迁移之后应该注意的问题。 +This chapter describes the differences between OpenTSDB and TDengine at the system functionality level. After reading this chapter, you can fully evaluate whether you can migrate some complex OpenTSDB-based applications to TDengine, and what you should pay attention to after migration. -TDengine 当前只支持 Grafana 的可视化看板呈现,所以如果你的应用中使用了 Grafana 以外的前端看板(例如[TSDash](https://github.com/facebook/tsdash)、[Status Wolf](https://github.com/box/StatusWolf)等),那么前端看板将无法直接迁移到 TDengine,需要将前端看板重新适配到 Grafana 才可以正常运行。 +TDengine currently only supports Grafana for visual kanban rendering, so if your application uses front-end kanban boards other than Grafana (e.g., [TSDash](https://github.com/facebook/tsdash), [Status Wolf](https://github) .com/box/StatusWolf), etc.). You cannot directly migrate those front-end kanbans to TDengine, and the front-end kanban will need to be ported to Grafana to work correctly. -截止到 2.3.0.x 版本,TDengine 只能够支持 collectd 和 StatsD 作为数据收集汇聚软件,当然后面会陆续提供更多的数据收集聚合软件的接入支持。如果您的收集端使用了其他类型的数据汇聚器,您的应用需要适配到这两个数据汇聚端系统,才能够将数据正常写入。除了上述两个数据汇聚端软件协议以外,TDengine 还支持通过 InfluxDB 的行协议和 OpenTSDB 的数据写入协议、JSON 格式将数据直接写入,您可以重写数据推送端的逻辑,使用 TDengine 支持的行协议来写入数据。 +TDengine version 2.3.0.x only supports collectd and StatsD as data collection aggregation software but will provide more data collection aggregation software in the future. If you use other data aggregators on the collection side, your application needs to be ported to these two data aggregation systems to write data correctly. +In addition to the two data aggregator software protocols mentioned above, TDengine also supports writing data directly via InfluxDB's row protocol and OpenTSDB's data writing protocol, JSON format. You can rewrite the logic on the data push side to write data using the row protocols supported by TDengine. -此外,如果你的应用中使用了 OpenTSDB 以下特性,在将应用迁移到 TDengine 之前你还需要了解以下注意事项: +In addition, if your application uses the following features of OpenTSDB, you need to understand the following considerations before migrating your application to TDengine. -1. ` /api/stats`:如果你的应用中使用了该项特性来监控 OpenTSDB 的服务状态,并在应用中建立了相关的逻辑来联动处理,那么这部分状态读取和获取的逻辑需要重新适配到 TDengine。TDengine 提供了全新的处理集群状态监控机制,来满足你的应用对其进行的监控和维护的需求。 -2. `/api/tree`:如果你依赖于 OpenTSDB 的该项特性来进行时间线的层级化组织和维护,那么便无法将其直接迁移至 TDengine。TDengine 采用了数据库->超级表->子表这样的层级来组织和维护时间线,归属于同一个超级表的所有的时间线在系统中同一个层级,但是可以通过不同标签值的特殊构造来模拟应用逻辑上的多级结构。 -3. `Rollup And PreAggregates`:采用了 Rollup 和 PreAggregates 需要应用来决定在合适的地方访问 Rollup 的结果,在某些场景下又要访问原始的结果,这种结构的不透明性让应用处理逻辑变得极为复杂而且完全不具有移植性。我们认为这种策略是时序数据库无法提供高性能聚合情况下的妥协与折中。TDengine 暂不支持多个时间线的自动降采样和(时间段范围的)预聚合,由于 其拥有的高性能查询处理逻辑,即使不依赖于 Rollup 和 (时间段)预聚合计算结果,也能够提供很高性能的查询响应,而且让你的应用查询处理逻辑更加简单。 -4. `Rate`: TDengine 提供了两个计算数值变化率的函数,分别是 Derivative(其计算结果与 InfluxDB 的 Derivative 行为一致)和 IRate(其计算结果与 Prometheus 中的 IRate 函数计算结果一致)。但是这两个函数的计算结果与 Rate 有细微的差别,但整体上功能更强大。此外,**OpenTSDB 提供的所有计算函数,TDengine 均有对应的查询函数支持,并且 TDengine 的查询函数功能远超过 OpenTSDB 支持的查询函数,**可以极大地简化你的应用处理逻辑。 +1. `/api/stats`: If your application uses this feature to monitor the service status of OpenTSDB, and you have built the relevant logic to link the processing in your application, then this part of the status reading and fetching logic needs to be re-adapted to TDengine. TDengine provides a new mechanism for handling cluster state monitoring to meet the monitoring and maintenance needs of your application. +2. `/api/tree`: If you rely on this feature of OpenTSDB for the hierarchical organization and maintenance of timelines, you cannot migrate it directly to TDengine, which uses a database -> super table -> sub-table hierarchy to organize and maintain timelines, with all timelines belonging to the same super table in the same system hierarchy, but it is possible to simulate a logical multi-level structure of the application through the unique construction of different tag values. +3. `Rollup And PreAggregates`: The use of Rollup and PreAggregates requires the application to decide where to access the Rollup results and, in some scenarios, to access the actual results. The opacity of this structure makes the application processing logic extraordinarily complex and not portable at all. We think this strategy is a compromise when the time-series database does not. +TDengine does not support automatic downsampling of multiple timelines and preaggregation (for a range of periods) for the time being. Still, thanks to its high-performance query processing logic can provide very high-performance query responses without relying on Rollup and preaggregation (for a range of periods), making your application query processing logic much more straightforward. +The logic is much simpler. +4. `Rate`: TDengine provides two functions to calculate the rate of change of values, namely `Derivative` (the result is consistent with the Derivative behavior of InfluxDB) and `IRate` (the result is compatible with the IRate function in Prometheus). However, the results of these two functions are slightly different from Rate, but the functions are more powerful overall. In addition, TDengine supports all the calculation functions provided by OpenTSDB, and TDengine's query functions are much more potent than those supported by OpenTSDB, which can significantly simplify the processing logic of your application. -通过上面的介绍,相信你应该能够了解 OpenTSDB 迁移到 TDengine 带来的变化,这些信息也有助于你正确地判断是否可以接受将应用 迁移到 TDengine 之上,体验 TDengine 提供的强大的时序数据处理能力和便捷的使用体验。 +Through the above introduction, I believe you should be able to understand the changes brought about by the migration of OpenTSDB to TDengine. And this information will also help you correctly determine whether you would migrate your application to TDengine to experience the powerful and convenient time-series data processing capability provided by TDengine. -### 2、迁移策略 +### 2. Migration strategy suggestion -首先将基于 OpenTSDB 的系统进行迁移涉及到的数据模式设计、系统规模估算、数据写入端改造,进行数据分流、应用适配工作;之后将两个系统并行运行一段时间,再将历史数据迁移到 TDengine 中。当然如果你的应用中有部分功能强依赖于上述 OpenTSDB 特性,同时又不希望停止使用,可以考虑保持原有的 OpenTSDB 系统运行,同时启动 TDengine 来提供主要的服务。 +First, the OpenTSDB-based system migration involves data schema design, system scale estimation, and data write end transformation, data streaming, and application adaptation; after that, the two systems will run in parallel for a while and then migrate the historical data to TDengine. Of course, if your application has some functions that strongly depend on the above OpenTSDB features and you do not want to stop using them, you can migrate the historical data to TDengine. +You can consider keeping the original OpenTSDB system running while starting TDengine to provide the primary services. -## 数据模型设计 +## Data model design -一方面,TDengine 要求其入库的数据具有严格的模式定义。另一方面,TDengine 的数据模型相对于 OpenTSDB 来说又更加丰富,多值模型能够兼容全部的单值模型的建立需求。 +On the one hand, TDengine requires a strict schema definition for its incoming data. On the other hand, the data model of TDengine is richer than that of OpenTSDB, and the multi-valued model is compatible with all single-valued model building requirements. -现在让我们假设一个 DevOps 的场景,我们使用了 collectd 收集设备的基础度量(metrics),包含了 memory 、swap、disk 等几个度量,其在 OpenTSDB 中的模式如下: +Let us now assume a DevOps scenario where we use collectd to collect the underlying metrics of the device, including memory, swap, disk, etc. The schema in OpenTSDB is as follows. -| 序号 | 测量(metric) | 值名称 | 类型 | tag1 | tag2 | tag3 | tag4 | tag5 | +| metric | value name | type | tag1 | tag2 | tag3 | tag4 | tag5 | | ---- | -------------- | ------ | ------ | ---- | ----------- | -------------------- | --------- | ------ | -| 1 | memory | value | double | host | memory_type | memory_type_instance | source | n/a | -| 2 | swap | value | double | host | swap_type | swap_type_instance | source | n/a | -| 3 | disk | value | double | host | disk_point | disk_instance | disk_type | source | +| 1 | memory | value | double | host | memory_type | memory_type_instance | source | n/a | +| 2 | swap | value | double | host | swap_type | swap_type_instance | source | n/a | +| 3 | disk | value | double | host | disk_point | disk_instance | disk_type | source | -TDengine 要求存储的数据具有数据模式,即写入数据之前需创建超级表并指定超级表的模式。对于数据模式的建立,你有两种方式来完成此项工作:1)充分利用 TDengine 对 OpenTSDB 的数据原生写入的支持,调用 TDengine 提供的 API 将(文本行或 JSON 格式)数据写入,并自动化地建立单值模型。采用这种方式不需要对数据写入应用进行较大的调整,也不需要对写入的数据格式进行转换。 +TDengine requires the data stored to have a data schema, i.e., you need to create a super table and specify the schema of the super table before writing the data. For data schema creation, you have two ways to do this: 1) Take advantage of TDengine's native data writing support for OpenTSDB by calling the TDengine API to write (text line or JSON format) +and automate the creation of single-value models. This approach does not require significant adjustments to the data writing application, nor does it require converting the written data format. -在 C 语言层面,TDengine 提供了 taos_insert_lines() 函数来直接写入 OpenTSDB 格式的数据(在 2.3.x 版本中该函数对应的是 taos_schemaless_insert())。其代码参考示例请参见安装包目录下示例代码 schemaless.c。 +At the C level, TDengine provides the `taos_schemaless_insert()` function to write data in OpenTSDB format directly (in early version this function was named `taos_insert_lines()`). Please refer to the sample code `schemaless.c` in the installation package directory as reference. -2)在充分理解 TDengine 的数据模型基础上,结合生成数据的特点,手动方式建立 OpenTSDB 到 TDengine 的数据模型调整的映射关系。TDengine 能够支持多值模型和单值模型,考虑到 OpenTSDB 均为单值映射模型,这里推荐使用单值模型在 TDengine 中进行建模。 +(2) based on a complete understanding of TDengine's data model, to establish the mapping relationship between OpenTSDB and TDengine's data model adjustment manually. Considering that OpenTSDB is a single-value mapping model, recommended using the single-value model in TDengine. TDengine can support both multi-value and single-value models. -- **单值模型**。 +- **Single-valued model**. -具体步骤如下:将度量(metrics)的名称作为 TDengine 超级表的名称,该超级表建成后具有两个基础的数据列—时间戳(timestamp)和值(value),超级表的标签等效于 度量 的标签信息,标签数量等同于度量 的标签的数量。子表的表名采用具有固定规则的方式进行命名:`metric + '_' + tags1_value + '_' + tag2_value + '_' + tag3_value ... `作为子表名称。 +The steps are as follows: use the name of the metrics as the name of the TDengine super table, which build with two basic data columns - timestamp and value, and the label of the super table is equivalent to the label information of the metrics, and the number of labels is equal to the number of labels of the metrics. The names of sub-tables are named with fixed rules: `metric + '_' + tags1_value + '_' + tag2_value + '_' + tag3_value ...` as the sub-table name. -在 TDengine 中建立 3 个超级表: +Create 3 super tables in TDengine. ```sql -create stable memory(ts timestamp, val float) tags(host binary(12),memory_type binary(20), memory_type_instance binary(20), source binary(20)); +create stable memory(ts timestamp, val float) tags(host binary(12), memory_type binary(20), memory_type_instance binary(20), source binary(20)) ; create stable swap(ts timestamp, val double) tags(host binary(12), swap_type binary(20), swap_type_binary binary(20), source binary(20)); create stable disk(ts timestamp, val double) tags(host binary(12), disk_point binary(20), disk_instance binary(20), disk_type binary(20), source binary(20)); ``` -对于子表使用动态建表的方式创建如下所示: +For sub-tables use dynamic table creation as shown below. ```sql -insert into memory_vm130_memory_bufferred_collectd using memory tags(‘vm130’, ‘memory’, 'buffer', 'collectd') values(1632979445, 3.0656); +insert into memory_vm130_memory_buffered_collectd using memory tags('vm130', 'memory', ' buffer', 'collectd') values(1632979445, 3.0656); ``` -最终系统中会建立 340 个左右的子表,3 个超级表。需要注意的是,如果采用串联标签值的方式导致子表名称超过系统限制(191 字节),那么需要采用一定的编码方式(例如 MD5)将其转化为可接受长度。 +The final system will have about 340 sub-tables and three super-tables. Note that if the use of concatenated tagged values causes the sub-table names to exceed the system limit (191 bytes), then some encoding (e.g., MD5) needs to be used to convert them to an acceptable length. -- **多值模型** +- **Multi-value model** -如果你想要利用 TDengine 的多值模型能力,需要首先满足以下要求:不同的采集量具有相同的采集频率,且能够通过消息队列**同时到达**数据写入端,从而确保使用 SQL 语句将多个指标一次性写入。将度量的名称作为超级表的名称,建立具有相同采集频率且能够同时到达的数据多列模型。子表的表名采用具有固定规则的方式进行命名。上述每个度量均只包含一个测量值,因此无法将其转化为多值模型。 +Suppose you want to take advantage of TDengine's multi-value modeling capabilities. In that case, you need first to meet the requirements that different collection quantities have the same collection frequency and can reach the **data write side simultaneously via a message queue**, thus ensuring writing multiple metrics at once using SQL statements. The metric's name is used as the name of the super table to create a multi-column model of data that has the same collection frequency and can arrive simultaneously. The names of the sub-tables are named using a fixed rule. Each of the above metrics contains only one measurement value, so converting it into a multi-value model is impossible. -## 数据分流与应用适配 +## Data triage and application adaptation -从消息队列中订阅数据,并启动调整后的写入程序写入数据。 +Subscribe data from the message queue and start the adapted writer to write the data. -数据开始写入持续一段时间后,可以采用 SQL 语句检查写入的数据量是否符合预计的写入要求。统计数据量使用如下 SQL 语句: +After writing the data starts for a while, you can use SQL statements to check whether the amount of data written meets the expected writing requirements. Use the following SQL statement to count the amount of data. ```sql select count(*) from memory ``` -完成查询后,如果写入的数据与预期的相比没有差别,同时写入程序本身没有异常的报错信息,那么可用确认数据写入是完整有效的。 +After completing the query, if the data written does not differ from what is expected and there are no abnormal error messages from the writing program itself, you can confirm that the written data is complete and valid. -TDengine 不支持采用 OpenTSDB 的查询语法进行查询或数据获取处理,但是针对 OpenTSDB 的每种查询都提供对应的支持。可以用检查附录 1 获取对应的查询处理的调整和应用使用的方式,如果需要全面了解 TDengine 支持的查询类型,请参阅 TDengine 的用户手册。 +TDengine does not support querying, or data fetching using the OpenTSDB query syntax but does provide a counterpart for each of the OpenTSDB queries. The corresponding query processing can be adapted and applied in a manner obtained by examining Appendix 1. To fully understand the types of queries supported by TDengine, refer to the TDengine user manual. -TDengine 支持标准的 JDBC 3.0 接口操纵数据库,你也可以使用其他类型的高级语言的连接器来查询读取数据,以适配你的应用。具体的操作和使用帮助也请参阅用户手册。 +TDengine supports the standard JDBC 3.0 interface for manipulating databases, but you can also use other types of high-level language connectors for querying and reading data to suit your application. Please read the user manual for specific operations and usage. -## 历史数据迁移 +## Historical Data Migration -### 1、使用工具自动迁移数据 +### 1. Use the tool to migrate data automatically -为了方便历史数据的迁移工作,我们为数据同步工具 DataX 提供了插件,能够将数据自动写入到 TDengine 中,需要注意的是 DataX 的自动化数据迁移只能够支持单值模型的数据迁移过程。 +To facilitate historical data migration, we provide a plug-in for the data synchronization tool DataX, which can automatically write data into TDengine.The automatic data migration of DataX can only support the data migration process of a single value model. -DataX 具体的使用方式及如何使用 DataX 将数据写入 TDengine 请参见[基于 DataX 的 TDeninge 数据迁移工具](https://www.taosdata.com/blog/2021/10/26/3156.html)。 +For the specific usage of DataX and how to use DataX to write data to TDengine, please refer to [DataX-based TDengine Data Migration Tool](https://www.taosdata.com/blog/2021/10/26/3156.html). -在对 DataX 进行迁移实践后,我们发现通过启动多个进程,同时迁移多个 metric 的方式,可以大幅度的提高迁移历史数据的效率,下面是迁移过程中的部分记录,希望这些能为应用迁移工作带来参考。 +After migrating via DataX, we found that we can significantly improve the efficiency of migrating historical data by starting multiple processes and migrating numerous metrics simultaneously. The following are some records of the migration process. I wish to use these for application migration as a reference. -| datax 实例个数 (并发进程个数) | 迁移记录速度 (条/秒) | -| ----------------------------- | --------------------- | -| 1 | 约 13.9 万 | -| 2 | 约 21.8 万 | -| 3 | 约 24.9 万 | -| 5 | 约 29.5 万 | -| 10 | 约 33 万 | +| Number of datax instances (number of concurrent processes) | Migration record speed (pieces/second) | +| ----------------------------- | ------------------- -- | +| 1 | About 139,000 | +| 2 | About 218,000 | +| 3 | About 249,000 | +| 5 | About 295,000 | +| 10 | About 330,000 | -
(注:测试数据源自 单节点 Intel(R) Core(TM) i7-10700 CPU@2.90GHz 16 核 64G 硬件设备,channel 和 batchSize 分别为 8 和 1000,每条记录包含 10 个 tag) +
(Note: The test data comes from a single-node Intel(R) Core(TM) i7-10700 CPU@2.90GHz 16-core 64G hardware device, the channel and batchSize are 8 and 1000 respectively, and each record contains 10 tags) -### 2、手动迁移数据 +### 2. Manual data migration -如果你需要使用多值模型进行数据写入,就需要自行开发一个将数据从 OpenTSDB 导出的工具,然后确认哪些时间线能够合并导入到同一个时间线,再将可以同时导入的时间通过 SQL 语句的写入到数据库中。 +Suppose you need to use the multi-value model for data writing. In that case, you need to develop a tool to export data from OpenTSDB, confirm which timelines can be merged and imported into the same timeline, and then pass the time to import simultaneously through the SQL statement—written to the database. -手动迁移数据需要注意以下两个问题: +Manual migration of data requires attention to the following two issues: -1)在磁盘中存储导出数据时,磁盘需要有足够的存储空间以便能够充分容纳导出的数据文件。为了避免全量数据导出后导致磁盘文件存储紧张,可以采用部分导入的模式,对于归属于同一个超级表的时间线优先导出,然后将导出部分的数据文件导入到 TDengine 系统中。 +1) When storing the exported data on the disk, the disk needs to have enough storage space to accommodate the exported data files fully. Adopting the partial import mode to avoid the shortage of disk file storage after the total amount of data is exported. Preferentially export the timelines belonging to the same super table. Then the exported data files are imported into the TDengine system. -2)在系统全负载运行下,如果有足够的剩余计算和 IO 资源,可以建立多线程的导入机制,最大限度地提升数据迁移的效率。考虑到数据解析对于 CPU 带来的巨大负载,需要控制最大的并行任务数量,以避免因导入历史数据而触发的系统整体过载。 +2) Under the full load of the system, if there are enough remaining computing and IO resources, establish a multi-threaded importing to maximize the efficiency of data migration. Considering the vast load that data parsing brings to the CPU, it is necessary to control the maximum number of parallel tasks to avoid the overall overload of the system triggered by importing historical data. -由于 TDegnine 本身操作简易性,所以不需要在整个过程中进行索引维护、数据格式的变化处理等工作,整个过程只需要顺序执行即可。 +Due to the ease of operation of TDengine itself, there is no need to perform index maintenance and data format change processing in the entire process. The whole process only needs to be executed sequentially. -当历史数据完全导入到 TDengine 以后,此时两个系统处于同时运行的状态,之后便可以将查询请求切换到 TDengine 上,从而实现无缝的应用切换。 +When wholly importing the historical data into TDengine, the two systems run simultaneously and then switch the query request to TDengine to achieve seamless application switching. -## 附录 1: OpenTSDB 查询函数对应表 +## Appendix 1: OpenTSDB query function correspondence table -**Avg** +### Avg -等效函数:avg +Equivalent function: avg -示例: +Example: +```sql SELECT avg(val) FROM (SELECT first(val) FROM super_table WHERE ts >= startTime and ts <= endTime INTERVAL(20s) Fill(linear)) INTERVAL(20s) +``` -备注: +Remark: -1. Interval 内的数值与外层查询的 interval 数值需要相同。 -2. 在 TDengine 中插值处理需要使用子查询来协助完成,如上所示,在内层查询中指明插值类型即可,由于 OpenTSDB 中数值的插值使用了线性插值,因此在插值子句中使用 fill(linear) 来声明插值类型。以下有相同插值计算需求的函数,均采用该方法处理。 -3. Interval 中参数 20s 表示将内层查询按照 20 秒一个时间窗口生成结果。在真实的查询中,需要调整为不同的记录之间的时间间隔。这样可确保等效于原始数据生成了插值结果。 -4. 由于 OpenTSDB 特殊的插值策略和机制,聚合查询(Aggregate)中先插值再计算的方式导致其计算结果与 TDengine 不可能完全一致。但是在降采样(Downsample)的情况下,TDengine 和 OpenTSDB 能够获得一致的结果(由于 OpenTSDB 在聚合查询和降采样查询中采用了完全不同的插值策略)。 +1. The value in Interval needs to be the same as the interval value in the outer query. +2. The interpolation processing in TDengine needs to use subqueries to assist in the completion. As shown above, it is enough to specify the interpolation type in the inner query. Since the interpolation of the values ​​in OpenTSDB uses linear interpolation, use fill( in the interpolation clause. linear) to declare the interpolation type. The following functions with the exact interpolation calculation requirements are processed by this method. +3. The parameter 20s in Interval indicates that the inner query will generate results according to a time window of 20 seconds. In an actual query, it needs to adjust to the time interval between different records. It ensures that producing interpolation results equivalent to the original data. +4. Due to the particular interpolation strategy and mechanism of OpenTSDB, the method of the first interpolation and then calculation in the aggregate query (Aggregate) makes the calculation results impossible to be utterly consistent with TDengine. But in the case of downsampling (Downsample), TDengine and OpenTSDB can obtain consistent results (since OpenTSDB performs aggregation and downsampling queries). -**Count** +### Count -等效函数:count +Equivalent function: count -示例: +Example: +```sql select count(\*) from super_table_name; +``` -**Dev** +### Dev -等效函数:stddev +Equivalent function: stddev -示例: +Example: +```sql Select stddev(val) from table_name +``` -**Estimated percentiles** +### Estimated percentiles -等效函数:apercentile +Equivalent function: apercentile -示例: +Example: +```sql Select apercentile(col1, 50, “t-digest”) from table_name +``` -备注: +Remark: -1. 近似查询处理过程中,OpenTSDB 默认采用 t-digest 算法,所以为了获得相同的计算结果,需要在 apercentile 函数中指明使用的算法。TDengine 能够支持两种不同的近似处理算法,分别通过“default”和“t-digest”来声明。 +1. During the approximate query processing, OpenTSDB uses the t-digest algorithm by default, so in order to obtain the same calculation result, the algorithm used needs to be specified in the `apercentile()` function. TDengine can support two different approximation processing algorithms, declared by "default" and "t-digest" respectively. -**First** +### First -等效函数:first +Equivalent function: first -示例: +Example: +```sql Select first(col1) from table_name +``` -**Last** +### Last -等效函数:last +Equivalent function: last -示例: +Example: +```sql Select last(col1) from table_name +``` -**Max** +### Max -等效函数:max +Equivalent function: max -示例: +Example: +```sql Select max(value) from (select first(val) value from table_name interval(10s) fill(linear)) interval(10s) +``` -备注:Max 函数需要插值,原因见上。 +Note: The Max function requires interpolation for the reasons described above. -**Min** +### Min -等效函数:min +Equivalent function: min -示例: +Example: +```sql Select min(value) from (select first(val) value from table_name interval(10s) fill(linear)) interval(10s); +``` -**MinMax** +### MinMax -等效函数:max +Equivalent function: max +```sql Select max(val) from table_name +``` -备注:该函数无插值需求,因此可用直接计算。 +Note: This function has no interpolation requirements, so it can be directly calculated. -**MimMin** +### MimMin -等效函数:min +Equivalent function: min +```sql Select min(val) from table_name +``` -备注:该函数无插值需求,因此可用直接计算。 +Note: This function has no interpolation requirements, so it can be directly calculated. -**Percentile** +### Percentile -等效函数:percentile +Equivalent function: percentile -备注: +Remark: -**Sum** +### Sum -等效函数:sum +Equivalent function: sum +```sql Select max(value) from (select first(val) value from table_name interval(10s) fill(linear)) interval(10s) +``` -备注:该函数无插值需求,因此可用直接计算。 +Note: This function has no interpolation requirements, so it can be directly calculated. -**Zimsum** +### Zimsum -等效函数:sum +Equivalent function: sum +```sql Select sum(val) from table_name +``` -备注:该函数无插值需求,因此可用直接计算。 +Note: This function has no interpolation requirements, so it can be directly calculated. -完整示例: +Complete example: -```json -// OpenTSDB 查询 JSON +````json +// OpenTSDB query JSON query = { -“start”:1510560000, -“end”: 1515000009, -“queries”:[{ -“aggregator”: “count”, -“metric”:”cpu.usage_user”, +"start": 1510560000, +"end": 1515000009, +"queries": [{ +"aggregator": "count", +"metric": "cpu.usage_user", }] } -//等效查询 SQL: +// Equivalent query SQL: SELECT count(*) FROM `cpu.usage_user` WHERE ts>=1510560000 AND ts<=1515000009 -``` +```` -## 附录 2: 资源估算方法 +## Appendix 2: Resource Estimation Methodology -### 数据生成环境 +### Data generation environment -我们仍然使用第 4 章中的假设环境,3 个测量值。分别是:温度和湿度的数据写入的速率是每 5 秒一条记录,时间线 10 万个。空气质量的写入速率是 10 秒一条记录,时间线 1 万个,查询的请求频率 500 QPS。 +We still use the hypothetical environment from Chapter 4. There are three measurements. Respectively: the data writing rate of temperature and humidity is one record every 5 seconds, and the timeline is 100,000. The writing rate of air pollution is one record every 10 seconds, the timeline is 10,000, and the query request frequency is 500 QPS. -### 存储资源估算 +### Storage resource estimation -假设产生数据并需要存储的传感器设备数量为 `n`,数据生成的频率为`t`条/秒,每条记录的长度为 `L` bytes,则每天产生的数据规模为 `n×t×L` bytes。假设压缩比为 C,则每日产生数据规模为 `(n×t×L)/C` bytes。存储资源预估为能够容纳 1.5 年的数据规模,生产环境下 TDengine 的压缩比 C 一般在 5 ~ 7 之间,同时为最后结果增加 20% 的冗余,可计算得到需要存储资源: +Assuming that the number of sensor devices that generate data and need to be stored is `n`, the frequency of data generation is `t` per second, and the length of each record is `L` bytes, the scale of data generated per day is `n * t * L` bytes. Assuming the compression ratio is `C`, the daily data size is `(n * t * L)/C` bytes. The storage resources are estimated to accommodate the data scale for 1.5 years. In the production environment, the compression ratio C of TDengine is generally between 5 and 7. +With additional 20% ​​redundancy, you can calculate the required storage resources: ```matlab -(n×t×L)×(365×1.5)×(1+20%)/C -``` +(n * t * L) * (365 * 1.5) * (1+20%)/C +```` -结合以上的计算公式,将参数带入计算公式,在不考虑标签信息的情况下,每年产生的原始数据规模是 11.8TB。需要注意的是,由于标签信息在 TDengine 中关联到每个时间线,并不是每条记录。所以需要记录的数据量规模相对于产生的数据有一定的降低,而这部分标签数据整体上可以忽略不记。假设压缩比为 5,则保留的数据规模最终为 2.56 TB。 +Combined with the above calculation formula, bring the parameters into the formula, and the raw data scale generated every year is 11.8TB without considering the label information. Note that since tag information is associated with each timeline in TDengine, not every record. The scale of the amount of data to be recorded is somewhat reduced relative to the generated data, and this part of label data can be ignored as a whole. Assuming a compression ratio of 5, the size of the retained data ends up being 2.56 TB. -### 存储设备选型考虑 +### Storage Device Selection Considerations -硬盘应该选用具有较好随机读性能的硬盘设备,如果能够有 SSD,尽可能考虑使用 SSD。较好的随机读性能的磁盘对于提升系统查询性能具有极大的帮助,能够整体上提升系统的查询响应性能。为了获得较好的查询性能,硬盘设备的单线程随机读 IOPS 的性能指标不应该低于 1000,能够达到 5000 IOPS 以上为佳。为了获得当前的设备随机读取的 IO 性能的评估,建议使用 fio 软件对其进行运行性能评估(具体的使用方式请参阅附录 1),确认其是否能够满足大文件随机读性能要求。 +The hard disk should be capable of better random read performance. Considering using an SSD as much as possible is a better choice. A disk with better random read performance is a great help to improve the system's query performance and improve the query response performance as a whole system. To obtain better query performance, the performance index of the single-threaded random read IOPS of the hard disk device should not be lower than 1000, and it is better to reach 5000 IOPS or more. Recommend to use `fio` utility software to evaluate the running performance (please refer to Appendix 1 for specific usage) for the random IO read of the current device to confirm whether it can meet the requirements of random read of large files. -硬盘写性能对于 TDengine 的影响不大。TDengine 写入过程采用了追加写的模式,所以只要有较好的顺序写性能即可,一般意义上的 SAS 硬盘和 SSD 均能够很好地满足 TDengine 对于磁盘写入性能的要求。 +Hard disk writing performance has little effect on TDengine. The TDengine writing process adopts the append write mode, so as long as it has good sequential write performance, both SAS hard disks and SSDs in the general sense can well meet TDengine's requirements for disk write performance. -### 计算资源估算 +### Computational resource estimates -由于物联网数据的特殊性,数据产生的频率固定以后,TDengine 写入的过程对于(计算和存储)资源消耗都保持一个相对固定的量。《[TDengine 运维指南](/operation/)》上的描述,该系统中每秒 22000 个写入,消耗 CPU 不到 1 个核。 +Due to the particularity of IoT data, after the frequency of data generation is consistent, the writing process of TDengine maintains a relatively fixed amount of resource consumption (computing and storage). According to the [TDengine Operation and Maintenance Guide](/operation/) description, the system consumes less than 1 CPU core at 22,000 writes per second. -在针对查询所需要消耗的 CPU 资源的估算上,假设应用要求数据库提供的 QPS 为 10000,每次查询消耗的 CPU 时间约 1 ms,那么每个核每秒提供的查询为 1000 QPS,满足 10000 QPS 的查询请求,至少需要 10 个核。为了让系统整体上 CPU 负载小于 50%,整个集群需要 10 个核的两倍,即 20 个核。 +In estimating the CPU resources consumed by the query, assuming that the application requires the database to provide 10,000 QPS, the CPU time consumed by each query is about 1 ms. The query provided by each core per second is 1,000 QPS, which satisfies 10,000 QPS. The query request requires at least 10 cores. For the system as a whole system to have less than 50% CPU load, the entire cluster needs twice as many as 10 cores or 20 cores. -### 内存资源估算 +### Memory resource estimation -数据库默认为每个 Vnode 分配内存 16MB\*3 缓冲区,集群系统包括 22 个 CPU 核,则默认会建立 22 个虚拟节点 Vnode,每个 Vnode 包含 1000 张表,则可以容纳所有的表。则约 1 个半小时写满一个 block,从而触发落盘,可以不做调整。22 个 Vnode 共计需要内存缓存约 1GB。考虑到查询所需要的内存,假设每次查询的内存开销约 50MB,则 500 个查询并发需要的内存约 25GB。 +The database allocates 16MB\*3 buffer memory for each Vnode by default. If the cluster system includes 22 CPU cores, TDengine will create 22 Vnodes (virtual nodes) by default. Each Vnode contains 1000 tables, which can accommodate all the tables. Then it takes about 1.5 hours to write a block, which triggers the drop, and no adjustment is required. A total of 22 Vnodes require about 1GB of memory cache. Considering the memory needed for the query, assuming that the memory overhead of each query is about 50MB, the memory required for 500 queries concurrently is about 25GB. -综上所述,可使用单台 16 核 32GB 的机器,或者使用 2 台 8 核 16GB 机器构成的集群。 +In summary, using a single 16-core 32GB machine or a cluster of 2 8-core 16GB machines is enough. -## 附录 3: 集群部署及启动 +## Appendix 3: Cluster Deployment and Startup -TDengine 提供了丰富的帮助文档说明集群安装、部署的诸多方面的内容,这里提供响应的文档索引,供你参考。 +TDengine provides a wealth of help documents to explain many aspects of cluster installation and deployment. Here is the list of corresponding document for your reference. -### 集群部署 +### Cluster Deployment -首先是安装 TDengine,从官网上下载 TDengine 最新稳定版,解压缩后运行 install.sh 进行安装。各种安装包的使用帮助请参见博客[《TDengine 多种安装包的安装和卸载》](https://www.taosdata.com/blog/2019/08/09/566.html)。 +The first is TDengine installation. Download the latest stable version of TDengine from the official website, and install it. Please refer to the blog ["Installation and Uninstallation of Various Installation Packages of TDengine"](https://www.taosdata.com/blog/2019/08/09/566.html) for the various installation package formats. -注意安装完成以后,不要立即启动 taosd 服务,在正确配置完成参数以后才启动 taosd 服务。 +Note that once the installation is complete, do not immediately start the `taosd` service, but start it after correctly configuring the parameters. -### 设置运行参数并启动服务 +### Set running parameters and start the service -为确保系统能够正常获取运行的必要信息。请在服务端正确设置以下关键参数: +To ensure that the system can obtain the necessary information for regular operation. Please set the following vital parameters correctly on the server: -FQDN、firstEp、secondEP、dataDir、logDir、tmpDir、serverPort。各参数的具体含义及设置的要求,可参见文档《[TDengine 集群安装、管理](/cluster/)》 +FQDN, firstEp, secondEP, dataDir, logDir, tmpDir, serverPort. For the specific meaning and setting requirements of each parameter, please refer to the document "[TDengine Cluster Installation and Management](/cluster/)" -按照相同的步骤,在需要运行的节点上设置参数,并启动 taosd 服务,然后添加 Dnode 到集群中。 +Follow the same steps to set parameters on the nodes that need running, start the taosd service, and then add Dnodes to the cluster. -最后启动 taos,执行命令 show dnodes,如果能看到所有的加入集群的节点,那么集群顺利搭建完成。具体的操作流程及注意事项,请参阅文档《[TDengine 集群安装、管理](/cluster/)》 +Finally, start `taos` and execute the `show dnodes` command. If you can see all the nodes that have joined the cluster, the cluster building process was successfully completed. For specific operation procedures and precautions, please refer to the document "[TDengine Cluster Installation and Management](/cluster/)". -## 附录 4: 超级表名称 +## Appendix 4: Super Table Names -由于 OpenTSDB 的 metric 名称中带有点号(“.“),例如“cpu.usage_user”这种名称的 metric。但是点号在 TDengine 中具有特殊含义,是用来分隔数据库和表名称的分隔符。TDengine 也提供转义符,以允许用户在(超级)表名称中使用关键词或特殊分隔符(如:点号)。为了使用特殊字符,需要采用转义字符将表的名称括起来,例如:`cpu.usage_user`这样就是合法的(超级)表名称。 +Since OpenTSDB's metric name has a dot (".") in it, for example, a metric with a name like "cpu.usage_user", the dot has a special meaning in TDengine and is a separator used to separate database and table names. TDengine also provides "escape" characters to allow users to use keywords or special separators (e.g., dots) in (super)table names. To use special characters, enclose the table name in escape characters, e.g.: `cpu.usage_user`. It is a valid (super) table name. -## 附录 5:参考文章 +## Appendix 5: Reference Articles -1. [使用 TDengine + collectd/StatsD + Grafana 快速搭建 IT 运维监控系统](/application/collectd/) -2. [通过 collectd 将采集数据直接写入 TDengine](/third-party/collectd/) +1. [Using TDengine + collectd/StatsD + Grafana to quickly build an IT operation and maintenance monitoring system](/application/collectd/) +2. [Write collected data directly to TDengine through collectd](/third-party/collectd/) diff --git a/docs-en/25-application/_category_.yml b/docs-en/25-application/_category_.yml index 912a96126865fabc1eea24d8fc12e78b217b0527..772d45e6cf7042e701968fe658b53ef53bd91c62 100644 --- a/docs-en/25-application/_category_.yml +++ b/docs-en/25-application/_category_.yml @@ -1,4 +1 @@ label: Application Practice -link: - slug: /application/ - type: generated-index diff --git a/docs-en/25-application/index.md b/docs-en/25-application/index.md new file mode 100644 index 0000000000000000000000000000000000000000..5383a00c67c515dc65fd2ed1cac4b218710288b5 --- /dev/null +++ b/docs-en/25-application/index.md @@ -0,0 +1,10 @@ +--- +title: Application Practice +--- + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-en/27-train-faq/03-docker.md b/docs-en/27-train-faq/03-docker.md index a86b72a39e94c4db7d3b229fba2260df36ef2a88..845a8751846c0995a43fb1c01e6ace3080176838 100644 --- a/docs-en/27-train-faq/03-docker.md +++ b/docs-en/27-train-faq/03-docker.md @@ -123,7 +123,7 @@ TDengine REST API 详情请参考[官方文档](/reference/rest-api/)。 ### 使用 Docker 容器运行 TDengine server 和 taosAdapter -在 TDegnine 2.4.0.0 之后版本的 Docker 容器,开始提供一个独立运行的组件 taosAdapter,代替之前版本 TDengine 中 taosd 进程中内置的 http server。taosAdapter 支持通过 RESTful 接口对 TDengine server 的数据写入和查询能力,并提供和 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine。在新版本 Docker 镜像中,默认启用了 taosAdapter,也可以使用 docker run 命令中设置 TAOS_DISABLE_ADAPTER=true 来禁用 taosAdapter;也可以在 docker run 命令中单独使用 taosAdapter,而不运行 taosd 。 +在 TDengine 2.4.0.0 之后版本的 Docker 容器,开始提供一个独立运行的组件 taosAdapter,代替之前版本 TDengine 中 taosd 进程中内置的 http server。taosAdapter 支持通过 RESTful 接口对 TDengine server 的数据写入和查询能力,并提供和 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine。在新版本 Docker 镜像中,默认启用了 taosAdapter,也可以使用 docker run 命令中设置 TAOS_DISABLE_ADAPTER=true 来禁用 taosAdapter;也可以在 docker run 命令中单独使用 taosAdapter,而不运行 taosd 。 注意:如果容器中运行 taosAdapter,需要根据需要映射其他端口,具体端口默认配置和修改方法请参考[taosAdapter 文档](/reference/taosadapter/)。 diff --git a/docs-en/27-train-faq/_category_.yml b/docs-en/27-train-faq/_category_.yml index 034d5894b9aea00e43caf4df21cb39487d8baf7b..7a8530c129b90c4ac382168a55c339bbd627cd05 100644 --- a/docs-en/27-train-faq/_category_.yml +++ b/docs-en/27-train-faq/_category_.yml @@ -1,4 +1 @@ -label: FAQ、教程及其它 -link: - slug: /train-faq/ - type: generated-index +label: FAQ & Others diff --git a/docs-en/27-train-faq/index.md b/docs-en/27-train-faq/index.md new file mode 100644 index 0000000000000000000000000000000000000000..2cb87aab005b0ecc9275b6fe10e267487d38c336 --- /dev/null +++ b/docs-en/27-train-faq/index.md @@ -0,0 +1,10 @@ +--- +title: FAQ & Others +--- + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; +import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; + + +``` \ No newline at end of file diff --git a/docs-examples/php/connect.php b/docs-examples/php/connect.php new file mode 100644 index 0000000000000000000000000000000000000000..5af77b9768e5c5ac4b774b433479a4ac8902beda --- /dev/null +++ b/docs-examples/php/connect.php @@ -0,0 +1,20 @@ +connect(); +} catch (TDengineException $e) { + // 连接失败捕获异常 + throw $e; +} diff --git a/docs-examples/php/insert.php b/docs-examples/php/insert.php new file mode 100644 index 0000000000000000000000000000000000000000..0d9cfc4843a2ec3e72d0ad128fa4c2650d6b9cf6 --- /dev/null +++ b/docs-examples/php/insert.php @@ -0,0 +1,33 @@ +connect(); + + // 插入 + $connection->query('CREATE DATABASE if not exists power'); + $connection->query('CREATE STABLE if not exists meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)'); + $resource = $connection->query(<<<'SQL' + INSERT INTO power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) + power.d1002 USING power.meters TAGS(Beijing.Chaoyang, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) + power.d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) + power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000) + SQL); + + // 影响行数 + var_dump($resource->affectedRows()); +} catch (TDengineException $e) { + // 捕获异常 + throw $e; +} diff --git a/docs-examples/php/insert_stmt.php b/docs-examples/php/insert_stmt.php new file mode 100644 index 0000000000000000000000000000000000000000..5d4b4809d215d781807c21172982feff2171fe07 --- /dev/null +++ b/docs-examples/php/insert_stmt.php @@ -0,0 +1,49 @@ +connect(); + + // 插入 + $connection->query('CREATE DATABASE if not exists power'); + $connection->query('CREATE STABLE if not exists meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)'); + $stmt = $connection->prepare('INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)'); + + // 设置表名和标签 + $stmt->setTableNameTags('d1001', [ + // 支持格式同参数绑定 + [TDengine\TSDB_DATA_TYPE_BINARY, 'Beijing.Chaoyang'], + [TDengine\TSDB_DATA_TYPE_INT, 2], + ]); + + $stmt->bindParams([ + [TDengine\TSDB_DATA_TYPE_TIMESTAMP, 1648432611249], + [TDengine\TSDB_DATA_TYPE_FLOAT, 10.3], + [TDengine\TSDB_DATA_TYPE_INT, 219], + [TDengine\TSDB_DATA_TYPE_FLOAT, 0.31], + ]); + $stmt->bindParams([ + [TDengine\TSDB_DATA_TYPE_TIMESTAMP, 1648432611749], + [TDengine\TSDB_DATA_TYPE_FLOAT, 12.6], + [TDengine\TSDB_DATA_TYPE_INT, 218], + [TDengine\TSDB_DATA_TYPE_FLOAT, 0.33], + ]); + $resource = $stmt->execute(); + + // 影响行数 + var_dump($resource->affectedRows()); +} catch (TDengineException $e) { + // 捕获异常 + throw $e; +} diff --git a/docs-examples/php/query.php b/docs-examples/php/query.php new file mode 100644 index 0000000000000000000000000000000000000000..4e86a2cec7426887686049977a8647e786ac2744 --- /dev/null +++ b/docs-examples/php/query.php @@ -0,0 +1,23 @@ +connect(); + + $resource = $connection->query('SELECT ts, current FROM meters LIMIT 2'); + var_dump($resource->fetch()); +} catch (TDengineException $e) { + // 捕获异常 + throw $e; +} diff --git a/documentation20/cn/08.connector/01.java/docs.md b/documentation20/cn/08.connector/01.java/docs.md index caa880618fad933f94a0177354907d7c5199603c..c5e0a92bd7f87576e9313a9d03630808b3c66db3 100644 --- a/documentation20/cn/08.connector/01.java/docs.md +++ b/documentation20/cn/08.connector/01.java/docs.md @@ -51,7 +51,7 @@ TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致 ```sql INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES(now, 24.6); ``` -* 从taos-jdbcdriver-2.0.36和TDengine 2.2.0.0 版本开始,如果在url中指定了dbname,那么,JDBC-RESTful会默认使用/rest/sql/dbname作为resful请求的url,在sql中不需要指定dbname。例如:url为jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行sql:insert into t1 using weather(ts, temperatrue) tags('beijing') values(now, 24.6); +* 从taos-jdbcdriver-2.0.36和TDengine 2.2.0.0 版本开始,如果在url中指定了dbname,那么,JDBC-RESTful会默认使用/rest/sql/dbname作为 restful 请求的 url,在 SQL 中不需要指定dbname。例如:url为jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行sql:insert into t1 using weather(ts, temperature) tags('beijing') values(now, 24.6); ## TAOS-JDBCDriver 版本以及支持的 TDengine 版本和 JDK 版本 diff --git a/documentation20/cn/08.connector/03.php/docs.md b/documentation20/cn/08.connector/03.php/docs.md index eb772689e4699716a45a78dfb2723aa7a0cfa516..0a5a0fdb31639f7a3f77c31719c6bb658cc31459 100644 --- a/documentation20/cn/08.connector/03.php/docs.md +++ b/documentation20/cn/08.connector/03.php/docs.md @@ -26,7 +26,7 @@ **下载代码并解压:** ```shell -curl -L -o php-tdengine.tar.gz https://github.com/Yurunsoft/php-tdengine/archive/refs/tags/v1.0.0.tar.gz \ +curl -L -o php-tdengine.tar.gz https://github.com/Yurunsoft/php-tdengine/archive/refs/tags/v1.0.2.tar.gz \ && mkdir php-tdengine \ && tar -xzf php-tdengine.tar.gz -C php-tdengine --strip-components=1 ``` @@ -95,7 +95,7 @@ $db = null; // 实例化 $connection = new Connection($host, $port, $user, $pass, $db); // 连接 -$connection->connection(); +$connection->connect(); // 获取连接参数 $connection->getHost(); $connection->getPort(); @@ -140,6 +140,11 @@ $resource->close(); ```php // 查询 $stmt = $connection->prepare($sql); // 支持查询和插入,参数用?占位 +// 设置表名和标签 +$stmt->setTableNameTags('表名', [ + // 支持格式同参数绑定 + [TDengine\TSDB_DATA_TYPE_INT, 36], +]); // 绑定参数方法1 $stmt->bindParams( // [字段类型, 值] @@ -190,7 +195,7 @@ $stmt->close(); ## tdengine-restful-connector -封装了 TDEngine 的 RESTful 接口,可以使用 PHP 轻松地操作 TDEngine 的数据插入和查询了。 +封装了 TDengine 的 RESTful 接口,可以使用 PHP 轻松地操作 TDengine 的数据插入和查询了。 此项目支持在 PHP >= 7.0 的项目中使用。 diff --git a/documentation20/cn/14.devops/03.immigrate/docs.md b/documentation20/cn/14.devops/03.immigrate/docs.md index 21f9aa9053e598774710069f5a1d2354da742858..7ca3a7950e6a2d90369592ad999faecb005dd65c 100644 --- a/documentation20/cn/14.devops/03.immigrate/docs.md +++ b/documentation20/cn/14.devops/03.immigrate/docs.md @@ -63,7 +63,7 @@ LoadPlugin write_tsdb 即可让 collectd 将数据使用推送到 OpenTSDB 的插件方式推送到 taosAdapter, taosAdapter 将调用 API 将数据写入到 taosd 中,从而完成数据的写入工作。如果你使用的是 StatsD 相应地调整配置文件信息。 -- **调整看板(Dashborad)系统** +- **调整看板(Dashboard)系统** 在数据能够正常写入 TDengine 后,可以调整适配 Grafana 将写入 TDengine 的数据可视化呈现出来。获取和使用 TDengine 提供的 Grafana 插件请参考[与其他工具的连接](https://www.taosdata.com/cn/documentation/connections#grafana)。 diff --git a/documentation20/en/13.faq/docs.md b/documentation20/en/13.faq/docs.md index 62b82a3ee257a0f676d6e663a16fb21157bd50ba..0fea7788b88ef6c5600fdf285b627f02da1a10de 100644 --- a/documentation20/en/13.faq/docs.md +++ b/documentation20/en/13.faq/docs.md @@ -159,3 +159,22 @@ ALTER LOCAL RESETLOG; This means wiping up all client-generated log files on the machine. +## 18. How to solve the golang component compilation failure? + +From version 2.3.0.0, a new component taosAdapter developed in go has been added in TDengine. taosAdapter needs to be run separately to replace the httpd built in taosd. It provideds REST API and data flow a variety of 3rd party tools like Prometheus, Telegraf, CollectD, StatsD, etc, can be inserted into TDengine through it. + +For details about taosAdapter, please refer to [taosAdapter](https://tdengine.com/docs/en/v2.0/tools/adapter#install-taosadapter). + +## 19. How do I query the disk space occupied by data? + +By default, TDengine data files are stored in /var/lib/taos and log files are stored in /var/log/taos. + +To check the size of all data files, run command `du -sh /var/lib/taos/vnode --exclude='wal'` on Linux Shell. The wal directory is excluded here because the size is almost fixed in case of continuous heavy writes, and wal directories are emptied whenever TDengine is normally shut down. + +To check the size of a single database, run the `show vgroups;` command in the taos command to specify a database, go to /var/lib/taos/vnode with the obtained VGroup ID to check the contained folder size. + +If you only want to see the block distribution and size of a (super) table, You can use _block_dist functions: + +```mysql +SELECT _block_dist () FROM {tb_name | stb_name} +``` diff --git a/examples/C#/C#checker/C#checker.cs b/examples/C#/C#checker/C#checker.cs index 29ad290343bb4fbacade48a0b59e0350bd35f213..7d0b6a50b673278ac6982a97de7eb31ce76761b6 100644 --- a/examples/C#/C#checker/C#checker.cs +++ b/examples/C#/C#checker/C#checker.cs @@ -133,11 +133,11 @@ namespace TDengineDriver String indent = " "; Console.WriteLine("taosTest is simple example to operate TDengine use C# Language.\n"); Console.WriteLine("{0:G}{1:G}", indent, "-h"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "TDEngine server IP address to connect"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "TDengine server IP address to connect"); Console.WriteLine("{0:G}{1:G}", indent, "-u"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is root"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDengine user name to use when connecting to the server, default is root"); Console.WriteLine("{0:G}{1:G}", indent, "-p"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is taosdata"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDengine user name to use when connecting to the server, default is taosdata"); Console.WriteLine("{0:G}{1:G}", indent, "-d"); Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Database used to create table or import data, default is db"); Console.WriteLine("{0:G}{1:G}", indent, "-s"); diff --git a/examples/C#/TDengineTest/TDengineTest.cs b/examples/C#/TDengineTest/TDengineTest.cs index 9f84634ffb400e5d891a9fdeaeee0c013829f969..9953c227b0b07df0c4844745c7810d2c1c365294 100644 --- a/examples/C#/TDengineTest/TDengineTest.cs +++ b/examples/C#/TDengineTest/TDengineTest.cs @@ -133,11 +133,11 @@ namespace TDengineDriver String indent = " "; Console.WriteLine("taosTest is simple example to operate TDengine use C# Language.\n"); Console.WriteLine("{0:G}{1:G}", indent, "-h"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "TDEngine server IP address to connect"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "TDengine server IP address to connect"); Console.WriteLine("{0:G}{1:G}", indent, "-u"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is root"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDengine user name to use when connecting to the server, default is root"); Console.WriteLine("{0:G}{1:G}", indent, "-p"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is taosdata"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDengine user name to use when connecting to the server, default is taosdata"); Console.WriteLine("{0:G}{1:G}", indent, "-d"); Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Database used to create table or import data, default is db"); Console.WriteLine("{0:G}{1:G}", indent, "-s"); diff --git a/examples/C#/insertCn/Program.cs b/examples/C#/insertCn/Program.cs index 85d3e42533897d5790f148a1e1f9ed286f56dbea..eefe5c678e6a896152ee5fe05dc9dcd6a8efd525 100644 --- a/examples/C#/insertCn/Program.cs +++ b/examples/C#/insertCn/Program.cs @@ -49,7 +49,7 @@ namespace insertCn String table = stable + "_subtable_1"; var colData = new List{1637064040000,1,"涛思数据","保利广场","Beijing","China", 1637064041000,2,"涛思数据taosdata","保利广场baoli","Beijing","China", - 1637064042000,3,"TDegnine涛思数据","time广场","NewYork","US", + 1637064042000,3,"TDengine涛思数据","time广场","NewYork","US", 1637064043000,4,"4涛思数据","4广场南部","London","UK", 1637064044000,5,"涛思数据5","!广场路中部123","Tokyo","JP", 1637064045000,6,"taos涛思数据6","青年广场123号!","Washin","DC", @@ -99,7 +99,7 @@ namespace insertCn { var colData = new List{1637064040000,1,"涛思数据","保利广场","Beijing","China", 1637064041000,2,"涛思数据taosdata","保利广场baoli","Beijing","China", - 1637064042000,3,"TDegnine涛思数据","time广场","NewYork","US", + 1637064042000,3,"TDengine涛思数据","time广场","NewYork","US", 1637064043000,4,"4涛思数据","4广场南部","London","UK", 1637064044000,5,"涛思数据5","!广场路中部123","Tokyo","JP", 1637064045000,6,"taos涛思数据6","青年广场123号!","Washin","DC", diff --git a/packaging/macOS/com.taosdata.tdengine.plist b/packaging/macOS/com.taosdata.tdengine.plist new file mode 100644 index 0000000000000000000000000000000000000000..6e41a3bbf7dde072e6c3954140364a62804524c4 --- /dev/null +++ b/packaging/macOS/com.taosdata.tdengine.plist @@ -0,0 +1,22 @@ + + + + + KeepAlive + + Label + com.taosdata.tdengine.taosd + Program + /usr/local/bin/taosd + ProgramArguments + + /usr/local/bin/taosd + + RunAtLoad + + SessionCreate + + StandardOutPath + /var/log/tdengine.log + + \ No newline at end of file diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 19fa1f969e39ee46434a6127cd8823e252804d2a..f07705ff442b65f1295431e59b48ef50a76cadc0 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -15,6 +15,7 @@ serverFqdn="" # -----------------------Variables definition--------------------- script_dir=$(dirname $(readlink -f "$0")) # Dynamic directory + clientName="taos" serverName="taosd" configFile="taos.cfg" @@ -27,6 +28,10 @@ dataDir="/var/lib/taos" logDir="/var/log/taos" configDir="/etc/taos" installDir="/usr/local/taos" +adapterName="taosadapter" +benchmarkName="taosBenchmark" +dumpName="taosdump" +demoName="taosdemo" data_dir=${dataDir} log_dir=${logDir} @@ -39,7 +44,6 @@ inc_link_dir="/usr/include" #install main path install_main_dir=${installDir} - # old bin dir bin_dir="${installDir}/bin" @@ -122,6 +126,9 @@ else fi # ============================= get input parameters ================================================= + +# install.sh -v [server | client] -e [yes | no] -i [systemd | service | ...] + # set parameters by default value interactiveFqdn=yes # [yes | no] verType=server # [server | client] @@ -167,11 +174,11 @@ function install_main_path() { ${csudo}mkdir -p ${install_main_dir} ${csudo}mkdir -p ${install_main_dir}/cfg ${csudo}mkdir -p ${install_main_dir}/bin - # ${csudo}mkdir -p ${install_main_dir}/connector + # ${csudo}mkdir -p ${install_main_dir}/connector ${csudo}mkdir -p ${install_main_dir}/driver ${csudo}mkdir -p ${install_main_dir}/examples ${csudo}mkdir -p ${install_main_dir}/include - # ${csudo}mkdir -p ${install_main_dir}/init.d + # ${csudo}mkdir -p ${install_main_dir}/init.d if [ "$verMode" == "cluster" ]; then ${csudo}mkdir -p ${nginx_dir} fi @@ -185,13 +192,11 @@ function install_bin() { # Remove links ${csudo}rm -f ${bin_link_dir}/${clientName} || : ${csudo}rm -f ${bin_link_dir}/${serverName} || : - ${csudo}rm -f ${bin_link_dir}/taosadapter || : - ${csudo}rm -f ${bin_link_dir}/taosdemo || : - ${csudo}rm -f ${bin_link_dir}/taosdump || : + ${csudo}rm -f ${bin_link_dir}/${adapterName} || : ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : ${csudo}rm -f ${bin_link_dir}/tarbitrator || : ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo}rm -f ${bin_link_dir}/run_taosd_and_taosadapter.sh || : + ${csudo}rm -f ${bin_link_dir}/run_${serverName}_and_${adapterName}.sh || : ${csudo}rm -f ${bin_link_dir}/TDinsight.sh || : ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* @@ -199,14 +204,14 @@ function install_bin() { #Make link [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || : [ -x ${install_main_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || : - [ -x ${install_main_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || : - [ -x ${install_main_dir}/bin/taosBenchmark ] && ${csudo}ln -s ${install_main_dir}/bin/taosBenchmark ${bin_link_dir}/taosdemo || : - [ -x ${install_main_dir}/bin/taosBenchmark ] && ${csudo}ln -s ${install_main_dir}/bin/taosBenchmark ${bin_link_dir}/taosBenchmark || : - [ -x ${install_main_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : + [ -x ${install_main_dir}/bin/${adapterName} ] && ${csudo}ln -s ${install_main_dir}/bin/${adapterName} ${bin_link_dir}/${adapterName} || : + [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || : + [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || : + [ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || : [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/bin/run_taosd_and_taosadapter.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd_and_taosadapter.sh ${bin_link_dir}/run_taosd_and_taosadapter.sh || : + [ -x ${install_main_dir}/bin/run_${serverName}_and_${adapterName}.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_${serverName}_and_${adapterName}.sh ${bin_link_dir}/run_${serverName}_and_${adapterName}.sh || : [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : if [ "$verMode" == "cluster" ]; then @@ -220,6 +225,7 @@ function install_lib() { # Remove links ${csudo}rm -f ${lib_link_dir}/libtaos.* || : ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 @@ -350,9 +356,6 @@ function set_hostname() { echo "set hostname fail!" return fi - #echo -e -n "$(hostnamectl status --static)" - #echo -e -n "$(hostnamectl status --transient)" - #echo -e -n "$(hostnamectl status --pretty)" #ubuntu/centos /etc/hostname if [[ -e /etc/hostname ]]; then @@ -465,24 +468,25 @@ function local_fqdn_check() { fi } -function install_taosadapter_config() { - if [ ! -f "${cfg_install_dir}/taosadapter.toml" ]; then +function install_adapter_config() { + if [ ! -f "${cfg_install_dir}/${adapterName}.toml" ]; then ${csudo}mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/taosadapter.toml ] && ${csudo}cp ${script_dir}/cfg/taosadapter.toml ${cfg_install_dir} - [ -f ${cfg_install_dir}/taosadapter.toml ] && ${csudo}chmod 644 ${cfg_install_dir}/taosadapter.toml + [ -f ${script_dir}/cfg/${adapterName}.toml ] && ${csudo}cp ${script_dir}/cfg/${adapterName}.toml ${cfg_install_dir} + [ -f ${cfg_install_dir}/${adapterName}.toml ] && ${csudo}chmod 644 ${cfg_install_dir}/${adapterName}.toml fi - [ -f ${script_dir}/cfg/taosadapter.toml ] && - ${csudo}cp -f ${script_dir}/cfg/taosadapter.toml ${cfg_install_dir}/taosadapter.toml.new + [ -f ${script_dir}/cfg/${adapterName}.toml ] && + ${csudo}cp -f ${script_dir}/cfg/${adapterName}.toml ${cfg_install_dir}/${adapterName}.toml.new - [ -f ${cfg_install_dir}/taosadapter.toml ] && - ${csudo}ln -s ${cfg_install_dir}/taosadapter.toml ${install_main_dir}/cfg/taosadapter.toml + [ -f ${cfg_install_dir}/${adapterName}.toml ] && + ${csudo}ln -s ${cfg_install_dir}/${adapterName}.toml ${install_main_dir}/cfg/${adapterName}.toml [ ! -z $1 ] && return 0 || : # only install client } function install_config() { + if [ ! -f "${cfg_install_dir}/${configFile}" ]; then ${csudo}mkdir -p ${cfg_install_dir} [ -f ${script_dir}/cfg/${configFile} ] && ${csudo}cp ${script_dir}/cfg/${configFile} ${cfg_install_dir} @@ -504,12 +508,6 @@ function install_config() { local_fqdn_check - #FQDN_FORMAT="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" - #FQDN_FORMAT="(:[1-6][0-9][0-9][0-9][0-9]$)" - #PORT_FORMAT="(/[1-6][0-9][0-9][0-9][0-9]?/)" - #FQDN_PATTERN=":[0-9]{1,5}$" - - # first full-qualified domain name (FQDN) for TDengine cluster system echo echo -e -n "${GREEN}Enter FQDN:port (like h1.${emailName}:6030) of an existing ${productName} cluster node to join${NC}" echo @@ -517,37 +515,21 @@ function install_config() { read firstEp while true; do if [ ! -z "$firstEp" ]; then - # check the format of the firstEp - #if [[ $firstEp == $FQDN_PATTERN ]]; then - # Write the first FQDN to configuration file ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/${configFile} break - #else - # read -p "Please enter the correct FQDN:port: " firstEp - #fi else break fi done - # user email - #EMAIL_PATTERN='^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$' - #EMAIL_PATTERN='^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$' - #EMAIL_PATTERN="^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$" echo echo -e -n "${GREEN}Enter your email address for priority support or enter empty to skip${NC}: " read emailAddr while true; do if [ ! -z "$emailAddr" ]; then - # check the format of the emailAddr - #if [[ "$emailAddr" =~ $EMAIL_PATTERN ]]; then - # Write the email address to temp file email_file="${install_main_dir}/email" ${csudo}bash -c "echo $emailAddr > ${email_file}" break - #else - # read -p "Please enter the correct email address: " emailAddr - #fi else break fi @@ -622,16 +604,15 @@ function install_service_on_sysvinit() { clean_service_on_sysvinit sleep 1 - # Install server service if ((${os_type} == 1)); then - # ${csudo}cp -f ${script_dir}/init.d/${serverName}.deb ${install_main_dir}/init.d/${serverName} + # ${csudo}cp -f ${script_dir}/init.d/${serverName}.deb ${install_main_dir}/init.d/${serverName} ${csudo}cp ${script_dir}/init.d/${serverName}.deb ${service_config_dir}/${serverName} && ${csudo}chmod a+x ${service_config_dir}/${serverName} - # ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + # ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type} == 2)); then - # ${csudo}cp -f ${script_dir}/init.d/${serverName}.rpm ${install_main_dir}/init.d/${serverName} + # ${csudo}cp -f ${script_dir}/init.d/${serverName}.rpm ${install_main_dir}/init.d/${serverName} ${csudo}cp ${script_dir}/init.d/${serverName}.rpm ${service_config_dir}/${serverName} && ${csudo}chmod a+x ${service_config_dir}/${serverName} - # ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + # ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi @@ -694,21 +675,24 @@ function install_service_on_systemd() { ${service_config_dir}/ || : ${csudo}systemctl daemon-reload - [ -f ${script_dir}/cfg/nginxd.service ] && - ${csudo}cp ${script_dir}/cfg/nginxd.service \ - ${service_config_dir}/ || : + if [ "$verMode" == "cluster" ]; then + [ -f ${script_dir}/cfg/nginxd.service ] && + ${csudo}cp ${script_dir}/cfg/nginxd.service \ + ${service_config_dir}/ || : + ${csudo}systemctl daemon-reload - if ! ${csudo}systemctl enable nginxd &>/dev/null; then - ${csudo}systemctl daemon-reexec - ${csudo}systemctl enable nginxd + if ! ${csudo}systemctl enable nginxd &>/dev/null; then + ${csudo}systemctl daemon-reexec + ${csudo}systemctl enable nginxd + fi + ${csudo}systemctl start nginxd fi - ${csudo}systemctl start nginxd } -function install_taosadapter_service() { +function install_adapter_service() { if ((${service_mod} == 0)); then - [ -f ${script_dir}/cfg/taosadapter.service ] && - ${csudo}cp ${script_dir}/cfg/taosadapter.service \ + [ -f ${script_dir}/cfg/${adapterName}.service ] && + ${csudo}cp ${script_dir}/cfg/${adapterName}.service \ ${service_config_dir}/ || : ${csudo}systemctl daemon-reload fi @@ -760,7 +744,6 @@ function is_version_compatible() { min_compatible_version=$(${script_dir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 5) fi - # [TD-5628] prompt to execute taosd --force-keep-file if upgrade from lower version within 2.0.16.0 exist_version=$(${installDir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 3) vercomp $exist_version "2.0.16.0" case $? in @@ -779,7 +762,7 @@ function is_version_compatible() { esac } -function update_TDengine() { +function updateProduct() { # Check if version compatible if ! is_version_compatible; then echo -e "${RED}Version incompatible${NC}" @@ -793,8 +776,6 @@ function update_TDengine() { fi tar -zxf ${tarName} install_jemalloc - #install_avro lib - #install_avro lib64 echo -e "${GREEN}Start to update ${productName}...${NC}" # Stop the service if running @@ -836,9 +817,9 @@ function update_TDengine() { if [ -z $1 ]; then install_bin install_service - install_taosadapter_service + install_adapter_service install_config - install_taosadapter_config + install_adapter_config openresty_work=false if [ "$verMode" == "cluster" ]; then @@ -854,17 +835,15 @@ function update_TDengine() { fi fi - #echo - #echo -e "\033[44;32;1mTDengine is updated successfully!${NC}" echo - echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${configDir}/${configFile}" - echo -e "${GREEN_DARK}To configure Taos Adapter (if has) ${NC}: edit ${configDir}/taosadapter.toml" + echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${cfg_install_dir}/${configFile}" + echo -e "${GREEN_DARK}To configure Adapter (if has) ${NC}: edit ${cfg_install_dir}/${adapterName}.toml" if ((${service_mod} == 0)); then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}" elif ((${service_mod} == 1)); then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}" else - echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start Adapter (if has)${NC}: ${adapterName} &${NC}" echo -e "${GREEN_DARK}To start ${productName} ${NC}: ./${serverName}${NC}" fi @@ -888,10 +867,10 @@ function update_TDengine() { echo -e "\033[44;32;1m${productName} client is updated successfully!${NC}" fi - rm -rf $(tar -tf ${tarName} |grep -v "^\./$") + rm -rf $(tar -tf ${tarName} | grep -v "^\./$") } -function install_TDengine() { +function installProduct() { # Start to install if [ ! -e ${tarName} ]; then echo "File ${tarName} does not exist" @@ -923,7 +902,8 @@ function install_TDengine() { # For installing new install_bin install_service - install_taosadapter_service + install_adapter_service + install_adapter_config openresty_work=false if [ "$verMode" == "cluster" ]; then @@ -941,17 +921,15 @@ function install_TDengine() { install_config # Ask if to start the service - #echo - #echo -e "\033[44;32;1mTDengine is installed successfully!${NC}" echo - echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${configDir}/${configFile}" - echo -e "${GREEN_DARK}To configure taosadapter (if has) ${NC}: edit ${configDir}/taosadapter.toml" + echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${cfg_install_dir}/${configFile}" + echo -e "${GREEN_DARK}To configure ${adapterName} (if has) ${NC}: edit ${cfg_install_dir}/${adapterName}.toml" if ((${service_mod} == 0)); then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}" elif ((${service_mod} == 1)); then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}" else - echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start Adapter (if has)${NC}: ${adapterName} &${NC}" echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}" fi @@ -985,7 +963,7 @@ function install_TDengine() { fi touch ~/.${historyFile} - rm -rf $(tar -tf ${tarName} |grep -v "^\./$") + rm -rf $(tar -tf ${tarName} | grep -v "^\./$") } ## ==============================Main program starts from here============================ @@ -994,18 +972,18 @@ if [ "$verType" == "server" ]; then # Install server and client if [ -x ${bin_dir}/${serverName} ]; then update_flag=1 - update_TDengine + updateProduct else - install_TDengine + installProduct fi elif [ "$verType" == "client" ]; then interactiveFqdn=no # Only install client if [ -x ${bin_dir}/${clientName} ]; then update_flag=1 - update_TDengine client + updateProduct client else - install_TDengine client + installProduct client fi else echo "please input correct verType" diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 21aa476fecf153f4c1a91f93390b5818c29b1127..139749e4e64bd2f7c4983915274c8c2b879ad775 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -60,13 +60,15 @@ if [ "$pagMode" == "lite" ]; then strip ${build_dir}/bin/${serverName} strip ${build_dir}/bin/${clientName} # lite version doesn't include taosadapter, which will lead to no restful interface - bin_files="${build_dir}/bin/${serverName} ${build_dir}/bin/${clientName} ${script_dir}/remove.sh ${script_dir}/startPre.sh ${build_dir}/bin/taosBenchmark" + bin_files="${build_dir}/bin/${serverName} ${build_dir}/bin/${clientName} ${script_dir}/remove.sh ${script_dir}/startPre.sh ${build_dir}/bin/${benchmarkName}" taostools_bin_files="" else - wget https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh -O ${build_dir}/bin/TDinsight.sh \ - && echo "TDinsight.sh downloaded!" \ - || echo "failed to download TDinsight.sh" + + wget https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh -O ${build_dir}/bin/TDinsight.sh && + echo "TDinsight.sh downloaded!" || + echo "failed to download TDinsight.sh" + # download TDinsight caches orig_pwd=$(pwd) tdinsight_caches="" @@ -76,11 +78,12 @@ else cd $orig_pwd echo "TDinsight caches: $tdinsight_caches" - taostools_bin_files=" ${build_dir}/bin/taosdump \ - ${build_dir}/bin/taosBenchmark \ + taostools_bin_files=" ${build_dir}/bin/${dumpName} \ + ${build_dir}/bin/${benchmarkName} \ ${build_dir}/bin/TDinsight.sh \ $tdinsight_caches" + #!!! do not change taosadapter here bin_files="${build_dir}/bin/${serverName} \ ${build_dir}/bin/${clientName} \ ${taostools_bin_files} \ @@ -115,10 +118,11 @@ mkdir -p ${install_dir} mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/${configFile} ${install_dir}/cfg/${configFile} +# !!! do not change the taosadapter here!!! if [ -f "${compile_dir}/test/cfg/taosadapter.toml" ]; then cp ${compile_dir}/test/cfg/taosadapter.toml ${install_dir}/cfg || : fi - +# !!! do not change the taosadapter here!!! if [ -f "${compile_dir}/test/cfg/taosadapter.service" ]; then cp ${compile_dir}/test/cfg/taosadapter.service ${install_dir}/cfg || : fi @@ -141,50 +145,52 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/${se mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_deb} ${install_dir}/init.d/tarbitratord.deb || : mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}/init.d/tarbitratord.rpm || : +# !!! do not change taosadaptor here if [ $adapterName != "taosadapter" ]; then + # !!! do not change taosadaptor here mv ${install_dir}/cfg/taosadapter.toml ${install_dir}/cfg/$adapterName.toml sed -i "s/path = \"\/var\/log\/taos\"/path = \"\/var\/log\/${productName}\"/g" ${install_dir}/cfg/$adapterName.toml sed -i "s/password = \"taosdata\"/password = \"${defaultPasswd}\"/g" ${install_dir}/cfg/$adapterName.toml - + # !!! do not change taosadaptor here mv ${install_dir}/cfg/taosadapter.service ${install_dir}/cfg/$adapterName.service sed -i "s/TDengine/${productName}/g" ${install_dir}/cfg/$adapterName.service sed -i "s/taosAdapter/${adapterName}/g" ${install_dir}/cfg/$adapterName.service sed -i "s/taosadapter/${adapterName}/g" ${install_dir}/cfg/$adapterName.service - + # !!! do not change taosadaptor here mv ${install_dir}/bin/taosadapter ${install_dir}/bin/${adapterName} mv ${install_dir}/bin/run_taosd_and_taosadapter.sh ${install_dir}/bin/run_${serverName}_and_${adapterName}.sh mv ${install_dir}/bin/taosd-dump-cfg.gdb ${install_dir}/bin/${serverName}-dump-cfg.gdb fi if [ -n "${taostools_bin_files}" ]; then - mkdir -p ${taostools_install_dir} || echo -e "failed to create ${taostools_install_dir}" - mkdir -p ${taostools_install_dir}/bin \ - && cp ${taostools_bin_files} ${taostools_install_dir}/bin \ - && chmod a+x ${taostools_install_dir}/bin/* || : - - if [ -f ${top_dir}/src/kit/taos-tools/packaging/tools/install-taostools.sh ]; then - cp ${top_dir}/src/kit/taos-tools/packaging/tools/install-taostools.sh \ - ${taostools_install_dir}/ > /dev/null \ - && chmod a+x ${taostools_install_dir}/install-taostools.sh \ - || echo -e "failed to copy install-taostools.sh" - else - echo -e "install-taostools.sh not found" - fi + mkdir -p ${taostools_install_dir} || echo -e "failed to create ${taostools_install_dir}" + mkdir -p ${taostools_install_dir}/bin && + cp ${taostools_bin_files} ${taostools_install_dir}/bin && + chmod a+x ${taostools_install_dir}/bin/* || : + + if [ -f ${top_dir}/src/kit/taos-tools/packaging/tools/install-${toolsName}.sh ]; then + cp ${top_dir}/src/kit/taos-tools/packaging/tools/install-${toolsName}.sh \ + ${taostools_install_dir}/ >/dev/null && + chmod a+x ${taostools_install_dir}/install-${toolsName}.sh || + echo -e "failed to copy install-${toolsName}.sh" + else + echo -e "install-${toolsName}.sh not found" + fi - if [ -f ${top_dir}/src/kit/taos-tools/packaging/tools/uninstall-taostools.sh ]; then - cp ${top_dir}/src/kit/taos-tools/packaging/tools/uninstall-taostools.sh \ - ${taostools_install_dir}/ > /dev/null \ - && chmod a+x ${taostools_install_dir}/uninstall-taostools.sh \ - || echo -e "failed to copy uninstall-taostools.sh" - else - echo -e "uninstall-taostools.sh not found" - fi + if [ -f ${top_dir}/src/kit/taos-tools/packaging/tools/uninstall-${toolsName}.sh ]; then + cp ${top_dir}/src/kit/taos-tools/packaging/tools/uninstall-${toolsName}.sh \ + ${taostools_install_dir}/ >/dev/null && + chmod a+x ${taostools_install_dir}/uninstall-${toolsName}.sh || + echo -e "failed to copy uninstall-${toolsName}.sh" + else + echo -e "uninstall-${toolsName}.sh not found" + fi - if [ -f ${build_dir}/lib/libavro.so.23.0.0 ]; then - mkdir -p ${taostools_install_dir}/avro/{lib,lib/pkgconfig} || echo -e "failed to create ${taostools_install_dir}/avro" - cp ${build_dir}/lib/libavro.* ${taostools_install_dir}/avro/lib - cp ${build_dir}/lib/pkgconfig/avro-c.pc ${taostools_install_dir}/avro/lib/pkgconfig - fi + if [ -f ${build_dir}/lib/libavro.so.23.0.0 ]; then + mkdir -p ${taostools_install_dir}/avro/{lib,lib/pkgconfig} || echo -e "failed to create ${taostools_install_dir}/avro" + cp ${build_dir}/lib/libavro.* ${taostools_install_dir}/avro/lib + cp ${build_dir}/lib/pkgconfig/avro-c.pc ${taostools_install_dir}/avro/lib/pkgconfig + fi fi if [ -f ${build_dir}/bin/jemalloc-config ]; then @@ -366,13 +372,13 @@ if [ "$exitcode" != "0" ]; then fi if [ -n "${taostools_bin_files}" ]; then - wget https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh -O ${taostools_install_dir}/bin/TDinsight.sh && echo "TDinsight.sh downloaded!"|| echo "failed to download TDinsight.sh" - tar -zcv -f "$(basename ${taostools_pkg_name}).tar.gz" "$(basename ${taostools_install_dir})" --remove-files || : - exitcode=$? - if [ "$exitcode" != "0" ]; then - echo "tar ${taostools_pkg_name}.tar.gz error !!!" - exit $exitcode - fi + wget https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh -O ${taostools_install_dir}/bin/TDinsight.sh && echo "TDinsight.sh downloaded!" || echo "failed to download TDinsight.sh" + tar -zcv -f "$(basename ${taostools_pkg_name}).tar.gz" "$(basename ${taostools_install_dir})" --remove-files || : + exitcode=$? + if [ "$exitcode" != "0" ]; then + echo "tar ${taostools_pkg_name}.tar.gz error !!!" + exit $exitcode + fi fi cd ${curr_dir} diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index e24f56ba57b0b01146c3d878901bf2f6d19a0a9a..71d666e23a10bac219c4cd4ab845b3ae572ac246 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -10248,6 +10248,9 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS tstrncpy(pTableMetaInfo1->aliasName, subInfo->aliasName.z, subInfo->aliasName.n + 1); } + if (TPARSER_HAS_TOKEN(pSqlNode->interval.interval) && pSub->order.orderColId == INT32_MIN) { + pSub->order.orderColId = PRIMARYKEY_TIMESTAMP_COL_INDEX; + } // NOTE: order mix up in subquery not support yet. pQueryInfo->order = pSub->order; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java index 029e58bd61f3f29cedfac024182faaedd0e388f7..ac8f68d918375643b5066d3091c3e06010bc0afe 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java @@ -66,6 +66,11 @@ public class TSDBDriver extends AbstractDriver { * Just for Cloud Service */ public static final String PROPERTY_KEY_TOKEN = "token"; + /** + * Use SSL (true/false) to communicate with the server. The default value is false. + * Just for Cloud Service + */ + public static final String PROPERTY_KEY_USE_SSL = "useSSL"; /** * Key for the configuration file directory of TSDB client in properties instance */ diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java index e818736096355c4937e5af0470b77c95486c86db..f3ce3a742ee8dcb3e0217fa99a84adb0b451eb44 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java @@ -17,17 +17,21 @@ public class RestfulConnection extends AbstractConnection { private final int port; private final String url; private final String database; + private final String auth; + private final boolean useSsl; private final String token; private boolean isClosed; private final DatabaseMetaData metadata; - public RestfulConnection(String host, String port, Properties props, String database, String url, String token) { + public RestfulConnection(String host, String port, Properties props, String database, String url, String auth, boolean useSsl, String token) { super(props); this.host = host; this.port = Integer.parseInt(port); this.database = database; this.url = url; + this.auth = "Basic " + auth; + this.useSsl = useSsl; this.token = token; this.metadata = new RestfulDatabaseMetaData(url, props.getProperty(TSDBDriver.PROPERTY_KEY_USER), this); } @@ -88,4 +92,12 @@ public class RestfulConnection extends AbstractConnection { public String getToken() { return token; } + + public String getAuth() { + return auth; + } + + public boolean isUseSsl() { + return useSsl; + } } \ No newline at end of file diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java index 99b6c3bd3e659dc021741a9455d30ec4ef009fb4..3cb4749335961f5584dea7f414590533f7ed9c27 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java @@ -1,8 +1,9 @@ package com.taosdata.jdbc.rs; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.taosdata.jdbc.*; +import com.taosdata.jdbc.AbstractDriver; +import com.taosdata.jdbc.TSDBDriver; +import com.taosdata.jdbc.TSDBError; +import com.taosdata.jdbc.TSDBErrorNumbers; import com.taosdata.jdbc.enums.TimestampFormat; import com.taosdata.jdbc.utils.HttpClientPoolUtil; import com.taosdata.jdbc.ws.InFlightRequest; @@ -16,6 +17,7 @@ import java.net.URISyntaxException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.sql.*; +import java.util.Base64; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -52,7 +54,6 @@ public class RestfulDriver extends AbstractDriver { String user; String password; - String cloudToken = null; try { if (!props.containsKey(TSDBDriver.PROPERTY_KEY_USER)) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_USER_IS_REQUIRED); @@ -64,15 +65,25 @@ public class RestfulDriver extends AbstractDriver { } catch (UnsupportedEncodingException e) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE, "unsupported UTF-8 concoding, user: " + props.getProperty(TSDBDriver.PROPERTY_KEY_USER) + ", password: " + props.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD)); } + + String cloudToken = null; if (props.containsKey(TSDBDriver.PROPERTY_KEY_TOKEN)) { cloudToken = props.getProperty(TSDBDriver.PROPERTY_KEY_TOKEN); } + boolean useSsl = Boolean.parseBoolean(props.getProperty(TSDBDriver.PROPERTY_KEY_USE_SSL, "false")); String loginUrl; String batchLoad = info.getProperty(TSDBDriver.PROPERTY_KEY_BATCH_LOAD); if (Boolean.parseBoolean(batchLoad)) { - loginUrl = "ws://" + props.getProperty(TSDBDriver.PROPERTY_KEY_HOST) + String protocol = "ws"; + if (useSsl) { + protocol = "wss"; + } + loginUrl = protocol + "://" + props.getProperty(TSDBDriver.PROPERTY_KEY_HOST) + ":" + props.getProperty(TSDBDriver.PROPERTY_KEY_PORT) + "/rest/ws"; + if (null != cloudToken) { + loginUrl = loginUrl + "?token=" + cloudToken; + } WSClient client; Transport transport; try { @@ -106,24 +117,13 @@ public class RestfulDriver extends AbstractDriver { props.setProperty(TSDBDriver.PROPERTY_KEY_TIMESTAMP_FORMAT, String.valueOf(TimestampFormat.TIMESTAMP)); return new WSConnection(url, props, transport, database); } - loginUrl = "http://" + props.getProperty(TSDBDriver.PROPERTY_KEY_HOST) + ":" + props.getProperty(TSDBDriver.PROPERTY_KEY_PORT) + "/rest/login/" + user + "/" + password + ""; - if (null != cloudToken) { - loginUrl += "?token=" + cloudToken; - } int poolSize = Integer.parseInt(props.getProperty("httpPoolSize", HttpClientPoolUtil.DEFAULT_MAX_PER_ROUTE)); boolean keepAlive = Boolean.parseBoolean(props.getProperty("httpKeepAlive", HttpClientPoolUtil.DEFAULT_HTTP_KEEP_ALIVE)); - HttpClientPoolUtil.init(poolSize, keepAlive); - String result = HttpClientPoolUtil.execute(loginUrl); - JSONObject jsonResult = JSON.parseObject(result); - String status = jsonResult.getString("status"); - String token = jsonResult.getString("desc"); - - if (!status.equals("succ")) { - throw new SQLException(jsonResult.getString("desc")); - } - RestfulConnection conn = new RestfulConnection(host, port, props, database, url, token); + String auth = Base64.getEncoder().encodeToString( + (user + ":" + password).getBytes(StandardCharsets.UTF_8)); + RestfulConnection conn = new RestfulConnection(host, port, props, database, url, auth, useSsl, cloudToken); if (database != null && !database.trim().replaceAll("\\s", "").isEmpty()) { try (Statement stmt = conn.createStatement()) { stmt.execute("use " + database); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java index b145fe85e979bb98ec713951be1e2d63e510f630..7befd0007fd334b5fff221a034f283b09682c932 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java @@ -63,7 +63,7 @@ public class RestfulStatement extends AbstractStatement { //如果执行了use操作应该将当前Statement的catalog设置为新的database boolean result = true; - String response = HttpClientPoolUtil.execute(getUrl(), sql, this.conn.getToken()); + String response = HttpClientPoolUtil.execute(getUrl(), sql, this.conn.getAuth()); JSONObject jsonObject = JSON.parseObject(response); if (null == jsonObject) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "sql: " + sql); @@ -95,6 +95,10 @@ public class RestfulStatement extends AbstractStatement { private String getUrl() throws SQLException { String dbname = conn.getClientInfo(TSDBDriver.PROPERTY_KEY_DBNAME); + String protocol = "http"; +// if (conn.isUseSsl()) { +// protocol = "https"; +// } if (dbname == null || dbname.trim().isEmpty()) { dbname = ""; } else { @@ -105,13 +109,16 @@ public class RestfulStatement extends AbstractStatement { switch (timestampFormat) { case TIMESTAMP: - url = "http://" + conn.getHost() + ":" + conn.getPort() + "/rest/sqlt" + dbname; + url = protocol + "://" + conn.getHost() + ":" + conn.getPort() + "/rest/sqlt" + dbname; break; case UTC: - url = "http://" + conn.getHost() + ":" + conn.getPort() + "/rest/sqlutc" + dbname; + url = protocol + "://" + conn.getHost() + ":" + conn.getPort() + "/rest/sqlutc" + dbname; break; default: - url = "http://" + conn.getHost() + ":" + conn.getPort() + "/rest/sql" + dbname; + url = protocol + "://" + conn.getHost() + ":" + conn.getPort() + "/rest/sql" + dbname; + } + if (this.conn.getToken() != null && !"".equals(this.conn.getToken().trim())) { + url = url + "?token=" + this.conn.getToken(); } return url; } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java index cdadcd2d28a03d3db4b490049a4e84f2fc38ea02..2923ad76aa1ba930a1de7afc304fb822e3ed111e 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/HttpClientPoolUtil.java @@ -5,7 +5,6 @@ import com.taosdata.jdbc.TSDBErrorNumbers; import org.apache.http.HeaderElement; import org.apache.http.HeaderElementIterator; import org.apache.http.HttpEntity; -import org.apache.http.NoHttpResponseException; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.*; @@ -97,12 +96,12 @@ public class HttpClientPoolUtil { } /*** execute POST request ***/ - public static String execute(String uri, String data, String token) throws SQLException { + public static String execute(String uri, String data, String auth) throws SQLException { HttpEntityEnclosingRequestBase method = (HttpEntityEnclosingRequestBase) getRequest(uri, HttpPost.METHOD_NAME); method.setHeader(HTTP.CONTENT_TYPE, "text/plain"); method.setHeader(HTTP.CONN_DIRECTIVE, isKeepAlive); - method.setHeader("Authorization", "Taosd " + token); + method.setHeader("Authorization", auth); method.setEntity(new StringEntity(data, StandardCharsets.UTF_8)); HttpContext context = HttpClientContext.create(); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/HttpClientPoolUtilTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/HttpClientPoolUtilTest.java index 128a62e5d964bc2276328312eb9998895923547f..9c71a8c33ba374e0564429bd040b6e170e753a0c 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/HttpClientPoolUtilTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/HttpClientPoolUtilTest.java @@ -84,7 +84,7 @@ public class HttpClientPoolUtilTest { if (!status.equals("succ")) { throw new SQLException(jsonResult.getString("desc")); } - return token; + return "Basic " + token; } private boolean executeOneSql(String sql, String token) throws SQLException { diff --git a/src/connector/node-red-contrib-tdengine/README.md b/src/connector/node-red-contrib-tdengine/README.md index b23c72939455fff2be245b2cf099567062c99e79..c4696610cd2ce746114e5e478a05d8eb87a4b011 100644 --- a/src/connector/node-red-contrib-tdengine/README.md +++ b/src/connector/node-red-contrib-tdengine/README.md @@ -1,4 +1,4 @@ -This repositry create a custom Node-Red node for configing TDEngine server connection and execute SQL from preview node msg.payload +This repositry create a custom Node-Red node for configing TDengine server connection and execute SQL from preview node msg.payload ## Design Use Taos data restful API to commit SQL, API call like ``` @@ -14,9 +14,9 @@ Use [axios](https://axios-http.com/) to call http request ## Usage 1. Start Node-Red -2. Install TDEngine node +2. Install TDengine node 3. Add "taos query" node to workspace from palette -4. Setup a TDEngine server and database name +4. Setup a TDengine server and database name 5. Add function or other node to create SQL, put SQL into msg.payload 6. Link to "taos query" node @@ -27,9 +27,9 @@ docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node ``` 2. Import sample flow "demo/flow.json" ![import-flow](demo/ImportFlow.png) -3. Install TDEngine node by name "node-red-contrib-tdengine", current version is 0.0.2 -![alt](demo/InstallTDEngineNode.png) -4. Modify your TDEngine server config +3. Install TDengine node by name "node-red-contrib-tdengine", current version is 0.0.2 +![alt](demo/InstallTDengineNode.png) +4. Modify your TDengine server config ![alt](demo/ModifyServerConfig.png) 5. Edit test SQL ![alt](demo/EditTestSQL.png) diff --git a/src/connector/node-red-contrib-tdengine/demo/InstallTDEngineNode.png b/src/connector/node-red-contrib-tdengine/demo/InstallTDengineNode.png similarity index 100% rename from src/connector/node-red-contrib-tdengine/demo/InstallTDEngineNode.png rename to src/connector/node-red-contrib-tdengine/demo/InstallTDengineNode.png diff --git a/src/connector/node-red-contrib-tdengine/package-lock.json b/src/connector/node-red-contrib-tdengine/package-lock.json index 32a4442ac68ddd8ed2d9412f03c741022dad10fb..faedb369358933de487129c1f9fb7f3731b18ae2 100644 --- a/src/connector/node-red-contrib-tdengine/package-lock.json +++ b/src/connector/node-red-contrib-tdengine/package-lock.json @@ -1,29 +1,3306 @@ { "name": "node-red-contrib-tdengine", "version": "0.0.3", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "node-red-contrib-tdengine", + "version": "0.0.3", + "license": "ISC", + "dependencies": { + "axios": "^0.24.0" + }, + "devDependencies": { + "node-red": "^2.1.4" + } + }, + "node_modules/@babel/runtime": { + "version": "7.17.9", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.9.tgz", + "integrity": "sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==", + "dev": true, + "dependencies": { + "regenerator-runtime": "^0.13.4" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@mapbox/node-pre-gyp": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.9.tgz", + "integrity": "sha512-aDF3S3rK9Q2gey/WAttUlISduDItz5BU3306M9Eyv6/oS40aMprnopshtlKTykxRNIBEZuRMaZAnbrQ4QtKGyw==", + "dev": true, + "optional": true, + "dependencies": { + "detect-libc": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "make-dir": "^3.1.0", + "node-fetch": "^2.6.7", + "nopt": "^5.0.0", + "npmlog": "^5.0.1", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.11" + }, + "bin": { + "node-pre-gyp": "bin/node-pre-gyp" + } + }, + "node_modules/@node-red/editor-api": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/editor-api/-/editor-api-2.2.2.tgz", + "integrity": "sha512-5PUXtMCjsKevCiz8OjHqAckctOv/zzPcssH4yzTxMYEN4JtTng5lFfZzTFWZC/UnCGQMgwe/0e4iGHbMbN1pqg==", + "dev": true, + "dependencies": { + "@node-red/editor-client": "2.2.2", + "@node-red/util": "2.2.2", + "bcryptjs": "2.4.3", + "body-parser": "1.19.1", + "clone": "2.1.2", + "cors": "2.8.5", + "express": "4.17.2", + "express-session": "1.17.2", + "memorystore": "1.6.7", + "mime": "3.0.0", + "multer": "1.4.4", + "mustache": "4.2.0", + "oauth2orize": "1.11.1", + "passport": "0.5.2", + "passport-http-bearer": "1.0.1", + "passport-oauth2-client-password": "0.1.2", + "ws": "7.5.6" + }, + "optionalDependencies": { + "bcrypt": "5.0.1" + } + }, + "node_modules/@node-red/editor-client": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/editor-client/-/editor-client-2.2.2.tgz", + "integrity": "sha512-DivbfvVfoh4sRKHmOGucE9kV8MWwGczbxsJfaEVedCtVt9ZDX40N61+FzPVlf2FGDi8q21cIRV7klV1GWhDFxw==", + "dev": true + }, + "node_modules/@node-red/nodes": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/nodes/-/nodes-2.2.2.tgz", + "integrity": "sha512-RJ8yR90e/tF0KIiS7ZDe8+q0Zk9uJQZDNUcheEeJKWXfIf3WcMo+5KhQ5HJfy8UedmPXzNLRX75FuTXwcd+NKA==", + "dev": true, + "dependencies": { + "acorn": "8.7.0", + "acorn-walk": "8.2.0", + "ajv": "8.10.0", + "body-parser": "1.19.1", + "cheerio": "1.0.0-rc.10", + "content-type": "1.0.4", + "cookie": "0.4.2", + "cookie-parser": "1.4.6", + "cors": "2.8.5", + "cronosjs": "1.7.1", + "denque": "2.0.1", + "form-data": "4.0.0", + "fs-extra": "10.0.0", + "got": "11.8.3", + "hash-sum": "2.0.0", + "hpagent": "0.1.2", + "https-proxy-agent": "5.0.0", + "iconv-lite": "0.6.3", + "is-utf8": "0.2.1", + "js-yaml": "3.14.1", + "media-typer": "1.1.0", + "mqtt": "4.3.5", + "multer": "1.4.4", + "mustache": "4.2.0", + "on-headers": "1.0.2", + "raw-body": "2.4.3", + "tough-cookie": "4.0.0", + "uuid": "8.3.2", + "ws": "7.5.6", + "xml2js": "0.4.23" + } + }, + "node_modules/@node-red/registry": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/registry/-/registry-2.2.2.tgz", + "integrity": "sha512-zszKLaR2XpBE4wG4o8cwe+dtOvqlG/Cl0iRXg1wpJ9zC96WIPRq+UqAkVkZm6uRuNhW5ZjKk8f77Wh1+v6QBAw==", + "dev": true, + "dependencies": { + "@node-red/util": "2.2.2", + "clone": "2.1.2", + "fs-extra": "10.0.0", + "semver": "7.3.5", + "tar": "6.1.11", + "uglify-js": "3.15.1" + } + }, + "node_modules/@node-red/runtime": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/runtime/-/runtime-2.2.2.tgz", + "integrity": "sha512-PW+HGDmY7Q5nXx+zPVpbFaFpn59EyPLb2QYYL1T5MarCQpUfIaL44NMhSG//n0+vkGZBLi9T6ltapWgEYW4x9g==", + "dev": true, + "dependencies": { + "@node-red/registry": "2.2.2", + "@node-red/util": "2.2.2", + "async-mutex": "0.3.2", + "clone": "2.1.2", + "express": "4.17.2", + "fs-extra": "10.0.0", + "json-stringify-safe": "5.0.1" + } + }, + "node_modules/@node-red/util": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/util/-/util-2.2.2.tgz", + "integrity": "sha512-tUGLGj3fTgOjWwhp9uK6M+LUb3rxIrU61DbA0fVpANCEeqk5UNJpje4vOag9dWmJS7hn/ONcDK7dslHLyOQUIQ==", + "dev": true, + "dependencies": { + "fs-extra": "10.0.0", + "i18next": "21.6.11", + "json-stringify-safe": "5.0.1", + "jsonata": "1.8.6", + "lodash.clonedeep": "^4.5.0", + "moment-timezone": "0.5.34" + } + }, + "node_modules/@sindresorhus/is": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", + "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, + "node_modules/@szmarczak/http-timer": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", + "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", + "dev": true, + "dependencies": { + "defer-to-connect": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@types/cacheable-request": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.2.tgz", + "integrity": "sha512-B3xVo+dlKM6nnKTcmm5ZtY/OL8bOAOd2Olee9M1zft65ox50OzjEHW91sDiU9j6cvW8Ejg1/Qkf4xd2kugApUA==", + "dev": true, + "dependencies": { + "@types/http-cache-semantics": "*", + "@types/keyv": "*", + "@types/node": "*", + "@types/responselike": "*" + } + }, + "node_modules/@types/http-cache-semantics": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz", + "integrity": "sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==", + "dev": true + }, + "node_modules/@types/json-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/json-buffer/-/json-buffer-3.0.0.tgz", + "integrity": "sha512-3YP80IxxFJB4b5tYC2SUPwkg0XQLiu0nWvhRgEatgjf+29IcWO9X1k8xRv5DGssJ/lCrjYTjQPcobJr2yWIVuQ==", + "dev": true + }, + "node_modules/@types/keyv": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", + "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "17.0.33", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.33.tgz", + "integrity": "sha512-miWq2m2FiQZmaHfdZNcbpp9PuXg34W5JZ5CrJ/BaS70VuhoJENBEQybeiYSaPBRNq6KQGnjfEnc/F3PN++D+XQ==", + "dev": true + }, + "node_modules/@types/responselike": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz", + "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dev": true, + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/acorn": { + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", + "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dev": true, + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/agent-base/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/agent-base/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/ajv": { + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.10.0.tgz", + "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY=", + "dev": true + }, + "node_modules/aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "dev": true, + "optional": true + }, + "node_modules/are-we-there-yet": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", + "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "dev": true, + "optional": true, + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", + "dev": true + }, + "node_modules/async-mutex": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.3.2.tgz", + "integrity": "sha512-HuTK7E7MT7jZEh1P9GtRW9+aTWiDWWi9InbZ5hjxrnRa39KS4BW04+xLBhYNS2aXhHUIKZSw3gj4Pn1pj+qGAA==", + "dev": true, + "dependencies": { + "tslib": "^2.3.1" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "node_modules/axios": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", + "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", + "dependencies": { + "follow-redirects": "^1.14.4" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "dev": true, + "dependencies": { + "safe-buffer": "5.1.2" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/basic-auth/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/bcrypt": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.0.1.tgz", + "integrity": "sha512-9BTgmrhZM2t1bNuDtrtIMVSmmxZBrJ71n8Wg+YgdjHuIWYF7SjjmCPZFB+/5i/o/PIeRpwVJR3P+NrpIItUjqw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "dependencies": { + "@mapbox/node-pre-gyp": "^1.0.0", + "node-addon-api": "^3.1.0" + }, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=", + "dev": true + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dev": true, + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/body-parser": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz", + "integrity": "sha512-8ljfQi5eBk8EJfECMrgqNGWPEY5jWP+1IzkzkGdFFEwFQZZyaZ21UqdaHktgiMlH0xLHqIFtE/u2OYE5dOtViA==", + "dev": true, + "dependencies": { + "bytes": "3.1.1", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.8.1", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.9.6", + "raw-body": "2.4.2", + "type-is": "~1.6.18" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/body-parser/node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/body-parser/node_modules/raw-body": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.2.tgz", + "integrity": "sha512-RPMAFUJP19WIet/99ngh6Iv8fzAbqum4Li7AD6DtGaW2RpMB/11xDoalPiJMTbu6I3hkbMVkATvZrqb9EEqeeQ==", + "dev": true, + "dependencies": { + "bytes": "3.1.1", + "http-errors": "1.8.1", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/busboy": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz", + "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", + "dev": true, + "dependencies": { + "dicer": "0.2.5", + "readable-stream": "1.1.x" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/busboy/node_modules/readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/busboy/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "node_modules/bytes": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.1.tgz", + "integrity": "sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/cacheable-lookup": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", + "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", + "dev": true, + "engines": { + "node": ">=10.6.0" + } + }, + "node_modules/cacheable-request": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz", + "integrity": "sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew==", + "dev": true, + "dependencies": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^4.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^6.0.1", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cheerio": { + "version": "1.0.0-rc.10", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.10.tgz", + "integrity": "sha512-g0J0q/O6mW8z5zxQ3A8E8J1hUgp4SMOvEoW/x84OwyHKe/Zccz83PVT4y5Crcr530FV6NgmKI1qvGTKVl9XXVw==", + "dev": true, + "dependencies": { + "cheerio-select": "^1.5.0", + "dom-serializer": "^1.3.2", + "domhandler": "^4.2.0", + "htmlparser2": "^6.1.0", + "parse5": "^6.0.1", + "parse5-htmlparser2-tree-adapter": "^6.0.1", + "tslib": "^2.2.0" + }, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/cheeriojs/cheerio?sponsor=1" + } + }, + "node_modules/cheerio-select": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-1.6.0.tgz", + "integrity": "sha512-eq0GdBvxVFbqWgmCm7M3XGs1I8oLy/nExUnh6oLqmBditPO9AqQJrkslDpMun/hZ0yyTs8L0m85OHp4ho6Qm9g==", + "dev": true, + "dependencies": { + "css-select": "^4.3.0", + "css-what": "^6.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.3.1", + "domutils": "^2.8.0" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/cli-table": { + "version": "0.3.11", + "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.11.tgz", + "integrity": "sha512-IqLQi4lO0nIB4tcdTpN4LCB9FI3uqrJZK7RC515EnhZ6qBaglkIgICb1wjeAqpdoOabm1+SuQtkXIPdYC93jhQ==", + "dev": true, + "dependencies": { + "colors": "1.0.3" + }, + "engines": { + "node": ">= 0.2.0" + } + }, + "node_modules/clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/clone-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", + "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "dev": true, + "dependencies": { + "mimic-response": "^1.0.0" + } + }, + "node_modules/color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "dev": true, + "optional": true, + "bin": { + "color-support": "bin.js" + } + }, + "node_modules/colors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", + "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", + "dev": true, + "engines": { + "node": ">=0.1.90" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commist": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/commist/-/commist-1.1.0.tgz", + "integrity": "sha512-rraC8NXWOEjhADbZe9QBNzLAN5Q3fsTPQtBV+fEVj6xKIgDgNiEVE6ZNfHpZOqfQ21YUzfVNUXLOEZquYvQPPg==", + "dev": true, + "dependencies": { + "leven": "^2.1.0", + "minimist": "^1.1.0" + } + }, + "node_modules/compress-brotli": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/compress-brotli/-/compress-brotli-1.3.8.tgz", + "integrity": "sha512-lVcQsjhxhIXsuupfy9fmZUFtAIdBmXA7EGY6GBdgZ++qkM9zG4YFT8iU7FoBxzryNDMOpD1HIFHUSX4D87oqhQ==", + "dev": true, + "dependencies": { + "@types/json-buffer": "~3.0.0", + "json-buffer": "~3.0.1" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "node_modules/concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "dev": true, + "engines": [ + "node >= 6.0" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "dev": true, + "optional": true + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dev": true, + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-parser": { + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.6.tgz", + "integrity": "sha512-z3IzaNjdwUC2olLIB5/ITd0/setiaFMLYiZJle7xg5Fe9KWAceil7xszYfHHBtDFYLSgJduS2Ty0P1uJdPDJeA==", + "dev": true, + "dependencies": { + "cookie": "0.4.1", + "cookie-signature": "1.0.6" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/cookie-parser/node_modules/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", + "dev": true + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dev": true, + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/cronosjs": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/cronosjs/-/cronosjs-1.7.1.tgz", + "integrity": "sha512-d6S6+ep7dJxsAG8OQQCdKuByI/S/AV64d9OF5mtmcykOyPu92cAkAnF3Tbc9s5oOaLQBYYQmTNvjqYRkPJ/u5Q==", + "dev": true, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/css-select": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.3.0.tgz", + "integrity": "sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.0.1", + "domhandler": "^4.3.1", + "domutils": "^2.8.0", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "dev": true, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dev": true, + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/decompress-response/node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/defer-to-connect": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", + "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "dev": true, + "optional": true + }, + "node_modules/denque": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.0.1.tgz", + "integrity": "sha512-tfiWc6BQLXNLpNiR5iGd0Ocu3P3VpxfzFiqubLgMfhfOw9WyvgJBd46CClNn9k3qfbjvT//0cf7AlYRX/OslMQ==", + "dev": true, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", + "dev": true + }, + "node_modules/detect-libc": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz", + "integrity": "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==", + "dev": true, + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/dicer": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", + "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=", + "dev": true, + "dependencies": { + "readable-stream": "1.1.x", + "streamsearch": "0.1.2" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/dicer/node_modules/readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/dicer/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "node_modules/dom-serializer": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", + "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", + "dev": true, + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] + }, + "node_modules/domhandler": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", + "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", + "dev": true, + "dependencies": { + "domelementtype": "^2.2.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", + "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==", + "dev": true, + "dependencies": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/duplexify": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.2.tgz", + "integrity": "sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw==", + "dev": true, + "dependencies": { + "end-of-stream": "^1.4.1", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1", + "stream-shift": "^1.0.0" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "dev": true + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "optional": true + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "dev": true, + "dependencies": { + "ansi-colors": "^4.1.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "dev": true + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.2.tgz", + "integrity": "sha512-oxlxJxcQlYwqPWKVJJtvQiwHgosH/LrLSPA+H4UxpyvSS6jC5aH+5MoHFM+KABgTOt0APue4w66Ha8jCUo9QGg==", + "dev": true, + "dependencies": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.1", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.4.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.9.6", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.17.2", + "serve-static": "1.14.2", + "setprototypeof": "1.2.0", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/express-session": { + "version": "1.17.2", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.2.tgz", + "integrity": "sha512-mPcYcLA0lvh7D4Oqr5aNJFMtBMKPLl++OKKxkHzZ0U0oDq1rpKBnkR5f5vCHR26VeArlTOEF9td4x5IjICksRQ==", + "dev": true, + "dependencies": { + "cookie": "0.4.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~2.0.0", + "on-headers": "~1.0.2", + "parseurl": "~1.3.3", + "safe-buffer": "5.2.1", + "uid-safe": "~2.1.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/express-session/node_modules/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express-session/node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/express/node_modules/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "dev": true, + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz", + "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "node_modules/gauge": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", + "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", + "dev": true, + "optional": true, + "dependencies": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.2", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.1", + "object-assign": "^4.1.1", + "signal-exit": "^3.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/got": { + "version": "11.8.3", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.3.tgz", + "integrity": "sha512-7gtQ5KiPh1RtGS9/Jbv1ofDpBFuq42gyfEib+ejaRBJuj/3tQFeR5+gw57e4ipaU8c/rCjvX6fkQz2lyDlGAOg==", + "dev": true, + "dependencies": { + "@sindresorhus/is": "^4.0.0", + "@szmarczak/http-timer": "^4.0.5", + "@types/cacheable-request": "^6.0.1", + "@types/responselike": "^1.0.0", + "cacheable-lookup": "^5.0.3", + "cacheable-request": "^7.0.2", + "decompress-response": "^6.0.0", + "http2-wrapper": "^1.0.0-beta.5.2", + "lowercase-keys": "^2.0.0", + "p-cancelable": "^2.0.0", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=10.19.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/got?sponsor=1" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "dev": true, + "optional": true + }, + "node_modules/hash-sum": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hash-sum/-/hash-sum-2.0.0.tgz", + "integrity": "sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==", + "dev": true + }, + "node_modules/help-me": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/help-me/-/help-me-3.0.0.tgz", + "integrity": "sha512-hx73jClhyk910sidBB7ERlnhMlFsJJIBqSVMFDwPN8o2v9nmp5KgLq1Xz1Bf1fCMMZ6mPrX159iG0VLy/fPMtQ==", + "dev": true, + "dependencies": { + "glob": "^7.1.6", + "readable-stream": "^3.6.0" + } + }, + "node_modules/hpagent": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/hpagent/-/hpagent-0.1.2.tgz", + "integrity": "sha512-ePqFXHtSQWAFXYmj+JtOTHr84iNrII4/QRlAAPPE+zqnKy4xJo7Ie1Y4kC7AdB+LxLxSTTzBMASsEcy0q8YyvQ==", + "dev": true + }, + "node_modules/htmlparser2": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "dev": true, + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.5.2", + "entities": "^2.0.0" + } + }, + "node_modules/http-cache-semantics": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", + "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "dev": true + }, + "node_modules/http-errors": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/http2-wrapper": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", + "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", + "dev": true, + "dependencies": { + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.0.0" + }, + "engines": { + "node": ">=10.19.0" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", + "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "dev": true, + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/https-proxy-agent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/https-proxy-agent/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/i18next": { + "version": "21.6.11", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-21.6.11.tgz", + "integrity": "sha512-tJ2+o0lVO+fhi8bPkCpBAeY1SgkqmQm5NzgPWCQssBrywJw98/o+Kombhty5nxQOpHtvMmsxcOopczUiH6bJxQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://locize.com" + }, + { + "type": "individual", + "url": "https://locize.com/i18next.html" + }, + { + "type": "individual", + "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + } + ], + "dependencies": { + "@babel/runtime": "^7.12.0" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "dev": true, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "node_modules/js-sdsl": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-2.1.4.tgz", + "integrity": "sha512-/Ew+CJWHNddr7sjwgxaVeIORIH4AMVC9dy0hPf540ZGMVgS9d3ajwuVdyhDt6/QUvT8ATjR3yuYBKsS79F+H4A==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "node_modules/jsonata": { + "version": "1.8.6", + "resolved": "https://registry.npmjs.org/jsonata/-/jsonata-1.8.6.tgz", + "integrity": "sha512-ZH2TPYdNP2JecOl/HvrH47Xc+9imibEMQ4YqKy/F/FrM+2a6vfbGxeCX23dB9Fr6uvGwv+ghf1KxWB3iZk09wA==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/keyv": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.2.8.tgz", + "integrity": "sha512-IZZo6krhHWPhgsP5mBkEdPopVPN/stgCnBVuqi6dda/Nm5mDTOSVTrFMkWqlJsDum+B0YSe887tNxdjDWkO7aQ==", + "dev": true, + "dependencies": { + "compress-brotli": "^1.3.8", + "json-buffer": "3.0.1" + } + }, + "node_modules/leven": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", + "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, + "node_modules/lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "dependencies": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "optional": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "optional": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/memorystore": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/memorystore/-/memorystore-1.6.7.tgz", + "integrity": "sha512-OZnmNY/NDrKohPQ+hxp0muBcBKrzKNtHr55DbqSx9hLsYVNnomSAMRAtI7R64t3gf3ID7tHQA7mG4oL3Hu9hdw==", + "dev": true, + "dependencies": { + "debug": "^4.3.0", + "lru-cache": "^4.0.3" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/memorystore/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/memorystore/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", + "dev": true + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", + "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", + "dev": true + }, + "node_modules/minipass": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.6.tgz", + "integrity": "sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minipass/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minizlib/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/moment": { + "version": "2.29.3", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz", + "integrity": "sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/moment-timezone": { + "version": "0.5.34", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz", + "integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==", + "dev": true, + "dependencies": { + "moment": ">= 2.9.0" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mqtt": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.3.5.tgz", + "integrity": "sha512-l29WGHAc0EayK1cjb6moozc+rlgK6YRCPbP3zB1CrJw84Bjk4kG9EJCXojdn4r29lA80SCqxRKq1QJ87+Xevng==", + "dev": true, + "dependencies": { + "commist": "^1.0.0", + "concat-stream": "^2.0.0", + "debug": "^4.1.1", + "duplexify": "^4.1.1", + "help-me": "^3.0.0", + "inherits": "^2.0.3", + "lru-cache": "^6.0.0", + "minimist": "^1.2.5", + "mqtt-packet": "^6.8.0", + "number-allocator": "^1.0.9", + "pump": "^3.0.0", + "readable-stream": "^3.6.0", + "reinterval": "^1.1.0", + "rfdc": "^1.3.0", + "split2": "^3.1.0", + "ws": "^7.5.5", + "xtend": "^4.0.2" + }, + "bin": { + "mqtt": "bin/mqtt.js", + "mqtt_pub": "bin/pub.js", + "mqtt_sub": "bin/sub.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/mqtt-packet": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/mqtt-packet/-/mqtt-packet-6.10.0.tgz", + "integrity": "sha512-ja8+mFKIHdB1Tpl6vac+sktqy3gA8t9Mduom1BA75cI+R9AHnZOiaBQwpGiWnaVJLDGRdNhQmFaAqd7tkKSMGA==", + "dev": true, + "dependencies": { + "bl": "^4.0.2", + "debug": "^4.1.1", + "process-nextick-args": "^2.0.1" + } + }, + "node_modules/mqtt-packet/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mqtt-packet/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/mqtt/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mqtt/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mqtt/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/mqtt/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "node_modules/multer": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.4.tgz", + "integrity": "sha512-2wY2+xD4udX612aMqMcB8Ws2Voq6NIUPEtD1be6m411T4uDH/VtL9i//xvcyFlTVfRdaBsk7hV5tgrGQqhuBiw==", + "dev": true, + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^0.2.11", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "on-finished": "^2.3.0", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/multer/node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/multer/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "node_modules/multer/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/multer/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/multer/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/mustache": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", + "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", + "dev": true, + "bin": { + "mustache": "bin/mustache" + } + }, + "node_modules/mute-stream": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", + "dev": true + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-addon-api": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", + "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==", + "dev": true, + "optional": true + }, + "node_modules/node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "dev": true, + "optional": true, + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-red": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/node-red/-/node-red-2.2.2.tgz", + "integrity": "sha512-DAx4v9/W2MEBb/tHNO94bmjeELdAg7CVZlPJX+UBH1RsmXB0q/3ZYW1Zi55NVMVN/0sBBO1g+dI/L0NWCG8s9A==", + "dev": true, + "dependencies": { + "@node-red/editor-api": "2.2.2", + "@node-red/nodes": "2.2.2", + "@node-red/runtime": "2.2.2", + "@node-red/util": "2.2.2", + "basic-auth": "2.0.1", + "bcryptjs": "2.4.3", + "express": "4.17.2", + "fs-extra": "10.0.0", + "node-red-admin": "^2.2.3", + "nopt": "5.0.0", + "semver": "7.3.5" + }, + "bin": { + "node-red": "red.js", + "node-red-pi": "bin/node-red-pi" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "bcrypt": "5.0.1" + } + }, + "node_modules/node-red-admin": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/node-red-admin/-/node-red-admin-2.2.4.tgz", + "integrity": "sha512-DlJpMFopqBNj10k5rGGI9ZNBi+whAIS+IHrSZH1xllfuJKZxQBZgR+o+rJeufDyc0OBRgHRqmX776HrBrlDtMA==", + "dev": true, + "dependencies": { + "ansi-colors": "^4.1.1", + "axios": "0.27.0", + "bcryptjs": "^2.4.3", + "cli-table": "^0.3.11", + "enquirer": "^2.3.6", + "minimist": "^1.2.6", + "mustache": "^4.2.0", + "read": "^1.0.7" + }, + "bin": { + "node-red-admin": "node-red-admin.js" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "bcrypt": "5.0.1" + } + }, + "node_modules/node-red-admin/node_modules/axios": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.0.tgz", + "integrity": "sha512-XV/WrPxXfzgZ8j4lcB5i6LyaXmi90yetmV/Fem0kmglGx+mpY06CiweL3YxU6wOTNLmqLUePW4G8h45nGZ/+pA==", + "deprecated": "Formdata complete broken, incorrect build size", + "dev": true, + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/nopt": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", + "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/normalize-url": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", + "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npmlog": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", + "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", + "dev": true, + "optional": true, + "dependencies": { + "are-we-there-yet": "^2.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^3.0.0", + "set-blocking": "^2.0.0" + } + }, + "node_modules/nth-check": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.1.tgz", + "integrity": "sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/number-allocator": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/number-allocator/-/number-allocator-1.0.10.tgz", + "integrity": "sha512-K4AvNGKo9lP6HqsZyfSr9KDaqnwFzW203inhQEOwFrmFaYevpdX4VNwdOLk197aHujzbT//z6pCBrCOUYSM5iw==", + "dev": true, + "dependencies": { + "debug": "^4.3.1", + "js-sdsl": "^2.1.2" + } + }, + "node_modules/number-allocator/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/number-allocator/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/oauth2orize": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/oauth2orize/-/oauth2orize-1.11.1.tgz", + "integrity": "sha512-9dSx/Gwm0J2Rvj4RH9+h7iXVnRXZ6biwWRgb2dCeQhCosODS0nYdM9I/G7BUGsjbgn0pHjGcn1zcCRtzj2SlRA==", + "dev": true, + "dependencies": { + "debug": "2.x.x", + "uid2": "0.0.x", + "utils-merge": "1.x.x" + }, + "engines": { + "node": ">= 0.4.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/jaredhanson" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "dev": true, + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/on-headers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-cancelable": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", + "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/parse5": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", + "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", + "dev": true + }, + "node_modules/parse5-htmlparser2-tree-adapter": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz", + "integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==", + "dev": true, + "dependencies": { + "parse5": "^6.0.1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/passport": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/passport/-/passport-0.5.2.tgz", + "integrity": "sha512-w9n/Ot5I7orGD4y+7V3EFJCQEznE5RxHamUxcqLT2QoJY0f2JdN8GyHonYFvN0Vz+L6lUJfVhrk2aZz2LbuREw==", + "dev": true, + "dependencies": { + "passport-strategy": "1.x.x", + "pause": "0.0.1" + }, + "engines": { + "node": ">= 0.4.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/jaredhanson" + } + }, + "node_modules/passport-http-bearer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/passport-http-bearer/-/passport-http-bearer-1.0.1.tgz", + "integrity": "sha1-FHRp6jZp4qhMYWfvmdu3fh8AmKg=", + "dev": true, + "dependencies": { + "passport-strategy": "1.x.x" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/passport-oauth2-client-password": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/passport-oauth2-client-password/-/passport-oauth2-client-password-0.1.2.tgz", + "integrity": "sha1-TzeLZ4uS0W270jOmxwZSAJPlYbo=", + "dev": true, + "dependencies": { + "passport-strategy": "1.x.x" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/passport-strategy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", + "integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ=", + "dev": true, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", + "dev": true + }, + "node_modules/pause": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", + "integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10=", + "dev": true + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dev": true, + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "node_modules/psl": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", + "dev": true + }, + "node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/qs": { + "version": "6.9.6", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.6.tgz", + "integrity": "sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ==", + "dev": true, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/random-bytes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", + "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", + "dev": true, + "dependencies": { + "bytes": "3.1.2", + "http-errors": "1.8.1", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/raw-body/node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/raw-body/node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/read": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", + "integrity": "sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ=", + "dev": true, + "dependencies": { + "mute-stream": "~0.0.4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.9", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", + "dev": true + }, + "node_modules/reinterval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reinterval/-/reinterval-1.1.0.tgz", + "integrity": "sha1-M2Hs+jymwYKDOA3Qu5VG85D17Oc=", + "dev": true + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve-alpn": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", + "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==", + "dev": true + }, + "node_modules/responselike": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz", + "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==", + "dev": true, + "dependencies": { + "lowercase-keys": "^2.0.0" + } + }, + "node_modules/rfdc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", + "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==", + "dev": true + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "optional": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "node_modules/sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true + }, + "node_modules/semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/send": { + "version": "0.17.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", + "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==", + "dev": true, + "dependencies": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "1.8.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/serve-static": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz", + "integrity": "sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ==", + "dev": true, + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true, + "optional": true + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "optional": true + }, + "node_modules/split2": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", + "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", + "dev": true, + "dependencies": { + "readable-stream": "^3.0.0" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/stream-shift": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", + "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==", + "dev": true + }, + "node_modules/streamsearch": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "optional": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "optional": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tar": { + "version": "6.1.11", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz", + "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==", + "dev": true, + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^3.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/tar/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/tar/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/tough-cookie": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz", + "integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==", + "dev": true, + "dependencies": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.1.2" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tough-cookie/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", + "dev": true, + "optional": true + }, + "node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dev": true, + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/type-is/node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "node_modules/uglify-js": { + "version": "3.15.1", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.1.tgz", + "integrity": "sha512-FAGKF12fWdkpvNJZENacOH0e/83eG6JyVQyanIJaBXCN1J11TUQv1T1/z8S+Z0CG0ZPk1nPcreF/c7lrTd0TEQ==", + "dev": true, + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/uid-safe": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", + "integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", + "dev": true, + "dependencies": { + "random-bytes": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/uid2": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.4.tgz", + "integrity": "sha512-IevTus0SbGwQzYh3+fRsAMTVVPOoIVufzacXcHPmdlle1jUpq7BRL+mw3dgeLanvGZdwwbWhRV6XrcFNdBmjWA==", + "dev": true + }, + "node_modules/universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", + "dev": true, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=", + "dev": true, + "optional": true + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "dev": true, + "optional": true, + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "dev": true, + "optional": true, + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "node_modules/ws": { + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.6.tgz", + "integrity": "sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "dev": true, + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + } + }, "dependencies": { "@babel/runtime": { - "version": "7.16.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.5.tgz", - "integrity": "sha512-TXWihFIS3Pyv5hzR7j6ihmeLkZfrXGxAr5UfSl8CHf+6q/wpiYDkUau0czckpYG8QmnCIuPpdLtuA9VmuGGyMA==", + "version": "7.17.9", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.9.tgz", + "integrity": "sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==", "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } }, "@mapbox/node-pre-gyp": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.8.tgz", - "integrity": "sha512-CMGKi28CF+qlbXh26hDe6NxCd7amqeAzEqnS6IHeO6LoaKyM/n+Xw3HT1COdq8cuioOdlKdqn/hCmqPUOMOywg==", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.9.tgz", + "integrity": "sha512-aDF3S3rK9Q2gey/WAttUlISduDItz5BU3306M9Eyv6/oS40aMprnopshtlKTykxRNIBEZuRMaZAnbrQ4QtKGyw==", "dev": true, "optional": true, "requires": { - "detect-libc": "^1.0.3", + "detect-libc": "^2.0.0", "https-proxy-agent": "^5.0.0", "make-dir": "^3.1.0", - "node-fetch": "^2.6.5", + "node-fetch": "^2.6.7", "nopt": "^5.0.0", "npmlog": "^5.0.1", "rimraf": "^3.0.2", @@ -32,57 +3309,56 @@ } }, "@node-red/editor-api": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@node-red/editor-api/-/editor-api-2.1.4.tgz", - "integrity": "sha512-FQn/lAIEa/1oJqkq8cPWMQ/RMiLkZDOFoYw6gM3WjAKwpX7AN/FuZi8R6qUfcn0cylwQzYzx43ggUq2/3f81xQ==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/editor-api/-/editor-api-2.2.2.tgz", + "integrity": "sha512-5PUXtMCjsKevCiz8OjHqAckctOv/zzPcssH4yzTxMYEN4JtTng5lFfZzTFWZC/UnCGQMgwe/0e4iGHbMbN1pqg==", "dev": true, "requires": { - "@node-red/editor-client": "2.1.4", - "@node-red/util": "2.1.4", + "@node-red/editor-client": "2.2.2", + "@node-red/util": "2.2.2", "bcrypt": "5.0.1", "bcryptjs": "2.4.3", - "body-parser": "1.19.0", + "body-parser": "1.19.1", "clone": "2.1.2", "cors": "2.8.5", - "express": "4.17.1", + "express": "4.17.2", "express-session": "1.17.2", - "memorystore": "1.6.6", - "mime": "2.5.2", - "multer": "1.4.3", + "memorystore": "1.6.7", + "mime": "3.0.0", + "multer": "1.4.4", "mustache": "4.2.0", "oauth2orize": "1.11.1", - "passport": "0.5.0", + "passport": "0.5.2", "passport-http-bearer": "1.0.1", "passport-oauth2-client-password": "0.1.2", - "ws": "7.5.1" + "ws": "7.5.6" } }, "@node-red/editor-client": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@node-red/editor-client/-/editor-client-2.1.4.tgz", - "integrity": "sha512-Q9HUZDnEw6VbQBs14yW01uV4KbIgqxqriFkwfEzfbi5dNag2sqQSrf6XSfg7OuqIf3iC10Wbm5/0Y67rMtV9gA==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/editor-client/-/editor-client-2.2.2.tgz", + "integrity": "sha512-DivbfvVfoh4sRKHmOGucE9kV8MWwGczbxsJfaEVedCtVt9ZDX40N61+FzPVlf2FGDi8q21cIRV7klV1GWhDFxw==", "dev": true }, "@node-red/nodes": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@node-red/nodes/-/nodes-2.1.4.tgz", - "integrity": "sha512-di57I/0BUMfpRL9vLBomOp1QIyStDwvb+TXUd54b8FEopfAn5h3E7avL6te7yZSUuKVipqUd54CHJepRubRxBQ==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/nodes/-/nodes-2.2.2.tgz", + "integrity": "sha512-RJ8yR90e/tF0KIiS7ZDe8+q0Zk9uJQZDNUcheEeJKWXfIf3WcMo+5KhQ5HJfy8UedmPXzNLRX75FuTXwcd+NKA==", "dev": true, "requires": { - "acorn": "8.6.0", + "acorn": "8.7.0", "acorn-walk": "8.2.0", - "ajv": "8.8.2", - "body-parser": "1.19.0", + "ajv": "8.10.0", + "body-parser": "1.19.1", "cheerio": "1.0.0-rc.10", "content-type": "1.0.4", - "cookie": "0.4.1", + "cookie": "0.4.2", "cookie-parser": "1.4.6", "cors": "2.8.5", "cronosjs": "1.7.1", "denque": "2.0.1", "form-data": "4.0.0", "fs-extra": "10.0.0", - "fs.notify": "0.0.4", "got": "11.8.3", "hash-sum": "2.0.0", "hpagent": "0.1.2", @@ -91,141 +3367,64 @@ "is-utf8": "0.2.1", "js-yaml": "3.14.1", "media-typer": "1.1.0", - "mqtt": "4.2.8", - "multer": "1.4.3", + "mqtt": "4.3.5", + "multer": "1.4.4", "mustache": "4.2.0", "on-headers": "1.0.2", - "raw-body": "2.4.2", + "raw-body": "2.4.3", "tough-cookie": "4.0.0", "uuid": "8.3.2", - "ws": "7.5.1", + "ws": "7.5.6", "xml2js": "0.4.23" - }, - "dependencies": { - "bytes": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.1.tgz", - "integrity": "sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==", - "dev": true - }, - "cookie": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", - "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", - "dev": true - }, - "http-errors": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", - "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", - "dev": true, - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.1" - } - }, - "iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - } - }, - "media-typer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", - "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", - "dev": true - }, - "raw-body": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.2.tgz", - "integrity": "sha512-RPMAFUJP19WIet/99ngh6Iv8fzAbqum4Li7AD6DtGaW2RpMB/11xDoalPiJMTbu6I3hkbMVkATvZrqb9EEqeeQ==", - "dev": true, - "requires": { - "bytes": "3.1.1", - "http-errors": "1.8.1", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "dependencies": { - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - } - } - }, - "setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "dev": true - }, - "toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "dev": true - } } }, "@node-red/registry": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@node-red/registry/-/registry-2.1.4.tgz", - "integrity": "sha512-OinEVN4js8ewEf4q89FJxoCdGELXIjuZo+3AtlXDqZD8uJOnKnB48avXhrWuMFjYCJhQN8PUqulHj6Ru596lPA==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/registry/-/registry-2.2.2.tgz", + "integrity": "sha512-zszKLaR2XpBE4wG4o8cwe+dtOvqlG/Cl0iRXg1wpJ9zC96WIPRq+UqAkVkZm6uRuNhW5ZjKk8f77Wh1+v6QBAw==", "dev": true, "requires": { - "@node-red/util": "2.1.4", + "@node-red/util": "2.2.2", "clone": "2.1.2", "fs-extra": "10.0.0", "semver": "7.3.5", "tar": "6.1.11", - "uglify-js": "3.14.4" + "uglify-js": "3.15.1" } }, "@node-red/runtime": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@node-red/runtime/-/runtime-2.1.4.tgz", - "integrity": "sha512-fU6lvgmpcnxQPc0CEyvgvDtGmNsgS5k6zJ9No+9jPCAkUAO069pFrecCddo9j/sN+8FRw4ikwqvKI0uAgTFx1Q==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/runtime/-/runtime-2.2.2.tgz", + "integrity": "sha512-PW+HGDmY7Q5nXx+zPVpbFaFpn59EyPLb2QYYL1T5MarCQpUfIaL44NMhSG//n0+vkGZBLi9T6ltapWgEYW4x9g==", "dev": true, "requires": { - "@node-red/registry": "2.1.4", - "@node-red/util": "2.1.4", + "@node-red/registry": "2.2.2", + "@node-red/util": "2.2.2", "async-mutex": "0.3.2", "clone": "2.1.2", - "express": "4.17.1", + "express": "4.17.2", "fs-extra": "10.0.0", "json-stringify-safe": "5.0.1" } }, "@node-red/util": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@node-red/util/-/util-2.1.4.tgz", - "integrity": "sha512-OdlMz2Q2ivfw1NoW2qi4ymB+WMRe3ICGkPkPhc1dlp1NSsuXXXNdi9jXglYo/cTF8v/QLihnXZf2ppCm4iiqRQ==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@node-red/util/-/util-2.2.2.tgz", + "integrity": "sha512-tUGLGj3fTgOjWwhp9uK6M+LUb3rxIrU61DbA0fVpANCEeqk5UNJpje4vOag9dWmJS7hn/ONcDK7dslHLyOQUIQ==", "dev": true, "requires": { "fs-extra": "10.0.0", - "i18next": "21.5.4", + "i18next": "21.6.11", "json-stringify-safe": "5.0.1", - "jsonata": "1.8.5", + "jsonata": "1.8.6", "lodash.clonedeep": "^4.5.0", "moment-timezone": "0.5.34" } }, "@sindresorhus/is": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz", - "integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", + "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", "dev": true }, "@szmarczak/http-timer": { @@ -255,19 +3454,25 @@ "integrity": "sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==", "dev": true }, + "@types/json-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/json-buffer/-/json-buffer-3.0.0.tgz", + "integrity": "sha512-3YP80IxxFJB4b5tYC2SUPwkg0XQLiu0nWvhRgEatgjf+29IcWO9X1k8xRv5DGssJ/lCrjYTjQPcobJr2yWIVuQ==", + "dev": true + }, "@types/keyv": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.3.tgz", - "integrity": "sha512-FXCJgyyN3ivVgRoml4h94G/p3kY+u/B86La+QptcqJaWtBWtmc6TtkNfS40n9bIvyLteHh7zXOtgbobORKPbDg==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", + "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", "dev": true, "requires": { "@types/node": "*" } }, "@types/node": { - "version": "17.0.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.4.tgz", - "integrity": "sha512-6xwbrW4JJiJLgF+zNypN5wr2ykM9/jHcL7rQ8fZe2vuftggjzZeRSM4OwRc6Xk8qWjwJ99qVHo/JgOGmomWRog==", + "version": "17.0.33", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.33.tgz", + "integrity": "sha512-miWq2m2FiQZmaHfdZNcbpp9PuXg34W5JZ5CrJ/BaS70VuhoJENBEQybeiYSaPBRNq6KQGnjfEnc/F3PN++D+XQ==", "dev": true }, "@types/responselike": { @@ -286,19 +3491,19 @@ "dev": true }, "accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", "dev": true, "requires": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" + "mime-types": "~2.1.34", + "negotiator": "0.6.3" } }, "acorn": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.6.0.tgz", - "integrity": "sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", + "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", "dev": true }, "acorn-walk": { @@ -314,12 +3519,29 @@ "dev": true, "requires": { "debug": "4" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "ajv": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.8.2.tgz", - "integrity": "sha512-x9VuX+R/jcFj1DHo/fCp99esgGDWiHENrKxaCENuCxpoMCmAt/COCGVDwA7kleEpEzJjDnvh3yGoOuLu0Dtllw==", + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.10.0.tgz", + "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -380,12 +3602,6 @@ "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", "dev": true }, - "async": { - "version": "0.1.22", - "resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz", - "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=", - "dev": true - }, "async-mutex": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.3.2.tgz", @@ -467,37 +3683,43 @@ } }, "body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz", + "integrity": "sha512-8ljfQi5eBk8EJfECMrgqNGWPEY5jWP+1IzkzkGdFFEwFQZZyaZ21UqdaHktgiMlH0xLHqIFtE/u2OYE5dOtViA==", "dev": true, "requires": { - "bytes": "3.1.0", + "bytes": "3.1.1", "content-type": "~1.0.4", "debug": "2.6.9", "depd": "~1.1.2", - "http-errors": "1.7.2", + "http-errors": "1.8.1", "iconv-lite": "0.4.24", "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" + "qs": "6.9.6", + "raw-body": "2.4.2", + "type-is": "~1.6.18" }, "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, "requires": { - "ms": "2.0.0" + "safer-buffer": ">= 2.1.2 < 3" } }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "raw-body": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.2.tgz", + "integrity": "sha512-RPMAFUJP19WIet/99ngh6Iv8fzAbqum4Li7AD6DtGaW2RpMB/11xDoalPiJMTbu6I3hkbMVkATvZrqb9EEqeeQ==", + "dev": true, + "requires": { + "bytes": "3.1.1", + "http-errors": "1.8.1", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } } } }, @@ -564,9 +3786,9 @@ } }, "bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.1.tgz", + "integrity": "sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==", "dev": true }, "cacheable-lookup": { @@ -606,16 +3828,16 @@ } }, "cheerio-select": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-1.5.0.tgz", - "integrity": "sha512-qocaHPv5ypefh6YNxvnbABM07KMxExbtbfuJoIie3iZXX1ERwYmJcIiRrr9H05ucQP1k28dav8rpdDgjQd8drg==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-1.6.0.tgz", + "integrity": "sha512-eq0GdBvxVFbqWgmCm7M3XGs1I8oLy/nExUnh6oLqmBditPO9AqQJrkslDpMun/hZ0yyTs8L0m85OHp4ho6Qm9g==", "dev": true, "requires": { - "css-select": "^4.1.3", - "css-what": "^5.0.1", + "css-select": "^4.3.0", + "css-what": "^6.0.1", "domelementtype": "^2.2.0", - "domhandler": "^4.2.0", - "domutils": "^2.7.0" + "domhandler": "^4.3.1", + "domutils": "^2.8.0" } }, "chownr": { @@ -680,6 +3902,16 @@ "minimist": "^1.1.0" } }, + "compress-brotli": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/compress-brotli/-/compress-brotli-1.3.8.tgz", + "integrity": "sha512-lVcQsjhxhIXsuupfy9fmZUFtAIdBmXA7EGY6GBdgZ++qkM9zG4YFT8iU7FoBxzryNDMOpD1HIFHUSX4D87oqhQ==", + "dev": true, + "requires": { + "@types/json-buffer": "~3.0.0", + "json-buffer": "~3.0.1" + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -687,53 +3919,15 @@ "dev": true }, "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", "dev": true, "requires": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", - "readable-stream": "^2.2.2", + "readable-stream": "^3.0.2", "typedarray": "^0.0.6" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } } }, "console-control-strings": { @@ -744,20 +3938,12 @@ "optional": true }, "content-disposition": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", - "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", "dev": true, "requires": { - "safe-buffer": "5.1.2" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - } + "safe-buffer": "5.2.1" } }, "content-type": { @@ -767,9 +3953,9 @@ "dev": true }, "cookie": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", - "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", "dev": true }, "cookie-parser": { @@ -819,31 +4005,31 @@ "dev": true }, "css-select": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.2.0.tgz", - "integrity": "sha512-6YVG6hsH9yIb/si3Th/is8Pex7qnVHO6t7q7U6TIUnkQASGbS8tnUDBftnPynLNnuUl/r2+PTd0ekiiq7R0zJw==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.3.0.tgz", + "integrity": "sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==", "dev": true, "requires": { "boolbase": "^1.0.0", - "css-what": "^5.1.0", - "domhandler": "^4.3.0", + "css-what": "^6.0.1", + "domhandler": "^4.3.1", "domutils": "^2.8.0", "nth-check": "^2.0.1" } }, "css-what": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.1.0.tgz", - "integrity": "sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", "dev": true }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { - "ms": "2.1.2" + "ms": "2.0.0" } }, "decompress-response": { @@ -901,9 +4087,9 @@ "dev": true }, "detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz", + "integrity": "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==", "dev": true, "optional": true }, @@ -938,9 +4124,9 @@ } }, "dom-serializer": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", - "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", + "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", "dev": true, "requires": { "domelementtype": "^2.0.1", @@ -949,15 +4135,15 @@ } }, "domelementtype": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", - "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", "dev": true }, "domhandler": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.0.tgz", - "integrity": "sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", + "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", "dev": true, "requires": { "domelementtype": "^2.2.0" @@ -1048,17 +4234,17 @@ "dev": true }, "express": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", - "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.2.tgz", + "integrity": "sha512-oxlxJxcQlYwqPWKVJJtvQiwHgosH/LrLSPA+H4UxpyvSS6jC5aH+5MoHFM+KABgTOt0APue4w66Ha8jCUo9QGg==", "dev": true, "requires": { "accepts": "~1.3.7", "array-flatten": "1.1.1", - "body-parser": "1.19.0", - "content-disposition": "0.5.3", + "body-parser": "1.19.1", + "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.4.0", + "cookie": "0.4.1", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "~1.1.2", @@ -1072,38 +4258,23 @@ "on-finished": "~2.3.0", "parseurl": "~1.3.3", "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.5", - "qs": "6.7.0", + "proxy-addr": "~2.0.7", + "qs": "6.9.6", "range-parser": "~1.2.1", - "safe-buffer": "5.1.2", - "send": "0.17.1", - "serve-static": "1.14.1", - "setprototypeof": "1.1.1", + "safe-buffer": "5.2.1", + "send": "0.17.2", + "serve-static": "1.14.2", + "setprototypeof": "1.2.0", "statuses": "~1.5.0", "type-is": "~1.6.18", "utils-merge": "1.0.1", - "vary": "~1.1.2" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "vary": "~1.1.2" + }, + "dependencies": { + "cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", "dev": true } } @@ -1130,26 +4301,11 @@ "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", "dev": true }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, "depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", "dev": true - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true } } }, @@ -1172,29 +4328,12 @@ "parseurl": "~1.3.3", "statuses": "~1.5.0", "unpipe": "~1.0.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } } }, "follow-redirects": { - "version": "1.14.8", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", - "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==" + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz", + "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==" }, "form-data": { "version": "4.0.0", @@ -1239,16 +4378,6 @@ "minipass": "^3.0.0" } }, - "fs.notify": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/fs.notify/-/fs.notify-0.0.4.tgz", - "integrity": "sha1-YyhNRaNLUs5gCIpt2+xbd208AT0=", - "dev": true, - "requires": { - "async": "~0.1.22", - "retry": "~0.6.0" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1316,9 +4445,9 @@ } }, "graceful-fs": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", - "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, "has-unicode": { @@ -1369,24 +4498,16 @@ "dev": true }, "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", "dev": true, "requires": { "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" - }, - "dependencies": { - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - } + "toidentifier": "1.0.1" } }, "http2-wrapper": { @@ -1407,24 +4528,41 @@ "requires": { "agent-base": "6", "debug": "4" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "i18next": { - "version": "21.5.4", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-21.5.4.tgz", - "integrity": "sha512-ukwRJpLhYg4EUfCOtbaKjlwF71qyel1XMXQN78OkQMcaQG68UzlYgLC6g2fhoTNBvoH2tJkaaqzDumhC9skAhA==", + "version": "21.6.11", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-21.6.11.tgz", + "integrity": "sha512-tJ2+o0lVO+fhi8bPkCpBAeY1SgkqmQm5NzgPWCQssBrywJw98/o+Kombhty5nxQOpHtvMmsxcOopczUiH6bJxQ==", "dev": true, "requires": { "@babel/runtime": "^7.12.0" } }, "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", "dev": true, "requires": { - "safer-buffer": ">= 2.1.2 < 3" + "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "ieee754": { @@ -1474,6 +4612,12 @@ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, + "js-sdsl": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-2.1.4.tgz", + "integrity": "sha512-/Ew+CJWHNddr7sjwgxaVeIORIH4AMVC9dy0hPf540ZGMVgS9d3ajwuVdyhDt6/QUvT8ATjR3yuYBKsS79F+H4A==", + "dev": true + }, "js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", @@ -1503,9 +4647,9 @@ "dev": true }, "jsonata": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/jsonata/-/jsonata-1.8.5.tgz", - "integrity": "sha512-ilDyTBkg6qhNoNVr8PUPzz5GYvRK+REKOM5MdOGzH2y6V4yvPRMegSvbZLpbTtI0QAgz09QM7drDhSHUlwp9pA==", + "version": "1.8.6", + "resolved": "https://registry.npmjs.org/jsonata/-/jsonata-1.8.6.tgz", + "integrity": "sha512-ZH2TPYdNP2JecOl/HvrH47Xc+9imibEMQ4YqKy/F/FrM+2a6vfbGxeCX23dB9Fr6uvGwv+ghf1KxWB3iZk09wA==", "dev": true }, "jsonfile": { @@ -1519,11 +4663,12 @@ } }, "keyv": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.4.tgz", - "integrity": "sha512-vqNHbAc8BBsxk+7QBYLW0Y219rWcClspR6WSeoHYKG5mnsSoOH+BL1pWq02DDCVdvvuUny5rkBlzMRzoqc+GIg==", + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.2.8.tgz", + "integrity": "sha512-IZZo6krhHWPhgsP5mBkEdPopVPN/stgCnBVuqi6dda/Nm5mDTOSVTrFMkWqlJsDum+B0YSe887tNxdjDWkO7aQ==", "dev": true, "requires": { + "compress-brotli": "^1.3.8", "json-buffer": "3.0.1" } }, @@ -1546,12 +4691,13 @@ "dev": true }, "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "dev": true, "requires": { - "yallist": "^4.0.0" + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" } }, "make-dir": { @@ -1574,35 +4720,34 @@ } }, "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", "dev": true }, "memorystore": { - "version": "1.6.6", - "resolved": "https://registry.npmjs.org/memorystore/-/memorystore-1.6.6.tgz", - "integrity": "sha512-EbLl1xg9+DlnjXkZK/eMUoWyhZ1IxcWMpSuFyqyA/Z4BNuH7BR+E0yC40WbLZZ6G8LxHiUZ2DPhqV8DR8+9UQQ==", + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/memorystore/-/memorystore-1.6.7.tgz", + "integrity": "sha512-OZnmNY/NDrKohPQ+hxp0muBcBKrzKNtHr55DbqSx9hLsYVNnomSAMRAtI7R64t3gf3ID7tHQA7mG4oL3Hu9hdw==", "dev": true, "requires": { "debug": "^4.3.0", "lru-cache": "^4.0.3" }, "dependencies": { - "lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" + "ms": "2.1.2" } }, - "yallist": { + "ms": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } @@ -1620,24 +4765,24 @@ "dev": true }, "mime": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", - "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", + "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", "dev": true }, "mime-db": { - "version": "1.51.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", "dev": true }, "mime-types": { - "version": "2.1.34", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", - "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dev": true, "requires": { - "mime-db": "1.51.0" + "mime-db": "1.52.0" } }, "mimic-response": { @@ -1647,9 +4792,9 @@ "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" @@ -1668,6 +4813,14 @@ "dev": true, "requires": { "yallist": "^4.0.0" + }, + "dependencies": { + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } } }, "minizlib": { @@ -1678,18 +4831,29 @@ "requires": { "minipass": "^3.0.0", "yallist": "^4.0.0" + }, + "dependencies": { + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } } }, "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } }, "moment": { - "version": "2.29.2", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz", - "integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==", + "version": "2.29.3", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz", + "integrity": "sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==", "dev": true }, "moment-timezone": { @@ -1702,9 +4866,9 @@ } }, "mqtt": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.2.8.tgz", - "integrity": "sha512-DJYjlXODVXtSDecN8jnNzi6ItX3+ufGsEs9OB3YV24HtkRrh7kpx8L5M1LuyF0KzaiGtWr2PzDcMGAY60KGOSA==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.3.5.tgz", + "integrity": "sha512-l29WGHAc0EayK1cjb6moozc+rlgK6YRCPbP3zB1CrJw84Bjk4kG9EJCXojdn4r29lA80SCqxRKq1QJ87+Xevng==", "dev": true, "requires": { "commist": "^1.0.0", @@ -1713,27 +4877,48 @@ "duplexify": "^4.1.1", "help-me": "^3.0.0", "inherits": "^2.0.3", + "lru-cache": "^6.0.0", "minimist": "^1.2.5", "mqtt-packet": "^6.8.0", + "number-allocator": "^1.0.9", "pump": "^3.0.0", "readable-stream": "^3.6.0", "reinterval": "^1.1.0", + "rfdc": "^1.3.0", "split2": "^3.1.0", - "ws": "^7.5.0", + "ws": "^7.5.5", "xtend": "^4.0.2" }, "dependencies": { - "concat-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", - "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.0.2", - "typedarray": "^0.0.6" + "ms": "2.1.2" + } + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true } } }, @@ -1746,18 +4931,35 @@ "bl": "^4.0.2", "debug": "^4.1.1", "process-nextick-args": "^2.0.1" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, "multer": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.3.tgz", - "integrity": "sha512-np0YLKncuZoTzufbkM6wEKp68EhWJXcU6fq6QqrSwkckd2LlMgd1UqhUJLj6NS/5sZ8dE8LYDWslsltJznnXlg==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.4.tgz", + "integrity": "sha512-2wY2+xD4udX612aMqMcB8Ws2Voq6NIUPEtD1be6m411T4uDH/VtL9i//xvcyFlTVfRdaBsk7hV5tgrGQqhuBiw==", "dev": true, "requires": { "append-field": "^1.0.0", @@ -1770,13 +4972,52 @@ "xtend": "^4.0.0" }, "dependencies": { - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { - "minimist": "^1.2.5" + "safe-buffer": "~5.1.0" } } } @@ -1794,9 +5035,9 @@ "dev": true }, "negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", "dev": true }, "node-addon-api": { @@ -1817,49 +5058,50 @@ } }, "node-red": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/node-red/-/node-red-2.1.4.tgz", - "integrity": "sha512-ScpFFE0G+NlxFWrHnMcIkaF8gW+6jwK7n5qRGId66fCTICYnBGkOxXBvV3Q45H+4iQUro5aIRj737Gu7shjsJw==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/node-red/-/node-red-2.2.2.tgz", + "integrity": "sha512-DAx4v9/W2MEBb/tHNO94bmjeELdAg7CVZlPJX+UBH1RsmXB0q/3ZYW1Zi55NVMVN/0sBBO1g+dI/L0NWCG8s9A==", "dev": true, "requires": { - "@node-red/editor-api": "2.1.4", - "@node-red/nodes": "2.1.4", - "@node-red/runtime": "2.1.4", - "@node-red/util": "2.1.4", + "@node-red/editor-api": "2.2.2", + "@node-red/nodes": "2.2.2", + "@node-red/runtime": "2.2.2", + "@node-red/util": "2.2.2", "basic-auth": "2.0.1", "bcrypt": "5.0.1", "bcryptjs": "2.4.3", - "express": "4.17.1", + "express": "4.17.2", "fs-extra": "10.0.0", - "node-red-admin": "^2.2.1", + "node-red-admin": "^2.2.3", "nopt": "5.0.0", "semver": "7.3.5" } }, "node-red-admin": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/node-red-admin/-/node-red-admin-2.2.1.tgz", - "integrity": "sha512-xYp6mZaRbAWLR8nO4HRVvthYZoPGBotPvetAGho4AXpRJW7fXw38XwK0KPSffvLSis6cxaskJq9nZBLp3PJtng==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/node-red-admin/-/node-red-admin-2.2.4.tgz", + "integrity": "sha512-DlJpMFopqBNj10k5rGGI9ZNBi+whAIS+IHrSZH1xllfuJKZxQBZgR+o+rJeufDyc0OBRgHRqmX776HrBrlDtMA==", "dev": true, "requires": { "ansi-colors": "^4.1.1", - "axios": "0.22.0", + "axios": "0.27.0", "bcrypt": "5.0.1", "bcryptjs": "^2.4.3", - "cli-table": "^0.3.4", + "cli-table": "^0.3.11", "enquirer": "^2.3.6", - "minimist": "^1.2.5", + "minimist": "^1.2.6", "mustache": "^4.2.0", "read": "^1.0.7" }, "dependencies": { "axios": { - "version": "0.22.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.22.0.tgz", - "integrity": "sha512-Z0U3uhqQeg1oNcihswf4ZD57O3NrR1+ZXhxaROaWpDmsDTx7T2HNBV2ulBtie2hwJptu8UvgnJoK+BIqdzh/1w==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.0.tgz", + "integrity": "sha512-XV/WrPxXfzgZ8j4lcB5i6LyaXmi90yetmV/Fem0kmglGx+mpY06CiweL3YxU6wOTNLmqLUePW4G8h45nGZ/+pA==", "dev": true, "requires": { - "follow-redirects": "^1.14.4" + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" } } } @@ -1901,34 +5143,44 @@ "boolbase": "^1.0.0" } }, - "oauth2orize": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/oauth2orize/-/oauth2orize-1.11.1.tgz", - "integrity": "sha512-9dSx/Gwm0J2Rvj4RH9+h7iXVnRXZ6biwWRgb2dCeQhCosODS0nYdM9I/G7BUGsjbgn0pHjGcn1zcCRtzj2SlRA==", + "number-allocator": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/number-allocator/-/number-allocator-1.0.10.tgz", + "integrity": "sha512-K4AvNGKo9lP6HqsZyfSr9KDaqnwFzW203inhQEOwFrmFaYevpdX4VNwdOLk197aHujzbT//z6pCBrCOUYSM5iw==", "dev": true, "requires": { - "debug": "2.x.x", - "uid2": "0.0.x", - "utils-merge": "1.x.x" + "debug": "^4.3.1", + "js-sdsl": "^2.1.2" }, "dependencies": { "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "2.1.2" } }, "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } }, + "oauth2orize": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/oauth2orize/-/oauth2orize-1.11.1.tgz", + "integrity": "sha512-9dSx/Gwm0J2Rvj4RH9+h7iXVnRXZ6biwWRgb2dCeQhCosODS0nYdM9I/G7BUGsjbgn0pHjGcn1zcCRtzj2SlRA==", + "dev": true, + "requires": { + "debug": "2.x.x", + "uid2": "0.0.x", + "utils-merge": "1.x.x" + } + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -1987,9 +5239,9 @@ "dev": true }, "passport": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/passport/-/passport-0.5.0.tgz", - "integrity": "sha512-ln+ue5YaNDS+fes6O5PCzXKSseY5u8MYhX9H5Co4s+HfYI5oqvnHKoOORLYDUPh+8tHvrxugF2GFcUA1Q1Gqfg==", + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/passport/-/passport-0.5.2.tgz", + "integrity": "sha512-w9n/Ot5I7orGD4y+7V3EFJCQEznE5RxHamUxcqLT2QoJY0f2JdN8GyHonYFvN0Vz+L6lUJfVhrk2aZz2LbuREw==", "dev": true, "requires": { "passport-strategy": "1.x.x", @@ -2083,9 +5335,9 @@ "dev": true }, "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "version": "6.9.6", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.6.tgz", + "integrity": "sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ==", "dev": true }, "quick-lru": { @@ -2107,15 +5359,32 @@ "dev": true }, "raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", + "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", "dev": true, "requires": { - "bytes": "3.1.0", - "http-errors": "1.7.2", + "bytes": "3.1.2", + "http-errors": "1.8.1", "iconv-lite": "0.4.24", "unpipe": "1.0.0" + }, + "dependencies": { + "bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "dev": true + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + } } }, "read": { @@ -2171,10 +5440,10 @@ "lowercase-keys": "^2.0.0" } }, - "retry": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/retry/-/retry-0.6.1.tgz", - "integrity": "sha1-/ckO7ZQ/3hG4k1VLjMY9DombqRg=", + "rfdc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", + "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==", "dev": true }, "rimraf": { @@ -2212,12 +5481,29 @@ "dev": true, "requires": { "lru-cache": "^6.0.0" + }, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } } }, "send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "version": "0.17.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", + "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==", "dev": true, "requires": { "debug": "2.6.9", @@ -2227,31 +5513,14 @@ "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.7.2", + "http-errors": "1.8.1", "mime": "1.6.0", - "ms": "2.1.1", + "ms": "2.1.3", "on-finished": "~2.3.0", "range-parser": "~1.2.1", "statuses": "~1.5.0" }, "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - }, - "dependencies": { - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, "mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", @@ -2259,23 +5528,23 @@ "dev": true }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true } } }, "serve-static": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", - "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz", + "integrity": "sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ==", "dev": true, "requires": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.17.1" + "send": "0.17.2" } }, "set-blocking": { @@ -2286,15 +5555,15 @@ "optional": true }, "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "dev": true }, "signal-exit": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz", - "integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==", + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true, "optional": true }, @@ -2331,6 +5600,15 @@ "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=", "dev": true }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "requires": { + "safe-buffer": "~5.2.0" + } + }, "string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -2343,15 +5621,6 @@ "strip-ansi": "^6.0.1" } }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "requires": { - "safe-buffer": "~5.2.0" - } - }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -2374,12 +5643,26 @@ "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" + }, + "dependencies": { + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } } }, "toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", "dev": true }, "tough-cookie": { @@ -2409,9 +5692,9 @@ "optional": true }, "tslib": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", - "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", "dev": true }, "type-is": { @@ -2422,6 +5705,14 @@ "requires": { "media-typer": "0.3.0", "mime-types": "~2.1.24" + }, + "dependencies": { + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "dev": true + } } }, "typedarray": { @@ -2431,9 +5722,9 @@ "dev": true }, "uglify-js": { - "version": "3.14.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.4.tgz", - "integrity": "sha512-AbiSR44J0GoCeV81+oxcy/jDOElO2Bx3d0MfQCUShq7JRXaM4KtQopZsq2vFv8bCq2yMaGrw1FgygUd03RyRDA==", + "version": "3.15.1", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.1.tgz", + "integrity": "sha512-FAGKF12fWdkpvNJZENacOH0e/83eG6JyVQyanIJaBXCN1J11TUQv1T1/z8S+Z0CG0ZPk1nPcreF/c7lrTd0TEQ==", "dev": true }, "uid-safe": { @@ -2531,10 +5822,11 @@ "dev": true }, "ws": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.1.tgz", - "integrity": "sha512-2c6faOUH/nhoQN6abwMloF7Iyl0ZS2E9HGtsiLrWn0zOOMWlhtDmdf/uihDt6jnuCxgtwGBNy6Onsoy2s2O2Ow==", - "dev": true + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.6.tgz", + "integrity": "sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA==", + "dev": true, + "requires": {} }, "xml2js": { "version": "0.4.23", @@ -2559,9 +5851,9 @@ "dev": true }, "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", "dev": true } } diff --git a/src/connector/node-red-contrib-tdengine/tdengine.html b/src/connector/node-red-contrib-tdengine/tdengine.html index 5d98b6ec51826c0af7ee39674973bfb6403a340f..c7a23e1fb1fbcbf293ce14d5dec787551285d079 100644 --- a/src/connector/node-red-contrib-tdengine/tdengine.html +++ b/src/connector/node-red-contrib-tdengine/tdengine.html @@ -22,7 +22,7 @@ } }, label: function () { - return this.host || "TDEngine host"; + return this.host || "TDengine host"; } }); @@ -49,7 +49,7 @@ \ No newline at end of file +

TDengine Query

+

Execute SQL on remote TDengine server by restful API

+ diff --git a/src/connector/odbc/examples/c/main.c b/src/connector/odbc/examples/c/main.c index de01d2b85eda0a6851ceede8b1932ce6d9231595..e84f772f6d332d5acdacf594cd41065e488d4b12 100644 --- a/src/connector/odbc/examples/c/main.c +++ b/src/connector/odbc/examples/c/main.c @@ -203,6 +203,9 @@ static int do_statement(SQLHSTMT stmt, const char *statement) { fprintf(stdout, "\n"); } } while (0); + if (r==SQL_SUCCESS || r==SQL_NO_DATA) + return SQL_SUCCESS; + return r; } diff --git a/src/connector/odbc/src/base/tsdb_impl.c b/src/connector/odbc/src/base/tsdb_impl.c index eebe96c7ff108236f36c0886369db8adc6dbe051..a2e37d481666909362f74083095df3a3a523509d 100644 --- a/src/connector/odbc/src/base/tsdb_impl.c +++ b/src/connector/odbc/src/base/tsdb_impl.c @@ -190,17 +190,20 @@ static SQLRETURN tsdb_conn_connect(conn_t *conn) { conn_val_t *val = &conn->val; const char *dsn = val->dsn; + const char *driver = val->driver; const char *uid = val->uid; const char *pwd = val->pwd; const char *db = val->db; const char *svr = val->server; - OILE(dsn, ""); + OILE(dsn || driver, ""); int use_default = 0; char server[4096]; server[0] = '\0'; if (!svr || !svr[0]) { - int n = SQLGetPrivateProfileString(dsn, "Server", "", server, sizeof(server)-1, "Odbc.ini"); + const char *filename = dsn ? "Odbc.ini" : "odbcinst.ini"; + int n; + n = SQLGetPrivateProfileString(dsn, "Server", "", server, sizeof(server)-1, filename); if (n<=0) { snprintf(server, sizeof(server), DEFAULT_SERVER); n = (int)strlen(server); diff --git a/src/connector/odbc/src/todbc_flex.h b/src/connector/odbc/src/todbc_flex.h index 762ffba0bec7bcfd47f45ad4475d08f20dc2375a..347a8dc0d7dfff35b2641e833fb010fae134aef7 100644 --- a/src/connector/odbc/src/todbc_flex.h +++ b/src/connector/odbc/src/todbc_flex.h @@ -40,6 +40,7 @@ struct map_tsdb_type_s { typedef struct conn_val_s conn_val_t; struct conn_val_s { char *dsn; + char *driver; char *uid; char *pwd; char *db; diff --git a/src/connector/odbc/src/todbc_scanner.l b/src/connector/odbc/src/todbc_scanner.l index b36c894f73cd7d8eb3b1642eb8b9c3bb433f2a5b..ef558efb93bf3ef02cf2a2aa06b5be10d9f4e3f2 100644 --- a/src/connector/odbc/src/todbc_scanner.l +++ b/src/connector/odbc/src/todbc_scanner.l @@ -46,6 +46,10 @@ do { \ free(yyextra->dsn); \ yyextra->dsn = strdup(yytext); \ } break; \ + case DRIVER: { \ + free(yyextra->driver); \ + yyextra->driver = strdup(yytext); \ + } break; \ case UID: { \ free(yyextra->uid); \ yyextra->uid = strdup(yytext); \ @@ -121,7 +125,7 @@ do { %option 8bit %option case-insensitive -%x DSN UID PWD SERVER DB +%x DSN DRIVER UID PWD SERVER DB %x ENC_CHAR ENC_WCHAR ENC_DB ENC_LOCAL %x TSDB_FLOAT TSDB_BIGINT %x KEY EQ BRACE1 BRACE2 VAL @@ -132,6 +136,7 @@ do { if (state == VAL) yyterminate(); FAIL(); } [[:space:]]+ { } +"DRIVER" { PUSH_STATE(DRIVER); } "DSN" { PUSH_STATE(DSN); } "UID" { PUSH_STATE(UID); } "PWD" { PUSH_STATE(PWD); } @@ -146,9 +151,9 @@ do { [[:alnum:]_]+ { PUSH_STATE(KEY); } .|\n { FAIL(); } -[[:space:]]+ { } -[=] { PUSH_STATE(EQ); } -.|\n { FAIL(); } +[[:space:]]+ { } +[=] { PUSH_STATE(EQ); } +.|\n { FAIL(); } [[:space:]]+ { } [{] { CHG_STATE(BRACE1); } @@ -181,7 +186,7 @@ int todbc_parse_conn_string(const char *conn, conn_val_t *val) { yy_scan_string(conn, arg); int ret =yylex(arg); yylex_destroy(arg); - if (ret || !val->dsn) { + if (ret || (!val->dsn && !val->driver)) { conn_val_reset(val); } else { if (!val->uid) { @@ -201,6 +206,9 @@ void conn_val_reset(conn_val_t *val) { if (val->dsn) { free(val->dsn); val->dsn = NULL; } + if (val->driver) { + free(val->driver); val->driver = NULL; + } if (val->uid) { free(val->uid); val->uid = NULL; } diff --git a/src/kit/taos-tools b/src/kit/taos-tools index d25265d2449c2db91dfd1e4789876c553da3e950..0aad27d725f4ee6b18daf1db0c07d933aed16eea 160000 --- a/src/kit/taos-tools +++ b/src/kit/taos-tools @@ -1 +1 @@ -Subproject commit d25265d2449c2db91dfd1e4789876c553da3e950 +Subproject commit 0aad27d725f4ee6b18daf1db0c07d933aed16eea diff --git a/tests/pytest/util/buildClusterEnv.sh b/tests/pytest/util/buildClusterEnv.sh index f31fafa19b4af1618d499dd8f03c133c3444a307..e1f17ccd08062ea19c9a6221f4f6d1c7b6da1b4d 100755 --- a/tests/pytest/util/buildClusterEnv.sh +++ b/tests/pytest/util/buildClusterEnv.sh @@ -44,7 +44,7 @@ function prepareBuild { if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then if [ ! -e $DOCKER_DIR/TDengine-enterprise-server-$VERSION-Linux-x64.tar.gz ] || [ ! -e $DOCKER_DIR/TDengine-enterprise-arbitrator-$VERSION-Linux-x64.tar.gz ]; then - echo "generating TDeninge enterprise packages" + echo "generating TDengine enterprise packages" ./release.sh -v cluster -n $VERSION >> /dev/null 2>&1 if [ ! -e $CURR_DIR/../../release/TDengine-enterprise-server-$VERSION-Linux-x64.tar.gz ]; then @@ -64,7 +64,7 @@ function prepareBuild { else if [ ! -e $DOCKER_DIR/TDengine-server-$VERSION-Linux-x64.tar.gz ] || [ ! -e $DOCKER_DIR/TDengine-arbitrator-$VERSION-Linux-x64.tar.gz ]; then - echo "generating TDeninge community packages" + echo "generating TDengine community packages" ./release.sh -v edge -n $VERSION >> /dev/null 2>&1 if [ ! -e $CURR_DIR/../../release/TDengine-server-$VERSION-Linux-x64.tar.gz ]; then @@ -118,4 +118,4 @@ function clusterUp { } prepareBuild -clusterUp \ No newline at end of file +clusterUp