Step-by-Step Guide to Configure Zabbix MySQL Monitoring on CentOS
This tutorial walks through setting up Zabbix to monitor MySQL on a CentOS server, covering environment preparation, creating configuration files, adjusting paths, restarting services, applying the MySQL template on the Zabbix server, and customizing triggers and actions.
1. System Environment
Software and versions OS: CentOS 6.8 zabbix: zabbix-3.2.4.tar.gz nginx: nginx-1.10.3.tar.gz MySQL: mysql-5.5.53-linux2.6-x86_64.tar.gz PHP: php-5.5.38.tar.gz
Installation paths Zabbix: /usr/local/zabbix MySQL:
/usr/local/mysql2. Operations on the MySQL Server
2.1 Create .my.conf
The hidden .my.conf file stores MySQL credentials for Zabbix. Place it in the Zabbix etc directory, e.g.:
vim /usr/local/zabbix/etc/.my.conf
[mysql]
host=localhost
user=zabbix
password=zabbix
socket=/tmp/mysql.sock
[mysqladmin]
host=localhost
user=zabbix
password=zabbix
socket=/tmp/mysql.sock2.2 Deploy userparameter_mysql.conf
Copy the supplied user‑parameter file and adjust paths:
cp ~/softwares/zabbix-3.2.4/conf/zabbix_agentd/userparameter_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/Edit the file:
Change HOME=/var/lib/zabbix to HOME=/usr/local/zabbix/etc (the directory containing .my.conf).
Replace the relative mysql and mysqladmin commands with absolute paths, e.g.:
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/usr/local/zabbix/etc /usr/local/mysql/bin/mysql -N | awk '{print $$2}'
UserParameter=mysql.ping,HOME=/usr/local/zabbix/etc /usr/local/mysql/bin/mysqladmin ping | grep -c alive
UserParameter=mysql.version,HOME=/usr/local/zabbix/etc /usr/local/mysql/bin/mysql -V2.3 Include the file in zabbix_agentd.conf
Add the include line and uncomment it:
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/2.4 Restart the agent
service zabbix_agentd restart3. Operations on the Zabbix Server
3.1 Apply the MySQL monitoring template
In the host configuration, add Template App MySQL. Screenshots illustrate the template selection.
3.2 View monitoring data
Navigate to Monitoring → Latest data, filter by host, and examine MySQL status, slow queries, etc. Screenshots show the data view.
4. Configure triggers and actions
Based on actual business needs, create appropriate triggers and actions. By default, a trigger fires when MySQL is down; further customization can be added as needed.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
