Graphite在centeros 6下安装
这段时间,一直在学习Graphite,做一个阶段性总结。
在centos 6.4系统下安装Graphite。
1.在官网中下载安装文件:
链接:https://launchpad.net/graphite/+download/
下载文件:carbon-0.9.10-pre3.tar.gz
graphite-web-0.9.10-pre4.tar.gz
whisper-0.9.10-pre3.tar.gz
check-dependencies.py
2.安装依赖包
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:
yum install -y git
3.安装Graphite
首先解压安装包: tar xf carbon-0.9.10-pre3.tar.gz
tar xf graphite-web-0.9.10-pre4.tar.gz
tar xf whisper-0.9.10-pre3.tar.gz
然后进入相应目录,执行setup.py:
cd carbon-0.9.10-pre3
python setup.py install
cd ..
cd graphite-web-0.9.10-pre4
python setup.py install
cd ..
cd whisper-0.9.10-pre3
python setup.py install
graphite默认安装在opt/graphite文件夹下。
4.配置Graphite
首先,确认本机上安装apache。
若未安装,执行 yum install httpd
创建graphite虚拟主机配置:
cat > /etc/httpd/conf.d/graphite.conf
Listen 8080
# You may need to manually edit this file to fit your needs.
# This configuration assumes the default installation prefix
# of /opt/graphite/, if you installed graphite somewhere else
# you will need to change all the occurances of /opt/graphite/
# in this file to your chosen install location.
<VirtualHost *:8080>
ServerName graphite
DocumentRoot “/opt/graphite/webapp”
# I\’ve found that an equal number of processes & threads tends
# to show the best performance for Graphite (ymmv).
WSGIDaemonProcess graphite processes=5 threads=5 display-name=\’%{GROUP}\’ inactivity-timeout=120
WSGIProcessGroup graphite
# You will need to create this file! There is a graphite.wsgi.example
# file in this directory that you can safely use, just copy it to graphite.wgsi
WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi
Alias /content/ /opt/graphite/webapp/content/
<Location “/content/”>
SetHandler None
</Location>
# NOTE: In order for the django admin site media to work you
# must change @DJANGO_ROOT@ to be the path to your django
# installation, which is probably something like:
# /usr/lib/python2.6/site-packages/django
Alias /media/ “/usr/lib/python2.4/site-packages/django/contrib/admin/media/”
<Location “/media/”>
SetHandler None
</Location>
# The graphite.wsgi file has to be accessible by apache. It won\’t
# be visible to clients because of the DocumentRoot though.
<Directory /opt/graphite/conf/>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
配置mod_wsgi模块
在 /etc/httpd/conf.d/wsgi.conf文件中添加以下两行:
LoadModule wsgi_module modules/mod_wsgi.so
WSGISocketPrefix /var/run/wsgi
配置Graphite:
cd /opt/graphite/conf/
for i in graphite.wsgi carbon.conf storage-schemas.conf storage-aggregation.conf; do cp $i.example $i; done
cd /opt/graphite/webapp/graphite/
cp local_settings.py.example local_settings.py
运行以下命令创建数据库:
cd /opt/graphite/webapp/graphite/
python manage.py syncdb
chown -R apache:apache /opt/graphite/
5.启动
service httpd start
/opt/graphite/bin/carbon-cache.py start
在浏览器中使用http://ip:8080
6.实验
运行graphite-web安装包内的examples/example-client.py可以喂数据给graphite:
python example-client.py
对应在浏览器窗口中的显示为在system目录下,loadavg_15min、loadavg_5min、loadavg_1min这三条线就是example-client.py的数据产生的图形。
7.FAQ
我在安装过程中,出现了未安装django的问题:
Traceback (most recent call last): File “manage.py”, line 2, in <module> from django.core.management import execute_manager ImportError: No module named django.core.management
提示没有django,手动yum install Django后提示
No package Django available.
遇到这种情况,请手动下载django安装包。
django-tagging可能也会遇到这样的问题,也用这种方法。
在这里分享一个链接,里面是常用的包:http://pan.baidu.com/s/1pJHlzBl