Mysql監視プラグインの追加
プラグインの追加
Mysql用プラグインはデフォルトで用意されているものを利用します。
# cd /etc/munin/plugins
# ln -s /usr/share/munin/plugins/mysql_ ./mysql_commands
# ln -s /usr/share/munin/plugins/mysql_ ./mysql_connections
# ln -s /usr/share/munin/plugins/mysql_ ./mysql_innodb_io
# ln -s /usr/share/munin/plugins/mysql_ ./mysql_innodb_bpool
# ln -s /usr/share/munin/plugins/mysql_ ./mysql_select_types
# ln -s /usr/share/munin/plugins/mysql_ ./mysql_slow
# ln -s /usr/share/munin/plugins/mysql_ ./mysql_qcache
# ln -s /usr/share/munin/plugins/mysql_ ./mysql_qcache_mem
# ln -s /usr/share/munin/plugins/mysql_ ./mysql_sorts
# ln -s /usr/share/munin/plugins/mysql_ ./mysql_table_locks
※利用するMysqlによっては上手く値を取得できないプラグインがあります。
プラグインに必要なパッケージの追加インストール
# yum install --enablerepo=epel perl-Cache-Cache perl-IPC-ShareLite perl-DBD-MySQL
プラグインの設定
mysqlへの接続方法を定義します。
# vim /etc/munin/plugin-conf.d/munin-node
[mysql_*]
env.mysqlconnection DBI:mysql:mysql;host=localhost;port=3306;mysql_socket=/opt/app/mysql/tmp/mysql.sock
env.mysqluser ${MYSQL_USER}
env.mysqlpassword ${MYSQL_PASSWD}
Mysqlの設定
プラグインがMysqlにログインし、パフォーマンス情報を取得できるよう権限を付与します。
CREATE USER 'ユーザー名'@'localhost' IDENTIFIED BY 'パスワード';
GRANT PROCESS,SUPER,REPLICATION CLIENT on *.* ${MYSQL_USER}@localhost;
プラグインの有効化
プラグインの動作確認
# cd /etc/munin/plugins
# munin-run mysql_connections
xxxxx.value 1234
のように値が取得できていれば成功です。
最後にサービスを再起動して有効化します。
# systemctl restart munin-node