自定义StoneDB systemd服务报错:未知StartLimitIntervalSec指令求助
StoneDB systemd服务启动报错:未知的StartLimitIntervalSec/StartLimitInterval指令问题
问题说明
创建自定义StoneDB systemd服务后,执行systemctl daemon-reload && systemctl status stonedb -l时出现报错,日志提示Unit或Service段存在未知的StartLimitIntervalSec/StartLimitInterval指令,但未在自定义服务文件中配置这些指令。
报错信息
[root@stonedb system]# systemctl daemon-reload && systemctl status stonedb -l ● stonedb.service - StoneDB database server Loaded: loaded (/etc/systemd/system/stonedb.service; enabled; vendor preset: disabled) Active: failed (Result: start-limit) since Wed 2023-10-11 18:53:03 CEST; 5 days ago Main PID: 23915 (code=exited, status=1/FAILURE) Oct 11 18:53:03 stonedb.reporting systemd[1]: stonedb.service failed. Oct 12 00:18:57 stonedb.reporting systemd[1]: [/etc/systemd/system/stonedb.service:4] Unknown lvalue 'StartLimitIntervalSec' in section 'Unit' Oct 12 00:38:17 stonedb.reporting systemd[1]: [/etc/systemd/system/stonedb.service:4] Unknown lvalue 'StartLimitIntervalSec' in section 'Unit' Oct 12 01:53:15 stonedb.reporting systemd[1]: [/etc/systemd/system/stonedb.service:4] Unknown lvalue 'StartLimitIntervalSec' in section 'Unit' Oct 12 02:07:40 stonedb.reporting systemd[1]: [/etc/systemd/system/stonedb.service:4] Unknown lvalue 'StartLimitIntervalSec' in section 'Unit' Oct 12 02:14:26 stonedb.reporting systemd[1]: [/etc/systemd/system/stonedb.service:4] Unknown lvalue 'StartLimitIntervalSec' in section 'Unit' Oct 12 02:18:23 stonedb.reporting systemd[1]: [/usr/lib/systemd/system/stonedb.service:34] Unknown lvalue 'StartLimitIntervalSec' in section 'Service' Oct 12 02:19:13 stonedb.reporting systemd[1]: [/usr/lib/systemd/system/stonedb.service:30] Unknown lvalue 'StartLimitIntervalSec' in section 'Unit' Oct 17 01:24:37 stonedb.reporting systemd[1]: [/etc/systemd/system/stonedb.service:4] Unknown lvalue 'StartLimitInterval' in section 'Unit' Oct 17 01:27:18 stonedb.reporting systemd[1]: [/etc/systemd/system/stonedb.service:11] Unknown lvalue 'StartLimitIntervalSec' in section 'Service'
自定义服务文件内容
[Unit] Description=StoneDB database server After=network.target [Service] Type=forking User=root ExecStart=/opt/stonedb57/install/mysql_server TimeoutSec=300 [Install] WantedBy=multi-user.target
当前systemd版本
[root@stonedb system]# systemctl --version systemd 219 +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN
解决建议
1. 排查重复的服务文件
报错日志显示同时存在/etc/systemd/system/stonedb.service和/usr/lib/systemd/system/stonedb.service两个服务文件,/usr/lib下的文件大概率是StoneDB安装时自动生成的,其中可能包含了StartLimitIntervalSec指令。
- 查看该文件内容:
cat /usr/lib/systemd/system/stonedb.service - 若存在不兼容指令,直接备份删除该文件(/etc下的服务文件优先级更高):
mv /usr/lib/systemd/system/stonedb.service /usr/lib/systemd/system/stonedb.service.bak
2. 适配低版本systemd的参数规则
systemd 219(如CentOS 7默认版本)不支持StartLimitIntervalSec参数,该参数在systemd 230版本才引入。旧版本中对应的参数是StartLimitInterval,且必须放在[Unit]段,而非[Service]段。
若需配置启动限制,可在自定义服务文件的[Unit]段添加兼容参数(示例):
[Unit] Description=StoneDB database server After=network.target StartLimitInterval=10 StartLimitBurst=5
注:
StartLimitInterval单位为秒,StartLimitBurst为允许的最大失败启动次数。
3. 重置服务状态并重新加载
执行以下命令清理失效配置并重置启动失败计数:
systemctl daemon-reload systemctl reset-failed stonedb.service
4. 排查服务启动失败的根本原因
当前服务处于failed状态(Main PID: 23915 (code=exited, status=1/FAILURE)),这才是触发启动限制的根源:
- 查看系统日志:
grep stonedb /var/log/messages - 查看StoneDB自身日志(通常在
/opt/stonedb57/install/log/或类似路径),确认mysql_server启动失败的具体原因。
内容的提问来源于stack exchange,提问作者H Aßdöµ
相关产品推荐
相关产品推荐

