RHEL7.5 上執行的服務未在 RHEL8 上執行(httpd 服務)

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 中則不然。這裡要注意的另一件事是網頁伺服器正在按預期工作,儘管給了我這個錯誤。

    #!/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

請幫我解決這個問題。

答案1

如果您在日記條目中看到:

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 服務單元,您可能會有更好的運氣。

相關內容