##################################### 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####################################cdsudo apt-get updatesudo apt-get upgradewget https://launchpad.net/graphite/0.9/0.9.10/+download/graphite-web-0.9.10.tar.gzwget https://launchpad.net/graphite/0.9/0.9.10/+download/carbon-0.9.10.tar.gzwget https://launchpad.net/graphite/0.9/0.9.10/+download/whisper-0.9.10.tar.gztar -zxvf graphite-web-0.9.10.tar.gztar -zxvf carbon-0.9.10.tar.gztar -zxvf whisper-0.9.10.tar.gzmv graphite-web-0.9.10 graphitemv carbon-0.9.10 carbonmv whisper-0.9.10 whisperrm graphite-web-0.9.10.tar.gzrm carbon-0.9.10.tar.gzrm whisper-0.9.10.tar.gzsudo 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-setuptoolssudo easy_install django-taggingsudo easy_install zope.interfacesudo easy_install twistedsudo easy_install txamqp##################################### INSTALL WHISPER####################################cd ~/whispersudo python setup.py install##################################### INSTALL CARBON####################################cd ~/carbonsudo python setup.py installcd /opt/graphite/confsudo cp carbon.conf.example carbon.confsudo cp storage-schemas.conf.example storage-schemas.confsudo gedit storage-schemas.conf### Replace contents of storage-schemas.conf to be the following[stats ]priority = 110pattern = .*retentions = 10:2160,60:10080,600:262974######################################## CONFIGURE GRAPHITE (webapp)####################################cd ~/graphitesudo python check-dependencies.pysudo python setup.py install# CONFIGURE APACHE###################cd ~/graphite/examplessudo cp example-graphite-vhost.conf /etc/apache2/sites-available/defaultsudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgisudo mkdir /etc/httpdsudo mkdir /etc/httpd/wsgisudo 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 usersudo chown -R www-data:www-data /opt/graphite/storage/sudo /etc/init.d/apache2 restartcd /opt/graphite/webapp/graphitesudo cp local_settings.py.example local_settings.py##################################### START CARBON####################################cd /opt/graphite/sudo ./bin/carbon-cache.py startGentoo 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安装完毕。浏览器中的效果如图所示,可以对数据源、图表的风格等分别自定义,也可以实现自动刷新、对图表进行聚合等等,功能丰富完备。
三. 备注
python_graph-ite
最新推荐文章于 2024-06-17 23:02:01 发布