Linux
在 RHEL7.5 上執行的服務未在 RHEL8 上執行(httpd 服務)
我的服務在 RHEL 7.5 上執行良好,現在我已經升級到 RHEL 8,同樣的服務失敗,狀態如下:
Service.service - LSB: Web Server Loaded: loaded (/etc/rc.d/init.d/Service; generated) Active: failed (Result: protocol) since Mon 2020-04-06 12:02:21 IST; 38min ago Docs: man:systemd-sysv-generator(8) Process: 403 ExecStart=/etc/rc.d/init.d/Service start (code=exited, status=0/SUCCESS) Apr 06 12:02:21 localhost.localdomain systemd[1]: Starting LSB: Web Server... Apr 06 12:02:21 localhost.localdomain Service[403]: httpd (pid 29434) already running Apr 06 12:02:21 localhost.localdomain systemd[1]: Service.service: Refusing to accept PID outside of service control group, acquired through unsafe symlink chain: /usr/local/apache/logs/Service.pid Apr 06 12:02:21 localhost.localdomain systemd[1]: Service.service: Refusing to accept PID outside of service control group, acquired through unsafe symlink chain: /usr/local/apache/logs/Service.pid Apr 06 12:02:21 localhost.localdomain systemd[1]: Service.service: Failed with result 'protocol'. Apr 06 12:02:21 localhost.localdomain systemd[1]: Failed to start LSB: Web Server
這是我放置在 /etc/init.d/Service 下的服務單元,對於 RHEL 7.5 也是如此,但是該服務正在執行,而在 RHEL 8 中則沒有。這裡要注意的另一件事是 Web 伺服器按預期工作,儘管給了我這個錯誤。
#!/bin/sh # # chkconfig: 345 97 03 # description:Web Server # processname: httpd # config: /usr/local/Test/apache/conf/httpd.conf # pidfile: /usr/local/Test/apache/logs/httpd.pid ### BEGIN INIT INFO # Provides: Service # Required-Start: $remote_fs $network $syslog # Should-Start: # Required-Stop: # Default-Start: 3 4 5 # Default-Stop: 0 1 2 6`enter code here` # Short-Description: Web Server # Description: Web Server ### END INIT INFO LANG=en_US.iso88591 export LANG BASEDIR=/usr/local/Test/apache PATH=$BASEDIR/bin:/usr/bin:/bin export PATH LD_LIBRARY_PATH=$BASEDIR/lib export LD_LIBRARY_PATH inst=/usr/local/Test MIBDIRS=$inst/mibs export MIBDIRS case $1 in start) apachectl start ;; stop) apachectl stop ;; restart) apachectl restart ;; *) echo "usage: $0 { start | stop | restart }" ;; esac
請幫我解決這個問題。
如果您在日記帳分錄中看到:
Refusing to accept PID outside of service control group, acquired through unsafe symlink chain:
7.5 中的 systemd 版本沒有額外的檢查來檢查服務的 pid 是否在 systemd 單元的 cgroup 之外。
如果您要將 7.5 系統更新到 7.7 或更高版本,它也會失敗並出現相同的錯誤。
如果您將 sysv init 腳本轉換為真正的 systemd 服務單元,您可能會有更好的運氣。