6/23/2023 0 Comments Monit web portCopy the value of the PIDFile variable and add it to the ExecStart directive. To fix this issue, you need to update the MySQL service file located at /lib/systemd/system/rvice. But in case of MySQL, you will notice that the status is shown as "Initializating" for some time and then it will change to: Execution Failed | Does not exist Normally if you follow the steps mentioned in this guide to monitor any other serivce, it should work without any issues. You can also check the status of the MySQL service from the monit web interface by visiting Error: Execution Failed Once done, you can check the status of the MySQL service using the following command: sudo monit status Now if you reload the monit service, it will start monitoring MySQL: sudo monit reload You can change the configuration as per your requirement. You can see that it is checking the status of the MySQL process and if it is not running, it will restart the service. If you open the mysql file, you will see the following content: check process mysqld with pidfile /var/run/mysqld/mysqld.pid group database group mysql start program = " /etc/init.d/mysql start " stop program = " /etc/init.d/mysql stop " if failed host localhost port 3306 protocol mysql with timeout 15 seconds for 3 times within 4 cycles then restart if failed unixsocket /var/run/mysqld/mysqld.sock protocol mysql for 3 times within 4 cycles then restart if 5 restarts with 5 cycles then timeout depend mysql_bin depend mysql_rc check file mysql_bin with path /usr/sbin/mysqld group mysql include /etc/monit/templates/rootbin check file mysql_rc with path /etc/init.d/mysql group mysql include /etc/monit/templates/rootbin sudo cp /etc/monit/conf-available/mysql /etc/monit/conf-enabled/mysql So that it will be loaded by monit when it starts. You can copy the mysql template to /etc/monit/conf-enabled directory. You can find the list of templates in the /etc/monit/conf-available directory. Monit comes with a set of predefined templates that you can use to monitor different services. Let's move on to the next step and see how we can monitor MySQL using monit. You can use the username and password that you have set in the configuration file to login.Īlright, now we have monit installed and configured. Now if you open your browser and go to you should see the monit web interface. Once done, you can use the following command to check the status of the monit service and see if it is running: sudo monit status If there are no errors, you can start the monit service: sudo monit reload Now you can run the follow command to verify the configuration: sudo monit -t I have used 0.0.0.0/0 to allow access from any IP address. If you want to allow access from any IP address, you can use allow directive with the IP address and subnet mask. You can change the port number and the username and password as per your preference. This will allow you to access the monit web interface from your browser. Open the file in your favorite editor and uncomment the following lines: set httpd port 2812 and use address localhost allow localhost allow 0.0.0.0/0 # Add any IP address you want to allow allow admin:monit You can configure monit by editing the configuration file located at /etc/monit/monitrc. You can install it using the following command: sudo apt update sudo apt install monit Configuring Monit Monit is available in the default Ubuntu repository. I am using Ubuntu 20.04 for this guide but you can use any other Linux distribution as well and the steps should be the same. In this guide, we will learn how to monitor and auto-restart MySQL using monit on failure. For example, it can attempt to restart the service if it does not respond, it can trigger alerts on failures and other conditions that you may have configured. It conducts automatic maintenance and repair and can execute meaningful causal actions in error situations. Monit is a small Open Source utility for managing and monitoring, processes, files, directories and filesystems on a Unix system.
0 Comments
Leave a Reply. |