腳本不接受 systemctl 指令

腳本不接受 systemctl 指令

我已經為 StoneDb(MySQL 修改版本)建立了一個自訂服務{start|stop|restart|reload|force-reload|status},但在檢查狀態時出現此錯誤: 在此輸入影像描述

這顯然意味著即使我使用相同的腳本手動管理服務,StoneDb 也不會執行該命令。

[Unit]
Description=StoneDB database server
After=network.target
#StartLimitIntervalSec=90

[Service]
Type=forking
ExecStart=/opt/stonedb57/install/mysql_server
TimeoutSec=300

[Install]
WantedBy=multi-user.target

我在這裡缺少什麼?

答案1

systemctl啟動和停止的命令服務單位不要傳遞您的(systemctl)命令列參數,ExecStart= 啟動服務的命令將按照服務單元中的定義逐字執行。

如果該腳本需要一個參數,例如stop或 之類的選項start,就像您的錯誤訊息所建議的那樣,則該參數必須包含在定義中ExecStart=script some-argument

正如已經評論過的:

[Service]
Type=forking
ExecStart=/opt/stonedb57/install/mysql_server start
ExecStop=/opt/stonedb57/install/mysql_server stop
ExecReload=/opt/stonedb57/install/mysql_server reload
TimeoutSec=300

...

儘管不是呼叫mysql_server幫助器/包裝器腳本:您可能會考慮使用 MySQL 和 StoneDB 提供的更原生的 systemd 服務單元作為服務單元模板:

https://github.com/stoneatom/stonedb/tree/stonedb-5.7-dev/scripts/systemd

相關內容