Bookmark this page

Guided Exercise: Identifying and Resolving Failing Services

Resolve an issue where two services fail to start at boot.

Outcomes

You should be able to resolve an issue where two services fail to start at boot.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

[student@workstation ~]$ lab start boot-failingservices

Instructions

Your servera machine is set up to serve both web and FTP content with the httpd and vsftpd services. The specification states that both daemons operate simultaneously on the same system.

Your colleague attempted to satisfy this requirement but now both services fail to start at boot time. You are asked to resolve this issue. You are only required to ensure that both services start. You do not need to verify or configure that both services always operate simultaneously.

  1. On the servera system, check the status of the httpd and vsftpd services to troubleshoot the issue.

    1. Log in to servera and switch to the root user.

      [student@workstation ~]$ ssh student@servera
      ...output omitted...
      [student@servera ~]$ sudo -i
      [sudo] password for student: student
      [root@servera ~]#
    2. Check the status of the httpd service. Because status lines sometimes contain useful information past the 80-character limit, use the -l option to display full status lines.

      [root@servera ~]# systemctl status -l httpd
      ● httpd.service - The Apache HTTP Server
         Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
        Drop-In: /etc/systemd/system/httpd.service.d
                 └─10-dependencies.conf
         Active: inactive (dead)
           Docs: man:httpd.service(8)
      
      Sep 24 21:50:42 servera.lab.example.com systemd[1]: httpd.service: Found ordering cycle on vsftpd.service/start
      Sep 24 21:50:42 servera.lab.example.com systemd[1]: httpd.service: Found dependency on httpd.service/start
      Sep 24 21:50:42 servera.lab.example.com systemd[1]: httpd.service: Unable to break cycle starting with httpd.service/start
      Sep 24 21:50:42 servera.lab.example.com systemd[1]: vsftpd.service: Found ordering cycle on httpd.service/start
      Sep 24 21:50:42 servera.lab.example.com systemd[1]: vsftpd.service: Found dependency on vsftpd.service/start
      Sep 24 21:50:42 servera.lab.example.com systemd[1]: vsftpd.service: Unable to break cycle starting with vsftpd.service/start
      ...output omitted...
    3. Check the status of the vsftpd service.

      [root@servera ~]# systemctl status -l vsftpd
      ● vsftpd.service - Vsftpd ftp daemon
         Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
        Drop-In: /etc/systemd/system/vsftpd.service.d
                 └─10-dependencies.conf
         Active: inactive (dead)
      
      ...output omitted...
      Sep 24 21:50:42 servera.lab.example.com systemd[1]: httpd.service: Unable to break cycle starting with httpd.service/start
      ...output omitted...
  2. Both services have start dependencies on each other. The systemctl status command output includes the files that are responsible for the dependencies. View the contents of those drop-in configuration files.

    1. From the output of the systemctl status commands, observe that two nonstandard drop-in files were added to the services:

      • /etc/systemd/system/httpd.service.d/10-dependencies.conf

      • /etc/systemd/system/vsftpd.service.d/10-dependencies.conf

    2. View the contents of these two files.

      [root@servera ~]# cat /etc/systemd/system/httpd.service.d/10-dependencies.conf
      [Unit]
      After=vsftpd.service
      Requires=vsftpd.service
      [root@servera ~]# cat /etc/systemd/system/vsftpd.service.d/10-dependencies.conf
      [Unit]
      After=httpd.service
      Requires=httpd.service
  3. Form a hypothesis of why these two services fail to start.

    1. Both services have a Requires directive for the other service, but this directive ensures only that if one of them is started, then the other is started as well.

    2. Both services have an After requirement on the other service. This requirement causes a cyclic dependency, which systemd resolves by not starting these services.

  4. Describe two possible solutions.

    1. Removing both drop-in directories and files entirely, and then reloading systemd, and finally starting the services. This approach removes all dependencies.

    2. Changing one of the two After lines to Before ensures that the services are always started together, without causing a cyclic dependency.

  5. Attempt to fix this issue by changing the After line for the httpd service to Before.

    Reload systemd and start both services to verify.

    1. Change the After line for the httpd service to Before. Edit /etc/systemd/system/httpd.service.d/10-dependencies.conf to match this text:

      [Unit]
      Before=vsftpd.service
      Requires=vsftpd.service
    2. Reload the active systemd configuration.

      [root@servera ~]# systemctl daemon-reload
    3. Start the httpd.service and vsftpd.service services.

      [root@servera ~]# systemctl start httpd.service vsftpd.service
      [root@servera ~]#
  6. Reboot the servera machine to verify that both services successfully start during boot.

    1. Reboot servera.

      [root@servera ~]# reboot
      Connection to servera closed by remote host.
      Connection to servera closed.
      [student@workstation ~]$
    2. Log in to servera and switch to the root user.

      [student@workstation ~]$ ssh student@servera
      ...output omitted...
      [student@servera ~]$ sudo -i
      [sudo] password for student: student
      [root@servera ~]#
    3. Check that the httpd and vsftpd services are active.

      [root@servera ~]# systemctl status httpd.service vsftpd.service
      ● httpd.service - The Apache HTTP Server
         Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
        Drop-In: /etc/systemd/system/httpd.service.d
                 └─10-dependencies.conf
         Active: active (running) since Fri 2021-09-24 23:22:35 EDT; 2min 23s ago
      
      ...output omitted...
      
      ● vsftpd.service - Vsftpd ftp daemon
         Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
        Drop-In: /etc/systemd/system/vsftpd.service.d
                 └─10-dependencies.conf
         Active: active (running) since Fri 2021-09-24 23:22:35 EDT; 2min 23s ago
      
      ...output omitted...
  7. Return to workstation as the student user.

    [root@servera ~]# exit
    [student@servera ~]$ exit
    [student@workstation ~]$

Finish

On the workstation machine, use the lab command to complete this exercise. This is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish boot-failingservices

Revision: rh342-8.4-6dd89bd