In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to use zabbix to monitor MySQL. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Summary:
If you want to set up a set of mysql surveillance
If you want to learn zabbix
Then this article is suitable for you.
MySQL Monitoring-- zabbix
Liu Chunlei modifies vi / etc/services to add the following lines
Zabbix-agent 10050/tcp # zabbix agent
Zabbix-agent 10050/udp # zabbix agent
Zabbix-trapper 10051/tcp # zabbix trapper
Zabbix-trapper 10051/udp # zabbix trapper
8. Modify the configuration of zabbix:
[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 # modify this line
[root@localhost ~] # vi / etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix # modify this line
9. Modify httpd configuration
[root@192.168.94.78 zabbix-2.4.4] # vi / etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
DocumentRoot "/ var/www/html"
ServerName 192.168.94.78
10. Enable httpd
[root@192.168.94.78 core] # service httpd restart
Stopping 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-iRU 80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Httpd 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)
10. Make a few soft connections
[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/
11. Enable the zabbix server:
[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 ona 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
2. Copy / create Quick
[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
3. Modify the configuration file
[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 # client IP
4. Enable agent of zabbix
[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. Add host to the interface
At this point, you can add host to the interface for monitoring and testing, because custom monitoring is added later, which is ignored here.
Custom monitoring configuration 1. Prepare to check the script
Prepare a script to check the status of 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
Note: you can customize the script here, return key=value, or use the template of percona. Here, take the custom monitoring script as an example for configuration monitoring.
2. Modify the configuration file of agent
[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}'
Note: com_delet is the name of the key value, followed by the key value
Restart agent
/ etc/init.d/zabbix_agentd stop
/ usr/local/zabbix/sbin/zabbix_agentd-c / usr/local/zabbix/etc/zabbix_agentd.conf
3. Server side check
Check
[root@192.168.94.78 bin] # pwd
/ usr/local/zabbix/bin
[root@192.168.94.784.1 add host
4.2 add template
4.3 create an application set
4.4 create a project
4.5 create a graphic
5. View the monitoring chart
6. Other processes
This is the end of this article on "how to use zabbix to monitor MySQL". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.