Shell scripts monitor MySQL services and shell scripts monitor mysql

Source: Internet
Author: User

Shell scripts monitor MySQL services and shell scripts monitor mysql
The main content of this article describes how to monitor whether the MySQL service is normal by using shell scripts. For more information, see

The general idea is to check whether the MySQL service is normal: Check whether port 3306 is started, ps to check whether the mysqld process is started, and run the command line to log on to mysql to execute the statement and return the result, php or jsp program detection (developers need to develop programs) and so on;

Method 1: Listen to port 3306

Method 2: view the mysqld Process

Note: If you use process filtering, if the script name contains mysql, script execution is pitfall. Remember !!! The result is inaccurate because the script is grep once;

The execution result is as follows:

Method 3: The mysql service is normal only when both processes and ports are successful.

Method 4: Use the client to log on to mysql and run the command to check whether the returned result Test Service is started. Theoretically, this method is the most reliable.

The execution result is as follows:
[Root @ localhost baby] # sh check_db_client.sh
MySQL is running

The above are four ways for shell scripts to monitor whether the MySQL service is normal. I hope this will be helpful for your learning.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.