Zabbix監控MySQL備份成功失敗

來源:互聯網
上載者:User

Zabbix監控MySQL備份成功失敗

環境:

    A:172.16.16.1 (MySQL機器)
    B:172.16.16.2 (備份機器)
    C:172.16.16.3 (zabbix伺服器)

介紹
    因公司開發需要,需要備份內網測試資料庫A.B.C三個庫,在每天淩晨2點打包備份到B機器上面。 

計劃

    1、在B機器上面使用mysqldump配合指令碼在本地備份資料庫
    2、在zabbix機器上面設定監控項,備份不成功則想營運部門發送郵件

1、指令碼內容  部署在B機器的/data1/local_backup/mysqlbak/IP裡面

#!/bin/sh
messages_dir=/data1/backup/local_backup/mysqlbak/172.16.16.1 /
cd /data1/backup/local_backup/mysqlbak/172.16.16.1 /
Now=$(date +"%d-%m-%Y")
File=web_mysql_172.16.16.1 _3306_$Now.sql
mysqldump -uroot -p'password' -h 172.16.16.1  -B A B C | gzip -9 > /data1/backup/local_backup/mysqlbak/172.16.16.1 /$File.sql.gz
/usr/bin/find ${messages_dir} -name '*web_mysql_172.16.16.1 _3306*' -mtime +7 -exec rm -f {} \;
echo $? > /data1/backup/local_backup/mysqlbak/172.16.16.1 /mysqlbak172.16.16.1.log

2、設定定時任務

[root@git ~]# vi /etc/crontab
00 02 * * * /bin/sh /data1/backup/local_backup/mysqlbak/172.16.16.1 /backup-172.16.16.1.sh
[root@git ~]# /sbin/service crond restart
[root@git ~]# chkconfig –level 35 crond on

3、定義key變數

12 [root@git ~]# cat /usr/local/zabbix_agent/etc/zabbix_agentd.conf | grep "UserParameter"
UserParameter=mysqlbak.log,/bin/cat /data1/backup/local_backup/mysqlbak/172.16.16.1 /mysqlbak172.16.16.1.log

#重啟zabbix-agent

4、在主機上面添加模板,調用key變數

5、設定觸發器

一些Zabbix相關教程集合:

Ubuntu 14.04下Zabbix2.4.5 源碼編譯安裝 

安裝部署分布式監控系統Zabbix 2.06

《安裝部署分布式監控系統Zabbix 2.06》

CentOS 6.3下Zabbix安裝部署

Zabbix分布式監控系統實踐

CentOS 6.3下Zabbix監控apache server-status

CentOS 6.3下Zabbix監控MySQL資料庫參數

64位CentOS 6.2下安裝Zabbix 2.0.6   

ZABBIX 的詳細介紹:請點這裡
ZABBIX 的:請點這裡

本文永久更新連結地址:

相關文章

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.