【Munin】rrdcachedでIOを取り戻せ!

【Munin】rrdcachedでIOを取り戻せ! はてなブックマーク - 【Munin】rrdcachedでIOを取り戻せ!


Munin の監視ノードが増えてくると、ストレージの IO がボトルネックになりがち。Munin によるランダムなファイルの読み書きが主な原因。改善するためには、 rrdcached と Munin を連携する方法が手軽で確実な方法です。Muninサーバの処理が重いなと思ったら、SSD など高速ストレージを導入する前に、まずは rrdcached の導入がおすすめです。

記事内容は、rrdcached のメリット(1台で300ノードまでの監視に対応)と、RHEL5 で導入したときの手順メモ、そして rrdcached の効果を知る為の rrdcached プラグインの導入方法です。

■rrdcached を何故使うのか?

rrdcached 導入後はIO(write)が一気に減少


Munin  RRD (IO)

 munin-update  Munin  munin-update 

CPUのiowaitも減少します。


Munin 2.0  rrdcached rrdcached RRD rrdcached IO

rrdcached 使1( CPU Xeon 4core 4GBHDD SATA )  300 

 Load Average  iowait munin-update 

rrdcached (1/3) rrdtool 

RHEL5 CentOS5  RHEL6/CentOS6 

 rrdtool  ( 1.2  ) 1.4 rpm  yum erase rrdtool Munin 
# rpm -e rrdtool rrdtool-perl

rrdtool  1.4 EPEL  CentOS rpmforge 
RHEL5/CentOS5 (x86_64)
$ wget http://pkgs.repoforge.org/rrdtool/rrdtool-1.4.7-1.el5.rf.x86_64.rpm
$ wget http://pkgs.repoforge.org/rrdtool/perl-rrdtool-1.4.7-1.el5.rf.x86_64.rpm

RHEL6/CentOS6 (x86_64)
$ wget http://pkgs.repoforge.org/rrdtool/rrdtool-1.4.7-1.el6.rfx.x86_64.rpm
$ wget http://pkgs.repoforge.org/rrdtool/perl-rrdtool-1.4.7-1.el6.rfx.x86_64.rpm

rpm 
# rpm -ivh ./rrdtool-1.4.7-1.el5.rf.x86_64.rpm ./perl-rrdtool-1.4.7-1.el5.rf.x86_64.rpm

 -ivh  -Uvh 使


警告: ./perl-rrdtool-1.4.7-1.el6.rfx.x86_64.rpm: ヘッダ V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
エラー: 依存性の欠如:
        xorg-x11-fonts-Type1 は rrdtool-1.4.7-1.el6.rfx.x86_64 に必要とされています

yum install xorg-x11-fonts-Type1 

RHLE5  lua  EPEL 
# yum install lua --enablerepo=epel

 rrdtool failed to load /usr/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf

rrdcached (2/3) rrdcached 

 rrdcached /etc/sysconfig/rrdcached 
OPTIONS="-l unix:/var/rrdtool/rrdcached/rrdcached.sock -l 127.0.0.1 -s apache -m 664 -b /var/rrdtool/rrdcached -F -j /var/lib/munin/rrdcached-journal -w 1800 -z 1800 -f 3600"
RRDC_USER=munin


-l 127.0.0.1 

-s  apache 

-m 

-b 

-F  rrdcached 

-j 

-w 1800 30

-z 1800 30

-f 3600 60

RRDC_USER= munin 


-w -z -f 5rrdcached  Munin  wiki 使



# vi /etc/init.d/rrdcached
     27 start() {
     28     [ -x $rrdcached ] || exit 5
     29     echo -n $"Starting $prog: "
     30     daemon --user=${RRDC_USER} $rrdcached -p ${pidfile} ${OPTIONS}
     31     retval=$?
     32     echo
     33     [ $retval -eq 0 ] && touch $lockfile
     34     chgrp apache /var/rrdtool/rrdcached/rrdcached.sock
     35     chmod g+w /var/rrdtool/rrdcached/rrdcached.sock
     36     return $retval
     37 }

3435


# mkdir /var/lib/munin/rrdcached-journal
# chown munin.munin /var/lib/munin/rrdcached-journal


# chown munin.munin /var/rrdtool/rrdcached/

rrdcached 
# /sbin/service rrdcached start

rrdcached : bash: line 1:  3064 
/var/log/messages [WARN] RRDCached feature ignored: rrdcached socket not writable

 42217 (rrdcached 使) 
# /usr/sbin/lsof -i:42217
COMMAND     PID  USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
rrdcached 25428 munin    5u  IPv4 26402007      0t0  TCP localhost:42217 (LISTEN)

  telnet nc STATS 
# nc localhost 42217
STATS
9 Statistics follow
QueueLength: 0
UpdatesReceived: 0
FlushesReceived: 0
UpdatesWritten: 0
DataSetsWritten: 0
TreeNodesNumber: 0
TreeDepth: 0
JournalBytes: 0
JournalRotate: 0
quit


# /sbin/chkconfig rrdcached on
# /sbin/chkconfig --list rrdcached
rrdcached       0:off   1:off   2:on    3:on    4:on    5:on    6:off

 /var/log/messages 
Jul  5 22:55:30 sv rrdcached[25428]: starting up
Jul  5 22:55:30 sv rrdcached[25428]: checking for journal files
Jul  5 22:55:30 sv rrdcached[25428]: journal processing complete
Jul  5 22:55:30 sv rrdcached[25428]: listening for connections

rrdcached (3/3) Munin調

munin  /etc/munin/munin.conf 87 rrdcached 
# RRD updates are per default, performed directly on the rrd files.
# To reduce IO and enable the use of the rrdcached, uncomment it and set it to
# the location of the socket that rrdcached uses.
#
rrdcached_socket /var/rrdtool/rrdcached/rrdcached.sock



Munin  rrdcached 

rrdcached プラグインを通して、動作状況を確認


Munin rrdcached 

 

rrdcached 使

github 
$ wget https://raw.github.com/munin-monitoring/munin/2.0.16/plugins/node.d.debug/rrdcached.in

1
#!@@PERL@@


#!/usr/bin/perl



8
my $PEER = exists $ENV{'PEER'} ? $ENV{'PEER'} : "/var/rrdtool/rrdcached/rrdcached.sock";

16
 15 if ($arg && $arg eq "config") {
 16         print "graph_title rrdcached stats\n";
 17         print "graph_category rrdcached\n";

37
my $sock = new IO::Socket::UNIX(
        Type => SOCK_STREAM,
        Peer => $PEER,
#       Peer => "/tmp/rrdcached.munin.sock",
) or die "Cannot open socket : $!";




# mv rrdcached.in /usr/share/munin/plugins/rrdcached
# chmod 755 /usr/share/munin/plugins/rrdcached
# ln -s /usr/share/munin/plugins/rrdcached  /etc/munin/plugins/

 /etc/munin/plugin-conf.d/munin-node 
[rrdcached]
    group apache
    env.PEER    /var/rrdtool/rrdcached/rrdcached.sock

group apache CGI  apache 

 munin-run 使
# /usr/sbin/munin-run rrdcached
QueueLength.value 0
UpdatesReceived.value 0
FlushesReceived.value 0
UpdatesWritten.value 0
DataSetsWritten.value 0
TreeNodesNumber.value 0
TreeDepth.value 0
JournalBytes.value 0
JournalRotate.value 0

 Cannot open socket : No such file or directory at /etc/munin/plugins/rrdcached line 32. 
rrdcached CGI  /var/log/munin/munin-cgi-graph.log 

 munin-node 
# /sbin/service munin-node restart

rrdcached 使IO



rrdcached  Munin
http://munin-monitoring.org/wiki/rrdcached

RRDtool  rrdcached
http://oss.oetiker.ch/rrdtool/doc/rrdcached.en.html

Scaling the munin master with rrdcached  Munin 2.1.2-53-gcdca5e1 documentation
https://munin.readthedocs.org/en/latest/master/rrdcached.html

lightning talk about rrdcached and munin
https://gist.github.com/ssm/5767967