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.2systemdバージョン:v239

RHEL 7.9systemdバージョン: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

関連情報