33 Star 124 Fork 42

重点研发计划2017 / incubator-iotdb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

English | 中文

IoTDB

Build Status coveralls GitHub release License IoTDB Website Maven Version

简介

IoTDB (Internet of Things Database) 是一个时序数据的数据管理系统,可以为用户提供数据收集、存储和分析等特定的服务。IoTDB由于其轻量级的结构、高性能和可用的特性,以及与Hadoop和Spark生态的无缝集成,满足了工业IoTDB领域中海量数据存储、高吞吐量数据写入和复杂数据分析的需求。

主要特点

IoTDB的主要特点如下:

  1. 灵活的部署策略。IoTDB为用户提供了一个在云平台或终端设备上的一键安装工具,以及一个连接云平台和终端上的数据的数据同步工具。
  2. 硬件成本低。IoTDB可以达到很高的磁盘存储压缩比。
  3. 高效的目录结构。IoTDB支持智能网络设备对复杂时间序列数据结构的高效组织,同类设备对时间序列数据的组织,海量复杂时间序列数据目录的模糊搜索策略。
  4. 高吞吐量读写。IoTDB支持数以百万计的低功耗设备的强连接数据访问、高速数据读写,适用于上述智能网络设备和混合设备。
  5. 丰富的查询语义。IoTDB支持跨设备和测量的时间序列数据的时间对齐、时间序列字段的计算(频域转换)和时间维度的丰富聚合函数支持。
  6. 学习成本非常低。IoTDB支持类似sql的语言、JDBC标准API和易于使用的导入/导出工具。
  7. 与先进的开放源码生态系统的无缝集成。IoTDB支持分析生态系统,如Hadoop、Spark和可视化工具(如Grafana)。

有关IoTDB的最新信息,请访问IoTDB官方网站。如果您在使用IoTDB时遇到任何问题或发现任何bug,请在[jira]中提交(https://issues.apache.org/jira/projects/IOTDB/issues)。

目录

快速开始

这篇简短的指南将带您了解使用IoTDB的基本过程。如需更详细的介绍,请访问我们的网站用户指南

环境准备

要使用IoTDB,您需要:

  1. Java >= 1.8 (目前 1.8、11和13 已经被验证可用。请确保环变量境路径已正确设置)。
  2. Maven >= 3.1 (如果希望从源代码编译和安装IoTDB)。
  3. 设置 max open files 为 65535,以避免"too many open files"错误。

安装

IoTDB提供了三种安装方法,您可以参考以下建议,选择最适合您的一种:

  • 从源代码安装。如果需要自己修改代码,可以使用此方法。

  • 从二进制文件安装。推荐的方法是从官方网站下载二进制文件,您将获得一个开箱即用的二进制发布包。

  • 使用Docker: dockerfile的路径是https://github.com/apache/iotdb/tree/master/docker/src/main

在这篇《快速入门》中,我们简要介绍如何使用源代码安装IoTDB。如需进一步资料,请参阅《用户指南》第3章。

从源码构建

如果您使用Windows,请跳过此段。我们使用Thrift作为RPC模块来提供客户端-服务器间的通信和协议支持,因此在编译阶段我们需要使用Thrift 0.13.0 (或更高)编译器生成对应的Java代码。Thrift只提供了Windows下的二进制编译器,Unix下需要通过源码自行编译。但我们预先编译了一个Thrift编译器,并将其上传到了GitHub ,借助一个Maven插件,在编译时可以自动将其下载。该预编译的Thrift编译器在gcc8,Ubuntu, CentOS, MacOS下可以工作,但是在更低的gcc 版本以及其他操作系统上尚未确认。如果您在编译时发现了Thrift编译器相关的问题,请升级您的gcc版本或者依照Thrift 官方的指示自行编译编译器,并将编译器放置到目录{project_root}\thrift\target\tools\thrift_0.12.0_0.13.0_linux.exe。 如果您已经安装了一个兼容的Thrift编译器,您可以在运行Maven时通过以下参数指定使用您的编译器:-Dthrift.download-url=http://apache.org/licenses/LICENSE-2.0.txt -Dthrift.exec.absolute.path=<YOUR LOCAL THRIFT BINARY FILE>。 您也可以使用以下Maven参数来更换Thrift编译器的下载地址:-Dthrift.download-url=<THE REMOTE URL FOR DOWNLOADING> -Dthrift.exec.absolute.path=<THE DOWNLOADED BINARY FILE NAME>。 如果您对Maven足够熟悉,您也可以直接修改我们的根pom文件来避免每次编译都使用上述参数。 Thrift官方网址为:https://thrift.apache.org/

从 git 克隆源代码:

git clone https://github.com/apache/iotdb.git

默认的主分支是dev分支,如果你想使用某个发布版本x.x.x,请切换分支:

git checkout release/x.x.x

在 iotdb 根目录下执行 maven 编译:

> mvn clean package -DskipTests

执行完成之后,可以在distribution/target/apache-iotdb-{project.version}-bin.zip找到编译完成的二进制版本(包括服务器和客户端)

注意:"thrift/target/generated-sources/thrift" 和 "antlr/target/generated-sources/antlr4" 目录需要添加到源代码根中,以免在 IDE 中产生编译错误。

配置

配置文件在"conf"文件夹下

  • 环境配置模块(iotdb-env.bat, iotdb-env.sh),
  • 系统配置模块(iotdb-engine.properties)
  • 日志配置模块(logback.xml)。

有关详细信息,请参见Chapter3: Server

开始

您可以通过以下步骤来测试安装,如果执行后没有返回错误,安装就完成了。

启动 IoTDB

可以通过运行 sbin 文件夹下的 start-server 脚本启动 IoTDB。

# Unix/OS X
> nohup sbin/start-server.sh >/dev/null 2>&1 &
or
> nohup sbin/start-server.sh -c <conf_path> -rpc_port <rpc_port> >/dev/null 2>&1 &

# Windows
> sbin\start-server.bat -c <conf_path> -rpc_port <rpc_port>
  • "-c" and "-rpc_port" 都是可选的。
  • 选项 "-c" 指定了配置文件所在的文件夹。
  • 选项 "-rpc_port" 指定了启动的 rpc port。
  • 如果两个选项同时指定,那么rpc_port将会覆盖conf_path下面的配置。

使用 IoTDB

使用 Cli 命令行

IoTDB提供了与服务器交互的不同方式,这里我们将介绍使用 Cli 工具插入和查询数据的基本步骤。

安装 IoTDB 后,有一个默认的用户root,它的默认密码也是root。用户可以使用这个 默认用户登录 Cli 并使用 IoTDB。Cli 的启动脚本是 sbin 文件夹中的 start-cli 脚本。 在执行脚本时,用户应该指定 IP,端口,USER_NAME 和 密码。默认参数为-h 127.0.0.1 -p 6667 -u root -pw root

下面是启动 Cli 的命令:

# Unix/OS X
> sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root

# Windows
> sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root

命令行客户端是交互式的,所以如果一切就绪,您应该看到欢迎标志和声明:

 _____       _________  ______   ______
|_   _|     |  _   _  ||_   _ `.|_   _ \
  | |   .--.|_/ | | \_|  | | `. \ | |_) |
  | | / .'`\ \  | |      | |  | | |  __'.
 _| |_| \__. | _| |_    _| |_.' /_| |__) |
|_____|'.__.' |_____|  |______.'|_______/  version x.x.x


IoTDB> login successfully
IoTDB>

基本的 IoTDB 命令

现在,让我们介绍创建 timeseries、插入数据和查询数据的方法。

IoTDB中的数据组织为 timeseries。每个 timeseries 包含多个数据-时间对,由一个存储组拥有。 在定义 timeseries 之前,我们应该先使用SET storage group来定义一个存储组,下面是一个例子:

IoTDB> SET STORAGE GROUP TO root.ln

我们也可以使用SHOW STORAGE GROUP来检查正在创建的存储组:

IoTDB> SHOW STORAGE GROUP
+-----------------------------------+
|                      Storage Group|
+-----------------------------------+
|                            root.ln|
+-----------------------------------+
storage group number = 1

在设置存储组之后,我们可以使用CREATE TIMESERIES来创建一个新的TIMESERIES。 在创建 timeseries 时,我们应该定义它的数据类型和编码方案。这里我们创建两个 timeseries:

IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN
IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=RLE

为了查询特定的timeseries,我们可以使用 SHOW TIMESERIES <Path>. 表示被查询的 timeseries 的路径. 默认值是null, 表示查询系统中所有的 timeseries (同SHOW TIMESERIES root). 以下是一些示例:

  1. 查询系统中所有 timeseries:
IoTDB> SHOW TIMESERIES
+-------------------------------+------+-------------+--------+--------+-----------+----+----------+
|                   timeseries  | alias|storage group|dataType|encoding|compression|tags|attributes|
+-------------------------------+------+-------------+--------+--------+-----------+----+----------+
|       root.ln.wf01.wt01.status|  null|      root.ln| BOOLEAN|   PLAIN|     SNAPPY|null|      null|
|  root.ln.wf01.wt01.temperature|  null|      root.ln|   FLOAT|     RLE|     SNAPPY|null|      null|
+-------------------------------+------+-------------+--------+--------+-----------+----+----------+
Total timeseries number = 2
  1. 查询指定的 timeseries(root.ln.wf01.wt01.status):
IoTDB> SHOW TIMESERIES root.ln.wf01.wt01.status
+-------------------------------+------+-------------+--------+--------+-----------+----+----------+
|                   timeseries  | alias|storage group|dataType|encoding|compression|tags|attributes|
+-------------------------------+------+-------------+--------+--------+-----------+----+----------+
|       root.ln.wf01.wt01.status|  null|      root.ln| BOOLEAN|   PLAIN|     SNAPPY|null|      null|
+-------------------------------+------+-------------+--------+--------+-----------+----+----------+
Total timeseries number = 1

插入 timeseries 数据是IoTDB的一个基本操作,你可以使用INSERT 命令来完成这个操作。 在插入之前,您应该指定时间戳和后缀路径名:

IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status) values(100,true);
IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status,temperature) values(200,false,20.71)

你刚才插入的数据会显示如下:

IoTDB> SELECT status FROM root.ln.wf01.wt01
+-----------------------+------------------------+
|                   Time|root.ln.wf01.wt01.status|
+-----------------------+------------------------+
|1970-01-01T08:00:00.100|                    true|
|1970-01-01T08:00:00.200|                   false|
+-----------------------+------------------------+
Total line number = 2

您还可以使用一条SQL语句查询多个 timeseries 数据:

IoTDB> SELECT * FROM root.ln.wf01.wt01
+-----------------------+--------------------------+-----------------------------+
|                   Time|  root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
+-----------------------+--------------------------+-----------------------------+
|1970-01-01T08:00:00.100|                      true|                         null|
|1970-01-01T08:00:00.200|                     false|                        20.71|
+-----------------------+--------------------------+-----------------------------+
Total line number = 2

你可以使用如下命令退出:

IoTDB> quit
or
IoTDB> exit

有关IoTDB SQL支持的命令的更多信息,请参见SQL 参考文档

停止 IoTDB

server 可以使用 "ctrl-C" 或者执行下面的脚本:

# Unix/OS X
> sbin/stop-server.sh

# Windows
> sbin\stop-server.bat

只编译 server

在 iotdb 根目录下执行:

> mvn clean package -pl server -am -DskipTests

编译完成后, IoTDB server 将生成在: "server/target/iotdb-server-{project.version}".

只编译 cli

在 iotdb 根目录下执行:

> mvn clean package -pl cli -am -DskipTests

编译完成后, IoTDB cli 将生成在 "cli/target/iotdb-cli-{project.version}".

导入导出CSV工具

查看 导入导出CSV工具

常见编译错误

查看 常见编译错误

联系我们

QQ群

  • Apache IoTDB 交流群:659990460

Wechat Group

  • 添加好友 tietouqiao,我们会邀请您进群

获取更多内容,请查看 加入社区

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -------------------------------------------------------------------------------- APACHE IOTDB SUBCOMPONENTS -------------------------------------------------------------------------------- The following class is copied from maven-wrapper (https://github.com/takari/maven-wrapper), which is under Apache License 2.0: ./.mvn/wrapper/MavenWrapperDownloader.java -------------------------------------------------------------------------------- The following class is modified from Apache commons-collections ./tsfile/src/main/java/org/apache/iotdb/tsfile/utils/Murmur128Hash.java Relevant pr is: https://github.com/apache/commons-collections/pull/83/ -------------------------------------------------------------------------------- The following files include code modified from Michael Burman's gorilla-tsc project. ./tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/GorillaEncoderV2.java ./tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntGorillaEncoder.java ./tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongGorillaEncoder.java ./tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/SinglePrecisionEncoderV2.java ./tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DoublePrecisionEncoderV2.java ./tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/GorillaDecoderV2.java ./tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/IntGorillaDecoder.java ./tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/LongGorillaDecoder.java ./tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/SinglePrecisionDecoderV2.java ./tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/DoublePrecisionDecoderV2.java Copyright: 2016-2018 Michael Burman and/or other contributors Project page: https://github.com/burmanm/gorilla-tsc License: http://www.apache.org/licenses/LICENSE-2.0

简介

Apache IoTDB 是针对时间序列数据收集、存储与分析一体化的数据管理引擎。它具有体量轻、性能高、易使用的特点,完美对接Hadoop与Spark生态,适用于工业物联网应用中海量时间序列数据高速写入和复杂分析查询的需求。 展开 收起
Java 等 6 种语言
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/zdyfjh2017/incubator-iotdb.git
git@gitee.com:zdyfjh2017/incubator-iotdb.git
zdyfjh2017
incubator-iotdb
incubator-iotdb
master

搜索帮助