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 服务单元,您可能会有更好的运气。

相关内容