Zabbix monitor MySQL master and slave

Source: Internet
Author: User

Environment:

192.168.127.131 primary Database and Zabbix server

192.168.127.130 from database and Zabbix client

A. First, assign a monitor account to MySQL.

Mysql>

Grant all privileges the zabbix.* to [e-mail protected] identified by ' Zabbix ';


b. Write a script

Vim/sh/mysql-replication.sh#!/bin/bash/usr/local/mysql/bin/mysql-uzabbix-pzabbix-e ' show slave status\G ' |grep-e ' Slave_io_running| Slave_sql_running "|awk ' {print $} ' |grep-c Yes



#先用zabbix这个用户来获取slave的所有状态, then grep out the two states, then output the second column, and finally look at a few yes states, normally with two yes states.
In fact, we will find that there is only one command, but I wrote it into a script, here I say, because if you write the command in the configuration file, every time you modify, you have to restart the agent, so write to the script is more convenient debugging changes, this should be a good habit.

C. Adding monitoring items to the agent
Add the following line at the end of the file
Vim/etc/zabbix_agentd.conf

userparameter=mysql.replication,/home/zabbix/mysql-replication.sh # #脚本所在的目录
#等号后面的字符串中, the comma is preceded by the key, followed by the executed script (the script does not forget to execute the permissions), after the addition, restart the agent program

d. Server-side testing is normal

Zabbix_get-s 192.168.127.130-p10050-k "Mysql.replication"

2

Return 2 is the normal

Then, on the Web page, add the monitoring item


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/80/59/wKioL1c-iFvCrl1gAACxTwplByc661.png "style=" float: none; "title=" 1.png "alt=" Wkiol1c-ifvcrl1gaacxtwplbyc661.png "/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/80/5B/wKiom1c-h3DiREoQAACGuvHeY58971.png "style=" float: none; "title=" 2.png "alt=" Wkiom1c-h3direoqaacguvhey58971.png "/>


Trigger Settings


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/80/5B/wKiom1c-h3DzromoAABlx3NPNeA826.png "style=" float: none; "title=" 3.png "alt=" Wkiom1c-h3dzromoaablx3npnea826.png "/>




Select the monitoring item that you created in the first step mysql-repelication

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/5B/wKiom1c-h3DzrNfOAACL-fNcp_k639.png "style=" float: none; "title=" 4.png "alt=" Wkiom1c-h3dzrnfoaacl-fncp_k639.png "/>


Last Test, stop the MySQL service from the server to see if the alarm is triggered


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/80/59/wKioL1c-iF3yuMO7AAC1DnnHoMc884.png "style=" float: none; "title=" 5.png "alt=" Wkiol1c-if3yumo7aac1dnnhomc884.png "/>



Finally, you can also view the image data in the latest data

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/80/59/wKioL1c-iv-gjTL6AAGY0qgWrIU985.png "title=" 6.png " alt= "Wkiol1c-iv-gjtl6aagy0qgwriu985.png"/>

This article is from the "Drifting Away" blog, make sure to keep this source http://825536458.blog.51cto.com/4417836/1775341

Zabbix monitor MySQL master and slave

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.