Centos 7上配置Munin MySQL插件.

Munin自带的有MySQL插件,但是并不太好用,本文将介绍如何安装和配置第三方的Munin MySQL监控插件.
本文中所有操作都在Centos 7, MaraiDB 11.2下完成.

1.安装必要的Perl依赖

yum -y install perl-DBI perl-DBD-mysql perl-Module-Pluggable

2.下载,解压munin-mysql插件

wget https://github.com/kjellm/munin-mysql/archive/master.zip -O munin-mysql.zip
unzip munin-mysql.zip
cd munin-mysql-master

3.修改mysql.conf配置
修改 env.mysqlconnection DBI:mysql:mysql 为 env.mysqlconnection DBI:mysql:munin
修改env.mysqluser root 为 env.mysqluser munin
去掉env.mysqlpassword前面的#号,并把geheim修改成你将要使用监控MySQL账号的密码

4.编辑Makefile, 找到$(MUNIN_NODE) restart (大约45行),备注或者删除掉

5.安装, 在munin-mysql-master目录执行make install

6.配置MySQL,在phpmyadmin或者mysql -u root -p 下执行以下SQL

CREATE USER `munin` @`localhost` IDENTIFIED BY '0do8KxdWULQu'; #请自行把0do8KxdWULQu替换为你在mysql.conf里设置的密码
GRANT SUPER ON *.* TO `munin` @`localhost`;
GRANT PROCESS ON *.* TO `munin` @`localhost`;
CREATE DATABASE IF NOT EXISTS `munin`;
GRANT ALL PRIVILEGES ON `munin`.* TO 'munin'@'localhost';
FLUSH PRIVILEGES;

7.运行munin-run mysql,如果看到以下内容则安装成功.

multigraph mysql_bin_relay_log
Binlog_cache_disk_use.value 0
Binlog_cache_use.value 0
Binlog_stmt_cache_disk_use.value 0
Binlog_stmt_cache_use.value 0
ma_binlog_size.value 0
.....

7.重启munin-node,稍等片刻之后即可在Munin页面上看到MySQL的图表

systemctl restart munin-node

 

20160730163646