良玉的博客 点点滴滴,积水成河_良玉的博客_页游、手游linux运维工程师之路

spine轮询器优化cacti

    出于效率原因,在大量采集数据时使用自带的cmd.php轮询器会比较慢,1分钟1次的采集频率可能无法完成轮询所有机器。这里为了优化,采用官方推荐的spine来高效轮询。本例使用源代码编译安装,下载的版本是spine-0.8.8a,所用cacti为0.8.7g
1. 下载安装spine
# cd /home
#  wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz
# tar -xvf cacti-spine-0.8.8a.tar.gz
#cd cacti-spine-0.8.8a
# ./configure
# ./make
# ./make install
2.修改访问数据库用户名密码信息
#cp  /usr/local/spine/etc/spine.conf.dist  /usr/local/spine/etc/spine.conf
# vi /usr/local/spine/etc/spine.conf
3.测试是否正常
报错:
# /usr/local/spine/bin/spine
SPINE: Using spine config file [spine.conf]
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
09/11/2014 08:29:08 PM - SPINE: Poller[0] FATAL: Connection Failed, Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' (Spine init)
修改了mysql的
socket           = /var/lib/mysql/mysql.sock
如果MySQL是5.5,需要将cacti.sql中的TYPE=MyISAM,改成ENGINE=MyISAM
一个补丁文件cacti.sql-MySQL-5.5.9.patch,可以改cacti.sql文件
# /usr/local/spine/bin/spine

SPINE: Using spine config file [../etc/spine.conf]
SPINE: Version 0.8.8a starting
SPINE: Time: 0.2911 s, Threads: 5, Hosts: 2
(如果提示找不到配置文件,可以加-C选项手动指定配置文件路径)
4.在cacti里设置spine路径
Console -> Configuration -> Settings -> Paths -> Alternate Poller Path -> Spine Poller File Path
/usr/local/spine/bin/spine
5. 修改Cacti使用的Poller Type
Console -> Cacti Settings->Poller->Poller Type
在下拉中选择spine
===================================================================================
以下线程调整引用自http://www.chenjunlu.com/2011/05/tips-for-improving-the-performance-of-cacti-server/
       修改 Spine Specific Execution Parameters 里的 Maximum Threads per Process 为监控服务器 cpu 个数的2倍。我在实际的操作中将该值从默认值“1”修改为“16”,但是 Poller 的运行时间反倒增加了,再修改为“8”,情况好一些,所以大家可以自己随意改写该数值,然后在 cacti.log 文件中查询 Poller 轮询运行时间的变化,然后确定最优的方案。
===================================================================================
    实际测试,21台机器,4个线程,4秒左右轮询一遍,而采用cmd.php的时候基本需要14.6~15.2秒。提升效果还是很明显的。


留言列表
发表评论
来宾的头像