Auto-start on Boot of Apache IoTDB Cluster

Apache IoTDB is a high-performance time series database designed specifically for the industrial Internet of Things (IoT). In the production environment where an IoTDB cluster is deployed, it is crucial to ensure system stability. This article introduces how to manage the IoTDB cluster through Linux system services, achieving efficient startup, monitoring, and automatic restart.

The traditional methods of starting IoTDB have some limitations, such as requiring additional parameters for background startup and lacking features like automatic retry and boot-time startup. To address these issues, IoTDB introduced the daemon-confignode.sh and daemon-datanode.sh scripts in version V1.3.1 to register IoTDB as a system service.

Environment Requirements

  • Linux system

  • systemctl command available

  • JAVA_HOME is set up

  • Operating user is root or has corresponding permissions

Introduction to New Scripts

  • sbin/daemon-confignode.sh registers IoTDB ConfigNode as a system service.

  • sbin/daemon-datanode.sh registers IoTDB DataNode as a system service.

After executing the scripts, IoTDB's ConfigNode and DataNode will be registered as system services. The service files will be generated in the /etc/systemd/system directory. We can use the systemctl command to manage these services.

Usage Instructions

Start the Service Manually

systemctl start iotdb-confignode
systemctl start iotdb-datanode

Configure Auto-Start on Boot

systemctl enable iotdb-confignode
systemctl enable iotdb-datanode

Disable Auto-Start on Boot

systemctl disable iotdb-confignode
systemctl disable iotdb-datanode

Stop the Service

systemctl stop iotdb-confignode
systemctl stop iotdb-datanode

After stopping the service, the status should be inactive (dead); otherwise, check the logs to analyze the issue.

Note:

  • When starting IoTDB with systemctl start iotdb-confignode or systemctl start iotdb-datanode, you can stop IoTDB using the sbin/stop-confignode.sh or sbin/stop-datanode.sh scripts. In this case, the corresponding nodes will not automatically restart.

  • When starting IoTDB with sbin/start-confignode.sh or sbin/start-datanode.sh, the process status cannot be observed using systemctl (it is recommended to use systemctl for starting and stopping).

Check the Status

systemctl status iotdb-confignode
systemctl status iotdb-datanode

Restart the Service

systemctl restart iotdb-confignode
systemctl restart iotdb-datanode

Service Features

The service will have the following features:

  • Automatic restart on startup failure

  • Automatic restart on abnormal exit (e.g., Java process out of memory or JVM crash)

  • No automatic restart on normal exit (e.g., using the kill command or systemctl stop)

Precautions

  • IoTDB logs are located in the logs directory within the IoTDB installation directory.

  • After starting, you can use start-cli.sh to execute show cluster to check the cluster status.

  • When the status is active (running), it does not necessarily mean the service is fully started. If the status remains active (running) after 10 minutes, the service has successfully started.

  • If the status is failed, you need to check the logs, resolve the issues, then run systemctl daemon-reload before starting the service again with systemctl.

How to Adjust Default Service Configuration

Method 1

  • Modify the [Unit], [Service], and [Install] section configurations in daemon-confignode.sh and daemon-datanode.sh. For detailed explanations of the configuration items, refer to the appendix.

  • Execute the daemon-confignode.sh and daemon-datanode.sh scripts.

Method 2

  • Modify the iotdb-confignode.service and iotdb-datanode.service files in /etc/systemd/system.

  • Execute systemctl daemon-reload.

Summary

This article provides a detailed guide on efficiently managing IoTDB clusters through Linux system services, focusing on achieving automatic startup, monitoring, and restarting. To overcome the limitations of traditional startup methods, IoTDB introduced the daemon-confignode.sh and daemon-datanode.sh scripts in version 1.3.1, allowing IoTDB to be registered as a system service.

The methods described in this article can significantly improve the management efficiency of IoTDB clusters in production environments, ensuring stable operation and achieving efficient startup, monitoring, and automatic restart. We encourage everyone to use these practices.