Graphite 只是一个数据绘图工具,安装完成之后还需要喂数据给它,具体的数据采集工作是由第三方工具完成,具体的工具可以参考 Graphite协作工具 。本文使用 collectd 来收集服务器的性能指标,然后发送这些数据到 Graphite,再将图形绘制出来。
一、Graphite准备
1、安装依赖包
[root@~]#rpm -Uvh http://dl.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
[root@collectd ~]# yum install -y bitmap bitmap-fonts-compat Django django-tagging fontconfig cairo python-devel python-memcached python-twisted pycairo mod_python python-ldap python-simplejson memcached python-zope-interface mod_wsgi python-sqlite2 git gcc gcc-c++ make
2、安装Graphite组件
Graphite组件:whisper、carbon、graphite-web
安装方式:源代码、pip、virtualenv(本例使用源码安装)
下载文件
[root@]# wget https://launchpad.net/graphite/0.9/0.9.10/+download/graphite-web-0.9.10.tar.gz
[root@]# wget https://launchpad.net/graphite/0.9/0.9.10/+download/carbon-0.9.10.tar.gz
[root@]# wget https://launchpad.net/graphite/0.9/0.9.10/+download/whisper-0.9.10.tar.gz
安装方法(默认安装位置/opt/graphite目录)
whisper、carbon、graphite-web安装方法相同,解压软件,进入软件目录,执行以下命令
[root@collectd soft]# tar zxvf carbon-0.9.10.tar.gz
[root@collectd soft]# cd carbon-0.9.10
[root@collectd carbon-0.9.10]# python setup.py install
[root@collectd soft]# tar zxvf graphite-web-0.9.10.tar.gz
[root@collectd soft]# cd graphite-web-0.9.10
[root@collectd graphite-web-0.9.10]# python setup.py install
[root@collectd soft]# tar zxvf whisper-0.9.10.tar.gz
[root@collectd soft]# cd whisper-0.9.10
[root@collectd whisper-0.9.10]# python setup.py install
3、配置graphite
1)设置graphite配置文件
[root@collectd ~]# cd /opt/graphite/conf/
[root@collectd conf]# cp carbon.conf.example carbon.conf
[root@collectd conf]# cp storage-schemas.conf.example storage-schemas.conf
[root@collectd conf]# cp graphite.wsgi.example graphite.wsgi
其中:
/opt/graphite/conf是配置文件存放目录
carbon.conf是carbon的配置文件,分三个片段cache、relay和aggregator
storage-schemas.conf配置文件定义数据的存储
graphite.wsgi配置文件配置django
2)设置apache虚拟主机
apache虚拟主机配置有一个样例在graphite-web安装包内的examples/example-graphite-vhost.conf,复制这个文件到apache配置文件
Graphite和collectd 建立监控服务器 PDF 下载:
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是www.linuxidc.com
具体下载目录在 /2013年资料/4月/17日/Graphite和collectd 建立监控服务器 PDF
