LoginSignup
4
4

More than 5 years have passed since last update.

MuninでMySQLの情報を表示させたい

Last updated at Posted at 2015-11-11

muninでMySQL(InnoDB)の情報を見れるようにmunin plugin入れた時の手順メモ

必要なパッケージのインストール

# yumでインストール
$ yum install -y perl-IPC-ShareLite perl-Cache-Cache perl-DBD-Mysql 

もしも、yum使えねぇよ馬鹿って場合

下記サイトから、必要なrpmパッケージをダウンロードする

perl-Cache-Cache
perl-IPC-ShareLite
perl-DBD-Mysql

上記サイトからローカル落とすなり、wgetで取ってくるなりよしなにお願いします。

ローカルからサーバへ送る場合はこんな感じで転送して下さい

$ scp Desktop/perl-IPC-ShareLite-0.13-4.el6.x86_64.rpm user@XXX.XXX.XXX.XXX:/usr/local/src/

サーバに持ってこれたら、こんな感じパッケージインストールします

$ rpm -ivh /usr/local/src/perl-IO-Socket-SSL-1.44-1.el6.rfx.noarch.rpm
$ rpm -ivh /usr/local/src/perl-IPC-ShareLite-0.13-4.el6.x86_64.rpm
$ rpm -ivh /usr/local/src/perl-DBD-MySQL-4.013-3.el6.x86_64.rpm

ここまでの手順で、必要なパッケージのインストールが終わったはずなので、
ここからは、muninのpluginの設定を行います

プラグインを追加する(シンボリックリンクを貼る)

ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_bytes
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_commands
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_connections
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_bpool
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_bin_relay_log
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_files_tables
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_bpool_act
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_insert_buf
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_io
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_io_pend
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_log
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_rows
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_semaphores
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_tnx
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_network_traffic
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_qcache
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_qcache_mem
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_select_types
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_slow
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_sorts
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_table_locks
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_tmp_tables

mysqlにmuninから監視権限を付与する

デフォルトのmysqlユーザでする場合は特に設定いらない

# こんな感じで権限付けておく
grant all on *.* to munin@localhost identified by 'munin';

munin-nodeからmysqlに接続出来るように設定する

$ vim /etc/munin/plugin-conf.d/munin-node
# munin用のユーザ作った場合
[mysql*]
env.mysqlopts -umunin --password=munin
env.mysqlconnection DBI:mysql:mysql;host=localhost;port=3306
env.mysqluser munin
env.mysqlpassword munin

# デフォルトのmysqlユーザの場合
[mysql*]
env.mysqlconnection DBI:mysql:mysql;host=127.0.0.1;port=3306

munin-nodeを再起動する

$ /etc/init.d/munin-node restart
Stopping Munin Node agents:                                [  OK  ]
Starting Munin Node:                                       [  OK  ]

munin pluginが有効になっているか確認する

# munin-runコマンドで値が取れるか試してみる
$ munin-run mysql_innodb_bpool
ib_bpool_size.value 393216
ib_bpool_dbpages.value 306
ib_bpool_free.value 392909
ib_bpool_modpages.value 0

# config情報も見たい場合はこっちのコマンドで
$ munin-run mysql_innodb_bpool config
graph_args --base 1024
graph_title InnoDB Buffer Pool
graph_vlabel Pages
graph_category mysql2
ib_bpool_size.draw AREA
ib_bpool_size.colour ffd660
ib_bpool_size.min 0
ib_bpool_size.label Buffer pool size
ib_bpool_size.type GAUGE
ib_bpool_dbpages.draw AREA
ib_bpool_dbpages.colour cdcfc4
ib_bpool_dbpages.min 0
ib_bpool_dbpages.label Database pages
ib_bpool_dbpages.type GAUGE
ib_bpool_free.draw LINE2
ib_bpool_free.min 0
ib_bpool_free.label Free pages
ib_bpool_free.type GAUGE
ib_bpool_modpages.draw LINE2
ib_bpool_modpages.min 0
ib_bpool_modpages.label Modified pages
ib_bpool_modpages.type GAUGE

その他munin周りで使いそうなコマンド

# munin pluginの設定状況を一覧表示する
$ munin-node-configure

# munin pluginが使えない時に、理由を一覧表示してくれる
$ munin-node-configure -suggest

# 有効にすべきmunin pluginの一覧を表示してくれる
$ munin-node-configure --shell

# munin pluginが使えるようにシンボリックリンク作成してくれる
$ munin-node-configure --shell | sh
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4