Chinaunix首页 | 论坛 | 博客
  • 博客访问: 538918
  • 博文数量: 102
  • 博客积分: 950
  • 博客等级: 准尉
  • 技术积分: 1094
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-28 16:07
文章分类

全部博文(102)

文章存档

2020年(2)

2016年(5)

2015年(15)

2014年(25)

2013年(18)

2012年(19)

2011年(18)

我的朋友

分类: LINUX

2014-04-20 17:50:48

:# cat /etc/redhat-release
CentOS release 6.4 (Final)

1. 添加额外源

除了CentOS源base、updates、extra之外,再添加两个源:epel和rpmforge。

wget

wget

2. 安装依赖包

依赖包相当多,争取一次搞定。


点击(此处)折叠或打开

  1. yum -y install bitmap bitmap-fonts Django pycairo python-devel python-ldap python-memcached mod_wsgi python-sqlite2 glibc-devel gcc gcc-c++ git openssl-devel python-zope-interface httpd memcached python-hashlib django-tagging python-twisted python-simplejson


这里还是做一下简单说明:cairo是graphite的绘图库,是必须的软件。

  • bitmap-fonts字体也是需要的,否则可能图形显示不正常。
  •  python-twisted必须安装rpmforge源的python-twisted-core-8.2.0-1.el5.rf,这也是为什么添加rpmforge源的原因。
  • mod_wsgi是apache的模块

3. 安装Graphite组件

Graphite组件包括三个部分:carbon、whisper和graphite-web。

安装

pip install carbon
pip install whisper
pip install graphite-web

pip install daemonize


4. 配置 Apache 服务

  • 配置 graphite 虚拟主机

创建 Graphite 的虚拟主机配置:/etc/httpd/conf.d/graphite.conf,创建方法如下:

vi /etc/httpd/conf.d/graphite.conf


点击(此处)折叠或打开

  1. Listen 8080

  2. # You may need to manually edit this file to fit your needs.
  3. # This configuration assumes the default installation prefix
  4. # of /opt/graphite/, if you installed graphite somewhere else
  5. # you will need to change all the occurances of /opt/graphite/
  6. # in this file to your chosen install location.
  7. <VirtualHost *:8080>
  8.  ServerName graphite
  9.  DocumentRoot "/opt/graphite/webapp"

  10.  # I've found that an equal number of processes & threads tends
  11.  # to show the best performance for Graphite (ymmv).
  12.  WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
  13.  WSGIProcessGroup graphite

  14.  # You will need to create this file! There is a graphite.wsgi.example
  15.  # file in this directory that you can safely use, just copy it to graphite.wgsi
  16.  WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi

  17.  Alias /content/ /opt/graphite/webapp/content/
  18.  
  19.  SetHandler None
  20.  

  21.  # NOTE: In order for the django admin site media to work you
  22.  # must change @DJANGO_ROOT@ to be the path to your django
  23.  # installation, which is probably something like:
  24.  # /usr/lib/python2.6/site-packages/django
  25.  Alias /media/ "/usr/lib/python2.4/site-packages/django/contrib/admin/media/"
  26.  
  27.  SetHandler None
  28.  

  29.  # The graphite.wsgi file has to be accessible by apache. It won't
  30.  # be visible to clients because of the DocumentRoot though.
  31.  <Directory /opt/graphite/conf/>
  32.  Order deny,allow
  33.  Allow from all
  34.  </Directory>

  35. </VirtualHost>


2. 初始化数据库

运行以下命令创建数据库:

1
2
python /opt/graphite/webapp/graphite/manage.py syncdb
chown -R hd:hd /opt/graphite/storage/

hd是我自己定义的httpd服务运行的用户和组。

四、 启动服务和程序

启动httpd服务:

1
service httpd start

启动carbon-cache程序:

1
/opt/graphite/bin/carbon-cache.py start

启动会报错,解决方案如下:

[root@d1 conf]# /opt/graphite/bin/carbon-cache.py start
/usr/lib64/python2.6/site-packages/zope/__init__.py:3: UserWarning: Module twisted was already imported from /usr/lib64/python2.6/site-packages/twisted/__init__.pyc, but /opt/graphite/lib is being added to sys.path
  import pkg_resources
Traceback (most recent call last):
  File "/opt/graphite/bin/carbon-cache.py", line 29, in
    from carbon.util import run_twistd_plugin
  File "/opt/graphite/lib/carbon/util.py", line 21, in
    from twisted.scripts._twistd_unix import daemonize
ImportError: cannot import name daemonize
[root@d1 conf]# pip install daemonize
Downloading/unpacking daemonize
  Downloading daemonize-2.2.3.tar.gz
  Running setup.py egg_info for package daemonize
Installing collected packages: daemonize
  Running setup.py install for daemonize
Successfully installed daemonize
Cleaning up...
[root@d1 conf]# vi /opt/graphite/lib/carbon/util.py

改from twisted.scripts._twistd_unix import daemonize

变成
import daemonize
[root@d1 conf]# /opt/graphite/bin/carbon-cache.py start
/usr/lib64/python2.6/site-packages/zope/__init__.py:3: UserWarning: Module twisted was already imported from /usr/lib64/python2.6/site-packages/twisted/__init__.pyc, but /opt/graphite/lib is being added to sys.path
  import pkg_resources
Starting carbon-cache (instance a)


至此ok,# ps -ef |grep car
root     31273     1  0 17:41 ?        00:00:00 /usr/bin/python /opt/graphite/bin/carbon-cache.py start
root     31327 19915  0 17:49 pts/0    00:00:00 grep car



五、 测试

安装已经完成。在浏览器中使用,使用安装graphite的主机的ip代替。可以访问即可以肯定的告诉你CentOS 6.4安装Graphite成功了。


运行graphite-web安装包内的examples/example-client.py可以喂数据给graphite:

1
python example-client.py


阅读(5521) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~