RHEL 8.2에서 systemd 서비스 시작(SysV init) 스크립트를 사용할 수 없습니다.

RHEL 8.2에서 systemd 서비스 시작(SysV init) 스크립트를 사용할 수 없습니다.

ExecStartRHEL 8.2 에서 SysV init스크립트가 실패하는 문제에 직면했습니다 . 동일한 초기화 스크립트와 서비스 단위 설정을 사용하는 RHEL 7.9에서는 이 문제가 발생하지 않습니다. 온라인에서 많은 리소스를 확인했지만 여전히 이 문제의 근본 원인을 찾을 수 없습니다. 버전 문제 때문인지 RHEL 8.2 간의 systemd비호환성 때문인지 여부. 이상적으로는 서비스 단위로 변환해야 하지만 특정 요구 사항으로 인해 그렇게 할 수 없다는 점을 이해하십시오.SysV initsystemd

RHEL 8.2 systemd버전:v239

RHEL 7.9 systemd버전:v219

/etc/systemd/system/mq.service문서:

[Unit]
Description=MQ service
After=network.target

[Service]
Type=forking
ExecStart=/etc/init.d/rc.mq start
ExecStop=/etc/init.d/rc.mq stop

[Install]
WantedBy=multi-user.target

/etc/init.d/rc.mq스크립트:

#!/bin/sh
# chkconfig: 35 95 5

function fstart
{
  su - mqm -c "strmqm QMNAME" > /dev/null 2>&1
}

function fstop
{
  su - mqm -c "endmqm -i QMNAME"
  sleep 30
}

case $1 in
  start)
        fstart
        break;;
  stop)
        fstop
        break;;
  restart)
        fstop
        fstart
        break;;
  *)
    fstart
    break;;
esac
exit

$ systemctl status mq.service:

● mq.service - MQ service
   Loaded: loaded (/etc/systemd/system/mq.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Tue 2021-07-06 16:03:43 +08; 27s ago
  Process: 66183 ExecStop=/etc/init.d/rc.mq stop (code=exited, status=0/SUCCESS)
  Process: 66084 ExecStart=/etc/init.d/rc.mq start (code=exited, status=0/SUCCESS)

Jul 06 16:03:10 hostname.company.com su[66085]: pam_unix(su-l:session): session opened for user mqm by (uid=0)
Jul 06 16:03:10 hostname.company.com su[66085]: pam_unix(su-l:session): session opened for user mqm by (uid=0)
Jul 06 16:03:11 hostname.company.com su[66085]: pam_unix(su-l:session): session closed for user mqm
Jul 06 16:03:11 hostname.company.com su[66085]: pam_unix(su-l:session): session closed for user mqm
Jul 06 16:03:11 hostname.company.com su[66188]: (to mqm) root on none
Jul 06 16:03:11 hostname.company.com su[66188]: pam_unix(su-l:session): session opened for user mqm by (uid=0)
Jul 06 16:03:11 hostname.company.com su[66188]: pam_unix(su-l:session): session opened for user mqm by (uid=0)
Jul 06 16:03:11 hostname.company.com rc.mq[66183]: IBM MQ queue manager 'QMNAME' ending.
Jul 06 16:03:13 hostname.company.com rc.mq[66183]: IBM MQ queue manager 'QMNAME' ended.
Jul 06 16:03:43 hostname.company.com systemd[1]: Started MQ service.

$ journalctl -xe:

Jul 06 15:10:17 hostname.company.com systemd[1]: Starting MQ service...
-- Subject: Unit mq.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit mq.service has begun starting up.
Jul 06 15:10:17 hostname.company.com systemd[1]: Started system activity accounting tool.
-- Subject: Unit sysstat-collect.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit sysstat-collect.service has finished starting up.
--
-- The start-up result is done.
Jul 06 15:10:17 hostname.company.com su[62138]: (to mqm) root on none
Jul 06 15:10:17 hostname.company.com su[62138]: pam_unix(su-l:session): session opened for user mqm by (uid=0)
Jul 06 15:10:17 hostname.company.com systemd[1]: Started Session c513 of user mqm.
-- Subject: Unit session-c513.scope has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit session-c513.scope has finished starting up.
--
-- The start-up result is done.
Jul 06 15:10:17 hostname.company.com su[62138]: pam_unix(su-l:session): session opened for user mqm by (uid=0)
Jul 06 15:10:17 hostname.company.com su[62138]: pam_unix(su-l:session): session closed for user mqm
Jul 06 15:10:17 hostname.company.com su[62138]: pam_unix(su-l:session): session closed for user mqm
Jul 06 15:10:17 hostname.company.com su[62245]: (to mqm) root on none
Jul 06 15:10:17 hostname.company.com su[62245]: pam_unix(su-l:session): session opened for user mqm by (uid=0)
Jul 06 15:10:17 hostname.company.com systemd[1]: Started Session c514 of user mqm.
-- Subject: Unit session-c514.scope has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit session-c514.scope has finished starting up.
--
-- The start-up result is done.
Jul 06 15:10:17 hostname.company.com su[62245]: pam_unix(su-l:session): session opened for user mqm by (uid=0)
Jul 06 15:10:17 hostname.company.com rc.mq[62238]: IBM MQ queue manager 'QMNAME' ending.
Jul 06 15:10:19 hostname.company.com rc.mq[62238]: IBM MQ queue manager 'QMNAME' ended.
Jul 06 15:10:19 hostname.company.com su[62245]: pam_unix(su-l:session): session closed for user mqm
Jul 06 15:10:19 hostname.company.com su[62245]: pam_unix(su-l:session): session closed for user mqm
Jul 06 15:10:49 hostname.company.com systemd[1]: Started MQ service.
-- Subject: Unit mq.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit mq.service has finished starting up.
--
-- The start-up result is done.

ExecStart이것을 변경 하거나 ExecStart=/sbin/service rc.mq start실행 해 보았지만 export _SYSTEMCTL_SKIP_REDIRECT=1여전히 동일합니다.

그 이유가 무엇인지 알 수 있을까요? 다시 말하지만, 이 설정은 RHEL 7.9에서 작동합니다.

편집하다**

/etc/pam.d/system-auth파일에서 서비스 시작을 방지하는 다음 매개변수가 발견되었습니다 . 이유가 무엇인지 아십니까?

-session    optional      pam_systemd.so

관련 정보