分享更有价值
被信任是一种快乐

如何使用zabbix监控MySQL

文章页正文上

这篇文章将为大家详细讲解有关如何使用zabbix监控MySQL,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

概要:
如果你想搭建一套mysql监控
如果你想学习zabbix
那么此篇文章适合你 MySQL监控–zabbix
刘春雷修改 vi /etc/services,添加下面几行zabbix-agent 10050/tcp #zabbix agent
zabbix-agent 10050/udp #zabbix agent
zabbix-trapper 10051/tcp #zabbix trapper
zabbix-trapper 10051/udp #zabbix trapper[root@192.168.94.78 zabbix-2.4.4]#vi /usr/local/zabbix/etc/zabbix_server.conf
[root@192.168.94.78 zabbix-2.4.4]#cat /usr/local/zabbix/etc/zabbix_server.conf|grep -v ^# | grep -v ^$
LogFile=/data/zabbix/zabbix_server.log
PidFile=/data/zabbix/zabbix_server.pid
DBHost=192.168.94.78
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/tmp/mysql.sock
DBPort=6001
StartPollers=20
StartTrappers=15
StartPingers=10
User=zabbix [root@localhost ~]# vi /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix ##########修改这行
[root@localhost ~]# vi /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix ##########修改这行[root@192.168.94.78 zabbix-2.4.4]#vi /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1

Do免费主机域名cumentRoot “/var/www/html”
ServerName 192.168.94.78
[root@192.168.94.78 core]#service httpd restartStopping httpd: [ OK ]Starting httpd: httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName[ OK ][root@192.168.94.78 core]# lsof -i:80COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEhttpd 23923 root 4u IPv4 2582967064 0t0 TCP *:80(LISTEN)httpd 23925 apache 4u IPv4 2582967064 0t0 TCP *:80 (LISTEN)httpd 23926 apache 4u IPv4 2582967064 0t0 TCP *:80 (LISTEN)httpd 23927 apache 4u IPv4 2582967064 0t0 TCP *:80 (LISTEN)httpd 23928 apache 4u IPv4 2582967064 0t0 TCP *:80 (LISTEN)httpd 23929 apache 4u IPv4 2582967064 0t0 TCP *:80 (LISTEN)httpd 23930 apache 4u IPv4 2582967064 0t0 TCP *:80 (LISTEN)httpd 23931 apache 4u IPv4 2582967064 0t0 TCP *:80 (LISTEN)httpd 23932 apache 4u IPv4 2582967064 0t0 TCP *:80 (LISTEN)[root@localhost ~]# ln -s /usr/local/zabbix/bin/* /usr/bin/
[root@localhost ~]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/
[root@localhost ~]# cd/data/zabbix/zabbix-2.4.4/misc/init.d/fedora/core[root@localhost ~]# cp * /etc/init.d/
[root@192.168.94.78 subsys]# chown zabbix.zabbix /var/lock/subsys/ -R
[root@192.168.94.78 subsys]# chown zabbix.zabbix /usr/local/zabbix -R
[root@192.168.94.78 subsys]# chown zabbix.zabbix /data/zabbix/ -R
[root@192.168.94.78 core]#[root@192.168.94.78 zabbix]# scp zabbix-2.4.4.tar.gz 192.168.94.144:/data/zabbix_agent/


[root@192.168.94.144 zabbix_agent]# groupadd -g 201 zabbix

[root@192.168.94.144 zabbix_agent]# useradd -g zabbix -u 201 -m zabbix

[root@192.168.94.144 zabbix_agent]# passwd zabbix

Changing password for user zabbix.

New password:

BAD PASSWORD: it is based on a dictionary word

BAD PASSWORD: is too simple

Retype new password:

passwd: all authentication tokens updated successfully.

[root@192.168.94.144 zabbix-2.4.4]#cd/data/zabbix_agent/zabbix-2.4.4

[root@192.168.94.144 zabbix-2.4.4]# ./configure –prefix=/usr/local/zabbix –enable-agent –enable-proxy –with-mysql=/usr/local/mysql5.5/bin/mysql_config
[root@192.168.94.144 zabbix-2.4.4]# make && make install
[root@192.168.94.144 zabbix-2.4.4]# pwd
/data/zabbix_agent/zabbix-2.4.4
[root@192.168.94.144 zabbix-2.4.4]# cp misc/init.d/tru64/zabbix_agentd /etc/init.d/
[root@192.168.94.144 zabbix-2.4.4]# chmod +x /etc/init.d/zabbix_agentd
[root@192.168.94.144 zabbix-2.4.4]# vi /usr/local/zabbix/etc/zabbix_agentd.conf
[root@192.168.94.144 zabbix-2.4.4]# cat /usr/local/zabbix/etc/zabbix_agentd.conf | grep -v ^# | grep -v ^$
LogFile=/data/zabbix_agent/zabbix_agentd.log
UnsafeUserParameters=1
Include= /usr/local/zabbix/etc/zabbix_agentd.conf.d/
Server=192.168.94.78 #server端IP
ServerActive=192.168.94.78 #server端IP
Hostname=192.168.94.144 #客户端IP
[root@192.168.94.133 zabbix-2.4.4]# chown zabbix.zabbix /data/zabbix_agent/ -R
[root@192.168.94.133 zabbix-2.4.4]# chown zabbix.zabbix /usr/local/zabbix/ -R [root@192.168.94.133 zabbix-2.4.4]#chown zabbix.zabbix /soft/mysqlmonitor/port_6190 -R
[root@192.168.94.144 tmp]#5、界面添加host
此时可以在界面上面添加host进行监控测试了,因后面添加自定义监控,此处忽略
准备检查mysql状态的脚本
[root@192.168.94.144 ~]# cd /soft/port_6190/
[root@192.168.94.144 port_6190]# ./mysql_status.pl|grep com_writes
com_writes=0
[root@192.168.94.144 port_6190]# /soft/port_6190/mysql_status.pl |grep com_writes|awk -F ‘=’ ‘{print $2}’
0 :此处可以自定义脚本,返回key=value 即可,或者使用percona的模板,此处以自定义监控脚本为例来进行配置监控
[root@192.168.94.144 port_6190]# vi /usr/local/zabbix/etc/zabbix_agentd.conf
[root@192.168.94.144 port_6190]# cat /usr/local/zabbix/etc/zabbix_agentd.conf|grep -v ‘^#’|grep -v ‘^$’
LogFile=/data/zabbix_agent/zabbix免费主机域名_agentd.log
UnsafeUserParameters=1
Include= /usr/local/zabbix/etc/zabbix_agentd.conf.d/
Server=192.168.94.78
ServerActive=192.168.94.78
Hostname=test
UserParameter=com_writes,/soft/port_6190/mysql_status.pl |grep com_writes|awk -F ‘=’ ‘{print $2}’
UserParameter=com_reads,/soft/port_6190/mysql_status.pl |grep com_reads |awk -F ‘=’ ‘{print $2}’
UserParameter=com_update,/soft/port_6190/mysql_status.pl |grep com_update|awk -F ‘=’ ‘{print $2}’
UserParameter=com_insert,/soft/port_6190/mysql_status.pl |grep com_insert|awk -F ‘=’ ‘{print $2}’
UserParameter=com_delete,/soft/port_6190/mysql_status.pl |grep com_delete|awk -F ‘=’ ‘{print $2}’ 注:com_delet 为键值名,后面为键值的值
重启agent
/etc/init.d/zabbix_agentd stop
/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf
检查
[root@192.168.94.78 bin]# pwd
/usr/local/zabbix/bin
[root@192.168.94.784.1添加host

关于“如何使用zabbix监控MySQL”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

相关推荐: SQL中的ACID指的是什么

本篇内容介绍了“SQL中的ACID指的是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,免费主机域名能够学有所成!  WAL的中心思想是对数据文件的修改(它们是表和索引的载…

文章页内容下
赞(0) 打赏
版权声明:本站采用知识共享、学习交流,不允许用于商业用途;文章由发布者自行承担一切责任,与本站无关。
文章页正文下
文章页评论上

云服务器、web空间可免费试用

宝塔面板主机、支持php,mysql等,SSL部署;安全高速企业专供99.999%稳定,另有高防主机、不限制内容等类型,具体可咨询QQ:360163164,Tel同微信:18905205712

主机选购导航云服务器试用

登录

找回密码

注册