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 availableJAVA_HOME
is set upOperating 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
orsystemctl start iotdb-datanode
, you can stop IoTDB using thesbin/stop-confignode.sh
orsbin/stop-datanode.sh
scripts. In this case, the corresponding nodes will not automatically restart.When starting IoTDB with
sbin/start-confignode.sh
orsbin/start-datanode.sh
, the process status cannot be observed usingsystemctl
(it is recommended to usesystemctl
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 orsystemctl stop
)
Precautions
IoTDB logs are located in the
logs
directory within the IoTDB installation directory.After starting, you can use
start-cli.sh
to executeshow 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 remainsactive (running)
after 10 minutes, the service has successfully started.If the status is
failed
, you need to check the logs, resolve the issues, then runsystemctl daemon-reload
before starting the service again withsystemctl
.
How to Adjust Default Service Configuration
Method 1
Modify the [Unit], [Service], and [Install] section configurations in
daemon-confignode.sh
anddaemon-datanode.sh
. For detailed explanations of the configuration items, refer to the appendix.Execute the
daemon-confignode.sh
anddaemon-datanode.sh
scripts.
Method 2
Modify the
iotdb-confignode.service
andiotdb-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.