Red Hat Enterprise Linux Diagnostics and Troubleshooting
Debug a third-party containerized application.
Outcomes
You should be able to diagnose and troubleshoot library dependency and application runtime issues.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
[student@workstation ~]$ lab start application-review
This command confirms that the required hosts for this exercise are accessible and deploys the containerized application.
Instructions
A system administrator deployed the showviews.php application on the servera machine by using the /var/www/html/showviews.php file, but it is not working. The application uses a web service with a containerized database service. Resolve the issue and verify that the containerized service is working and accessible on the servera machine.
Verify the newly deployed application and observe its behavior.
Log in to
serveraand switch to therootuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#View the web service status.
The service status shows an error in a missing library dependency,
libaprutil-1.so.0.[root@servera ~]#
systemctl status httpd● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/httpd.service.d └─php-fpm.conf Active: failed (Result: exit-code) since Thu 2021-11-04 20:51:43 EDT; 43s ago Docs: man:httpd.service(8) Process: 7455 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=127) Main PID: 7455 (code=exited, status=127) Nov 04 20:51:43 servera.lab.example.com systemd[1]: Starting The Apache HTTP Server... Nov 04 20:51:43 servera.lab.example.com httpd[7455]: /usr/sbin/httpd: error while loading shared libraries: libaprutil-1.so.0: cannot open shared object file: No such file> Nov 04 20:51:43 servera.lab.example.com systemd[1]: httpd.service: Main process exited, code=exited, status=127/n/a Nov 04 20:51:43 servera.lab.example.com systemd[1]: httpd.service: Failed with result 'exit-code'. Nov 04 20:51:43 servera.lab.example.com systemd[1]: Failed to start The Apache HTTP Server.
View the dynamic libraries of the web service for missing libraries. Install the packages that provide the shared library requirements.
View the shared libraries for the
httpdbinary.All of the shared libraries resolved except for one:
libaprutil-1.so.0.[root@servera ~]#
which httpd/usr/sbin/httpd [root@servera ~]#ldd /usr/sbin/httpdlibpcre.so.1 => /lib64/libpcre.so.1 (0x00007f3b9539a000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f3b95170000) libsystemd.so.0 => /lib64/libsystemd.so.0 (0x00007f3b94e29000) libaprutil-1.so.0 => not found ...output omitted...Locate the packages to install that provide the library.
[root@servera ~]#
yum provides libaprutil-1.so.0apr-util-1.6.1-6.el8.i686 : Apache Portable Runtime Utility library Repo : rhel-8.4-for-x86_64-appstream-rpms Matched from: Provide : libaprutil-1.so.0Install the package that provides the
libaprutil-1.so.0library.[root@servera ~]#
yum install apr-util...output omitted...Restart the web service and verify the service status.
[root@servera ~]#
systemctl restart httpd[root@servera ~]#systemctl status httpd● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/httpd.service.d └─php-fpm.conf Active: active (running) since Thu 2021-11-04 21:03:16 EDT; 3s ago Docs: man:httpd.service(8) Main PID: 7582 (httpd) Status: "Started, listening on: port 80" ...output omitted...Query the web service with the
localhostdefault.The application exposes the
showviews.phpURL.[root@servera ~]#
curl localhost<meta http-equiv="refresh" content="0; URL=showviews.php">Query the web service at the
showviews.phpURL.The service displays a page about views and visits, which verifies that the service is functioning.
However, the application is not obtaining data from the database. You must resolve the database connection issues.
[root@servera ~]#
curl localhost/showviews.php<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <table border="1" align="center"> <tr> <td>Site Name</td> <td>Views</td> <td>Details</td> </tr>
Resolve the issues that prevent the application from obtaining the database information.
View the
showviews.phpfile and verify the connection to the database.[root@servera ~]#
cat /var/www/html/showviews.php<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <?php $hostname = "10.89.0.7"; $username = "site_monitor"; $password = "reviews"; $db = "sitemonitor"; $dbconnect=mysqli_connect($hostname,$username,$password,$db); ...output omitted...View the status of the containerized database.
[root@servera ~]#
podman ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES da31cd1291c1 registry.access.redhat.com/rhscl/mariadb-101-rhel7:latest run-mysqld 7 minutes ago Up 7 minutes ago mariadb-serviceVerify the IP address of the database container.
[root@servera ~]#
podman inspect mariadb-service | jq '.[].NetworkSettings.Networks' | grep IPAddress"IPAddress": "10.89.0.2",Modify the
showviews.phpfile to use the correct IP address.[root@servera ~]#
cat /var/www/html/showviews.php<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <?php $hostname = "10.89.0.2"; ...output omitted...
Verify that the application runs correctly and displays data for the views and visits.
Verify that the application obtains data from the database.
[root@servera ~]#
curl localhost/showviews.php...output omitted... <table border="1" align="center"> <tr> <td>Site Name</td> <td>Views</td> <td>Details</td> </tr> <tr> <td>example.com</td> <td>15</td> <td>Example site</td> </tr> <tr> <td>site-test.com</td> <td>18</td> <td>Test site</td> </tr> </table> ...output omitted...Return to
workstationas thestudentuser.[root@servera ~]#
exit[student@servera ~]$exit[student@workstation ~]$On the
workstationmachine, open a web browser and navigate to http://servera/showviews.php.