서버 재부팅 시 내 시스템 장치가 실행되지 않는 이유는 무엇입니까?

서버 재부팅 시 내 시스템 장치가 실행되지 않는 이유는 무엇입니까?

서버를 재부팅할 때 시스템 서비스 단위 파일을 올바르게 실행하는 데 문제가 있습니다. 이 서버는 새로 설치된 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/

관련 정보