This article mainly studies how to use the LinuxShell script and the Apsara stack API to achieve automatic monitoring of MySQL databases and text message alerts, freeing DBA from heavy and repetitive monitoring work, while enjoying the sunshine and beach in the Maldives, MySQL databases in Beijing are monitored in real time. With the rapid development of the Internet and information technology, the "> <LINKhref =" http ://
This article mainly studies how to use Linux Shell scripts and Apsara stack APIs to achieve automatic monitoring of MySQL databases and text message alerts, freeing DBA from heavy and repetitive monitoring work, while enjoying the sunshine and beach in the Maldives, MySQL databases in Beijing are monitored in real time.
With the rapid development of the Internet and information technology, the amount of data produced by enterprise operations is growing. Therefore, most companies choose to store important commercial data in databases. If the database system is suddenly shut down or has other faults, it will inevitably affect the company's revenue, reputation, and even lead to user complaints. how to ensure the normal operation of the database system has always been a core concern of the company. This requires the DBA to monitor the various statuses of the database in real time and solve the problems before the fault occurs, so as to eliminate the risks in the cradle. This article describes how to use the MySQL Monitor Shell script to implement real-time MySQL monitoring and how to implement the MySQL SMS alarm function module, it also uses a real application scenario to demonstrate how "MySQL Monitor" works.
Background
Problems encountered by Nanfeng
Nanfeng is an Internet company that has 10 servers in the data center of Beijing Netcom zone 1 and 10 servers in the data center of Zone 2, there are also 10 servers in the data center of Shanghai Telecom 1 ......, given the importance of the company's data, DBAs must implement a series of monitoring measures to ensure the sound operation of the database, 20 checkpoints are set, including the disk space check of the operating system, database tablespace check, database table status check, and dual-host mutual backup check, which of the following options does DBA choose to implement such a big monitoring solution? The following is a traditional solution:
This is an inefficient serial method. DBAs must check 20 checkpoints of database servers one by one from every day, which is time consuming, this traditional solution will allow DBAs to repeat the mechanical work every day. when there are hundreds of monitored servers, this traditional solution is a nightmare for DBAs, so how can we monitor databases more effectively and become an urgent issue for DBAs?
Solutions provided by Nanfeng
Smart MySQL needs to be controlled in a smart way. Nanfeng DBA developed a "MySQL Monitor" solution, this solution makes full use of the advantages of "Shell script" + "Linux Cron timer service" + "China Mobile Feixin free text message API interface, an alert is sent to DBA only when a database checkpoint is faulty. in this way, a large number of unattended Database Server Monitoring frameworks are implemented. The following is a new solution:
This is an efficient way of working in parallel. to facilitate management, we first group database servers and each group of servers corresponds to a monitoring thread, these monitoring threads are deployed on the "monitoring workstation" and you must note that the "timeline" disappears because these monitoring threads run once every minute, the "timeline" is meaningless. If everything works normally, these monitoring threads only write logs and do not perform other operations. if an exception occurs on a database server, then, the "monitoring workstation" will send an SMS reminder to the DBA terminal, so that the DBA can immediately locate the problem and solve the problem, even if DBAs do not have computer terminals around them, they can learn the running status of MySQL servers in a timely manner.