####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
cd
sudo apt-get update
sudo apt-get upgrade
wget https://launchpad.net/graphite/0.9/0.9.10/+download/graphite-web-0.9.10.tar.gz
wget https://launchpad.net/graphite/0.9/0.9.10/+download/carbon-0.9.10.tar.gz
wget https://launchpad.net/graphite/0.9/0.9.10/+download/whisper-0.9.10.tar.gz
tar -zxvf graphite-web-0.9.10.tar.gz
tar -zxvf carbon-0.9.10.tar.gz
tar -zxvf whisper-0.9.10.tar.gz
mv graphite-web-0.9.10 graphite
mv carbon-0.9.10 carbon
mv whisper-0.9.10 whisper
rm graphite-web-0.9.10.tar.gz
rm carbon-0.9.10.tar.gz
rm whisper-0.9.10.tar.gz
sudo apt-get install --assume-yes apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 build-essential python3.2 python-dev libpython3.2 python3-minimal libapache2-mod-wsgi libaprutil1-ldap memcached python-cairo-dev python-django python-ldap python-memcache python-pysqlite2 sqlite3 erlang-os-mon erlang-snmp rabbitmq-server bzr expect ssh libapache2-mod-python python-setuptools
sudo easy_install django-tagging
sudo easy_install zope.interface
sudo easy_install twisted
sudo easy_install txamqp
####################################
# INSTALL WHISPER
####################################
cd ~/whisper
sudo python setup.py install
####################################
# INSTALL CARBON
####################################
cd ~/carbon
sudo python setup.py install
cd /opt/graphite/conf
sudo cp carbon.conf.example carbon.conf
sudo cp storage-schemas.conf.example storage-schemas.conf
sudo gedit storage-schemas.conf
### Replace contents of storage-schemas.conf to be the following
[stats
]
priority
= 110
pattern
= .*
retentions
= 10:2160,60:10080,600:262974
###
####################################
# CONFIGURE GRAPHITE (webapp)
####################################
cd ~/graphite
sudo python check-dependencies.py
sudo python setup.py install
# CONFIGURE APACHE
###################
cd ~/graphite/examples
sudo cp example-graphite-vhost.conf /etc/apache2/sites-available/default
sudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
sudo mkdir /etc/httpd
sudo mkdir /etc/httpd/wsgi
sudo gedit /etc/apache2/sites-available/default
#####
# Change the line: WSGISocketPrefix run/wsgi
# To: WSGISocketPrefix /etc/httpd/wsgi
#####
sudo /etc/init.d/apache2 reload
####################################
# INITIAL DATABASE CREATION
####################################
cd /opt/graphite/webapp/graphite/
sudo python manage.py syncdb
# follow prompts to setup django admin user
sudo chown -R www-data:www-data /opt/graphite/storage/
sudo /etc/init.d/apache2 restart
cd /opt/graphite/webapp/graphite
sudo cp local_settings.py.example local_settings.py
####################################
# START CARBON
####################################
cd /opt/graphite/
sudo ./bin/carbon-cache.py start
Gentoo x86
Graphite 0.9.9
Python 2.7.2
Apache 2.2.22
一. 關于Graphite
1. Graphite,相當年輕的企業級開源監控工具,可以用于采集、統計多個伺服器的實時狀态,包括使用者請求、memcached緩存命中、rabbitMQ消息伺服器狀态,以及基本的系統負載等。
2. 采用Python編寫,Django架構,sqlite資料庫存儲,自有簡單文本協定通訊,繪圖功能強大。
3. 事實上,嚴格地說,Graphite隻是一個根據資料繪圖的工具,資料收集通常由第三方工具或插件完成,自帶的是carbon,可根據其協定選用别的資料源供其繪圖。
二. 安裝流程
1. 更改Gentoo的python版本到2.7
# eselect python list
Available Python interpreters:
[1] python2.7
[2] python3.2 *
# eselect python set 1
2. 安裝軟體包,包括依賴包和graphite本身
# emerge apache apache-wsgi pip pysqlite
# pip install django django-tagging twisted cairo whisper carbon graphite-web
3. 初始化配置檔案
# cd /opt/graphite/conf
# cp carbon.conf.example carbon.conf
# cp storage-schemas.conf.example storage-schemas.conf
# cp graphite.wsgi.example graphite.wsgi
# cd /opt/graphite/webapp/graphite
# cp local_settings.py.example local_settings.py
4. 修改httpd.config添加wsgi子產品
在LoadModule的部分添加一行:
LoadModule wsgi_module modules/mod_wsgi.so
5. 修改預設的虛拟主機配置檔案
# cd /etc/apache2/vhosts.d
# mv 00_default_vhost.conf 00_default_vhost.conf.bak
# mkdir -p /etc/apache2/wsgi
# vim 00_default_vhost.conf
Listen 80
WSGISocketPrefix /etc/apache2/wsgi/
<VirtualHost *:80>
ServerName graphite
DocumentRoot “/opt/graphite/webapp”
ErrorLog /opt/graphite/storage/log/webapp/error.log
CustomLog /opt/graphite/storage/log/webapp/access.log common
WSGIDaemonProcess graphite processes=5 threads=5 display-name=’%{GROUP}’ inactivity-timeout=120
WSGIProcessGroup graphite
WSGIApplicationGroup %{GLOBAL}
WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi
Alias /content/ /opt/graphite/webapp/content/
<Location “/content/”>
SetHandler None
Order Deny,Allow
</Location>
Alias /media/ “/usr/lib/python2.7/site-packages/django/contrib/admin/media/”
<Location “/media/”>
SetHandler None
Order Deny,allow
</Location>
<Directory /opt/graphite/conf/>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
上面的配置檔案内容修改自graphite源碼包内的預設配置檔案,修改部分已經标出。
6. 生成資料庫并更改資料庫目錄權限
# cd /opt/graphite/webapp/graphite
# python manage.py syncdb
# chown -R apache:apache /opt/graphite/storage
7. 啟動相關程式
carbon:
/opt/graphite/bin/carbon-cache.py start
apache2:
/etc/init.d/apache2 start
至此Graphite安裝完畢。浏覽器中的效果如圖所示,可以對資料源、圖表的風格等分别自定義,也可以實作自動重新整理、對圖表進行聚合等等,功能豐富完備。
三. 備注