diff --git a/src/.vuepress/sidebar/V2.0.x/en-Table.ts b/src/.vuepress/sidebar/V2.0.x/en-Table.ts index 81d2082ba..e148e6ef6 100644 --- a/src/.vuepress/sidebar/V2.0.x/en-Table.ts +++ b/src/.vuepress/sidebar/V2.0.x/en-Table.ts @@ -122,6 +122,7 @@ export const enSidebar = { { text: 'Query Performance Analysis', link: 'Query-Performance-Analysis' }, { text: 'Cluster Maintenance', link: 'Load-Balance' }, { text: 'Maintenance statement', link: 'Maintenance-commands_apache' }, + { text: 'Auto-start On Boot', link: 'Auto-Start-On-Boot_apache' }, ], }, ], diff --git a/src/.vuepress/sidebar/V2.0.x/en-Tree.ts b/src/.vuepress/sidebar/V2.0.x/en-Tree.ts index 2aeebedea..11e04ad5f 100644 --- a/src/.vuepress/sidebar/V2.0.x/en-Tree.ts +++ b/src/.vuepress/sidebar/V2.0.x/en-Tree.ts @@ -138,6 +138,7 @@ export const enSidebar = { { text: 'Query Performance Analysis', link: 'Query-Performance-Analysis' }, { text: 'Cluster Maintenance', link: 'Load-Balance' }, { text: 'Maintenance statement', link: 'Maintenance-commands_apache' }, + { text: 'Auto-start On Boot', link: 'Auto-Start-On-Boot_apache' }, ], }, ], diff --git a/src/.vuepress/sidebar/V2.0.x/zh-Table.ts b/src/.vuepress/sidebar/V2.0.x/zh-Table.ts index 21403f9ca..b66faad96 100644 --- a/src/.vuepress/sidebar/V2.0.x/zh-Table.ts +++ b/src/.vuepress/sidebar/V2.0.x/zh-Table.ts @@ -120,6 +120,7 @@ export const zhSidebar = { { text: '查询性能分析', link: 'Query-Performance-Analysis' }, { text: '集群维护', link: 'Load-Balance' }, { text: '运维语句', link: 'Maintenance-statement_apache' }, + { text: '开机自启', link: 'Auto-Start-On-Boot_apache' }, ], }, ], diff --git a/src/.vuepress/sidebar/V2.0.x/zh-Tree.ts b/src/.vuepress/sidebar/V2.0.x/zh-Tree.ts index 79f701ecf..e3acde961 100644 --- a/src/.vuepress/sidebar/V2.0.x/zh-Tree.ts +++ b/src/.vuepress/sidebar/V2.0.x/zh-Tree.ts @@ -129,6 +129,7 @@ export const zhSidebar = { { text: '查询性能分析', link: 'Query-Performance-Analysis' }, { text: '集群维护', link: 'Load-Balance' }, { text: '运维语句', link: 'Maintenance-statement_apache' }, + { text: '开机自启', link: 'Auto-Start-On-Boot_apache' }, ], }, ], diff --git a/src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts b/src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts index 61aff83d8..49272a093 100644 --- a/src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts +++ b/src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts @@ -152,6 +152,7 @@ export const enSidebar = { { text: 'Query Performance Analysis', link: 'Query-Performance-Analysis' }, { text: 'Cluster Maintenance', link: 'Load-Balance' }, { text: 'Maintenance statement', link: 'Maintenance-commands_timecho' }, + { text: 'Auto-start On Boot', link: 'Auto-Start-On-Boot_timecho' }, ], }, ], diff --git a/src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts b/src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts index 584ffa5a3..dd2aad740 100644 --- a/src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts +++ b/src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts @@ -163,6 +163,7 @@ export const enSidebar = { { text: 'Query Performance Analysis', link: 'Query-Performance-Analysis' }, { text: 'Cluster Maintenance', link: 'Load-Balance' }, { text: 'Maintenance statement', link: 'Maintenance-commands_timecho' }, + { text: 'Auto-start On Boot', link: 'Auto-Start-On-Boot_timecho' }, ], }, ], diff --git a/src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts b/src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts index fce738581..4400dcae3 100644 --- a/src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts +++ b/src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts @@ -143,6 +143,7 @@ export const zhSidebar = { { text: '查询性能分析', link: 'Query-Performance-Analysis' }, { text: '集群维护', link: 'Load-Balance' }, { text: '运维语句', link: 'Maintenance-statement_timecho' }, + { text: '开机自启', link: 'Auto-Start-On-Boot_timecho' }, ], }, ], diff --git a/src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts b/src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts index 045833a63..a4cebbeb8 100644 --- a/src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts +++ b/src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts @@ -145,6 +145,7 @@ export const zhSidebar = { { text: '查询性能分析', link: 'Query-Performance-Analysis' }, { text: '集群维护', link: 'Load-Balance' }, { text: '运维语句', link: 'Maintenance-statement_timecho' }, + { text: '开机自启', link: 'Auto-Start-On-Boot_timecho' }, ], }, ], diff --git a/src/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_apache.md b/src/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_apache.md new file mode 100644 index 000000000..95bf83740 --- /dev/null +++ b/src/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_apache.md @@ -0,0 +1,213 @@ + + +# Auto-start on Boot +## 1. Overview +IoTDB supports registering ConfigNode, DataNode, and AINode as Linux system services via the three scripts `daemon-confignode.sh`, `daemon-datanode.sh`, and `daemon-ainode.sh`. Combined with the system-built `systemctl` command, it manages the IoTDB cluster in daemon mode, enabling more convenient startup, shutdown, restart, and auto-start on boot operations, and improving service stability. + +> Note: This feature is available starting from version 2.0.9-beta. + +## 2. Environment Requirements +| Item | Specification | +|--------------|-------------------------------------------------------------------------------| +| OS | Linux (supports the `systemctl` command) | +| User Privilege | root user | +| Environment Variable | `JAVA_HOME` must be set before deploying ConfigNode and DataNode | + +## 3. Service Registration +Enter the IoTDB installation directory and execute the corresponding daemon script: + +```bash +# Register ConfigNode service +./tools/ops/daemon-confignode.sh + +# Register DataNode service +./tools/ops/daemon-datanode.sh + +# Register AINode service +./tools/ops/daemon-ainode.sh +``` + +During script execution, you will be prompted with two options: +1. Whether to start the corresponding IoTDB service immediately (iotdb-confignode / iotdb-datanode / iotdb-ainode); +2. Whether to register the corresponding service for auto-start on boot. + +After script execution, the corresponding service files will be generated in the `/etc/systemd/system/` directory: +- `iotdb-confignode.service` +- `iotdb-datanode.service` +- `iotdb-ainode.service` + +## 4. Service Management +After service registration, you can use `systemctl` commands to start, stop, restart, check status, and configure auto-start on boot for each IoTDB node service. All commands below must be executed as the root user. + +### 4.1 Manual Service Startup +```bash +# Start ConfigNode service +systemctl start iotdb-confignode +# Start DataNode service +systemctl start iotdb-datanode +# Start AINode service +systemctl start iotdb-ainode +``` + +### 4.2 Manual Service Shutdown +```bash +# Stop ConfigNode service +systemctl stop iotdb-confignode +# Stop DataNode service +systemctl stop iotdb-datanode +# Stop AINode service +systemctl stop iotdb-ainode +``` + +After stopping the service, check the service status. If it shows `inactive (dead)`, the service has been shut down successfully. For other statuses, check IoTDB logs to analyze exceptions. + +### 4.3 Check Service Status +```bash +# Check ConfigNode service status +systemctl status iotdb-confignode +# Check DataNode service status +systemctl status iotdb-datanode +# Check AINode service status +systemctl status iotdb-ainode +``` + +Status Description: +- `active (running)`: Service is running. If this status persists for 10 minutes, the service has started successfully. +- `failed`: Service startup failed. Check IoTDB logs for troubleshooting. + +### 4.4 Restart Service +Restarting a service is equivalent to stopping and then starting it. Commands are as follows: +```bash +# Restart ConfigNode service +systemctl restart iotdb-confignode +# Restart DataNode service +systemctl restart iotdb-datanode +# Restart AINode service +systemctl restart iotdb-ainode +``` + +### 4.5 Enable Auto-start on Boot +```bash +# Enable ConfigNode auto-start on boot +systemctl enable iotdb-confignode +# Enable DataNode auto-start on boot +systemctl enable iotdb-datanode +# Enable AINode auto-start on boot +systemctl enable iotdb-ainode +``` + +### 4.6 Disable Auto-start on Boot +```bash +# Disable ConfigNode auto-start on boot +systemctl disable iotdb-confignode +# Disable DataNode auto-start on boot +systemctl disable iotdb-datanode +# Disable AINode auto-start on boot +systemctl disable iotdb-ainode +``` + +## 5. Custom Service Configuration +### 5.1 Customization Methods +#### 5.1.1 Method 1: Modify the Script +1. Modify the `[Unit]`, `[Service]`, and `[Install]` sections in the `daemon-xxx.sh` script. For details of configuration items, refer to the next section. +2. Execute the `daemon-xxx.sh` script. + +#### 5.1.2 Method 2: Modify the Service File +1. Modify the `xx.service` file in `/etc/systemd/system`. +2. Execute `systemctl daemon-reload`. + +### 5.2 `daemon-xxx.sh` Configuration Items +#### 5.2.1 `[Unit]` Section (Service Metadata) +| Item | Description | +|---------------|-----------------------------------------------------------------------------| +| Description | Service description | +| Documentation | Link to the official IoTDB documentation | +| After | Ensures the service starts only after the network service has started | + +#### 5.2.2 `[Service]` Section (Service Runtime Configuration) +| Item | Meaning | +|-------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| StandardOutput, StandardError | Specify storage paths for service standard output and error logs | +| LimitNOFILE=65536 | Set the maximum number of file descriptors, default value is 65536 | +| Type=simple | Service type is a simple foreground process; systemd tracks the main service process | +| User=root, Group=root | Run the service with root user and group permissions | +| ExecStart / ExecStop | Specify the paths of the service startup and shutdown scripts respectively | +| Restart=on-failure | Automatically restart the service only if it exits abnormally | +| SuccessExitStatus=143 | Treat exit code 143 (128+15, normal termination via SIGTERM) as a successful exit | +| RestartSec=5 | Interval between service restarts, default 5 seconds | +| StartLimitInterval=600s, StartLimitBurst=3 | Maximum 3 restarts within 10 minutes (600 seconds) to prevent excessive resource consumption from frequent restarts | +| RestartPreventExitStatus=SIGKILL | Do not auto-restart the service if killed by the SIGKILL signal, avoiding infinite restart of zombie processes | + +#### 5.2.3 `[Install]` Section (Installation Configuration) +| Item | Meaning | +|-----------------------|----------------------------------------------------------------------| +| WantedBy=multi-user.target | Start the service automatically when the system enters multi-user mode | + +### 5.3 Sample `.service` File Format +```bash +[Unit] +Description=iotdb-confignode +Documentation=https://iotdb.apache.org/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$IoTDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +Note: The above is the standard format of the `iotdb-confignode.service` file. The formats of `iotdb-datanode.service` and `iotdb-ainode.service` are similar. + +## 6. Notes +1. **Process Daemon Mechanism** + - **Auto-restart**: The system will auto-restart the service if it fails to start or exits abnormally during runtime (e.g., OOM). + - **No restart**: Normal exits (e.g., executing `kill`, `./sbin/stop-xxx.sh`, or `systemctl stop`) will not trigger auto-restart. + +2. **Log Location** + - All runtime logs are stored in the `logs` folder under the IoTDB installation directory. Refer to this directory for troubleshooting. + +3. **Cluster Status Check** + - After service startup, execute `./sbin/start-cli.sh` and run the `show cluster` command to view the cluster status. + +4. **Fault Recovery Procedure** + - If the service status is `failed`, after fixing the issue, **you must first execute `systemctl daemon-reload`** before running `systemctl start`, otherwise startup will fail. + +5. **Configuration Activation** + - After modifying the `daemon-xxx.sh` script, execute `systemctl daemon-reload` to re-register the service for new configurations to take effect. + +6. **Startup Mode Compatibility** + - Services started via `systemctl start` can be stopped using `./sbin/stop` (no restart triggered). + - Processes started via `./sbin/start` cannot be monitored via `systemctl`. \ No newline at end of file diff --git a/src/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_timecho.md b/src/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_timecho.md new file mode 100644 index 000000000..12fb0fc09 --- /dev/null +++ b/src/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_timecho.md @@ -0,0 +1,213 @@ + + +# Auto-start on Boot +## 1. Overview +TimechoDB supports registering ConfigNode, DataNode, and AINode as Linux system services via the three scripts `daemon-confignode.sh`, `daemon-datanode.sh`, and `daemon-ainode.sh`. Combined with the system-built `systemctl` command, it manages the TimechoDB cluster in daemon mode, enabling more convenient startup, shutdown, restart, and auto-start on boot operations, and improving service stability. + +> Note: This feature is available starting from version 2.0.9. + +## 2. Environment Requirements +| Item | Specification | +|--------------|-------------------------------------------------------------------------------| +| OS | Linux (supports the `systemctl` command) | +| User Privilege | root user | +| Environment Variable | `JAVA_HOME` must be set before deploying ConfigNode and DataNode | + +## 3. Service Registration +Enter the TimechoDB installation directory and execute the corresponding daemon script: + +```bash +# Register ConfigNode service +./tools/ops/daemon-confignode.sh + +# Register DataNode service +./tools/ops/daemon-datanode.sh + +# Register AINode service +./tools/ops/daemon-ainode.sh +``` + +During script execution, you will be prompted with two options: +1. Whether to start the corresponding TimechoDB service immediately (timechodb-confignode / timechodb-datanode / timechodb-ainode); +2. Whether to register the corresponding service for auto-start on boot. + +After script execution, the corresponding service files will be generated in the `/etc/systemd/system/` directory: +- `timechodb-confignode.service` +- `timechodb-datanode.service` +- `timechodb-ainode.service` + +## 4. Service Management +After service registration, you can use `systemctl` commands to start, stop, restart, check status, and configure auto-start on boot for each TimechoDB node service. All commands below must be executed as the root user. + +### 4.1 Manual Service Startup +```bash +# Start ConfigNode service +systemctl start timechodb-confignode +# Start DataNode service +systemctl start timechodb-datanode +# Start AINode service +systemctl start timechodb-ainode +``` + +### 4.2 Manual Service Shutdown +```bash +# Stop ConfigNode service +systemctl stop timechodb-confignode +# Stop DataNode service +systemctl stop timechodb-datanode +# Stop AINode service +systemctl stop timechodb-ainode +``` + +After stopping the service, check the service status. If it shows `inactive (dead)`, the service has been shut down successfully. For other statuses, check TimechoDB logs to analyze exceptions. + +### 4.3 Check Service Status +```bash +# Check ConfigNode service status +systemctl status timechodb-confignode +# Check DataNode service status +systemctl status timechodb-datanode +# Check AINode service status +systemctl status timechodb-ainode +``` + +Status Description: +- `active (running)`: Service is running. If this status persists for 10 minutes, the service has started successfully. +- `failed`: Service startup failed. Check TimechoDB logs for troubleshooting. + +### 4.4 Restart Service +Restarting a service is equivalent to stopping and then starting it. Commands are as follows: +```bash +# Restart ConfigNode service +systemctl restart timechodb-confignode +# Restart DataNode service +systemctl restart timechodb-datanode +# Restart AINode service +systemctl restart timechodb-ainode +``` + +### 4.5 Enable Auto-start on Boot +```bash +# Enable ConfigNode auto-start on boot +systemctl enable timechodb-confignode +# Enable DataNode auto-start on boot +systemctl enable timechodb-datanode +# Enable AINode auto-start on boot +systemctl enable timechodb-ainode +``` + +### 4.6 Disable Auto-start on Boot +```bash +# Disable ConfigNode auto-start on boot +systemctl disable timechodb-confignode +# Disable DataNode auto-start on boot +systemctl disable timechodb-datanode +# Disable AINode auto-start on boot +systemctl disable timechodb-ainode +``` + +## 5. Custom Service Configuration +### 5.1 Customization Methods +#### 5.1.1 Method 1: Modify the Script +1. Modify the `[Unit]`, `[Service]`, and `[Install]` sections in the `daemon-xxx.sh` script. For details of configuration items, refer to the next section. +2. Execute the `daemon-xxx.sh` script. + +#### 5.1.2 Method 2: Modify the Service File +1. Modify the `xx.service` file in `/etc/systemd/system`. +2. Execute `systemctl daemon-reload`. + +### 5.2 `daemon-xxx.sh` Configuration Items +#### 5.2.1 `[Unit]` Section (Service Metadata) +| Item | Description | +|---------------|-----------------------------------------------------------------------------| +| Description | Service description | +| Documentation | Link to the official TimechoDB documentation | +| After | Ensures the service starts only after the network service has started | + +#### 5.2.2 `[Service]` Section (Service Runtime Configuration) +| Item | Meaning | +|-------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| StandardOutput, StandardError | Specify storage paths for service standard output and error logs | +| LimitNOFILE=65536 | Set the maximum number of file descriptors, default value is 65536 | +| Type=simple | Service type is a simple foreground process; systemd tracks the main service process | +| User=root, Group=root | Run the service with root user and group permissions | +| ExecStart / ExecStop | Specify the paths of the service startup and shutdown scripts respectively | +| Restart=on-failure | Automatically restart the service only if it exits abnormally | +| SuccessExitStatus=143 | Treat exit code 143 (128+15, normal termination via SIGTERM) as a successful exit | +| RestartSec=5 | Interval between service restarts, default 5 seconds | +| StartLimitInterval=600s, StartLimitBurst=3 | Maximum 3 restarts within 10 minutes (600 seconds) to prevent excessive resource consumption from frequent restarts | +| RestartPreventExitStatus=SIGKILL | Do not auto-restart the service if killed by the SIGKILL signal, avoiding infinite restart of zombie processes | + +#### 5.2.3 `[Install]` Section (Installation Configuration) +| Item | Meaning | +|-----------------------|----------------------------------------------------------------------| +| WantedBy=multi-user.target | Start the service automatically when the system enters multi-user mode | + +### 5.3 Sample `.service` File Format +```bash +[Unit] +Description=timechodb-confignode +Documentation=https://www.timecho.com/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$TimechoDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +Note: The above is the standard format of the `timechodb-confignode.service` file. The formats of `timechodb-datanode.service` and `timechodb-ainode.service` are similar. + +## 6. Notes +1. **Process Daemon Mechanism** + - **Auto-restart**: The system will auto-restart the service if it fails to start or exits abnormally during runtime (e.g., OOM). + - **No restart**: Normal exits (e.g., executing `kill`, `./sbin/stop-xxx.sh`, or `systemctl stop`) will not trigger auto-restart. + +2. **Log Location** + - All runtime logs are stored in the `logs` folder under the TimechoDB installation directory. Refer to this directory for troubleshooting. + +3. **Cluster Status Check** + - After service startup, execute `./sbin/start-cli.sh` and run the `show cluster` command to view the cluster status. + +4. **Fault Recovery Procedure** + - If the service status is `failed`, after fixing the issue, **you must first execute `systemctl daemon-reload`** before running `systemctl start`, otherwise startup will fail. + +5. **Configuration Activation** + - After modifying the `daemon-xxx.sh` script, execute `systemctl daemon-reload` to re-register the service for new configurations to take effect. + +6. **Startup Mode Compatibility** + - Services started via `systemctl start` can be stopped using `./sbin/stop` (no restart triggered). + - Processes started via `./sbin/start` cannot be monitored via `systemctl`. \ No newline at end of file diff --git a/src/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_apache.md b/src/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_apache.md new file mode 100644 index 000000000..95bf83740 --- /dev/null +++ b/src/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_apache.md @@ -0,0 +1,213 @@ + + +# Auto-start on Boot +## 1. Overview +IoTDB supports registering ConfigNode, DataNode, and AINode as Linux system services via the three scripts `daemon-confignode.sh`, `daemon-datanode.sh`, and `daemon-ainode.sh`. Combined with the system-built `systemctl` command, it manages the IoTDB cluster in daemon mode, enabling more convenient startup, shutdown, restart, and auto-start on boot operations, and improving service stability. + +> Note: This feature is available starting from version 2.0.9-beta. + +## 2. Environment Requirements +| Item | Specification | +|--------------|-------------------------------------------------------------------------------| +| OS | Linux (supports the `systemctl` command) | +| User Privilege | root user | +| Environment Variable | `JAVA_HOME` must be set before deploying ConfigNode and DataNode | + +## 3. Service Registration +Enter the IoTDB installation directory and execute the corresponding daemon script: + +```bash +# Register ConfigNode service +./tools/ops/daemon-confignode.sh + +# Register DataNode service +./tools/ops/daemon-datanode.sh + +# Register AINode service +./tools/ops/daemon-ainode.sh +``` + +During script execution, you will be prompted with two options: +1. Whether to start the corresponding IoTDB service immediately (iotdb-confignode / iotdb-datanode / iotdb-ainode); +2. Whether to register the corresponding service for auto-start on boot. + +After script execution, the corresponding service files will be generated in the `/etc/systemd/system/` directory: +- `iotdb-confignode.service` +- `iotdb-datanode.service` +- `iotdb-ainode.service` + +## 4. Service Management +After service registration, you can use `systemctl` commands to start, stop, restart, check status, and configure auto-start on boot for each IoTDB node service. All commands below must be executed as the root user. + +### 4.1 Manual Service Startup +```bash +# Start ConfigNode service +systemctl start iotdb-confignode +# Start DataNode service +systemctl start iotdb-datanode +# Start AINode service +systemctl start iotdb-ainode +``` + +### 4.2 Manual Service Shutdown +```bash +# Stop ConfigNode service +systemctl stop iotdb-confignode +# Stop DataNode service +systemctl stop iotdb-datanode +# Stop AINode service +systemctl stop iotdb-ainode +``` + +After stopping the service, check the service status. If it shows `inactive (dead)`, the service has been shut down successfully. For other statuses, check IoTDB logs to analyze exceptions. + +### 4.3 Check Service Status +```bash +# Check ConfigNode service status +systemctl status iotdb-confignode +# Check DataNode service status +systemctl status iotdb-datanode +# Check AINode service status +systemctl status iotdb-ainode +``` + +Status Description: +- `active (running)`: Service is running. If this status persists for 10 minutes, the service has started successfully. +- `failed`: Service startup failed. Check IoTDB logs for troubleshooting. + +### 4.4 Restart Service +Restarting a service is equivalent to stopping and then starting it. Commands are as follows: +```bash +# Restart ConfigNode service +systemctl restart iotdb-confignode +# Restart DataNode service +systemctl restart iotdb-datanode +# Restart AINode service +systemctl restart iotdb-ainode +``` + +### 4.5 Enable Auto-start on Boot +```bash +# Enable ConfigNode auto-start on boot +systemctl enable iotdb-confignode +# Enable DataNode auto-start on boot +systemctl enable iotdb-datanode +# Enable AINode auto-start on boot +systemctl enable iotdb-ainode +``` + +### 4.6 Disable Auto-start on Boot +```bash +# Disable ConfigNode auto-start on boot +systemctl disable iotdb-confignode +# Disable DataNode auto-start on boot +systemctl disable iotdb-datanode +# Disable AINode auto-start on boot +systemctl disable iotdb-ainode +``` + +## 5. Custom Service Configuration +### 5.1 Customization Methods +#### 5.1.1 Method 1: Modify the Script +1. Modify the `[Unit]`, `[Service]`, and `[Install]` sections in the `daemon-xxx.sh` script. For details of configuration items, refer to the next section. +2. Execute the `daemon-xxx.sh` script. + +#### 5.1.2 Method 2: Modify the Service File +1. Modify the `xx.service` file in `/etc/systemd/system`. +2. Execute `systemctl daemon-reload`. + +### 5.2 `daemon-xxx.sh` Configuration Items +#### 5.2.1 `[Unit]` Section (Service Metadata) +| Item | Description | +|---------------|-----------------------------------------------------------------------------| +| Description | Service description | +| Documentation | Link to the official IoTDB documentation | +| After | Ensures the service starts only after the network service has started | + +#### 5.2.2 `[Service]` Section (Service Runtime Configuration) +| Item | Meaning | +|-------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| StandardOutput, StandardError | Specify storage paths for service standard output and error logs | +| LimitNOFILE=65536 | Set the maximum number of file descriptors, default value is 65536 | +| Type=simple | Service type is a simple foreground process; systemd tracks the main service process | +| User=root, Group=root | Run the service with root user and group permissions | +| ExecStart / ExecStop | Specify the paths of the service startup and shutdown scripts respectively | +| Restart=on-failure | Automatically restart the service only if it exits abnormally | +| SuccessExitStatus=143 | Treat exit code 143 (128+15, normal termination via SIGTERM) as a successful exit | +| RestartSec=5 | Interval between service restarts, default 5 seconds | +| StartLimitInterval=600s, StartLimitBurst=3 | Maximum 3 restarts within 10 minutes (600 seconds) to prevent excessive resource consumption from frequent restarts | +| RestartPreventExitStatus=SIGKILL | Do not auto-restart the service if killed by the SIGKILL signal, avoiding infinite restart of zombie processes | + +#### 5.2.3 `[Install]` Section (Installation Configuration) +| Item | Meaning | +|-----------------------|----------------------------------------------------------------------| +| WantedBy=multi-user.target | Start the service automatically when the system enters multi-user mode | + +### 5.3 Sample `.service` File Format +```bash +[Unit] +Description=iotdb-confignode +Documentation=https://iotdb.apache.org/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$IoTDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +Note: The above is the standard format of the `iotdb-confignode.service` file. The formats of `iotdb-datanode.service` and `iotdb-ainode.service` are similar. + +## 6. Notes +1. **Process Daemon Mechanism** + - **Auto-restart**: The system will auto-restart the service if it fails to start or exits abnormally during runtime (e.g., OOM). + - **No restart**: Normal exits (e.g., executing `kill`, `./sbin/stop-xxx.sh`, or `systemctl stop`) will not trigger auto-restart. + +2. **Log Location** + - All runtime logs are stored in the `logs` folder under the IoTDB installation directory. Refer to this directory for troubleshooting. + +3. **Cluster Status Check** + - After service startup, execute `./sbin/start-cli.sh` and run the `show cluster` command to view the cluster status. + +4. **Fault Recovery Procedure** + - If the service status is `failed`, after fixing the issue, **you must first execute `systemctl daemon-reload`** before running `systemctl start`, otherwise startup will fail. + +5. **Configuration Activation** + - After modifying the `daemon-xxx.sh` script, execute `systemctl daemon-reload` to re-register the service for new configurations to take effect. + +6. **Startup Mode Compatibility** + - Services started via `systemctl start` can be stopped using `./sbin/stop` (no restart triggered). + - Processes started via `./sbin/start` cannot be monitored via `systemctl`. \ No newline at end of file diff --git a/src/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_timecho.md b/src/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_timecho.md new file mode 100644 index 000000000..12fb0fc09 --- /dev/null +++ b/src/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_timecho.md @@ -0,0 +1,213 @@ + + +# Auto-start on Boot +## 1. Overview +TimechoDB supports registering ConfigNode, DataNode, and AINode as Linux system services via the three scripts `daemon-confignode.sh`, `daemon-datanode.sh`, and `daemon-ainode.sh`. Combined with the system-built `systemctl` command, it manages the TimechoDB cluster in daemon mode, enabling more convenient startup, shutdown, restart, and auto-start on boot operations, and improving service stability. + +> Note: This feature is available starting from version 2.0.9. + +## 2. Environment Requirements +| Item | Specification | +|--------------|-------------------------------------------------------------------------------| +| OS | Linux (supports the `systemctl` command) | +| User Privilege | root user | +| Environment Variable | `JAVA_HOME` must be set before deploying ConfigNode and DataNode | + +## 3. Service Registration +Enter the TimechoDB installation directory and execute the corresponding daemon script: + +```bash +# Register ConfigNode service +./tools/ops/daemon-confignode.sh + +# Register DataNode service +./tools/ops/daemon-datanode.sh + +# Register AINode service +./tools/ops/daemon-ainode.sh +``` + +During script execution, you will be prompted with two options: +1. Whether to start the corresponding TimechoDB service immediately (timechodb-confignode / timechodb-datanode / timechodb-ainode); +2. Whether to register the corresponding service for auto-start on boot. + +After script execution, the corresponding service files will be generated in the `/etc/systemd/system/` directory: +- `timechodb-confignode.service` +- `timechodb-datanode.service` +- `timechodb-ainode.service` + +## 4. Service Management +After service registration, you can use `systemctl` commands to start, stop, restart, check status, and configure auto-start on boot for each TimechoDB node service. All commands below must be executed as the root user. + +### 4.1 Manual Service Startup +```bash +# Start ConfigNode service +systemctl start timechodb-confignode +# Start DataNode service +systemctl start timechodb-datanode +# Start AINode service +systemctl start timechodb-ainode +``` + +### 4.2 Manual Service Shutdown +```bash +# Stop ConfigNode service +systemctl stop timechodb-confignode +# Stop DataNode service +systemctl stop timechodb-datanode +# Stop AINode service +systemctl stop timechodb-ainode +``` + +After stopping the service, check the service status. If it shows `inactive (dead)`, the service has been shut down successfully. For other statuses, check TimechoDB logs to analyze exceptions. + +### 4.3 Check Service Status +```bash +# Check ConfigNode service status +systemctl status timechodb-confignode +# Check DataNode service status +systemctl status timechodb-datanode +# Check AINode service status +systemctl status timechodb-ainode +``` + +Status Description: +- `active (running)`: Service is running. If this status persists for 10 minutes, the service has started successfully. +- `failed`: Service startup failed. Check TimechoDB logs for troubleshooting. + +### 4.4 Restart Service +Restarting a service is equivalent to stopping and then starting it. Commands are as follows: +```bash +# Restart ConfigNode service +systemctl restart timechodb-confignode +# Restart DataNode service +systemctl restart timechodb-datanode +# Restart AINode service +systemctl restart timechodb-ainode +``` + +### 4.5 Enable Auto-start on Boot +```bash +# Enable ConfigNode auto-start on boot +systemctl enable timechodb-confignode +# Enable DataNode auto-start on boot +systemctl enable timechodb-datanode +# Enable AINode auto-start on boot +systemctl enable timechodb-ainode +``` + +### 4.6 Disable Auto-start on Boot +```bash +# Disable ConfigNode auto-start on boot +systemctl disable timechodb-confignode +# Disable DataNode auto-start on boot +systemctl disable timechodb-datanode +# Disable AINode auto-start on boot +systemctl disable timechodb-ainode +``` + +## 5. Custom Service Configuration +### 5.1 Customization Methods +#### 5.1.1 Method 1: Modify the Script +1. Modify the `[Unit]`, `[Service]`, and `[Install]` sections in the `daemon-xxx.sh` script. For details of configuration items, refer to the next section. +2. Execute the `daemon-xxx.sh` script. + +#### 5.1.2 Method 2: Modify the Service File +1. Modify the `xx.service` file in `/etc/systemd/system`. +2. Execute `systemctl daemon-reload`. + +### 5.2 `daemon-xxx.sh` Configuration Items +#### 5.2.1 `[Unit]` Section (Service Metadata) +| Item | Description | +|---------------|-----------------------------------------------------------------------------| +| Description | Service description | +| Documentation | Link to the official TimechoDB documentation | +| After | Ensures the service starts only after the network service has started | + +#### 5.2.2 `[Service]` Section (Service Runtime Configuration) +| Item | Meaning | +|-------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| StandardOutput, StandardError | Specify storage paths for service standard output and error logs | +| LimitNOFILE=65536 | Set the maximum number of file descriptors, default value is 65536 | +| Type=simple | Service type is a simple foreground process; systemd tracks the main service process | +| User=root, Group=root | Run the service with root user and group permissions | +| ExecStart / ExecStop | Specify the paths of the service startup and shutdown scripts respectively | +| Restart=on-failure | Automatically restart the service only if it exits abnormally | +| SuccessExitStatus=143 | Treat exit code 143 (128+15, normal termination via SIGTERM) as a successful exit | +| RestartSec=5 | Interval between service restarts, default 5 seconds | +| StartLimitInterval=600s, StartLimitBurst=3 | Maximum 3 restarts within 10 minutes (600 seconds) to prevent excessive resource consumption from frequent restarts | +| RestartPreventExitStatus=SIGKILL | Do not auto-restart the service if killed by the SIGKILL signal, avoiding infinite restart of zombie processes | + +#### 5.2.3 `[Install]` Section (Installation Configuration) +| Item | Meaning | +|-----------------------|----------------------------------------------------------------------| +| WantedBy=multi-user.target | Start the service automatically when the system enters multi-user mode | + +### 5.3 Sample `.service` File Format +```bash +[Unit] +Description=timechodb-confignode +Documentation=https://www.timecho.com/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$TimechoDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +Note: The above is the standard format of the `timechodb-confignode.service` file. The formats of `timechodb-datanode.service` and `timechodb-ainode.service` are similar. + +## 6. Notes +1. **Process Daemon Mechanism** + - **Auto-restart**: The system will auto-restart the service if it fails to start or exits abnormally during runtime (e.g., OOM). + - **No restart**: Normal exits (e.g., executing `kill`, `./sbin/stop-xxx.sh`, or `systemctl stop`) will not trigger auto-restart. + +2. **Log Location** + - All runtime logs are stored in the `logs` folder under the TimechoDB installation directory. Refer to this directory for troubleshooting. + +3. **Cluster Status Check** + - After service startup, execute `./sbin/start-cli.sh` and run the `show cluster` command to view the cluster status. + +4. **Fault Recovery Procedure** + - If the service status is `failed`, after fixing the issue, **you must first execute `systemctl daemon-reload`** before running `systemctl start`, otherwise startup will fail. + +5. **Configuration Activation** + - After modifying the `daemon-xxx.sh` script, execute `systemctl daemon-reload` to re-register the service for new configurations to take effect. + +6. **Startup Mode Compatibility** + - Services started via `systemctl start` can be stopped using `./sbin/stop` (no restart triggered). + - Processes started via `./sbin/start` cannot be monitored via `systemctl`. \ No newline at end of file diff --git a/src/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_apache.md b/src/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_apache.md new file mode 100644 index 000000000..95bf83740 --- /dev/null +++ b/src/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_apache.md @@ -0,0 +1,213 @@ + + +# Auto-start on Boot +## 1. Overview +IoTDB supports registering ConfigNode, DataNode, and AINode as Linux system services via the three scripts `daemon-confignode.sh`, `daemon-datanode.sh`, and `daemon-ainode.sh`. Combined with the system-built `systemctl` command, it manages the IoTDB cluster in daemon mode, enabling more convenient startup, shutdown, restart, and auto-start on boot operations, and improving service stability. + +> Note: This feature is available starting from version 2.0.9-beta. + +## 2. Environment Requirements +| Item | Specification | +|--------------|-------------------------------------------------------------------------------| +| OS | Linux (supports the `systemctl` command) | +| User Privilege | root user | +| Environment Variable | `JAVA_HOME` must be set before deploying ConfigNode and DataNode | + +## 3. Service Registration +Enter the IoTDB installation directory and execute the corresponding daemon script: + +```bash +# Register ConfigNode service +./tools/ops/daemon-confignode.sh + +# Register DataNode service +./tools/ops/daemon-datanode.sh + +# Register AINode service +./tools/ops/daemon-ainode.sh +``` + +During script execution, you will be prompted with two options: +1. Whether to start the corresponding IoTDB service immediately (iotdb-confignode / iotdb-datanode / iotdb-ainode); +2. Whether to register the corresponding service for auto-start on boot. + +After script execution, the corresponding service files will be generated in the `/etc/systemd/system/` directory: +- `iotdb-confignode.service` +- `iotdb-datanode.service` +- `iotdb-ainode.service` + +## 4. Service Management +After service registration, you can use `systemctl` commands to start, stop, restart, check status, and configure auto-start on boot for each IoTDB node service. All commands below must be executed as the root user. + +### 4.1 Manual Service Startup +```bash +# Start ConfigNode service +systemctl start iotdb-confignode +# Start DataNode service +systemctl start iotdb-datanode +# Start AINode service +systemctl start iotdb-ainode +``` + +### 4.2 Manual Service Shutdown +```bash +# Stop ConfigNode service +systemctl stop iotdb-confignode +# Stop DataNode service +systemctl stop iotdb-datanode +# Stop AINode service +systemctl stop iotdb-ainode +``` + +After stopping the service, check the service status. If it shows `inactive (dead)`, the service has been shut down successfully. For other statuses, check IoTDB logs to analyze exceptions. + +### 4.3 Check Service Status +```bash +# Check ConfigNode service status +systemctl status iotdb-confignode +# Check DataNode service status +systemctl status iotdb-datanode +# Check AINode service status +systemctl status iotdb-ainode +``` + +Status Description: +- `active (running)`: Service is running. If this status persists for 10 minutes, the service has started successfully. +- `failed`: Service startup failed. Check IoTDB logs for troubleshooting. + +### 4.4 Restart Service +Restarting a service is equivalent to stopping and then starting it. Commands are as follows: +```bash +# Restart ConfigNode service +systemctl restart iotdb-confignode +# Restart DataNode service +systemctl restart iotdb-datanode +# Restart AINode service +systemctl restart iotdb-ainode +``` + +### 4.5 Enable Auto-start on Boot +```bash +# Enable ConfigNode auto-start on boot +systemctl enable iotdb-confignode +# Enable DataNode auto-start on boot +systemctl enable iotdb-datanode +# Enable AINode auto-start on boot +systemctl enable iotdb-ainode +``` + +### 4.6 Disable Auto-start on Boot +```bash +# Disable ConfigNode auto-start on boot +systemctl disable iotdb-confignode +# Disable DataNode auto-start on boot +systemctl disable iotdb-datanode +# Disable AINode auto-start on boot +systemctl disable iotdb-ainode +``` + +## 5. Custom Service Configuration +### 5.1 Customization Methods +#### 5.1.1 Method 1: Modify the Script +1. Modify the `[Unit]`, `[Service]`, and `[Install]` sections in the `daemon-xxx.sh` script. For details of configuration items, refer to the next section. +2. Execute the `daemon-xxx.sh` script. + +#### 5.1.2 Method 2: Modify the Service File +1. Modify the `xx.service` file in `/etc/systemd/system`. +2. Execute `systemctl daemon-reload`. + +### 5.2 `daemon-xxx.sh` Configuration Items +#### 5.2.1 `[Unit]` Section (Service Metadata) +| Item | Description | +|---------------|-----------------------------------------------------------------------------| +| Description | Service description | +| Documentation | Link to the official IoTDB documentation | +| After | Ensures the service starts only after the network service has started | + +#### 5.2.2 `[Service]` Section (Service Runtime Configuration) +| Item | Meaning | +|-------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| StandardOutput, StandardError | Specify storage paths for service standard output and error logs | +| LimitNOFILE=65536 | Set the maximum number of file descriptors, default value is 65536 | +| Type=simple | Service type is a simple foreground process; systemd tracks the main service process | +| User=root, Group=root | Run the service with root user and group permissions | +| ExecStart / ExecStop | Specify the paths of the service startup and shutdown scripts respectively | +| Restart=on-failure | Automatically restart the service only if it exits abnormally | +| SuccessExitStatus=143 | Treat exit code 143 (128+15, normal termination via SIGTERM) as a successful exit | +| RestartSec=5 | Interval between service restarts, default 5 seconds | +| StartLimitInterval=600s, StartLimitBurst=3 | Maximum 3 restarts within 10 minutes (600 seconds) to prevent excessive resource consumption from frequent restarts | +| RestartPreventExitStatus=SIGKILL | Do not auto-restart the service if killed by the SIGKILL signal, avoiding infinite restart of zombie processes | + +#### 5.2.3 `[Install]` Section (Installation Configuration) +| Item | Meaning | +|-----------------------|----------------------------------------------------------------------| +| WantedBy=multi-user.target | Start the service automatically when the system enters multi-user mode | + +### 5.3 Sample `.service` File Format +```bash +[Unit] +Description=iotdb-confignode +Documentation=https://iotdb.apache.org/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$IoTDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +Note: The above is the standard format of the `iotdb-confignode.service` file. The formats of `iotdb-datanode.service` and `iotdb-ainode.service` are similar. + +## 6. Notes +1. **Process Daemon Mechanism** + - **Auto-restart**: The system will auto-restart the service if it fails to start or exits abnormally during runtime (e.g., OOM). + - **No restart**: Normal exits (e.g., executing `kill`, `./sbin/stop-xxx.sh`, or `systemctl stop`) will not trigger auto-restart. + +2. **Log Location** + - All runtime logs are stored in the `logs` folder under the IoTDB installation directory. Refer to this directory for troubleshooting. + +3. **Cluster Status Check** + - After service startup, execute `./sbin/start-cli.sh` and run the `show cluster` command to view the cluster status. + +4. **Fault Recovery Procedure** + - If the service status is `failed`, after fixing the issue, **you must first execute `systemctl daemon-reload`** before running `systemctl start`, otherwise startup will fail. + +5. **Configuration Activation** + - After modifying the `daemon-xxx.sh` script, execute `systemctl daemon-reload` to re-register the service for new configurations to take effect. + +6. **Startup Mode Compatibility** + - Services started via `systemctl start` can be stopped using `./sbin/stop` (no restart triggered). + - Processes started via `./sbin/start` cannot be monitored via `systemctl`. \ No newline at end of file diff --git a/src/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_timecho.md b/src/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_timecho.md new file mode 100644 index 000000000..12fb0fc09 --- /dev/null +++ b/src/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_timecho.md @@ -0,0 +1,213 @@ + + +# Auto-start on Boot +## 1. Overview +TimechoDB supports registering ConfigNode, DataNode, and AINode as Linux system services via the three scripts `daemon-confignode.sh`, `daemon-datanode.sh`, and `daemon-ainode.sh`. Combined with the system-built `systemctl` command, it manages the TimechoDB cluster in daemon mode, enabling more convenient startup, shutdown, restart, and auto-start on boot operations, and improving service stability. + +> Note: This feature is available starting from version 2.0.9. + +## 2. Environment Requirements +| Item | Specification | +|--------------|-------------------------------------------------------------------------------| +| OS | Linux (supports the `systemctl` command) | +| User Privilege | root user | +| Environment Variable | `JAVA_HOME` must be set before deploying ConfigNode and DataNode | + +## 3. Service Registration +Enter the TimechoDB installation directory and execute the corresponding daemon script: + +```bash +# Register ConfigNode service +./tools/ops/daemon-confignode.sh + +# Register DataNode service +./tools/ops/daemon-datanode.sh + +# Register AINode service +./tools/ops/daemon-ainode.sh +``` + +During script execution, you will be prompted with two options: +1. Whether to start the corresponding TimechoDB service immediately (timechodb-confignode / timechodb-datanode / timechodb-ainode); +2. Whether to register the corresponding service for auto-start on boot. + +After script execution, the corresponding service files will be generated in the `/etc/systemd/system/` directory: +- `timechodb-confignode.service` +- `timechodb-datanode.service` +- `timechodb-ainode.service` + +## 4. Service Management +After service registration, you can use `systemctl` commands to start, stop, restart, check status, and configure auto-start on boot for each TimechoDB node service. All commands below must be executed as the root user. + +### 4.1 Manual Service Startup +```bash +# Start ConfigNode service +systemctl start timechodb-confignode +# Start DataNode service +systemctl start timechodb-datanode +# Start AINode service +systemctl start timechodb-ainode +``` + +### 4.2 Manual Service Shutdown +```bash +# Stop ConfigNode service +systemctl stop timechodb-confignode +# Stop DataNode service +systemctl stop timechodb-datanode +# Stop AINode service +systemctl stop timechodb-ainode +``` + +After stopping the service, check the service status. If it shows `inactive (dead)`, the service has been shut down successfully. For other statuses, check TimechoDB logs to analyze exceptions. + +### 4.3 Check Service Status +```bash +# Check ConfigNode service status +systemctl status timechodb-confignode +# Check DataNode service status +systemctl status timechodb-datanode +# Check AINode service status +systemctl status timechodb-ainode +``` + +Status Description: +- `active (running)`: Service is running. If this status persists for 10 minutes, the service has started successfully. +- `failed`: Service startup failed. Check TimechoDB logs for troubleshooting. + +### 4.4 Restart Service +Restarting a service is equivalent to stopping and then starting it. Commands are as follows: +```bash +# Restart ConfigNode service +systemctl restart timechodb-confignode +# Restart DataNode service +systemctl restart timechodb-datanode +# Restart AINode service +systemctl restart timechodb-ainode +``` + +### 4.5 Enable Auto-start on Boot +```bash +# Enable ConfigNode auto-start on boot +systemctl enable timechodb-confignode +# Enable DataNode auto-start on boot +systemctl enable timechodb-datanode +# Enable AINode auto-start on boot +systemctl enable timechodb-ainode +``` + +### 4.6 Disable Auto-start on Boot +```bash +# Disable ConfigNode auto-start on boot +systemctl disable timechodb-confignode +# Disable DataNode auto-start on boot +systemctl disable timechodb-datanode +# Disable AINode auto-start on boot +systemctl disable timechodb-ainode +``` + +## 5. Custom Service Configuration +### 5.1 Customization Methods +#### 5.1.1 Method 1: Modify the Script +1. Modify the `[Unit]`, `[Service]`, and `[Install]` sections in the `daemon-xxx.sh` script. For details of configuration items, refer to the next section. +2. Execute the `daemon-xxx.sh` script. + +#### 5.1.2 Method 2: Modify the Service File +1. Modify the `xx.service` file in `/etc/systemd/system`. +2. Execute `systemctl daemon-reload`. + +### 5.2 `daemon-xxx.sh` Configuration Items +#### 5.2.1 `[Unit]` Section (Service Metadata) +| Item | Description | +|---------------|-----------------------------------------------------------------------------| +| Description | Service description | +| Documentation | Link to the official TimechoDB documentation | +| After | Ensures the service starts only after the network service has started | + +#### 5.2.2 `[Service]` Section (Service Runtime Configuration) +| Item | Meaning | +|-------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| StandardOutput, StandardError | Specify storage paths for service standard output and error logs | +| LimitNOFILE=65536 | Set the maximum number of file descriptors, default value is 65536 | +| Type=simple | Service type is a simple foreground process; systemd tracks the main service process | +| User=root, Group=root | Run the service with root user and group permissions | +| ExecStart / ExecStop | Specify the paths of the service startup and shutdown scripts respectively | +| Restart=on-failure | Automatically restart the service only if it exits abnormally | +| SuccessExitStatus=143 | Treat exit code 143 (128+15, normal termination via SIGTERM) as a successful exit | +| RestartSec=5 | Interval between service restarts, default 5 seconds | +| StartLimitInterval=600s, StartLimitBurst=3 | Maximum 3 restarts within 10 minutes (600 seconds) to prevent excessive resource consumption from frequent restarts | +| RestartPreventExitStatus=SIGKILL | Do not auto-restart the service if killed by the SIGKILL signal, avoiding infinite restart of zombie processes | + +#### 5.2.3 `[Install]` Section (Installation Configuration) +| Item | Meaning | +|-----------------------|----------------------------------------------------------------------| +| WantedBy=multi-user.target | Start the service automatically when the system enters multi-user mode | + +### 5.3 Sample `.service` File Format +```bash +[Unit] +Description=timechodb-confignode +Documentation=https://www.timecho.com/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$TimechoDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +Note: The above is the standard format of the `timechodb-confignode.service` file. The formats of `timechodb-datanode.service` and `timechodb-ainode.service` are similar. + +## 6. Notes +1. **Process Daemon Mechanism** + - **Auto-restart**: The system will auto-restart the service if it fails to start or exits abnormally during runtime (e.g., OOM). + - **No restart**: Normal exits (e.g., executing `kill`, `./sbin/stop-xxx.sh`, or `systemctl stop`) will not trigger auto-restart. + +2. **Log Location** + - All runtime logs are stored in the `logs` folder under the TimechoDB installation directory. Refer to this directory for troubleshooting. + +3. **Cluster Status Check** + - After service startup, execute `./sbin/start-cli.sh` and run the `show cluster` command to view the cluster status. + +4. **Fault Recovery Procedure** + - If the service status is `failed`, after fixing the issue, **you must first execute `systemctl daemon-reload`** before running `systemctl start`, otherwise startup will fail. + +5. **Configuration Activation** + - After modifying the `daemon-xxx.sh` script, execute `systemctl daemon-reload` to re-register the service for new configurations to take effect. + +6. **Startup Mode Compatibility** + - Services started via `systemctl start` can be stopped using `./sbin/stop` (no restart triggered). + - Processes started via `./sbin/start` cannot be monitored via `systemctl`. \ No newline at end of file diff --git a/src/UserGuide/latest/User-Manual/Auto-Start-On-Boot_apache.md b/src/UserGuide/latest/User-Manual/Auto-Start-On-Boot_apache.md new file mode 100644 index 000000000..95bf83740 --- /dev/null +++ b/src/UserGuide/latest/User-Manual/Auto-Start-On-Boot_apache.md @@ -0,0 +1,213 @@ + + +# Auto-start on Boot +## 1. Overview +IoTDB supports registering ConfigNode, DataNode, and AINode as Linux system services via the three scripts `daemon-confignode.sh`, `daemon-datanode.sh`, and `daemon-ainode.sh`. Combined with the system-built `systemctl` command, it manages the IoTDB cluster in daemon mode, enabling more convenient startup, shutdown, restart, and auto-start on boot operations, and improving service stability. + +> Note: This feature is available starting from version 2.0.9-beta. + +## 2. Environment Requirements +| Item | Specification | +|--------------|-------------------------------------------------------------------------------| +| OS | Linux (supports the `systemctl` command) | +| User Privilege | root user | +| Environment Variable | `JAVA_HOME` must be set before deploying ConfigNode and DataNode | + +## 3. Service Registration +Enter the IoTDB installation directory and execute the corresponding daemon script: + +```bash +# Register ConfigNode service +./tools/ops/daemon-confignode.sh + +# Register DataNode service +./tools/ops/daemon-datanode.sh + +# Register AINode service +./tools/ops/daemon-ainode.sh +``` + +During script execution, you will be prompted with two options: +1. Whether to start the corresponding IoTDB service immediately (iotdb-confignode / iotdb-datanode / iotdb-ainode); +2. Whether to register the corresponding service for auto-start on boot. + +After script execution, the corresponding service files will be generated in the `/etc/systemd/system/` directory: +- `iotdb-confignode.service` +- `iotdb-datanode.service` +- `iotdb-ainode.service` + +## 4. Service Management +After service registration, you can use `systemctl` commands to start, stop, restart, check status, and configure auto-start on boot for each IoTDB node service. All commands below must be executed as the root user. + +### 4.1 Manual Service Startup +```bash +# Start ConfigNode service +systemctl start iotdb-confignode +# Start DataNode service +systemctl start iotdb-datanode +# Start AINode service +systemctl start iotdb-ainode +``` + +### 4.2 Manual Service Shutdown +```bash +# Stop ConfigNode service +systemctl stop iotdb-confignode +# Stop DataNode service +systemctl stop iotdb-datanode +# Stop AINode service +systemctl stop iotdb-ainode +``` + +After stopping the service, check the service status. If it shows `inactive (dead)`, the service has been shut down successfully. For other statuses, check IoTDB logs to analyze exceptions. + +### 4.3 Check Service Status +```bash +# Check ConfigNode service status +systemctl status iotdb-confignode +# Check DataNode service status +systemctl status iotdb-datanode +# Check AINode service status +systemctl status iotdb-ainode +``` + +Status Description: +- `active (running)`: Service is running. If this status persists for 10 minutes, the service has started successfully. +- `failed`: Service startup failed. Check IoTDB logs for troubleshooting. + +### 4.4 Restart Service +Restarting a service is equivalent to stopping and then starting it. Commands are as follows: +```bash +# Restart ConfigNode service +systemctl restart iotdb-confignode +# Restart DataNode service +systemctl restart iotdb-datanode +# Restart AINode service +systemctl restart iotdb-ainode +``` + +### 4.5 Enable Auto-start on Boot +```bash +# Enable ConfigNode auto-start on boot +systemctl enable iotdb-confignode +# Enable DataNode auto-start on boot +systemctl enable iotdb-datanode +# Enable AINode auto-start on boot +systemctl enable iotdb-ainode +``` + +### 4.6 Disable Auto-start on Boot +```bash +# Disable ConfigNode auto-start on boot +systemctl disable iotdb-confignode +# Disable DataNode auto-start on boot +systemctl disable iotdb-datanode +# Disable AINode auto-start on boot +systemctl disable iotdb-ainode +``` + +## 5. Custom Service Configuration +### 5.1 Customization Methods +#### 5.1.1 Method 1: Modify the Script +1. Modify the `[Unit]`, `[Service]`, and `[Install]` sections in the `daemon-xxx.sh` script. For details of configuration items, refer to the next section. +2. Execute the `daemon-xxx.sh` script. + +#### 5.1.2 Method 2: Modify the Service File +1. Modify the `xx.service` file in `/etc/systemd/system`. +2. Execute `systemctl daemon-reload`. + +### 5.2 `daemon-xxx.sh` Configuration Items +#### 5.2.1 `[Unit]` Section (Service Metadata) +| Item | Description | +|---------------|-----------------------------------------------------------------------------| +| Description | Service description | +| Documentation | Link to the official IoTDB documentation | +| After | Ensures the service starts only after the network service has started | + +#### 5.2.2 `[Service]` Section (Service Runtime Configuration) +| Item | Meaning | +|-------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| StandardOutput, StandardError | Specify storage paths for service standard output and error logs | +| LimitNOFILE=65536 | Set the maximum number of file descriptors, default value is 65536 | +| Type=simple | Service type is a simple foreground process; systemd tracks the main service process | +| User=root, Group=root | Run the service with root user and group permissions | +| ExecStart / ExecStop | Specify the paths of the service startup and shutdown scripts respectively | +| Restart=on-failure | Automatically restart the service only if it exits abnormally | +| SuccessExitStatus=143 | Treat exit code 143 (128+15, normal termination via SIGTERM) as a successful exit | +| RestartSec=5 | Interval between service restarts, default 5 seconds | +| StartLimitInterval=600s, StartLimitBurst=3 | Maximum 3 restarts within 10 minutes (600 seconds) to prevent excessive resource consumption from frequent restarts | +| RestartPreventExitStatus=SIGKILL | Do not auto-restart the service if killed by the SIGKILL signal, avoiding infinite restart of zombie processes | + +#### 5.2.3 `[Install]` Section (Installation Configuration) +| Item | Meaning | +|-----------------------|----------------------------------------------------------------------| +| WantedBy=multi-user.target | Start the service automatically when the system enters multi-user mode | + +### 5.3 Sample `.service` File Format +```bash +[Unit] +Description=iotdb-confignode +Documentation=https://iotdb.apache.org/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$IoTDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +Note: The above is the standard format of the `iotdb-confignode.service` file. The formats of `iotdb-datanode.service` and `iotdb-ainode.service` are similar. + +## 6. Notes +1. **Process Daemon Mechanism** + - **Auto-restart**: The system will auto-restart the service if it fails to start or exits abnormally during runtime (e.g., OOM). + - **No restart**: Normal exits (e.g., executing `kill`, `./sbin/stop-xxx.sh`, or `systemctl stop`) will not trigger auto-restart. + +2. **Log Location** + - All runtime logs are stored in the `logs` folder under the IoTDB installation directory. Refer to this directory for troubleshooting. + +3. **Cluster Status Check** + - After service startup, execute `./sbin/start-cli.sh` and run the `show cluster` command to view the cluster status. + +4. **Fault Recovery Procedure** + - If the service status is `failed`, after fixing the issue, **you must first execute `systemctl daemon-reload`** before running `systemctl start`, otherwise startup will fail. + +5. **Configuration Activation** + - After modifying the `daemon-xxx.sh` script, execute `systemctl daemon-reload` to re-register the service for new configurations to take effect. + +6. **Startup Mode Compatibility** + - Services started via `systemctl start` can be stopped using `./sbin/stop` (no restart triggered). + - Processes started via `./sbin/start` cannot be monitored via `systemctl`. \ No newline at end of file diff --git a/src/UserGuide/latest/User-Manual/Auto-Start-On-Boot_timecho.md b/src/UserGuide/latest/User-Manual/Auto-Start-On-Boot_timecho.md new file mode 100644 index 000000000..12fb0fc09 --- /dev/null +++ b/src/UserGuide/latest/User-Manual/Auto-Start-On-Boot_timecho.md @@ -0,0 +1,213 @@ + + +# Auto-start on Boot +## 1. Overview +TimechoDB supports registering ConfigNode, DataNode, and AINode as Linux system services via the three scripts `daemon-confignode.sh`, `daemon-datanode.sh`, and `daemon-ainode.sh`. Combined with the system-built `systemctl` command, it manages the TimechoDB cluster in daemon mode, enabling more convenient startup, shutdown, restart, and auto-start on boot operations, and improving service stability. + +> Note: This feature is available starting from version 2.0.9. + +## 2. Environment Requirements +| Item | Specification | +|--------------|-------------------------------------------------------------------------------| +| OS | Linux (supports the `systemctl` command) | +| User Privilege | root user | +| Environment Variable | `JAVA_HOME` must be set before deploying ConfigNode and DataNode | + +## 3. Service Registration +Enter the TimechoDB installation directory and execute the corresponding daemon script: + +```bash +# Register ConfigNode service +./tools/ops/daemon-confignode.sh + +# Register DataNode service +./tools/ops/daemon-datanode.sh + +# Register AINode service +./tools/ops/daemon-ainode.sh +``` + +During script execution, you will be prompted with two options: +1. Whether to start the corresponding TimechoDB service immediately (timechodb-confignode / timechodb-datanode / timechodb-ainode); +2. Whether to register the corresponding service for auto-start on boot. + +After script execution, the corresponding service files will be generated in the `/etc/systemd/system/` directory: +- `timechodb-confignode.service` +- `timechodb-datanode.service` +- `timechodb-ainode.service` + +## 4. Service Management +After service registration, you can use `systemctl` commands to start, stop, restart, check status, and configure auto-start on boot for each TimechoDB node service. All commands below must be executed as the root user. + +### 4.1 Manual Service Startup +```bash +# Start ConfigNode service +systemctl start timechodb-confignode +# Start DataNode service +systemctl start timechodb-datanode +# Start AINode service +systemctl start timechodb-ainode +``` + +### 4.2 Manual Service Shutdown +```bash +# Stop ConfigNode service +systemctl stop timechodb-confignode +# Stop DataNode service +systemctl stop timechodb-datanode +# Stop AINode service +systemctl stop timechodb-ainode +``` + +After stopping the service, check the service status. If it shows `inactive (dead)`, the service has been shut down successfully. For other statuses, check TimechoDB logs to analyze exceptions. + +### 4.3 Check Service Status +```bash +# Check ConfigNode service status +systemctl status timechodb-confignode +# Check DataNode service status +systemctl status timechodb-datanode +# Check AINode service status +systemctl status timechodb-ainode +``` + +Status Description: +- `active (running)`: Service is running. If this status persists for 10 minutes, the service has started successfully. +- `failed`: Service startup failed. Check TimechoDB logs for troubleshooting. + +### 4.4 Restart Service +Restarting a service is equivalent to stopping and then starting it. Commands are as follows: +```bash +# Restart ConfigNode service +systemctl restart timechodb-confignode +# Restart DataNode service +systemctl restart timechodb-datanode +# Restart AINode service +systemctl restart timechodb-ainode +``` + +### 4.5 Enable Auto-start on Boot +```bash +# Enable ConfigNode auto-start on boot +systemctl enable timechodb-confignode +# Enable DataNode auto-start on boot +systemctl enable timechodb-datanode +# Enable AINode auto-start on boot +systemctl enable timechodb-ainode +``` + +### 4.6 Disable Auto-start on Boot +```bash +# Disable ConfigNode auto-start on boot +systemctl disable timechodb-confignode +# Disable DataNode auto-start on boot +systemctl disable timechodb-datanode +# Disable AINode auto-start on boot +systemctl disable timechodb-ainode +``` + +## 5. Custom Service Configuration +### 5.1 Customization Methods +#### 5.1.1 Method 1: Modify the Script +1. Modify the `[Unit]`, `[Service]`, and `[Install]` sections in the `daemon-xxx.sh` script. For details of configuration items, refer to the next section. +2. Execute the `daemon-xxx.sh` script. + +#### 5.1.2 Method 2: Modify the Service File +1. Modify the `xx.service` file in `/etc/systemd/system`. +2. Execute `systemctl daemon-reload`. + +### 5.2 `daemon-xxx.sh` Configuration Items +#### 5.2.1 `[Unit]` Section (Service Metadata) +| Item | Description | +|---------------|-----------------------------------------------------------------------------| +| Description | Service description | +| Documentation | Link to the official TimechoDB documentation | +| After | Ensures the service starts only after the network service has started | + +#### 5.2.2 `[Service]` Section (Service Runtime Configuration) +| Item | Meaning | +|-------------------------------------------|-----------------------------------------------------------------------------------------------------------| +| StandardOutput, StandardError | Specify storage paths for service standard output and error logs | +| LimitNOFILE=65536 | Set the maximum number of file descriptors, default value is 65536 | +| Type=simple | Service type is a simple foreground process; systemd tracks the main service process | +| User=root, Group=root | Run the service with root user and group permissions | +| ExecStart / ExecStop | Specify the paths of the service startup and shutdown scripts respectively | +| Restart=on-failure | Automatically restart the service only if it exits abnormally | +| SuccessExitStatus=143 | Treat exit code 143 (128+15, normal termination via SIGTERM) as a successful exit | +| RestartSec=5 | Interval between service restarts, default 5 seconds | +| StartLimitInterval=600s, StartLimitBurst=3 | Maximum 3 restarts within 10 minutes (600 seconds) to prevent excessive resource consumption from frequent restarts | +| RestartPreventExitStatus=SIGKILL | Do not auto-restart the service if killed by the SIGKILL signal, avoiding infinite restart of zombie processes | + +#### 5.2.3 `[Install]` Section (Installation Configuration) +| Item | Meaning | +|-----------------------|----------------------------------------------------------------------| +| WantedBy=multi-user.target | Start the service automatically when the system enters multi-user mode | + +### 5.3 Sample `.service` File Format +```bash +[Unit] +Description=timechodb-confignode +Documentation=https://www.timecho.com/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$TimechoDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +Note: The above is the standard format of the `timechodb-confignode.service` file. The formats of `timechodb-datanode.service` and `timechodb-ainode.service` are similar. + +## 6. Notes +1. **Process Daemon Mechanism** + - **Auto-restart**: The system will auto-restart the service if it fails to start or exits abnormally during runtime (e.g., OOM). + - **No restart**: Normal exits (e.g., executing `kill`, `./sbin/stop-xxx.sh`, or `systemctl stop`) will not trigger auto-restart. + +2. **Log Location** + - All runtime logs are stored in the `logs` folder under the TimechoDB installation directory. Refer to this directory for troubleshooting. + +3. **Cluster Status Check** + - After service startup, execute `./sbin/start-cli.sh` and run the `show cluster` command to view the cluster status. + +4. **Fault Recovery Procedure** + - If the service status is `failed`, after fixing the issue, **you must first execute `systemctl daemon-reload`** before running `systemctl start`, otherwise startup will fail. + +5. **Configuration Activation** + - After modifying the `daemon-xxx.sh` script, execute `systemctl daemon-reload` to re-register the service for new configurations to take effect. + +6. **Startup Mode Compatibility** + - Services started via `systemctl start` can be stopped using `./sbin/stop` (no restart triggered). + - Processes started via `./sbin/start` cannot be monitored via `systemctl`. \ No newline at end of file diff --git a/src/zh/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_apache.md b/src/zh/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_apache.md new file mode 100644 index 000000000..b229505d6 --- /dev/null +++ b/src/zh/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_apache.md @@ -0,0 +1,243 @@ + + +# 开机自启 + +## 1.概述 + +IoTDB 支持通过 `daemon-confignode.sh`、`daemon-datanode.sh`、`daemon-ainode.sh` 三个脚本,将ConfigNode、DataNode、AINode 注册为 Linux 系统服务,结合系统自带的 `systemctl `命令,以守护进程方式管理 IoTDB 集群,实现更便捷的启动、停止、重启及开机自启等操作,提升服务稳定性。 + +> 注意:该功能从 V2.0.9-beta 版本开始提供。 + +## 2. 环境要求 + +| 操作系统 | Linux(支持`systemctl`命令) | +| ---------- |:-----------------------------------------------------:| +| 用户权限 | root 用户 | +| 环境变量 | 部署 ConfigNode 和 DataNode 前需设置`JAVA_HOME` | + +## 3. 服务注册 + +进入 IoTDB 安装目录,执行对应的守护进程脚本: + +```Bash +# 注册 ConfigNode 服务 +./tools/ops/daemon-confignode.sh + +# 注册 DataNode 服务 +./tools/ops/daemon-datanode.sh + +# 注册 AINode 服务 +./tools/ops/daemon-ainode.sh +``` + +执行脚本时将提示以下两个选择项: + +1. 是否本次直接启动对应 IoTDB 服务(iotdb-confignode/iotdb-datanode/iotdb-ainode); +2. 是否将对应服务注册为开机自启服务。 + +脚本执行完成后,将在 `/etc/systemd/system/` 目录生成对应的服务文件: + +* `iotdb-confignode.service` +* `iotdb-datanode.service` +* `iotdb-ainode.service` + +## 4. 服务管理 + +服务注册完成后,可通过 systemctl 命令对 IoTDB 各节点服务进行启动、停止、重启、查看状态及配置开机自启等操作,以下命令均需使用 root 用户执行。 + +### 4.1 手动启动服务 + +```bash +# 启动 ConfigNode 服务 +systemctl start iotdb-confignode +# 启动 DataNode 服务 +systemctl start iotdb-datanode +# 启动 AINode 服务 +systemctl start iotdb-ainode +``` + +### 4.2 手动停止服务 + +```bash +# 停止 ConfigNode 服务 +systemctl stop iotdb-confignode +# 停止 DataNode 服务 +systemctl stop iotdb-datanode +# 停止 AINode 服务 +systemctl stop iotdb-ainode +``` + +停止服务后,通过查看服务状态,若显示为 inactive(dead),则说明服务关闭成功;若为其他状态,需查看 IoTDB 日志,分析异常原因。 + +### 4.3 查看服务状态 + +```bash +# 查看 ConfigNode 服务状态 +systemctl status iotdb-confignode +# 查看 DataNode 服务状态 +systemctl status iotdb-datanode +# 查看 AINode 服务状态 +systemctl status iotdb-ainode +``` + +状态说明: + +* active(running):服务正在运行,若该状态持续 10 分钟,说明服务启动成功; +* failed:服务启动失败,需查看 IoTDB 日志排查问题。 + +### 4.4 重启服务 + +重启服务相当于先执行停止操作,再执行启动操作,命令如下: + +```bash +# 重启 ConfigNode 服务 +systemctl restart iotdb-confignode +# 重启 DataNode 服务 +systemctl restart iotdb-datanode +# 重启 AINode 服务 +systemctl restart iotdb-ainode +``` + +### 4.5 配置开机自启 + +```bash +# 配置 ConfigNode 开机自启 +systemctl enable iotdb-confignode +# 配置 DataNode 开机自启 +systemctl enable iotdb-datanode +# 配置 AINode 开机自启 +systemctl enable iotdb-ainode +``` + +### 4.6 取消开机自启 + +```bash +# 取消 ConfigNode 开机自启 +systemctl disable iotdb-confignode +# 取消 DataNode 开机自启 +systemctl disable iotdb-datanode +# 取消 AINode 开机自启 +systemctl disable iotdb-ainode +``` + +## 5. 自定义服务配置 + +### 5.1 自定义方式 + +#### 5.1.1 方案一:修改脚本 + +1. 修改 `daemon-xxx.sh` 中的[Unit]、[Service]、[Install]区域配置项,具体配置项的含义参考下一小节 +2. 执行 `daemon-xxx.sh` 脚本 + +#### 5.1.2 方案二:修改服务文件 + +1. 修改 `/etc/systemd/system` 中的 `xx.service` 文件 +2. 执行 `systemctl deamon-reload` + +### 5.2 `daemon-xxx.sh` 配置项 + +#### 5.2.1 [Unit] 部分(服务元信息) + +| 配置项 | 说明 | +| --------------- | ---------------------------------- | +| Description | 服务描述 | +| Documentation | 指向 IoTDB 官方文档 | +| After | 确保在网络服务启动后才启动该服务 | + +#### 5.2.2 [Service] 部分(服务运行配置) + +| 配置项 | 含义 | +| -------------------------------------------- | ---------------------------------------------------------------------- | +| StandardOutput、StandardError | 指定服务标准输出和错误日志的存储路径 | +| LimitNOFILE=65536 | 设置文件描述符上限,默认值为 65536 | +| Type=simple | 服务类型为简单前台进程,systemd 会跟踪服务主进程 | +| User=root、Group=root | 指定服务以 root 用户和 root 组的权限运行 | +| ExecStart/ExecStop | 分别指定服务的启动脚本和停止脚本的路径 | +| Restart=on-failure | 仅在服务异常退出时,自动重启服务 | +| SuccessExitStatus=143 | 将退出码 143(128+15,即 SIGTERM 正常终止)视为成功退出 | +| RestartSec=5 | 服务重启的间隔时间,默认为 5 秒 | +| StartLimitInterval=600s、StartLimitBurst=3 | 10 分钟(600 秒)内,服务最多重启 3 次,防止频繁重启导致系统资源浪费 | +| RestartPreventExitStatus=SIGKILL | 服务被 SIGKILL 信号杀死后,不自动重启,避免无限重启僵尸进程 | + +#### 5.2.3 [Install] 部分(安装配置) + +| 配置项 | 含义 | +| ---------------------------- | -------------------------------------------- | +| WantedBy=multi-user.target | 指定服务在系统进入多用户模式时,自动启动。 | + +### 5.3 .service 文件格式示例 + +```bash +[Unit] +Description=iotdb-confignode +Documentation=https://iotdb.apache.org/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$IoTDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +注:上述为 iotdb-confignode.service 文件的标准格式,iotdb-datanode.service、iotdb-ainode.service 文件格式类似。 + +## 6. 注意事项 + +1. **进程守护机制** + +* **自动重启**:服务启动失败或运行中异常退出(如 OOM)时,系统将自动重启。 +* **不重启**:正常退出(如执行 `kill`、`./sbin/stop-xxx.sh` 或 `systemctl stop`)不会触发自动重启。 + +2. **日志位置** + +* 所有运行日志均存储在 IoTDB 安装目录下的 `logs` 文件夹中,排查问题时请查阅该目录。 + +3. **集群状态查看** + +* 服务启动后,执行 `./sbin/start-cli.sh` 并输入 `show cluster` 命令,即可查看集群状态。 + +4. **故障恢复流程** + +* 若服务状态为 `failed`,修复问题后**必须**先执行 `systemctl daemon-reload`,然后再执行 `systemctl start`,否则启动将失败。 + +5. **配置生效** + +* 修改 `daemon-xxx.sh` 脚本内容后,需执行 `systemctl daemon-reload` 重新注册服务,新配置方可生效。 + +6. **启动方式兼容** + +* `systemctl start`启动的服务,可用`./sbin/stop` 停止(不重启)。 +* `./sbin/start` 启动的进程,无法通过 `systemctl` 监控状态。 diff --git a/src/zh/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_timecho.md b/src/zh/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_timecho.md new file mode 100644 index 000000000..4bcc356c5 --- /dev/null +++ b/src/zh/UserGuide/Master/Table/User-Manual/Auto-Start-On-Boot_timecho.md @@ -0,0 +1,243 @@ + + +# 开机自启 + +## 1.概述 + +TimechoDB 支持通过 `daemon-confignode.sh`、`daemon-datanode.sh`、`daemon-ainode.sh` 三个脚本,将ConfigNode、DataNode、AINode 注册为 Linux 系统服务,结合系统自带的 `systemctl `命令,以守护进程方式管理 TimechoDB 集群,实现更便捷的启动、停止、重启及开机自启等操作,提升服务稳定性。 + +> 注意:该功能从 V 2.0.9 版本开始提供。 + +## 2. 环境要求 + +| 操作系统 | Linux(支持`systemctl`命令) | +| ---------- |:-----------------------------------------------------:| +| 用户权限 | root 用户 | +| 环境变量 | 部署 ConfigNode 和 DataNode 前需设置`JAVA_HOME` | + +## 3. 服务注册 + +进入 TimechoDB 安装目录,执行对应的守护进程脚本: + +```Bash +# 注册 ConfigNode 服务 +./tools/ops/daemon-confignode.sh + +# 注册 DataNode 服务 +./tools/ops/daemon-datanode.sh + +# 注册 AINode 服务 +./tools/ops/daemon-ainode.sh +``` + +执行脚本时将提示以下两个选择项: + +1. 是否本次直接启动对应 TimechoDB 服务(timechodb-confignode/timechodb-datanode/timechodb-ainode); +2. 是否将对应服务注册为开机自启服务。 + +脚本执行完成后,将在 `/etc/systemd/system/` 目录生成对应的服务文件: + +* `timechodb-confignode.service` +* `timechodb-datanode.service` +* `timechodb-ainode.service` + +## 4. 服务管理 + +服务注册完成后,可通过 systemctl 命令对 TimechoDB 各节点服务进行启动、停止、重启、查看状态及配置开机自启等操作,以下命令均需使用 root 用户执行。 + +### 4.1 手动启动服务 + +```bash +# 启动 ConfigNode 服务 +systemctl start timechodb-confignode +# 启动 DataNode 服务 +systemctl start timechodb-datanode +# 启动 AINode 服务 +systemctl start timechodb-ainode +``` + +### 4.2 手动停止服务 + +```bash +# 停止 ConfigNode 服务 +systemctl stop timechodb-confignode +# 停止 DataNode 服务 +systemctl stop timechodb-datanode +# 停止 AINode 服务 +systemctl stop timechodb-ainode +``` + +停止服务后,通过查看服务状态,若显示为 inactive(dead),则说明服务关闭成功;若为其他状态,需查看 TimechoDB 日志,分析异常原因。 + +### 4.3 查看服务状态 + +```bash +# 查看 ConfigNode 服务状态 +systemctl status timechodb-confignode +# 查看 DataNode 服务状态 +systemctl status timechodb-datanode +# 查看 AINode 服务状态 +systemctl status timechodb-ainode +``` + +状态说明: + +* active(running):服务正在运行,若该状态持续 10 分钟,说明服务启动成功; +* failed:服务启动失败,需查看 TimechoDB 日志排查问题。 + +### 4.4 重启服务 + +重启服务相当于先执行停止操作,再执行启动操作,命令如下: + +```bash +# 重启 ConfigNode 服务 +systemctl restart timechodb-confignode +# 重启 DataNode 服务 +systemctl restart timechodb-datanode +# 重启 AINode 服务 +systemctl restart timechodb-ainode +``` + +### 4.5 配置开机自启 + +```bash +# 配置 ConfigNode 开机自启 +systemctl enable timechodb-confignode +# 配置 DataNode 开机自启 +systemctl enable timechodb-datanode +# 配置 AINode 开机自启 +systemctl enable timechodb-ainode +``` + +### 4.6 取消开机自启 + +```bash +# 取消 ConfigNode 开机自启 +systemctl disable timechodb-confignode +# 取消 DataNode 开机自启 +systemctl disable timechodb-datanode +# 取消 AINode 开机自启 +systemctl disable timechodb-ainode +``` + +## 5. 自定义服务配置 + +### 5.1 自定义方式 + +#### 5.1.1 方案一:修改脚本 + +1. 修改 `daemon-xxx.sh` 中的[Unit]、[Service]、[Install]区域配置项,具体配置项的含义参考下一小节 +2. 执行 `daemon-xxx.sh` 脚本 + +#### 5.1.2 方案二:修改服务文件 + +1. 修改 `/etc/systemd/system` 中的 `xx.service` 文件 +2. 执行 `systemctl deamon-reload` + +### 5.2 `daemon-xxx.sh` 配置项 + +#### 5.2.1 [Unit] 部分(服务元信息) + +| 配置项 | 说明 | +| --------------- | ---------------------------------- | +| Description | 服务描述 | +| Documentation | 指向 TimechoDB 官方文档 | +| After | 确保在网络服务启动后才启动该服务 | + +#### 5.2.2 [Service] 部分(服务运行配置) + +| 配置项 | 含义 | +| -------------------------------------------- | ---------------------------------------------------------------------- | +| StandardOutput、StandardError | 指定服务标准输出和错误日志的存储路径 | +| LimitNOFILE=65536 | 设置文件描述符上限,默认值为 65536 | +| Type=simple | 服务类型为简单前台进程,systemd 会跟踪服务主进程 | +| User=root、Group=root | 指定服务以 root 用户和 root 组的权限运行 | +| ExecStart/ExecStop | 分别指定服务的启动脚本和停止脚本的路径 | +| Restart=on-failure | 仅在服务异常退出时,自动重启服务 | +| SuccessExitStatus=143 | 将退出码 143(128+15,即 SIGTERM 正常终止)视为成功退出 | +| RestartSec=5 | 服务重启的间隔时间,默认为 5 秒 | +| StartLimitInterval=600s、StartLimitBurst=3 | 10 分钟(600 秒)内,服务最多重启 3 次,防止频繁重启导致系统资源浪费 | +| RestartPreventExitStatus=SIGKILL | 服务被 SIGKILL 信号杀死后,不自动重启,避免无限重启僵尸进程 | + +#### 5.2.3 [Install] 部分(安装配置) + +| 配置项 | 含义 | +| ---------------------------- | -------------------------------------------- | +| WantedBy=multi-user.target | 指定服务在系统进入多用户模式时,自动启动。 | + +### 5.3 .service 文件格式示例 + +```bash +[Unit] +Description=timechodb-confignode +Documentation=https://www.timecho.com/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$TimechoDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +注:上述为 timechodb-confignode.service 文件的标准格式,timechodb-datanode.service、timechodb-ainode.service 文件格式类似。 + +## 6. 注意事项 + +1. **进程守护机制** + +* **自动重启**:服务启动失败或运行中异常退出(如 OOM)时,系统将自动重启。 +* **不重启**:正常退出(如执行 `kill`、`./sbin/stop-xxx.sh` 或 `systemctl stop`)不会触发自动重启。 + +2. **日志位置** + +* 所有运行日志均存储在 TimechoDB 安装目录下的 `logs` 文件夹中,排查问题时请查阅该目录。 + +3. **集群状态查看** + +* 服务启动后,执行 `./sbin/start-cli.sh` 并输入 `show cluster` 命令,即可查看集群状态。 + +4. **故障恢复流程** + +* 若服务状态为 `failed`,修复问题后**必须**先执行 `systemctl daemon-reload`,然后再执行 `systemctl start`,否则启动将失败。 + +5. **配置生效** + +* 修改 `daemon-xxx.sh` 脚本内容后,需执行 `systemctl daemon-reload` 重新注册服务,新配置方可生效。 + +6. **启动方式兼容** + +* `systemctl start`启动的服务,可用`./sbin/stop` 停止(不重启)。 +* `./sbin/start` 启动的进程,无法通过 `systemctl` 监控状态。 diff --git a/src/zh/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_apache.md b/src/zh/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_apache.md new file mode 100644 index 000000000..b229505d6 --- /dev/null +++ b/src/zh/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_apache.md @@ -0,0 +1,243 @@ + + +# 开机自启 + +## 1.概述 + +IoTDB 支持通过 `daemon-confignode.sh`、`daemon-datanode.sh`、`daemon-ainode.sh` 三个脚本,将ConfigNode、DataNode、AINode 注册为 Linux 系统服务,结合系统自带的 `systemctl `命令,以守护进程方式管理 IoTDB 集群,实现更便捷的启动、停止、重启及开机自启等操作,提升服务稳定性。 + +> 注意:该功能从 V2.0.9-beta 版本开始提供。 + +## 2. 环境要求 + +| 操作系统 | Linux(支持`systemctl`命令) | +| ---------- |:-----------------------------------------------------:| +| 用户权限 | root 用户 | +| 环境变量 | 部署 ConfigNode 和 DataNode 前需设置`JAVA_HOME` | + +## 3. 服务注册 + +进入 IoTDB 安装目录,执行对应的守护进程脚本: + +```Bash +# 注册 ConfigNode 服务 +./tools/ops/daemon-confignode.sh + +# 注册 DataNode 服务 +./tools/ops/daemon-datanode.sh + +# 注册 AINode 服务 +./tools/ops/daemon-ainode.sh +``` + +执行脚本时将提示以下两个选择项: + +1. 是否本次直接启动对应 IoTDB 服务(iotdb-confignode/iotdb-datanode/iotdb-ainode); +2. 是否将对应服务注册为开机自启服务。 + +脚本执行完成后,将在 `/etc/systemd/system/` 目录生成对应的服务文件: + +* `iotdb-confignode.service` +* `iotdb-datanode.service` +* `iotdb-ainode.service` + +## 4. 服务管理 + +服务注册完成后,可通过 systemctl 命令对 IoTDB 各节点服务进行启动、停止、重启、查看状态及配置开机自启等操作,以下命令均需使用 root 用户执行。 + +### 4.1 手动启动服务 + +```bash +# 启动 ConfigNode 服务 +systemctl start iotdb-confignode +# 启动 DataNode 服务 +systemctl start iotdb-datanode +# 启动 AINode 服务 +systemctl start iotdb-ainode +``` + +### 4.2 手动停止服务 + +```bash +# 停止 ConfigNode 服务 +systemctl stop iotdb-confignode +# 停止 DataNode 服务 +systemctl stop iotdb-datanode +# 停止 AINode 服务 +systemctl stop iotdb-ainode +``` + +停止服务后,通过查看服务状态,若显示为 inactive(dead),则说明服务关闭成功;若为其他状态,需查看 IoTDB 日志,分析异常原因。 + +### 4.3 查看服务状态 + +```bash +# 查看 ConfigNode 服务状态 +systemctl status iotdb-confignode +# 查看 DataNode 服务状态 +systemctl status iotdb-datanode +# 查看 AINode 服务状态 +systemctl status iotdb-ainode +``` + +状态说明: + +* active(running):服务正在运行,若该状态持续 10 分钟,说明服务启动成功; +* failed:服务启动失败,需查看 IoTDB 日志排查问题。 + +### 4.4 重启服务 + +重启服务相当于先执行停止操作,再执行启动操作,命令如下: + +```bash +# 重启 ConfigNode 服务 +systemctl restart iotdb-confignode +# 重启 DataNode 服务 +systemctl restart iotdb-datanode +# 重启 AINode 服务 +systemctl restart iotdb-ainode +``` + +### 4.5 配置开机自启 + +```bash +# 配置 ConfigNode 开机自启 +systemctl enable iotdb-confignode +# 配置 DataNode 开机自启 +systemctl enable iotdb-datanode +# 配置 AINode 开机自启 +systemctl enable iotdb-ainode +``` + +### 4.6 取消开机自启 + +```bash +# 取消 ConfigNode 开机自启 +systemctl disable iotdb-confignode +# 取消 DataNode 开机自启 +systemctl disable iotdb-datanode +# 取消 AINode 开机自启 +systemctl disable iotdb-ainode +``` + +## 5. 自定义服务配置 + +### 5.1 自定义方式 + +#### 5.1.1 方案一:修改脚本 + +1. 修改 `daemon-xxx.sh` 中的[Unit]、[Service]、[Install]区域配置项,具体配置项的含义参考下一小节 +2. 执行 `daemon-xxx.sh` 脚本 + +#### 5.1.2 方案二:修改服务文件 + +1. 修改 `/etc/systemd/system` 中的 `xx.service` 文件 +2. 执行 `systemctl deamon-reload` + +### 5.2 `daemon-xxx.sh` 配置项 + +#### 5.2.1 [Unit] 部分(服务元信息) + +| 配置项 | 说明 | +| --------------- | ---------------------------------- | +| Description | 服务描述 | +| Documentation | 指向 IoTDB 官方文档 | +| After | 确保在网络服务启动后才启动该服务 | + +#### 5.2.2 [Service] 部分(服务运行配置) + +| 配置项 | 含义 | +| -------------------------------------------- | ---------------------------------------------------------------------- | +| StandardOutput、StandardError | 指定服务标准输出和错误日志的存储路径 | +| LimitNOFILE=65536 | 设置文件描述符上限,默认值为 65536 | +| Type=simple | 服务类型为简单前台进程,systemd 会跟踪服务主进程 | +| User=root、Group=root | 指定服务以 root 用户和 root 组的权限运行 | +| ExecStart/ExecStop | 分别指定服务的启动脚本和停止脚本的路径 | +| Restart=on-failure | 仅在服务异常退出时,自动重启服务 | +| SuccessExitStatus=143 | 将退出码 143(128+15,即 SIGTERM 正常终止)视为成功退出 | +| RestartSec=5 | 服务重启的间隔时间,默认为 5 秒 | +| StartLimitInterval=600s、StartLimitBurst=3 | 10 分钟(600 秒)内,服务最多重启 3 次,防止频繁重启导致系统资源浪费 | +| RestartPreventExitStatus=SIGKILL | 服务被 SIGKILL 信号杀死后,不自动重启,避免无限重启僵尸进程 | + +#### 5.2.3 [Install] 部分(安装配置) + +| 配置项 | 含义 | +| ---------------------------- | -------------------------------------------- | +| WantedBy=multi-user.target | 指定服务在系统进入多用户模式时,自动启动。 | + +### 5.3 .service 文件格式示例 + +```bash +[Unit] +Description=iotdb-confignode +Documentation=https://iotdb.apache.org/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$IoTDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +注:上述为 iotdb-confignode.service 文件的标准格式,iotdb-datanode.service、iotdb-ainode.service 文件格式类似。 + +## 6. 注意事项 + +1. **进程守护机制** + +* **自动重启**:服务启动失败或运行中异常退出(如 OOM)时,系统将自动重启。 +* **不重启**:正常退出(如执行 `kill`、`./sbin/stop-xxx.sh` 或 `systemctl stop`)不会触发自动重启。 + +2. **日志位置** + +* 所有运行日志均存储在 IoTDB 安装目录下的 `logs` 文件夹中,排查问题时请查阅该目录。 + +3. **集群状态查看** + +* 服务启动后,执行 `./sbin/start-cli.sh` 并输入 `show cluster` 命令,即可查看集群状态。 + +4. **故障恢复流程** + +* 若服务状态为 `failed`,修复问题后**必须**先执行 `systemctl daemon-reload`,然后再执行 `systemctl start`,否则启动将失败。 + +5. **配置生效** + +* 修改 `daemon-xxx.sh` 脚本内容后,需执行 `systemctl daemon-reload` 重新注册服务,新配置方可生效。 + +6. **启动方式兼容** + +* `systemctl start`启动的服务,可用`./sbin/stop` 停止(不重启)。 +* `./sbin/start` 启动的进程,无法通过 `systemctl` 监控状态。 diff --git a/src/zh/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_timecho.md b/src/zh/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_timecho.md new file mode 100644 index 000000000..4bcc356c5 --- /dev/null +++ b/src/zh/UserGuide/Master/Tree/User-Manual/Auto-Start-On-Boot_timecho.md @@ -0,0 +1,243 @@ + + +# 开机自启 + +## 1.概述 + +TimechoDB 支持通过 `daemon-confignode.sh`、`daemon-datanode.sh`、`daemon-ainode.sh` 三个脚本,将ConfigNode、DataNode、AINode 注册为 Linux 系统服务,结合系统自带的 `systemctl `命令,以守护进程方式管理 TimechoDB 集群,实现更便捷的启动、停止、重启及开机自启等操作,提升服务稳定性。 + +> 注意:该功能从 V 2.0.9 版本开始提供。 + +## 2. 环境要求 + +| 操作系统 | Linux(支持`systemctl`命令) | +| ---------- |:-----------------------------------------------------:| +| 用户权限 | root 用户 | +| 环境变量 | 部署 ConfigNode 和 DataNode 前需设置`JAVA_HOME` | + +## 3. 服务注册 + +进入 TimechoDB 安装目录,执行对应的守护进程脚本: + +```Bash +# 注册 ConfigNode 服务 +./tools/ops/daemon-confignode.sh + +# 注册 DataNode 服务 +./tools/ops/daemon-datanode.sh + +# 注册 AINode 服务 +./tools/ops/daemon-ainode.sh +``` + +执行脚本时将提示以下两个选择项: + +1. 是否本次直接启动对应 TimechoDB 服务(timechodb-confignode/timechodb-datanode/timechodb-ainode); +2. 是否将对应服务注册为开机自启服务。 + +脚本执行完成后,将在 `/etc/systemd/system/` 目录生成对应的服务文件: + +* `timechodb-confignode.service` +* `timechodb-datanode.service` +* `timechodb-ainode.service` + +## 4. 服务管理 + +服务注册完成后,可通过 systemctl 命令对 TimechoDB 各节点服务进行启动、停止、重启、查看状态及配置开机自启等操作,以下命令均需使用 root 用户执行。 + +### 4.1 手动启动服务 + +```bash +# 启动 ConfigNode 服务 +systemctl start timechodb-confignode +# 启动 DataNode 服务 +systemctl start timechodb-datanode +# 启动 AINode 服务 +systemctl start timechodb-ainode +``` + +### 4.2 手动停止服务 + +```bash +# 停止 ConfigNode 服务 +systemctl stop timechodb-confignode +# 停止 DataNode 服务 +systemctl stop timechodb-datanode +# 停止 AINode 服务 +systemctl stop timechodb-ainode +``` + +停止服务后,通过查看服务状态,若显示为 inactive(dead),则说明服务关闭成功;若为其他状态,需查看 TimechoDB 日志,分析异常原因。 + +### 4.3 查看服务状态 + +```bash +# 查看 ConfigNode 服务状态 +systemctl status timechodb-confignode +# 查看 DataNode 服务状态 +systemctl status timechodb-datanode +# 查看 AINode 服务状态 +systemctl status timechodb-ainode +``` + +状态说明: + +* active(running):服务正在运行,若该状态持续 10 分钟,说明服务启动成功; +* failed:服务启动失败,需查看 TimechoDB 日志排查问题。 + +### 4.4 重启服务 + +重启服务相当于先执行停止操作,再执行启动操作,命令如下: + +```bash +# 重启 ConfigNode 服务 +systemctl restart timechodb-confignode +# 重启 DataNode 服务 +systemctl restart timechodb-datanode +# 重启 AINode 服务 +systemctl restart timechodb-ainode +``` + +### 4.5 配置开机自启 + +```bash +# 配置 ConfigNode 开机自启 +systemctl enable timechodb-confignode +# 配置 DataNode 开机自启 +systemctl enable timechodb-datanode +# 配置 AINode 开机自启 +systemctl enable timechodb-ainode +``` + +### 4.6 取消开机自启 + +```bash +# 取消 ConfigNode 开机自启 +systemctl disable timechodb-confignode +# 取消 DataNode 开机自启 +systemctl disable timechodb-datanode +# 取消 AINode 开机自启 +systemctl disable timechodb-ainode +``` + +## 5. 自定义服务配置 + +### 5.1 自定义方式 + +#### 5.1.1 方案一:修改脚本 + +1. 修改 `daemon-xxx.sh` 中的[Unit]、[Service]、[Install]区域配置项,具体配置项的含义参考下一小节 +2. 执行 `daemon-xxx.sh` 脚本 + +#### 5.1.2 方案二:修改服务文件 + +1. 修改 `/etc/systemd/system` 中的 `xx.service` 文件 +2. 执行 `systemctl deamon-reload` + +### 5.2 `daemon-xxx.sh` 配置项 + +#### 5.2.1 [Unit] 部分(服务元信息) + +| 配置项 | 说明 | +| --------------- | ---------------------------------- | +| Description | 服务描述 | +| Documentation | 指向 TimechoDB 官方文档 | +| After | 确保在网络服务启动后才启动该服务 | + +#### 5.2.2 [Service] 部分(服务运行配置) + +| 配置项 | 含义 | +| -------------------------------------------- | ---------------------------------------------------------------------- | +| StandardOutput、StandardError | 指定服务标准输出和错误日志的存储路径 | +| LimitNOFILE=65536 | 设置文件描述符上限,默认值为 65536 | +| Type=simple | 服务类型为简单前台进程,systemd 会跟踪服务主进程 | +| User=root、Group=root | 指定服务以 root 用户和 root 组的权限运行 | +| ExecStart/ExecStop | 分别指定服务的启动脚本和停止脚本的路径 | +| Restart=on-failure | 仅在服务异常退出时,自动重启服务 | +| SuccessExitStatus=143 | 将退出码 143(128+15,即 SIGTERM 正常终止)视为成功退出 | +| RestartSec=5 | 服务重启的间隔时间,默认为 5 秒 | +| StartLimitInterval=600s、StartLimitBurst=3 | 10 分钟(600 秒)内,服务最多重启 3 次,防止频繁重启导致系统资源浪费 | +| RestartPreventExitStatus=SIGKILL | 服务被 SIGKILL 信号杀死后,不自动重启,避免无限重启僵尸进程 | + +#### 5.2.3 [Install] 部分(安装配置) + +| 配置项 | 含义 | +| ---------------------------- | -------------------------------------------- | +| WantedBy=multi-user.target | 指定服务在系统进入多用户模式时,自动启动。 | + +### 5.3 .service 文件格式示例 + +```bash +[Unit] +Description=timechodb-confignode +Documentation=https://www.timecho.com/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$TimechoDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +注:上述为 timechodb-confignode.service 文件的标准格式,timechodb-datanode.service、timechodb-ainode.service 文件格式类似。 + +## 6. 注意事项 + +1. **进程守护机制** + +* **自动重启**:服务启动失败或运行中异常退出(如 OOM)时,系统将自动重启。 +* **不重启**:正常退出(如执行 `kill`、`./sbin/stop-xxx.sh` 或 `systemctl stop`)不会触发自动重启。 + +2. **日志位置** + +* 所有运行日志均存储在 TimechoDB 安装目录下的 `logs` 文件夹中,排查问题时请查阅该目录。 + +3. **集群状态查看** + +* 服务启动后,执行 `./sbin/start-cli.sh` 并输入 `show cluster` 命令,即可查看集群状态。 + +4. **故障恢复流程** + +* 若服务状态为 `failed`,修复问题后**必须**先执行 `systemctl daemon-reload`,然后再执行 `systemctl start`,否则启动将失败。 + +5. **配置生效** + +* 修改 `daemon-xxx.sh` 脚本内容后,需执行 `systemctl daemon-reload` 重新注册服务,新配置方可生效。 + +6. **启动方式兼容** + +* `systemctl start`启动的服务,可用`./sbin/stop` 停止(不重启)。 +* `./sbin/start` 启动的进程,无法通过 `systemctl` 监控状态。 diff --git a/src/zh/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_apache.md b/src/zh/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_apache.md new file mode 100644 index 000000000..b229505d6 --- /dev/null +++ b/src/zh/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_apache.md @@ -0,0 +1,243 @@ + + +# 开机自启 + +## 1.概述 + +IoTDB 支持通过 `daemon-confignode.sh`、`daemon-datanode.sh`、`daemon-ainode.sh` 三个脚本,将ConfigNode、DataNode、AINode 注册为 Linux 系统服务,结合系统自带的 `systemctl `命令,以守护进程方式管理 IoTDB 集群,实现更便捷的启动、停止、重启及开机自启等操作,提升服务稳定性。 + +> 注意:该功能从 V2.0.9-beta 版本开始提供。 + +## 2. 环境要求 + +| 操作系统 | Linux(支持`systemctl`命令) | +| ---------- |:-----------------------------------------------------:| +| 用户权限 | root 用户 | +| 环境变量 | 部署 ConfigNode 和 DataNode 前需设置`JAVA_HOME` | + +## 3. 服务注册 + +进入 IoTDB 安装目录,执行对应的守护进程脚本: + +```Bash +# 注册 ConfigNode 服务 +./tools/ops/daemon-confignode.sh + +# 注册 DataNode 服务 +./tools/ops/daemon-datanode.sh + +# 注册 AINode 服务 +./tools/ops/daemon-ainode.sh +``` + +执行脚本时将提示以下两个选择项: + +1. 是否本次直接启动对应 IoTDB 服务(iotdb-confignode/iotdb-datanode/iotdb-ainode); +2. 是否将对应服务注册为开机自启服务。 + +脚本执行完成后,将在 `/etc/systemd/system/` 目录生成对应的服务文件: + +* `iotdb-confignode.service` +* `iotdb-datanode.service` +* `iotdb-ainode.service` + +## 4. 服务管理 + +服务注册完成后,可通过 systemctl 命令对 IoTDB 各节点服务进行启动、停止、重启、查看状态及配置开机自启等操作,以下命令均需使用 root 用户执行。 + +### 4.1 手动启动服务 + +```bash +# 启动 ConfigNode 服务 +systemctl start iotdb-confignode +# 启动 DataNode 服务 +systemctl start iotdb-datanode +# 启动 AINode 服务 +systemctl start iotdb-ainode +``` + +### 4.2 手动停止服务 + +```bash +# 停止 ConfigNode 服务 +systemctl stop iotdb-confignode +# 停止 DataNode 服务 +systemctl stop iotdb-datanode +# 停止 AINode 服务 +systemctl stop iotdb-ainode +``` + +停止服务后,通过查看服务状态,若显示为 inactive(dead),则说明服务关闭成功;若为其他状态,需查看 IoTDB 日志,分析异常原因。 + +### 4.3 查看服务状态 + +```bash +# 查看 ConfigNode 服务状态 +systemctl status iotdb-confignode +# 查看 DataNode 服务状态 +systemctl status iotdb-datanode +# 查看 AINode 服务状态 +systemctl status iotdb-ainode +``` + +状态说明: + +* active(running):服务正在运行,若该状态持续 10 分钟,说明服务启动成功; +* failed:服务启动失败,需查看 IoTDB 日志排查问题。 + +### 4.4 重启服务 + +重启服务相当于先执行停止操作,再执行启动操作,命令如下: + +```bash +# 重启 ConfigNode 服务 +systemctl restart iotdb-confignode +# 重启 DataNode 服务 +systemctl restart iotdb-datanode +# 重启 AINode 服务 +systemctl restart iotdb-ainode +``` + +### 4.5 配置开机自启 + +```bash +# 配置 ConfigNode 开机自启 +systemctl enable iotdb-confignode +# 配置 DataNode 开机自启 +systemctl enable iotdb-datanode +# 配置 AINode 开机自启 +systemctl enable iotdb-ainode +``` + +### 4.6 取消开机自启 + +```bash +# 取消 ConfigNode 开机自启 +systemctl disable iotdb-confignode +# 取消 DataNode 开机自启 +systemctl disable iotdb-datanode +# 取消 AINode 开机自启 +systemctl disable iotdb-ainode +``` + +## 5. 自定义服务配置 + +### 5.1 自定义方式 + +#### 5.1.1 方案一:修改脚本 + +1. 修改 `daemon-xxx.sh` 中的[Unit]、[Service]、[Install]区域配置项,具体配置项的含义参考下一小节 +2. 执行 `daemon-xxx.sh` 脚本 + +#### 5.1.2 方案二:修改服务文件 + +1. 修改 `/etc/systemd/system` 中的 `xx.service` 文件 +2. 执行 `systemctl deamon-reload` + +### 5.2 `daemon-xxx.sh` 配置项 + +#### 5.2.1 [Unit] 部分(服务元信息) + +| 配置项 | 说明 | +| --------------- | ---------------------------------- | +| Description | 服务描述 | +| Documentation | 指向 IoTDB 官方文档 | +| After | 确保在网络服务启动后才启动该服务 | + +#### 5.2.2 [Service] 部分(服务运行配置) + +| 配置项 | 含义 | +| -------------------------------------------- | ---------------------------------------------------------------------- | +| StandardOutput、StandardError | 指定服务标准输出和错误日志的存储路径 | +| LimitNOFILE=65536 | 设置文件描述符上限,默认值为 65536 | +| Type=simple | 服务类型为简单前台进程,systemd 会跟踪服务主进程 | +| User=root、Group=root | 指定服务以 root 用户和 root 组的权限运行 | +| ExecStart/ExecStop | 分别指定服务的启动脚本和停止脚本的路径 | +| Restart=on-failure | 仅在服务异常退出时,自动重启服务 | +| SuccessExitStatus=143 | 将退出码 143(128+15,即 SIGTERM 正常终止)视为成功退出 | +| RestartSec=5 | 服务重启的间隔时间,默认为 5 秒 | +| StartLimitInterval=600s、StartLimitBurst=3 | 10 分钟(600 秒)内,服务最多重启 3 次,防止频繁重启导致系统资源浪费 | +| RestartPreventExitStatus=SIGKILL | 服务被 SIGKILL 信号杀死后,不自动重启,避免无限重启僵尸进程 | + +#### 5.2.3 [Install] 部分(安装配置) + +| 配置项 | 含义 | +| ---------------------------- | -------------------------------------------- | +| WantedBy=multi-user.target | 指定服务在系统进入多用户模式时,自动启动。 | + +### 5.3 .service 文件格式示例 + +```bash +[Unit] +Description=iotdb-confignode +Documentation=https://iotdb.apache.org/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$IoTDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +注:上述为 iotdb-confignode.service 文件的标准格式,iotdb-datanode.service、iotdb-ainode.service 文件格式类似。 + +## 6. 注意事项 + +1. **进程守护机制** + +* **自动重启**:服务启动失败或运行中异常退出(如 OOM)时,系统将自动重启。 +* **不重启**:正常退出(如执行 `kill`、`./sbin/stop-xxx.sh` 或 `systemctl stop`)不会触发自动重启。 + +2. **日志位置** + +* 所有运行日志均存储在 IoTDB 安装目录下的 `logs` 文件夹中,排查问题时请查阅该目录。 + +3. **集群状态查看** + +* 服务启动后,执行 `./sbin/start-cli.sh` 并输入 `show cluster` 命令,即可查看集群状态。 + +4. **故障恢复流程** + +* 若服务状态为 `failed`,修复问题后**必须**先执行 `systemctl daemon-reload`,然后再执行 `systemctl start`,否则启动将失败。 + +5. **配置生效** + +* 修改 `daemon-xxx.sh` 脚本内容后,需执行 `systemctl daemon-reload` 重新注册服务,新配置方可生效。 + +6. **启动方式兼容** + +* `systemctl start`启动的服务,可用`./sbin/stop` 停止(不重启)。 +* `./sbin/start` 启动的进程,无法通过 `systemctl` 监控状态。 diff --git a/src/zh/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_timecho.md b/src/zh/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_timecho.md new file mode 100644 index 000000000..4bcc356c5 --- /dev/null +++ b/src/zh/UserGuide/latest-Table/User-Manual/Auto-Start-On-Boot_timecho.md @@ -0,0 +1,243 @@ + + +# 开机自启 + +## 1.概述 + +TimechoDB 支持通过 `daemon-confignode.sh`、`daemon-datanode.sh`、`daemon-ainode.sh` 三个脚本,将ConfigNode、DataNode、AINode 注册为 Linux 系统服务,结合系统自带的 `systemctl `命令,以守护进程方式管理 TimechoDB 集群,实现更便捷的启动、停止、重启及开机自启等操作,提升服务稳定性。 + +> 注意:该功能从 V 2.0.9 版本开始提供。 + +## 2. 环境要求 + +| 操作系统 | Linux(支持`systemctl`命令) | +| ---------- |:-----------------------------------------------------:| +| 用户权限 | root 用户 | +| 环境变量 | 部署 ConfigNode 和 DataNode 前需设置`JAVA_HOME` | + +## 3. 服务注册 + +进入 TimechoDB 安装目录,执行对应的守护进程脚本: + +```Bash +# 注册 ConfigNode 服务 +./tools/ops/daemon-confignode.sh + +# 注册 DataNode 服务 +./tools/ops/daemon-datanode.sh + +# 注册 AINode 服务 +./tools/ops/daemon-ainode.sh +``` + +执行脚本时将提示以下两个选择项: + +1. 是否本次直接启动对应 TimechoDB 服务(timechodb-confignode/timechodb-datanode/timechodb-ainode); +2. 是否将对应服务注册为开机自启服务。 + +脚本执行完成后,将在 `/etc/systemd/system/` 目录生成对应的服务文件: + +* `timechodb-confignode.service` +* `timechodb-datanode.service` +* `timechodb-ainode.service` + +## 4. 服务管理 + +服务注册完成后,可通过 systemctl 命令对 TimechoDB 各节点服务进行启动、停止、重启、查看状态及配置开机自启等操作,以下命令均需使用 root 用户执行。 + +### 4.1 手动启动服务 + +```bash +# 启动 ConfigNode 服务 +systemctl start timechodb-confignode +# 启动 DataNode 服务 +systemctl start timechodb-datanode +# 启动 AINode 服务 +systemctl start timechodb-ainode +``` + +### 4.2 手动停止服务 + +```bash +# 停止 ConfigNode 服务 +systemctl stop timechodb-confignode +# 停止 DataNode 服务 +systemctl stop timechodb-datanode +# 停止 AINode 服务 +systemctl stop timechodb-ainode +``` + +停止服务后,通过查看服务状态,若显示为 inactive(dead),则说明服务关闭成功;若为其他状态,需查看 TimechoDB 日志,分析异常原因。 + +### 4.3 查看服务状态 + +```bash +# 查看 ConfigNode 服务状态 +systemctl status timechodb-confignode +# 查看 DataNode 服务状态 +systemctl status timechodb-datanode +# 查看 AINode 服务状态 +systemctl status timechodb-ainode +``` + +状态说明: + +* active(running):服务正在运行,若该状态持续 10 分钟,说明服务启动成功; +* failed:服务启动失败,需查看 TimechoDB 日志排查问题。 + +### 4.4 重启服务 + +重启服务相当于先执行停止操作,再执行启动操作,命令如下: + +```bash +# 重启 ConfigNode 服务 +systemctl restart timechodb-confignode +# 重启 DataNode 服务 +systemctl restart timechodb-datanode +# 重启 AINode 服务 +systemctl restart timechodb-ainode +``` + +### 4.5 配置开机自启 + +```bash +# 配置 ConfigNode 开机自启 +systemctl enable timechodb-confignode +# 配置 DataNode 开机自启 +systemctl enable timechodb-datanode +# 配置 AINode 开机自启 +systemctl enable timechodb-ainode +``` + +### 4.6 取消开机自启 + +```bash +# 取消 ConfigNode 开机自启 +systemctl disable timechodb-confignode +# 取消 DataNode 开机自启 +systemctl disable timechodb-datanode +# 取消 AINode 开机自启 +systemctl disable timechodb-ainode +``` + +## 5. 自定义服务配置 + +### 5.1 自定义方式 + +#### 5.1.1 方案一:修改脚本 + +1. 修改 `daemon-xxx.sh` 中的[Unit]、[Service]、[Install]区域配置项,具体配置项的含义参考下一小节 +2. 执行 `daemon-xxx.sh` 脚本 + +#### 5.1.2 方案二:修改服务文件 + +1. 修改 `/etc/systemd/system` 中的 `xx.service` 文件 +2. 执行 `systemctl deamon-reload` + +### 5.2 `daemon-xxx.sh` 配置项 + +#### 5.2.1 [Unit] 部分(服务元信息) + +| 配置项 | 说明 | +| --------------- | ---------------------------------- | +| Description | 服务描述 | +| Documentation | 指向 TimechoDB 官方文档 | +| After | 确保在网络服务启动后才启动该服务 | + +#### 5.2.2 [Service] 部分(服务运行配置) + +| 配置项 | 含义 | +| -------------------------------------------- | ---------------------------------------------------------------------- | +| StandardOutput、StandardError | 指定服务标准输出和错误日志的存储路径 | +| LimitNOFILE=65536 | 设置文件描述符上限,默认值为 65536 | +| Type=simple | 服务类型为简单前台进程,systemd 会跟踪服务主进程 | +| User=root、Group=root | 指定服务以 root 用户和 root 组的权限运行 | +| ExecStart/ExecStop | 分别指定服务的启动脚本和停止脚本的路径 | +| Restart=on-failure | 仅在服务异常退出时,自动重启服务 | +| SuccessExitStatus=143 | 将退出码 143(128+15,即 SIGTERM 正常终止)视为成功退出 | +| RestartSec=5 | 服务重启的间隔时间,默认为 5 秒 | +| StartLimitInterval=600s、StartLimitBurst=3 | 10 分钟(600 秒)内,服务最多重启 3 次,防止频繁重启导致系统资源浪费 | +| RestartPreventExitStatus=SIGKILL | 服务被 SIGKILL 信号杀死后,不自动重启,避免无限重启僵尸进程 | + +#### 5.2.3 [Install] 部分(安装配置) + +| 配置项 | 含义 | +| ---------------------------- | -------------------------------------------- | +| WantedBy=multi-user.target | 指定服务在系统进入多用户模式时,自动启动。 | + +### 5.3 .service 文件格式示例 + +```bash +[Unit] +Description=timechodb-confignode +Documentation=https://www.timecho.com/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$TimechoDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +注:上述为 timechodb-confignode.service 文件的标准格式,timechodb-datanode.service、timechodb-ainode.service 文件格式类似。 + +## 6. 注意事项 + +1. **进程守护机制** + +* **自动重启**:服务启动失败或运行中异常退出(如 OOM)时,系统将自动重启。 +* **不重启**:正常退出(如执行 `kill`、`./sbin/stop-xxx.sh` 或 `systemctl stop`)不会触发自动重启。 + +2. **日志位置** + +* 所有运行日志均存储在 TimechoDB 安装目录下的 `logs` 文件夹中,排查问题时请查阅该目录。 + +3. **集群状态查看** + +* 服务启动后,执行 `./sbin/start-cli.sh` 并输入 `show cluster` 命令,即可查看集群状态。 + +4. **故障恢复流程** + +* 若服务状态为 `failed`,修复问题后**必须**先执行 `systemctl daemon-reload`,然后再执行 `systemctl start`,否则启动将失败。 + +5. **配置生效** + +* 修改 `daemon-xxx.sh` 脚本内容后,需执行 `systemctl daemon-reload` 重新注册服务,新配置方可生效。 + +6. **启动方式兼容** + +* `systemctl start`启动的服务,可用`./sbin/stop` 停止(不重启)。 +* `./sbin/start` 启动的进程,无法通过 `systemctl` 监控状态。 diff --git a/src/zh/UserGuide/latest/User-Manual/Auto-Start-On-Boot_apache.md b/src/zh/UserGuide/latest/User-Manual/Auto-Start-On-Boot_apache.md new file mode 100644 index 000000000..b229505d6 --- /dev/null +++ b/src/zh/UserGuide/latest/User-Manual/Auto-Start-On-Boot_apache.md @@ -0,0 +1,243 @@ + + +# 开机自启 + +## 1.概述 + +IoTDB 支持通过 `daemon-confignode.sh`、`daemon-datanode.sh`、`daemon-ainode.sh` 三个脚本,将ConfigNode、DataNode、AINode 注册为 Linux 系统服务,结合系统自带的 `systemctl `命令,以守护进程方式管理 IoTDB 集群,实现更便捷的启动、停止、重启及开机自启等操作,提升服务稳定性。 + +> 注意:该功能从 V2.0.9-beta 版本开始提供。 + +## 2. 环境要求 + +| 操作系统 | Linux(支持`systemctl`命令) | +| ---------- |:-----------------------------------------------------:| +| 用户权限 | root 用户 | +| 环境变量 | 部署 ConfigNode 和 DataNode 前需设置`JAVA_HOME` | + +## 3. 服务注册 + +进入 IoTDB 安装目录,执行对应的守护进程脚本: + +```Bash +# 注册 ConfigNode 服务 +./tools/ops/daemon-confignode.sh + +# 注册 DataNode 服务 +./tools/ops/daemon-datanode.sh + +# 注册 AINode 服务 +./tools/ops/daemon-ainode.sh +``` + +执行脚本时将提示以下两个选择项: + +1. 是否本次直接启动对应 IoTDB 服务(iotdb-confignode/iotdb-datanode/iotdb-ainode); +2. 是否将对应服务注册为开机自启服务。 + +脚本执行完成后,将在 `/etc/systemd/system/` 目录生成对应的服务文件: + +* `iotdb-confignode.service` +* `iotdb-datanode.service` +* `iotdb-ainode.service` + +## 4. 服务管理 + +服务注册完成后,可通过 systemctl 命令对 IoTDB 各节点服务进行启动、停止、重启、查看状态及配置开机自启等操作,以下命令均需使用 root 用户执行。 + +### 4.1 手动启动服务 + +```bash +# 启动 ConfigNode 服务 +systemctl start iotdb-confignode +# 启动 DataNode 服务 +systemctl start iotdb-datanode +# 启动 AINode 服务 +systemctl start iotdb-ainode +``` + +### 4.2 手动停止服务 + +```bash +# 停止 ConfigNode 服务 +systemctl stop iotdb-confignode +# 停止 DataNode 服务 +systemctl stop iotdb-datanode +# 停止 AINode 服务 +systemctl stop iotdb-ainode +``` + +停止服务后,通过查看服务状态,若显示为 inactive(dead),则说明服务关闭成功;若为其他状态,需查看 IoTDB 日志,分析异常原因。 + +### 4.3 查看服务状态 + +```bash +# 查看 ConfigNode 服务状态 +systemctl status iotdb-confignode +# 查看 DataNode 服务状态 +systemctl status iotdb-datanode +# 查看 AINode 服务状态 +systemctl status iotdb-ainode +``` + +状态说明: + +* active(running):服务正在运行,若该状态持续 10 分钟,说明服务启动成功; +* failed:服务启动失败,需查看 IoTDB 日志排查问题。 + +### 4.4 重启服务 + +重启服务相当于先执行停止操作,再执行启动操作,命令如下: + +```bash +# 重启 ConfigNode 服务 +systemctl restart iotdb-confignode +# 重启 DataNode 服务 +systemctl restart iotdb-datanode +# 重启 AINode 服务 +systemctl restart iotdb-ainode +``` + +### 4.5 配置开机自启 + +```bash +# 配置 ConfigNode 开机自启 +systemctl enable iotdb-confignode +# 配置 DataNode 开机自启 +systemctl enable iotdb-datanode +# 配置 AINode 开机自启 +systemctl enable iotdb-ainode +``` + +### 4.6 取消开机自启 + +```bash +# 取消 ConfigNode 开机自启 +systemctl disable iotdb-confignode +# 取消 DataNode 开机自启 +systemctl disable iotdb-datanode +# 取消 AINode 开机自启 +systemctl disable iotdb-ainode +``` + +## 5. 自定义服务配置 + +### 5.1 自定义方式 + +#### 5.1.1 方案一:修改脚本 + +1. 修改 `daemon-xxx.sh` 中的[Unit]、[Service]、[Install]区域配置项,具体配置项的含义参考下一小节 +2. 执行 `daemon-xxx.sh` 脚本 + +#### 5.1.2 方案二:修改服务文件 + +1. 修改 `/etc/systemd/system` 中的 `xx.service` 文件 +2. 执行 `systemctl deamon-reload` + +### 5.2 `daemon-xxx.sh` 配置项 + +#### 5.2.1 [Unit] 部分(服务元信息) + +| 配置项 | 说明 | +| --------------- | ---------------------------------- | +| Description | 服务描述 | +| Documentation | 指向 IoTDB 官方文档 | +| After | 确保在网络服务启动后才启动该服务 | + +#### 5.2.2 [Service] 部分(服务运行配置) + +| 配置项 | 含义 | +| -------------------------------------------- | ---------------------------------------------------------------------- | +| StandardOutput、StandardError | 指定服务标准输出和错误日志的存储路径 | +| LimitNOFILE=65536 | 设置文件描述符上限,默认值为 65536 | +| Type=simple | 服务类型为简单前台进程,systemd 会跟踪服务主进程 | +| User=root、Group=root | 指定服务以 root 用户和 root 组的权限运行 | +| ExecStart/ExecStop | 分别指定服务的启动脚本和停止脚本的路径 | +| Restart=on-failure | 仅在服务异常退出时,自动重启服务 | +| SuccessExitStatus=143 | 将退出码 143(128+15,即 SIGTERM 正常终止)视为成功退出 | +| RestartSec=5 | 服务重启的间隔时间,默认为 5 秒 | +| StartLimitInterval=600s、StartLimitBurst=3 | 10 分钟(600 秒)内,服务最多重启 3 次,防止频繁重启导致系统资源浪费 | +| RestartPreventExitStatus=SIGKILL | 服务被 SIGKILL 信号杀死后,不自动重启,避免无限重启僵尸进程 | + +#### 5.2.3 [Install] 部分(安装配置) + +| 配置项 | 含义 | +| ---------------------------- | -------------------------------------------- | +| WantedBy=multi-user.target | 指定服务在系统进入多用户模式时,自动启动。 | + +### 5.3 .service 文件格式示例 + +```bash +[Unit] +Description=iotdb-confignode +Documentation=https://iotdb.apache.org/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$IoTDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +注:上述为 iotdb-confignode.service 文件的标准格式,iotdb-datanode.service、iotdb-ainode.service 文件格式类似。 + +## 6. 注意事项 + +1. **进程守护机制** + +* **自动重启**:服务启动失败或运行中异常退出(如 OOM)时,系统将自动重启。 +* **不重启**:正常退出(如执行 `kill`、`./sbin/stop-xxx.sh` 或 `systemctl stop`)不会触发自动重启。 + +2. **日志位置** + +* 所有运行日志均存储在 IoTDB 安装目录下的 `logs` 文件夹中,排查问题时请查阅该目录。 + +3. **集群状态查看** + +* 服务启动后,执行 `./sbin/start-cli.sh` 并输入 `show cluster` 命令,即可查看集群状态。 + +4. **故障恢复流程** + +* 若服务状态为 `failed`,修复问题后**必须**先执行 `systemctl daemon-reload`,然后再执行 `systemctl start`,否则启动将失败。 + +5. **配置生效** + +* 修改 `daemon-xxx.sh` 脚本内容后,需执行 `systemctl daemon-reload` 重新注册服务,新配置方可生效。 + +6. **启动方式兼容** + +* `systemctl start`启动的服务,可用`./sbin/stop` 停止(不重启)。 +* `./sbin/start` 启动的进程,无法通过 `systemctl` 监控状态。 diff --git a/src/zh/UserGuide/latest/User-Manual/Auto-Start-On-Boot_timecho.md b/src/zh/UserGuide/latest/User-Manual/Auto-Start-On-Boot_timecho.md new file mode 100644 index 000000000..4bcc356c5 --- /dev/null +++ b/src/zh/UserGuide/latest/User-Manual/Auto-Start-On-Boot_timecho.md @@ -0,0 +1,243 @@ + + +# 开机自启 + +## 1.概述 + +TimechoDB 支持通过 `daemon-confignode.sh`、`daemon-datanode.sh`、`daemon-ainode.sh` 三个脚本,将ConfigNode、DataNode、AINode 注册为 Linux 系统服务,结合系统自带的 `systemctl `命令,以守护进程方式管理 TimechoDB 集群,实现更便捷的启动、停止、重启及开机自启等操作,提升服务稳定性。 + +> 注意:该功能从 V 2.0.9 版本开始提供。 + +## 2. 环境要求 + +| 操作系统 | Linux(支持`systemctl`命令) | +| ---------- |:-----------------------------------------------------:| +| 用户权限 | root 用户 | +| 环境变量 | 部署 ConfigNode 和 DataNode 前需设置`JAVA_HOME` | + +## 3. 服务注册 + +进入 TimechoDB 安装目录,执行对应的守护进程脚本: + +```Bash +# 注册 ConfigNode 服务 +./tools/ops/daemon-confignode.sh + +# 注册 DataNode 服务 +./tools/ops/daemon-datanode.sh + +# 注册 AINode 服务 +./tools/ops/daemon-ainode.sh +``` + +执行脚本时将提示以下两个选择项: + +1. 是否本次直接启动对应 TimechoDB 服务(timechodb-confignode/timechodb-datanode/timechodb-ainode); +2. 是否将对应服务注册为开机自启服务。 + +脚本执行完成后,将在 `/etc/systemd/system/` 目录生成对应的服务文件: + +* `timechodb-confignode.service` +* `timechodb-datanode.service` +* `timechodb-ainode.service` + +## 4. 服务管理 + +服务注册完成后,可通过 systemctl 命令对 TimechoDB 各节点服务进行启动、停止、重启、查看状态及配置开机自启等操作,以下命令均需使用 root 用户执行。 + +### 4.1 手动启动服务 + +```bash +# 启动 ConfigNode 服务 +systemctl start timechodb-confignode +# 启动 DataNode 服务 +systemctl start timechodb-datanode +# 启动 AINode 服务 +systemctl start timechodb-ainode +``` + +### 4.2 手动停止服务 + +```bash +# 停止 ConfigNode 服务 +systemctl stop timechodb-confignode +# 停止 DataNode 服务 +systemctl stop timechodb-datanode +# 停止 AINode 服务 +systemctl stop timechodb-ainode +``` + +停止服务后,通过查看服务状态,若显示为 inactive(dead),则说明服务关闭成功;若为其他状态,需查看 TimechoDB 日志,分析异常原因。 + +### 4.3 查看服务状态 + +```bash +# 查看 ConfigNode 服务状态 +systemctl status timechodb-confignode +# 查看 DataNode 服务状态 +systemctl status timechodb-datanode +# 查看 AINode 服务状态 +systemctl status timechodb-ainode +``` + +状态说明: + +* active(running):服务正在运行,若该状态持续 10 分钟,说明服务启动成功; +* failed:服务启动失败,需查看 TimechoDB 日志排查问题。 + +### 4.4 重启服务 + +重启服务相当于先执行停止操作,再执行启动操作,命令如下: + +```bash +# 重启 ConfigNode 服务 +systemctl restart timechodb-confignode +# 重启 DataNode 服务 +systemctl restart timechodb-datanode +# 重启 AINode 服务 +systemctl restart timechodb-ainode +``` + +### 4.5 配置开机自启 + +```bash +# 配置 ConfigNode 开机自启 +systemctl enable timechodb-confignode +# 配置 DataNode 开机自启 +systemctl enable timechodb-datanode +# 配置 AINode 开机自启 +systemctl enable timechodb-ainode +``` + +### 4.6 取消开机自启 + +```bash +# 取消 ConfigNode 开机自启 +systemctl disable timechodb-confignode +# 取消 DataNode 开机自启 +systemctl disable timechodb-datanode +# 取消 AINode 开机自启 +systemctl disable timechodb-ainode +``` + +## 5. 自定义服务配置 + +### 5.1 自定义方式 + +#### 5.1.1 方案一:修改脚本 + +1. 修改 `daemon-xxx.sh` 中的[Unit]、[Service]、[Install]区域配置项,具体配置项的含义参考下一小节 +2. 执行 `daemon-xxx.sh` 脚本 + +#### 5.1.2 方案二:修改服务文件 + +1. 修改 `/etc/systemd/system` 中的 `xx.service` 文件 +2. 执行 `systemctl deamon-reload` + +### 5.2 `daemon-xxx.sh` 配置项 + +#### 5.2.1 [Unit] 部分(服务元信息) + +| 配置项 | 说明 | +| --------------- | ---------------------------------- | +| Description | 服务描述 | +| Documentation | 指向 TimechoDB 官方文档 | +| After | 确保在网络服务启动后才启动该服务 | + +#### 5.2.2 [Service] 部分(服务运行配置) + +| 配置项 | 含义 | +| -------------------------------------------- | ---------------------------------------------------------------------- | +| StandardOutput、StandardError | 指定服务标准输出和错误日志的存储路径 | +| LimitNOFILE=65536 | 设置文件描述符上限,默认值为 65536 | +| Type=simple | 服务类型为简单前台进程,systemd 会跟踪服务主进程 | +| User=root、Group=root | 指定服务以 root 用户和 root 组的权限运行 | +| ExecStart/ExecStop | 分别指定服务的启动脚本和停止脚本的路径 | +| Restart=on-failure | 仅在服务异常退出时,自动重启服务 | +| SuccessExitStatus=143 | 将退出码 143(128+15,即 SIGTERM 正常终止)视为成功退出 | +| RestartSec=5 | 服务重启的间隔时间,默认为 5 秒 | +| StartLimitInterval=600s、StartLimitBurst=3 | 10 分钟(600 秒)内,服务最多重启 3 次,防止频繁重启导致系统资源浪费 | +| RestartPreventExitStatus=SIGKILL | 服务被 SIGKILL 信号杀死后,不自动重启,避免无限重启僵尸进程 | + +#### 5.2.3 [Install] 部分(安装配置) + +| 配置项 | 含义 | +| ---------------------------- | -------------------------------------------- | +| WantedBy=multi-user.target | 指定服务在系统进入多用户模式时,自动启动。 | + +### 5.3 .service 文件格式示例 + +```bash +[Unit] +Description=timechodb-confignode +Documentation=https://www.timecho.com/ +After=network.target + +[Service] +StandardOutput=null +StandardError=null +LimitNOFILE=65536 +Type=simple +User=root +Group=root +Environment=JAVA_HOME=$JAVA_HOME +ExecStart=$TimechoDB_SBIN_HOME/start-confignode.sh +Restart=on-failure +SuccessExitStatus=143 +RestartSec=5 +StartLimitInterval=600s +StartLimitBurst=3 +RestartPreventExitStatus=SIGKILL + +[Install] +WantedBy=multi-user.target +``` + +注:上述为 timechodb-confignode.service 文件的标准格式,timechodb-datanode.service、timechodb-ainode.service 文件格式类似。 + +## 6. 注意事项 + +1. **进程守护机制** + +* **自动重启**:服务启动失败或运行中异常退出(如 OOM)时,系统将自动重启。 +* **不重启**:正常退出(如执行 `kill`、`./sbin/stop-xxx.sh` 或 `systemctl stop`)不会触发自动重启。 + +2. **日志位置** + +* 所有运行日志均存储在 TimechoDB 安装目录下的 `logs` 文件夹中,排查问题时请查阅该目录。 + +3. **集群状态查看** + +* 服务启动后,执行 `./sbin/start-cli.sh` 并输入 `show cluster` 命令,即可查看集群状态。 + +4. **故障恢复流程** + +* 若服务状态为 `failed`,修复问题后**必须**先执行 `systemctl daemon-reload`,然后再执行 `systemctl start`,否则启动将失败。 + +5. **配置生效** + +* 修改 `daemon-xxx.sh` 脚本内容后,需执行 `systemctl daemon-reload` 重新注册服务,新配置方可生效。 + +6. **启动方式兼容** + +* `systemctl start`启动的服务,可用`./sbin/stop` 停止(不重启)。 +* `./sbin/start` 启动的进程,无法通过 `systemctl` 监控状态。