歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 5.5 安裝Graphite

CentOS 5.5 安裝Graphite

日期:2017/2/28 14:46:27   编辑:Linux教程

CentOS 5.5 安裝Graphite


1.系統信息匯總

[root@cc-monitor conf]# uname -a

Linux cc-monitor 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:52:25 EST 2011 x86_64 x86_64 x86_64 GNU/Linux


[root@cc-monitor conf]# python -V

Python 2.4.3


[root@cc-monitor conf]# getenforce

Disabled


2.安裝Graphite依賴包


添加額外的源

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

# 安裝epel源

wget http://mirrors.sohu.com/Fedora-epel/5/i386/epel-release-5-4.noarch.rpm

yum install epel-release-5-4.noarch.rpm

# 安裝rpmforge源

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

yum install rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm


安裝依賴包

依賴包相當多,爭取一次搞定

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

下載地址:

https://github.com/graphite-project/graphite-web/downloads

https://github.com/graphite-project/whisper/downloads

https://github.com/graphite-project/carbon/downloads

# install graphite-web

tar zxvf graphite-web-0.9.10.tar.gz

cd graphite-web-0.9.10

python setup.py install

cd ..

# install whisper

tar zxvf whisper-0.9.10.tar.gz

cd whisper-0.9.10

python setup.py install

cd ..

# install carbon

tar zxvf carbon-0.9.10.tar.gz

cd carbon-0.9.10

python setup.py install


4.配置apache服務


創建 Graphite 的虛擬主機配置:/etc/httpd/conf.d/graphite.conf,創建方法如下:

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


5.配置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/



6.啟動服務和程序


service httpd start

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

安裝已經完成。在浏覽器中使用http://ip:8080,使用安裝graphite的主機的ip代替。可以訪問即可以肯定的告訴你CentOS 5安裝Graphite成功了


7.安裝node-js和statsd


#先安裝python2.6

yum install bzip2* glibc-devel

cd Python-2.6.8

make clean

./configure

make

make install

ln -s /usr/local/bin/python /usr/bin/python


#再安裝node-js

wet http://nodejs.org/dist/node-v0.4.8.tar.gz

cd node-v0.8.7

./configure

make

make install


#驗證安裝是否成功

[root@cc-monitor statsd-2.0.1]# node -v

v0.8.7


#安裝statsd

git clone http://github.com/etsy/statsd.git

cp -R statsd /opt/graphite/

#Create /opt/graphite/statsd/local.js

[root@cc-monitor statsd]# cat local.js

{

graphitePort: 2003

, graphiteHost: "localhost"

, port: 8124

}


#start nodejs/statsd

cd /opt/graphite/statsd

nohup /usr/local/bin/node stats.js local.js &

更多CentOS相關信息見CentOS 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=14

Copyright © Linux教程網 All Rights Reserved