This article mainly introduces the configuration of Zabbix monitoring MySQL, including the use of Zabbix self-contained templates to monitor MySQL related information and custom key monitoring MySQL synchronization. at the same time, it introduces the creation of Trigger and Zabbix by mail.
First, configure the self-brought template monitoring MySQL
1. Provision profile Template
file location in Source package /usr/local/src/zabbix-3.0.4/conf/zabbix_agentd/userparameter_mysql.conf
#cp/usr/local/src/zabbix-3.0.4/conf/zabbix_agentd/userparameter_mysql.conf/usr/local/zabbix/etc/zabbix_ Agentd.conf.d
2. Modify the template file
#sed-i ' [email protected]/var/lib/[email protected]/usr/local/zabbix/[email protected] '/usr/local/zabbix/etc/ Zabbix_agentd.conf.d/userparameter_mysql.conf
The modified file
Userparameter=mysql.status[*],echo "show global status where Variable_name= ' $ ';" | Home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysql-n | awk ' {print $$2} '
Userparameter=mysql.size[*],bash-c ' echo ' Select SUM ($ (case "$ both|" "") echo "Data_length+index_length";; Data|index) echo "$3_length";; Free) echo "Data_free";; ESAC)) from information_schema.tables$ ([["$" = "All" | |! "$"] | | echo "wheretable_schema=\" $1\ "") $ ([[["$] =" All "| |!" $ "] | | echo "and table_name=\" $2\ ""); "| Home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysql-n '
Userparameter=mysql.ping,home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysqladmin Ping | Grep-c Alive
Userparameter=mysql.version,/usr/local/mysql/bin/mysql-v
3. provide the file of the agent-attached database
#vi/usr/local/zabbix/etc/.my.cnf[mysql]host=localhostuser=zabbixagentpassword=123456socket=/tmp/mysql.sock[ Mysqladmin]host=localhostuser=zabbixagentpassword=123456socket=/tmp/mysql.sock
4. Create an authorized account
mysql> GRANT usage,process,replication client,replication SLAVE on * * to ' zabbixagent ' @ ' localhost ' identified by ' 123 456 ';mysql> flush privileges;
5. Modify zabbix_agentd.conf
include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
Restart Service
6. associating MySQL templates in the Web interface
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/87/45/wKiom1fZNJXAsQIGAABZkdPa1Xg131.png-wh_500x0-wm_3 -wmp_4-s_801853015.png "title=" 01.png "alt=" Wkiom1fznjxasqigaabzkdpa1xg131.png-wh_50 "/>
7. Final Effect
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/87/43/wKioL1fZNMKTR9FSAADa92Wcfz8319.png-wh_500x0-wm_3 -wmp_4-s_3998225736.png "title=" 02.png "alt=" Wkiol1fznmktr9fsaada92wcfz8319.png-wh_50 "/>
Second, the custom key monitoring slave
1. provide a configuration file for monitoring slave
#cat/usr/local/zabbix/etc/zabbix_agentd.conf.d/mysql_slave.conf
Userparameter=mysql.slave.seconds_behind_master,echo "show Slave Status\g" | Home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysql |grep "Seconds_behind_master" |awk ' {print$2} '
Userparameter=mysql.slave.slave_io_running,echo "show Slave Status\g" | Home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysql |grep "slave_io_running" |awk ' {print $} '
Userparameter=mysql.slave.slave_sql_running,echo "show Slave Status\g" | Home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysql |grep "\<slave_sql_running\>" |awk ' {print $} '
2. Restart Agent service
# servicezabbix_agentd Restart
3. command to test the value obtained by key
#/usr/local/zabbix/bin/zabbix_get-s 192.168.1.16-k "Mysql.slave.Seconds_Behind_Master"
#/usr/local/zabbix/bin/zabbix_get-s 192.168.1.16-k "Mysql.slave.Slave_IO_Running"
#/usr/local/zabbix/bin/zabbix_get-s 192.168.1.16-k "Mysql.slave.Slave_SQL_Running"
The above command returns the normal value description of the custom key success
4. Configuring monitoring items in the Web interface
Create slave delay items
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/87/45/wKiom1fZNUCTkrC3AACBIV4okzQ200.png-wh_500x0-wm_3 -wmp_4-s_3490706135.png "style=" Float:none; "title=" 01.png "alt=" Wkiom1fznuctkrc3aacbiv4okzq200.png-wh_50 "/>
Create Slave IO threads items
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/87/43/wKioL1fZNUDBQgXxAACBo_iKV8A160.png-wh_500x0-wm_3 -wmp_4-s_1761872513.png "style=" Float:none; "title=" 02.png "alt=" Wkiol1fznudbqgxxaacbo_ikv8a160.png-wh_50 "/>
Create Slave SQL Threads items
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/87/43/wKioL1fZNUDwLB0RAACCXplOhwY819.png-wh_500x0-wm_3 -wmp_4-s_1841307907.png "style=" Float:none; "title=" 03.png "alt=" Wkiol1fznudwlb0raaccxplohwy819.png-wh_50 "/>
Third, master-slave synchronization delay Alarm configuration
1. defining triggers
Creating a master-slave delay Trigger
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/87/45/wKiom1fZNjqTq4WxAAB0CmArayg906.png-wh_500x0-wm_3 -wmp_4-s_1795678925.png "style=" Float:none; "title=" 01.png "alt=" Wkiom1fznjqtq4wxaab0cmarayg906.png-wh_50 "/>
2. define the action
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/87/46/wKiom1fZNjqiAcf_AABphb6uO6w151.png-wh_500x0-wm_3 -wmp_4-s_1134050000.png "style=" Float:none; "title=" 02.png "alt=" Wkiom1fznjqiacf_aabphb6uo6w151.png-wh_50 "/>
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/87/43/wKioL1fZNjuD5HOxAABE1DJFKTk371.png-wh_500x0-wm_3 -wmp_4-s_54504217.png "style=" Float:none; "title=" 03.png "alt=" Wkiol1fznjud5hoxaabe1djfktk371.png-wh_50 "/>
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/87/43/wKioL1fZNjuhqWpWAAB2gSm6NSU579.png-wh_500x0-wm_3 -wmp_4-s_1862202075.png "style=" Float:none; "title=" 04.png "alt=" Wkiol1fznjuhqwpwaab2gsm6nsu579.png-wh_50 "/>
3. define mail sending users
To modify the mail server address for the alert media type
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/87/46/wKiom1fZOCuzrxoSAABaKIKDWJM099.png-wh_500x0-wm_3 -wmp_4-s_1870314847.png "style=" Float:none; "title=" 07.png "alt=" Wkiom1fzocuzrxosaabakikdwjm099.png-wh_50 "/>
User linked to the alert media and set up the email account
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/87/46/wKiom1fZOCuAEmp5AABJjOlyrMY516.png-wh_500x0-wm_3 -wmp_4-s_509686980.png "style=" Float:none; "title=" 08.png "alt=" Wkiom1fzocuaemp5aabjjolyrmy516.png-wh_50 "/>
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/87/43/wKioL1fZOCvgjmfoAAA2dRYa7jc292.png-wh_500x0-wm_3 -wmp_4-s_1695146595.png "style=" Float:none; "title=" 09.png "alt=" Wkiol1fzocvgjmfoaaa2drya7jc292.png-wh_50 "/>
View Mail
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/87/46/wKiom1fZNjzTSE9zAABwX1nHHbo761.png-wh_500x0-wm_3 -wmp_4-s_2813792866.png "style=" Float:none; "title=" 05.png "alt=" Wkiom1fznjztse9zaabwx1nhhbo761.png-wh_50 "/>
e-Mail specific content
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/87/43/wKioL1fZNjzxCtEjAABl7rNYHGY504.png-wh_500x0-wm_3 -wmp_4-s_389821571.png "style=" Float:none; "title=" 06.png "alt=" Wkiol1fznjzxctejaabl7rnyhgy504.png-wh_50 "/>
Four, master-slave synchronization State Alarm configuration
1. Create a master-slave synchronization state trigger
Define IO Thread Status
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/87/43/wKioL1fZOT_wZFU4AACFD-XS4mg360.png-wh_500x0-wm_3 -wmp_4-s_193977423.png "style=" Float:none; "title=" 01.png "alt=" Wkiol1fzot_wzfu4aacfd-xs4mg360.png-wh_50 "/>
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/87/43/wKioL1fZOUCwEVQEAABvHxPQ0gI363.png-wh_500x0-wm_3 -wmp_4-s_2781128955.png "style=" Float:none; "title=" 02.png "alt=" Wkiol1fzoucwevqeaabvhxpq0gi363.png-wh_50 "/>
Define SQL Thread Status
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/87/46/wKiom1fZOUDyIH96AABucucu-jQ062.png-wh_500x0-wm_3 -wmp_4-s_2177504.png "style=" Float:none; "title=" 03.png "alt=" Wkiom1fzoudyih96aabucucu-jq062.png-wh_50 "/>
2. Testing
Stop IO threads and SQL threads separately on slave
Analog Stop IO Thread
mysql> Stop Slaveio_thread;
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/87/43/wKioL1fZOUGweuiMAABVSIsN5xo650.png-wh_500x0-wm_3 -wmp_4-s_1312608781.png "style=" Float:none; "title=" 04.png "alt=" Wkiol1fzougweuimaabvsisn5xo650.png-wh_50 "/>
Simultaneous alarm message issued
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/87/46/wKiom1fZOUHg87_YAABoIEst2_g351.png-wh_500x0-wm_3 -wmp_4-s_767957959.png "style=" Float:none; "title=" 05.png "alt=" Wkiom1fzouhg87_yaaboiest2_g351.png-wh_50 "/>
Recovering IO Threads
Mysql> Startslave Io_thread;
Recovery notification messages
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/87/43/wKioL1fZOUKgbi8qAABZAVZbNQc456.png-wh_500x0-wm_3 -wmp_4-s_2847544269.png "style=" Float:none; "title=" 06.png "alt=" Wkiol1fzoukgbi8qaabzavzbnqc456.png-wh_50 "/>
Simulate stopping SQL threads
mysql> Stop Slavesql_thread;
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/87/46/wKiom1fZOULBOgl-AABpW6S4uyU032.png-wh_500x0-wm_3 -wmp_4-s_2208605755.png "style=" Float:none; "title=" 07.png "alt=" Wkiom1fzoulbogl-aabpw6s4uyu032.png-wh_50 "/>
Simultaneous alarm message issued
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/87/43/wKioL1fZOUKysDDjAABnK8seoqQ072.png-wh_500x0-wm_3 -wmp_4-s_2309432044.png "style=" Float:none; "title=" 08.png "alt=" Wkiol1fzoukysddjaabnk8seoqq072.png-wh_50 "/>
Recovering SQL Threads
Mysql> Startslave Sql_thread;
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/87/46/wKiom1fZOUOSrHzgAAB7aF42R2Q189.png-wh_500x0-wm_3 -wmp_4-s_672992014.png "style=" Float:none; "title=" 09.png "alt=" Wkiom1fzouosrhzgaab7af42r2q189.png-wh_50 "/>
Recovery notification messages
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/87/43/wKioL1fZOUOj1_WbAABnLXMh_SY151.png-wh_500x0-wm_3 -wmp_4-s_597439503.png "style=" Float:none; "title=" 10.png "alt=" Wkiol1fzouoj1_wbaabnlxmh_sy151.png-wh_50 "/>
This article is from the "Linux Road" blog, make sure to keep this source http://hnr520.blog.51cto.com/4484939/1852838
Zabbix monitoring MySQL configuration and fault alarm configuration