1 简介
Apache IoTDB 是一个开源物联网时序数据库。
github地址:https://github.com/apache/iotdb
2 下载
下载地址:https://iotdb.apache.org/Download/
下载,输入命令:
wget https://archive.apache.org/dist/iotdb/1.0.0/apache-iotdb-1.0.0-all-bin.zip
下载完成后,解压,输入命令:
unzip apache-iotdb-1.0.0-all-bin.zip
解压后,修改目录名称为iotdb(路径简单一些)。
3 试用
第1步:进入sbin目录启动IoTDB:
第2步:启动Cli 工具,输入命令:
./start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root
启动成功后下图所示:
第3步:创建数据库,输入命令:
create database root.test
第4步:查看数据库,确保创建成功,输入命令:
show databases
第5步:创建时间序列:
IoTDB> CREATE TIMESERIES root.test.d001.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN
Msg: The statement is executed successfully.
IoTDB> CREATE TIMESERIES root.test.d001.temperature WITH DATATYPE=FLOAT, ENCODING=RLE
Msg: The statement is executed successfully.
第6步:查询时间序列,输入命令:
show timeseries
也可以查询具体的时间序列root.test.d001.status,输入命令:
show timeseries root.test.d001.status
第7步:手动插入数据。
IoTDB> INSERT INTO root.test.d001(timestamp,status) values(100,true);
Msg: The statement is executed successfully.
IoTDB> INSERT INTO root.test.d001(timestamp,status,temperature) values(200,false,26.3)
Msg: The statement is executed successfully.
第8步:查询数据。
IoTDB> SELECT * FROM root.test.d001
+-----------------------------+--------------------------+---------------------+
| Time|root.test.d001.temperature|root.test.d001.status|
+-----------------------------+--------------------------+---------------------+
|1970-01-01T08:00:00.100+08:00| null| true|
|1970-01-01T08:00:00.200+08:00| 26.3| false|
+-----------------------------+--------------------------+---------------------+
Total line number = 2