サーバーを再起動したときに私のシステムデバイスが起動しないのはなぜですか?

サーバーを再起動したときに私のシステムデバイスが起動しないのはなぜですか?

サーバーの再起動時にシステムサービスユニットファイルを正しく実行することはできません。サーバーはCentOS 7.0.1406を新しくインストールしたものです。複数のApache httpdインスタンスを使用してこれを設定しようとしています。以前のCentOSインストールではhttpdインスタンスが正しく機能していたので、systemdを使用してこれらの設定を新しいCentOSに移植しようとしました。

問題なくサービスを有効、開始、再起動、停止できます。再起動すると、「該当するファイルやディレクトリはありません」と表示されます。サービスを再度有効にすると、次回再起動するまですべてが正常に戻ります。



サービスファイル:

[Unit]
Description=Apache web server instance apache01
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/data/apacheinstances/apache01/logs/httpd.pid
ExecStart=/data/apacheinstances/apache01/bin/apachectl start
ExecStop=/data/apacheinstances/apache01/bin/apachectl stop
ExecReload=/data/apacheinstances/apache01/bin/apachectl reload
PrivateTmp=true
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target



どのように活性化しますか?

$ sudo systemctl enable /data/apacheinstances/apache01/bin/apache01.service
ln -s '/data/apacheinstances/apache01/bin/apache01.service' '/etc/systemd/system/multi-user.target.wants/apache01.service'
ln -s '/data/apacheinstances/apache01/bin/apache01.service' '/etc/systemd/system/apache01.service'


$ sudo systemctl status apache01
apache01.service - Apache web server instance apache01
   Loaded: loaded (/data/apacheinstances/apache01/bin/apache01.service; enabled)
   Active: inactive (dead)



私が始めた方法:

$ sudo systemctl start apache01


$ sudo systemctl status apache01
apache01.service - Apache web server instance apache01
   Loaded: loaded (/data/apacheinstances/apache01/bin/apache01.service; enabled)
   Active: active (running) since Wed 2014-10-08 14:37:56 PDT; 13s ago
  Process: 1740 ExecStart=/data/apacheinstances/apache01/bin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 1746 (httpd)
   CGroup: /system.slice/apache01.service
           +-1746 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start
           +-1747 /usr/local/sbin/cronolog /data/apacheinstances/apache01/logs/error_log-%Y%m
           +-1748 /usr/local/sbin/cronolog /data/apacheinstances/apache01/logs/access_log-%Y%m
           +-1749 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start
           +-1750 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start
           +-1751 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start

Oct 08 14:37:56 server105 apachectl[1740]: Starting apache01: [  OK  ]
Oct 08 14:37:56 server105 systemd[1]: PID file /data/apacheinstances/apache01/logs/httpd.pid not readable (yet?) after start.
Oct 08 14:37:56 server105 systemd[1]: Started Apache web server instance apache01.



再起動するにはどうすればよいですか?

$ sudo systemctl restart apache01


$ sudo systemctl status apache01
apache01.service - Apache web server instance apache01
   Loaded: loaded (/data/apacheinstances/apache01/bin/apache01.service; enabled)
   Active: active (running) since Wed 2014-10-08 14:38:40 PDT; 12s ago
  Process: 1836 ExecStop=/data/apacheinstances/apache01/bin/apachectl stop (code=exited, status=0/SUCCESS)
  Process: 1844 ExecStart=/data/apacheinstances/apache01/bin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 1850 (httpd)
   CGroup: /system.slice/apache01.service
           +-1850 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start
           +-1851 /usr/local/sbin/cronolog /data/apacheinstances/apache01/logs/error_log-%Y%m
           +-1852 /usr/local/sbin/cronolog /data/apacheinstances/apache01/logs/access_log-%Y%m
           +-1853 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start
           +-1855 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start
           +-1856 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start

Oct 08 14:38:40 server105 apachectl[1844]: Starting apache01: [  OK  ]
Oct 08 14:38:40 server105 systemd[1]: PID file /data/apacheinstances/apache01/logs/httpd.pid not readable (yet?) after start.
Oct 08 14:38:40 server105 systemd[1]: Started Apache web server instance apache01.



私がどのようにブロックしたか:

$ sudo systemctl stop apache01


$ sudo systemctl status apache01
apache01.service - Apache web server instance apache01
   Loaded: loaded (/data/apacheinstances/apache01/bin/apache01.service; enabled)
   Active: inactive (dead) since Wed 2014-10-08 14:39:44 PDT; 12s ago
  Process: 1940 ExecStop=/data/apacheinstances/apache01/bin/apachectl stop (code=exited, status=0/SUCCESS)
  Process: 1844 ExecStart=/data/apacheinstances/apache01/bin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 1850 (code=exited, status=0/SUCCESS)

Oct 08 14:38:40 server105 apachectl[1844]: Starting apache01: [  OK  ]
Oct 08 14:38:40 server105 systemd[1]: PID file /data/apacheinstances/apache01/logs/httpd.pid not readable (yet?) after start.
Oct 08 14:38:40 server105 systemd[1]: Started Apache web server instance apache01.
Oct 08 14:39:44 server105 systemd[1]: Stopping Apache web server instance apache01...
Oct 08 14:39:44 server105 apachectl[1940]: Stopping apache01: [  OK  ]
Oct 08 14:39:44 server105 systemd[1]: Stopped Apache web server instance apache01.



再起動後の状態:

$ sudo systemctl status apache01
apache01.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

Oct 08 14:44:58 server105 systemd[1]: Cannot add dependency job for unit apache01.service, ignoring: Unit apache01.service failed to load: No such file or directory.



再起動して起動するにはどうすればよいですか?

$ sudo systemctl reenable /data/apacheinstances/apache01/bin/apache01.service
rm '/etc/systemd/system/apache01.service'
rm '/etc/systemd/system/multi-user.target.wants/apache01.service'
ln -s '/data/apacheinstances/apache01/bin/apache01.service' '/etc/systemd/system/multi-user.target.wants/apache01.service'
ln -s '/data/apacheinstances/apache01/bin/apache01.service' '/etc/systemd/system/apache01.service'


$ sudo systemctl start apache01


$ sudo systemctl status apache01
apache01.service - Apache web server instance apache01
   Loaded: loaded (/data/apacheinstances/apache01/bin/apache01.service; enabled)
   Active: active (running) since Wed 2014-10-08 14:52:20 PDT; 5s ago
  Process: 1737 ExecStart=/data/apacheinstances/apache01/bin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 1743 (httpd)
   CGroup: /system.slice/apache01.service
           +-1743 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start
           +-1744 /usr/local/sbin/cronolog /data/apacheinstances/apache01/logs/error_log-%Y%m
           +-1745 /usr/local/sbin/cronolog /data/apacheinstances/apache01/logs/access_log-%Y%m
           +-1746 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start
           +-1747 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start
           +-1748 /usr/local/httpd-2.4.10-apache01/bin/httpd -f /data/apacheinstances/apache01/conf/httpd.conf -k start

Oct 08 14:52:20 server105 apachectl[1737]: Starting apache01: [  OK  ]
Oct 08 14:52:20 server105 systemd[1]: PID file /data/apacheinstances/apache01/logs/httpd.pid not readable (yet?) after start.
Oct 08 14:52:20 server105 systemd[1]: Started Apache web server instance apache01.

再起動する前には正常に動作しましたが、再起動後に失敗する理由はわかりません。再度有効にしないと、「該当するファイルやディレクトリはありません」という同じエラーが発生し続けます。

見つからないファイルやディレクトリを確認するためにsystemdのロギング機能を調べてみましたが、何も見つかりませんでした。

以前このような行動を経験した人はいますか?

ベストアンサー1

始める前にすべてのサービスをロードして確認する必要があり、systemdがすべてのサービスを確認している間にサービスが別のパーティションにあるため、開始プロセスの最初にサービスを使用することはできません。

この問題を解決するには、サービスをローカルに保持するか、/etc/systemd/system/展開用のパッケージを作成して/usr/lib/systemd/system/

おすすめ記事