Getting Started with IoTDB
IoTDB is a data management engine that integrates collection, storage, and analysis of time series data. It features lightweight, high performance, and ease of use. It can connect to Hadoop and Spark ecosystems and meets the requirements of high-speed write and complex analysis and query on massive time series data in industrial IoT applications.
Background
Assume that a group has three production lines with five devices on each. Sensors collect indicators (such as temperature, speed, and running status) of these devices in real time, as shown in Figure 1. The service process of storing and managing data using IoTDB is as follows:
- Create a storage group named root.Group name to represent the group.
- Create time series to store the device indicators.
- Simulate sensors and record indicators.
- Run SQL statements to query indicators.
- After the service is complete, delete the stored data.
Procedure
- Log in to the client.
- Log in to the node where the client is installed as the client installation user and run the following command to switch to the client installation directory, for example, /opt/client.
cd /opt/client
- Run the following command to configure environment variables:
- Before logging in to the IoTDB client for the first time, perform the following steps to generate a client SSL certificate:
- Run the following command to generate a client SSL certificate:
keytool -noprompt -import -alias myservercert -file ca.crt -keystore truststore.jks
After running this command, you are required to set a password.
- Copy the generated truststore.jks file to the Client installation directory/IoTDB/iotdb/conf directory.
cp truststore.jks Client installation directory/IoTDB/iotdb/conf
- Run the following command to generate a client SSL certificate:
- If Kerberos authentication is enabled for the current cluster, run the following command to authenticate the current user. The current user must have the permission to create IoTDB tables. For details, see IoTDB User Permission Management. If Kerberos authentication is disabled for the current cluster, skip this step.
kinit MRS cluster user
Example:
kinit iotdbuser
- Log in to the node where the client is installed as the client installation user and run the following command to switch to the client installation directory, for example, /opt/client.
- Run the following command to switch to the directory where the script for running IoTDB client is stored:
cd /opt/client/IoTDB/iotdb/sbin
- If Kerberos authentication is disabled for the cluster (the cluster is in normal mode), invoke the alter-cli-password.sh script to change the default password of the default user root.
sh alter-cli-password.sh IP address of the IoTDBServer instance RPC port number
- To view the IP address of the IoTDBServer instance node, log in to FusionInsight Manager and choose Cluster > Services > IoTDB > Instances.
- The IoTDBServer RPC port can be configured in the IoTDB_SERVER_RPC_PORT parameter. The default ports are as follows:
- The default open-source port number is 6667.
- The default customized port number is 22260.
Port customization/open source: When creating an LTS version cluster, you can set Component Port to Open source or Custom. If Open source is selected, the open source port is used. If Custom is selected, the customized port is used.
- The initial password of user root is root in versions earlier than MRS 3.3.0 and Iotdb@123 in MRS 3.3.3.0 and later versions.
The password must contain at least four characters in versions earlier than MRS 3.3.0 and at least eight characters in MRS 3.3.0 and later versions, and cannot contain spaces.
- Run the following command to log in to the client:
./start-cli.sh -h IP address of the IoTDBServer instance node -p IoTDBServer RPC port
The default IoTDBServer RPC can be configured in the IOTDB_SERVER_RPC_PORT parameter.
After running this command, specify the service username as needed (user root is used for login when Kerberos authentication is disabled for the cluster (the cluster is in normal mode)).
- To specify the service username, enter yes and enter the service username and password as prompted.
- If you will not specify the service username, enter no. In this case, you will perform subsequent operations as the user in 1.d.
- If you enter other information, you will log out.
- To specify the service username, enter yes and enter the service username and password as prompted.
- Create a storage group/database (MRS 3.3.0 and later versions) named root.company based on Figure 1.
set storage group to root.company;
- Create corresponding time series for sensors of the devices on the production line.
create timeseries root.company.line1.device1.spin WITH DATATYPE=FLOAT, ENCODING=RLE;
create timeseries root.company.line1.device1.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN;
create timeseries root.company.line1.device2.temperature WITH DATATYPE=FLOAT, ENCODING=RLE;
create timeseries root.company.line1.device2.power WITH DATATYPE=FLOAT, ENCODING=RLE;
create timeseries root.company.line2.device1.temperature WITH DATATYPE=FLOAT, ENCODING=RLE;
create timeseries root.company.line2.device1.speed WITH DATATYPE=FLOAT, ENCODING=RLE;
create timeseries root.company.line2.device2.speed WITH DATATYPE=FLOAT, ENCODING=RLE;
create timeseries root.company.line2.device2.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN;
- Adds data to time series.
insert into root.company.line1.device1(timestamp, spin) values (now(), 6684.0);
insert into root.company.line1.device1(timestamp, status) values (now(), false);
insert into root.company.line1.device2(timestamp, temperature) values (now(), 66.7);
insert into root.company.line1.device2(timestamp, power) values (now(), 996.4);
insert into root.company.line2.device1(timestamp, temperature) values (now(), 2684.0);
insert into root.company.line2.device1(timestamp, speed) values (now(), 120.23);
insert into root.company.line2.device2(timestamp, speed) values (now(), 130.56);
insert into root.company.line2.device2(timestamp, status) values (now(), false);
- Query indicators of all devices on the production line 1.
select * from root.company.line1.**;
+-----------------------------+-------------------------------+---------------------------------+--------------------------------------+--------------------------------+ | Time|root.company.line1.device1.spin|root.company.line1.device1.status|root.company.line1.device2.temperature|root.company.line1.device2.power| +-----------------------------+-------------------------------+---------------------------------+--------------------------------------+--------------------------------+ |2021-06-17T11:29:08.131+08:00| 6684.0| null| null| null| |2021-06-17T11:29:08.220+08:00| null| false| null| null| |2021-06-17T11:29:08.249+08:00| null| null| 66.7| null| |2021-06-17T11:29:08.282+08:00| null| null| null| 996.4| +-----------------------------+-------------------------------+---------------------------------+--------------------------------------+--------------------------------+
- Delete all device indicators on the production line 2.
delete timeseries root.company.line2.**;
Query the indicator data on production line 2. The result shows no indicator data exists.
select * from root.company.line2.**;
+----+ |Time| +----+ +----+ Empty set.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot