1. 安装cairo和pycairo
yum -y install cairo pycairo
2. pip安装方式
pip是python的一个组件,安装pip的方法可以参考pip安装和使用教程。
pip install django django-tagging carbon whisper graphite-web
2. 安装文件布局
Graphite安装之后,在安装位置(默认为/opt/graphite)的文件布局如下:
- bin - 二进制文件目录,包括carbon-cache.py、carbon-relay.py、validate-storage-schemas.py、carbon-aggregator.py、carbon-client.py等程序
- build
- conf - 配置文件目录
- lib - 库目录
- storage - 数据存放目录,包括log,whisper数据库,索引,rrd数据等
- webapp – webapp文件存放目录
3. 设置Graphite配置文件
cp carbon.conf.example carbon.confcp whitelist.conf.example whitelist.conf
- /opt/graphite/conf是配置文件存放目录
- carbon.conf是carbon的配置文件,分三个片段cache、relay和aggregator。需要使用到的配置项后面在必要的时候会讲到
- storage-schemas.conf配置文件定义数据的存储。
- graphite.wsgi配置文件配置django。
4. uwsgi和nginx安装
wget http://projects.unbit.it/downloads/uwsgi-1.9.20.tar.gz; tar xzvf uwsgi-1.9.20.tar.gz; cd uwsgi-1.9.20; python setup.py install
yum -y install nginx
5. nginx配置和uwsgi配置
vim /etc/nginx/conf.d/graphite.conf
server {
listen 1988;
server_name graphite;
access_log /opt/graphite/storage/log/webapp/access.log ;
error_log /opt/graphite/storage/log/webapp/error.log ;
location / {
uwsgi_pass 0.0.0.0:1999;
include uwsgi_params;
listen 1988;
server_name graphite;
access_log /opt/graphite/storage/log/webapp/access.log ;
error_log /opt/graphite/storage/log/webapp/error.log ;
location / {
uwsgi_pass 0.0.0.0:1999;
include uwsgi_params;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
}
}
proxy_send_timeout 300;
proxy_read_timeout 300;
}
}
vim /opt/graphite/webapp/graphite/wsgi_graphite.xml
<uwsgi>
<socket>0.0.0.0:1999</socket>
<workers>1</workers>
<processes>1</processes>
<listen>100</listen>
<chdir>/opt/graphite/webapp/graphite</chdir>
<pythonpath>..</pythonpath>
<module>wsgi</module>
<pidfile>graphite.pid</pidfile>
<master>true</master>
<enable-threads>true</enable-threads>
<logdate>true</logdate>
<daemonize>/var/log/uwsgi_graphite.log</daemonize>
</uwsgi>
<socket>0.0.0.0:1999</socket>
<workers>1</workers>
<processes>1</processes>
<listen>100</listen>
<chdir>/opt/graphite/webapp/graphite</chdir>
<pythonpath>..</pythonpath>
<module>wsgi</module>
<pidfile>graphite.pid</pidfile>
<master>true</master>
<enable-threads>true</enable-threads>
<logdate>true</logdate>
<daemonize>/var/log/uwsgi_graphite.log</daemonize>
</uwsgi>
6. 启动nginx和应用程序
service nginx start; uwsgi -x /opt/graphite/webapp/graphite/wsgi_graphite.xml