Translated message

A translation of this page exists in English.

Red Hat Enterprise Linux 7 でネットワークを起動してから SysV init スクリプトを実行する

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7
  • SysVinit サービススクリプト
  • systemd

Issue

  • systemd には、/etc/rc.d の SysVinit サービススクリプトに対する互換性が含まれていますが、その他のネイティブな systemd ユニット (ネットワーキングなど) の後でサードパーティの initscript が起動しないように、依存関係を設定するにはどうすれば良いですか?

  • RHEL5 から RHEL7 に古いプラットフォームを移植しようとしており、依存関係であるネットワークと NFS をを起動する前に、chkconfig を行った sysvinit サービスを開始すると問題が発生します。systemd init が終了するまで、もしくは wants がいくつか満たされるまで、sysvinit スクリプトを遅延させる方法はありますか?

  • RHEL 7 でネットワークを起動してから起動する必要がある古い SysV init スクリプトがありますが、このスクリプトを systemd サービスファイルに変換することができません。

Resolution

  • SysVinit スクリプトの LSB ヘッダーに Required-Start: $network ディレクティブを追加します。
    以下は、rhnsd サービススクリプトを使用した例となります。

    $ awk '/### BEGIN INIT INFO/,/### END INIT INFO/' /etc/init.d/rhnsd 
    ### BEGIN INIT INFO
    # Provides: rhnsd
    # Required-Start:$local_fs $network $remote_fs $named $time
    # Required-Stop:$local_fs $network $remote_fs $named
    # Default-Start:2 3 4 5
    # Default-Stop:0 1 6
    # Short-Description:Starts the Spacewalk Daemon
    # Description:This is a daemon which handles the task of connecting
    #               periodically to the Spacewalk servers to
    #               check for updates, notifications and perform system
    #               monitoring tasks according to the service level that
    #               this server is subscribed for.
    ### END INIT INFO
    
  • 以下も参照してください。

Root Cause

  • systemd では、init スクリプトの LSB ヘッダーが有効になります。これにより、$network を systemd オプションの After=network-online.target に変換します。
    詳細については、以下を参照してください。

Diagnostic Steps

  • 以下のように、提供されているツールを使用して、何が最初に起動しているかを特定します。

    systemd-analyze plot > analyzestartup.svg
    

    次に、firefox またはイメージビューアーで analyzestartup.svg を参照します。

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments