Auto routine check database connection

Operating System & Version
CentOS 7 - CloudLinux
cPanel & WHM Version
WHM 96.0.13

LotusBlossom

Member
Dec 20, 2019
6
1
3
California
cPanel Access Level
Root Administrator
All websites on my server this morning were reporting "Error establishing a database connection". I rebooted the server through WHM and everything came back online - I assumed it was caused by an automatic update to WHM version 96.0.13 - 2021-07-19 [security] TSR-2021-0004.

Is there a setting or method for the server to automatically restart MySQL when this happens? And sends me an email when a website loses database connection?

Here's the server software:
CloudLinux, Apache 2.4, PHP 7.4 (All PHP Opts, and mod_hostinglimits), and Ruby 2.7, OpCache.
MySQL 5.7 (I will be updating this to MariaDB 10.3 this evening).
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,810
892
313
cPanel Access Level
Root Administrator
Hey there! You can ensure the MySQL service is being monitored in WHM >> Service Manager, as that performs a check to the database service to ensure things are working well. If you have both boxes selected it will attempt a restart of the service if it detects an issue.
 

LotusBlossom

Member
Dec 20, 2019
6
1
3
California
cPanel Access Level
Root Administrator
Hey there! You can ensure the MySQL service is being monitored in WHM >> Service Manager, as that performs a check to the database service to ensure things are working well. If you have both boxes selected it will attempt a restart of the service if it detects an issue.
Thank you for the suggestion, unfortunately I already had that enabled and this problem still occured. From the reports received from my customers, my server was showing this database error message for several hours.
 

Attachments

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,810
892
313
cPanel Access Level
Root Administrator
The Service Monitoring tool just tests the connection to MySQL itself - it's not advanced enough to see if there are issues with user connections or table problems, but just does a check to see if the service is up and running.

While I'm sure they exist, I'm not personally aware of any more advanced monitoring tools for the database system.

If this happens again it would be useful to run the "mysqladmin proc status" command to see what state the database server was in. You could also try checking the MySQL error log in the system to see if there are any helpful details from around that time period.
 

LotusBlossom

Member
Dec 20, 2019
6
1
3
California
cPanel Access Level
Root Administrator
Thank you for your support. I wasn't able to find anything helpful in the MySQL error logs. I will make a note of the command you provided and I will look into a service for auto checking the status of web pages.
 
  • Like
Reactions: cPRex