公司自己寫的java程序,在centos7系統執行/etc/init.d/service_name start||stop的時候報錯:
grafana二次開發的程序
[root@docp1 init.d]# /etc/init.d/grafana status ● grafana.service - LSB: Start grafana at boot time Loaded: loaded (/etc/rc.d/init.d/grafana; bad; vendor preset: disabled) Active: activating (start) since 三 2019-04-10 11:46:19 CST; 9s ago Docs: man:systemd-sysv-generator(8) Control: 103931 (bash) CGroup: /system.slice/grafana.service ├─103931 bash /etc/rc.d/init.d/grafana start └─103998 sleep 1 4月 10 11:46:19 docp1 systemd[1]: Starting LSB: Start grafana at boot time... 4月 10 11:46:19 docp1 su[103941]: (to root) root on none 4月 10 11:46:19 docp1 grafana[103931]: Starting Grafana Server: ... [ OK ] [root@docp1 init.d]# /etc/init.d/grafana start Starting grafana (via systemctl): Job for grafana.service failed because the control process exited with error code. See "systemctl status grafana.service" and "journalctl -xe" for details. [失敗]
切換至/etc/init.d,然后去啟動該服務,正常
CentOS 7繼承了RHEL 7的新的特性,比如強大的systemctl,而systemctl的使用也使得以往系統服務的/etc/init.d的啟動腳本的方式就此改變,當執行/etc/init.d/service.name start || stop,系統默認回去調用systemctl start || stop service.name 去執行,
DOCP&&BDP大多數程序非centos標准包
因此:非centos7標准安裝的服務啟動腳本,無法通過/etc/init.d/service.name這種方式去啟動,需先進入到/etc/init.d目錄下,然后service.name start || stop 去執行。
CentOS 7的服務systemctl腳本存放在:/usr/lib/systemd/,有系統(system)和用戶(user)之分,像須要開機不登陸就能執行的程序,還是存在系統服務里吧,即:/usr/lib/systemd/system文件夾下