In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
How to use zabbix to monitor mysqldump regular backup database? Let's take a look at it together with Xiaobian. scene requirements
Most companies have test databases. However, the common practice of operation and maintenance personnel in these companies is to write a shell script through mysqldump, a mysql database backup tool combined with Linux crontab, a scheduled task command, to back up the database weekly or monthly. If you do not monitor whether these test databases are backed up successfully every week, it is likely that problems will occur in later work. So today around this topic, introduce how to monitor mysqldump database backup through zabbix.
experimental process
* 1. Create a demo database named test in mysql database, and create a test table in test database.
Mysql statements
Create database test; #Create a database named test
Use test; #Use test database
create test table (name varchar(50)); #Create a test table with only name field
1.1 Create test database test
1.2 Scripting database backups
Then write a simple shell script (bak.sh) to back up the database and set the time for the script to execute in the crontab timer task
Normally (name of database file backed up, database name plus database backup time if necessary)
Mysqldump -u User name-p Password-h Database ip Database name (test) > Location of the backup database
If the database backup was successful, it will be a 0 in/tmp/bak_result.txt. Otherwise, a non-zero is a database backup failure.
Note: It is best not to store the database backup in the user directory, otherwise other users may not be able to view it, so select the/tmp directory for testing.
Finally, add execution permissions to bak.sh, otherwise scheduled tasks cannot be executed.
Chmod o+x bak.sh
1.3 Set up a schedule for easy demonstration (backup time is set to 1 minute)
Crontab -e Open timed task
Check if backup succeeded
* 2. Create monitoring items
Configure custom keys in zabbix_agent.conf
Restart zabbix_agent
Configure monitoring items in zabbix_server
As shown in the figure above, mysql backup value is 0, that is, the backup is successful.
Create alerts. If the value is non-zero, the database backup failed.
Failed to verify backup. We can delete the database test. Then, the value of the monitoring item mysql whether the backup succeeds will not be 0, and then an alarm will appear.
drop database command (drop database name)
At this time, the value of monitoring item whether mysql backup succeeds is not 0. The exported database file is also invalid.
Trigger alarm also appears
Experiment complete.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.