LoginSignup
24
16

More than 5 years have passed since last update.

mackerelでmysqldを監視するための設定

Last updated at Posted at 2015-07-27

背景

mackerelは公式プラグインで簡単にmysqldを監視できる。

しかし、デフォルト設定ではrootユーザーを使ってしまうので、別途ユーザーを作成することにした。

作業手順

mysql側のユーザー作成

mysqlに特権でログイン。以下は例なので、環境に合わせて。

$ mysql -u root

ユーザーを作る。以下の例では『monitor_user』という名前にした。

mysql> create user 'monitor_user'@'127.0.0.1';
mysql> grant PROCESS, REPLICATION CLIENT on *.* to 'monitor_user'@'127.0.0.1';
mysql> flush privileges;

どうせローカルホストだし、mackerel-plugin側に平文でパスワードを書く必要があるので、パスワード設定はなし。
※ 権限に過不足があれば教えて下さい。

テスト

$ /usr/local/bin/mackerel-plugin-mysql -username=monitor_user -tempfile /tmp/mackerel-plugin-mysql-localhost-3306
mysql.innodb_lock_structures.innodb_lock_structs    0   1434080228
mysql.innodb_adaptive_hash_index.hash_index_cells_total 34679   1434080228
mysql.innodb_adaptive_hash_index.hash_index_cells_used  0   1434080228
mysql.innodb_buffer_pool_read.read_ahead    0   1434080228
以下略

いっぱい出ればOK。権限エラーが出たら権限不足。
tempfile作成でpermission deniedの時はsudoとかしないとダメかと。

mackerel-agentへの設定適用

mackerel-agent.confを修正する。

/etc/mackerel-agent/mackerel-agent.conf
[plugin.metrics.mysql]
command = "/usr/local/bin/mackerel-plugin-mysql -username=monitor_user"

設定適用

$ service mackerel-agent restart
24
16
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
24
16