Graphite是一个Django的项目,所以必须有基础的Python环境,并推荐使用pip作为Python模块的管理工具,我这里安装的Python版本是Python2.7.6。

按照Graphite官网(http://graphite.wikidot.com/installation)安装graphite依赖,特别强调Django的安装版本是Django1.5.x(1.6以上版本会有一些模块变更,导致不兼容)

1.安装graphite依赖

yum install -y pycairo,mod_python,python-ldap,python-memcached,python-sqlite2,bitmap,bitmap-fonts,python-devel,mod_wsgi
pip install Django==1.5.1
pip install django-tagging
pip install twisted

还有一个需要注意的地方就是默认安装的Twisted在这里不兼容,会导致报出:ImportError: cannot import name daemonize 这样的错误,而要解决这个问题,需要做的就是修正一下版本:
pip uninstall Twisted  
pip install "Twisted<12.0"
可以使用pip freeze查看安装列表

2.安装Graphite的三个主要组件

2.1.安装whisper

tar -zxvf whisper-0.9.12.tar.gz
cd whisper-0.9.12
python setup.py install

Whisper 脚本现在应该在应有的位置上:

[root@VMS04798 graphite]# ls -l /usr/bin/whisper*
-rwxr-xr-x 1 root root 1658 Apr 13 14:48 /usr/bin/whisper-create.py
-rwxr-xr-x 1 root root 2902 Apr 13 14:48 /usr/bin/whisper-dump.py
-rwxr-xr-x 1 root root 1780 Apr 13 14:48 /usr/bin/whisper-fetch.py
-rwxr-xr-x 1 root root 1071 Apr 13 14:48 /usr/bin/whisper-info.py
-rwxr-xr-x 1 root root  675 Apr 13 14:48 /usr/bin/whisper-merge.py
-rwxr-xr-x 1 root root 5984 Apr 13 14:48 /usr/bin/whisper-resize.py
-rwxr-xr-x 1 root root  919 Apr 13 14:48 /usr/bin/whisper-set-aggregation-method.py
-rwxr-xr-x 1 root root  970 Apr 13 14:48 /usr/bin/whisper-update.py

2.2.安装carbon

tar -zxvf carbon-0.9.12.tar.gz
cd carbon-0.9.12
python setup.py install

/opt/graphite 现在应该有carbon的lib 包和配置文件:

[root@VMS04798 graphite]# ls -l /opt/graphite
total 48
drwxr-xr-x 2 apache apache    4096 Apr 13 14:48 bin
drwxrwxrwx 2 apache apache    4096 Apr 15 18:34 conf
drwxr-xr-x 2 apache apache    4096 Apr 13 15:40 examples
drwxr-xr-x 4 apache apache    4096 Apr 13 14:47 lib
drwxr-xr-x 6 apache apache    4096 Apr 15 16:19 storage

2.3.安装graphite-web

tar -zxvf graphite-web-0.9.12.tar.gz
cd graphite-web-0.9.12
python check-dependencies.py
python setup.py install

修改配置:

cp graphite.wsgi.example graphite.wsgi
cd /opt/graphite/webapp/graphite
cp local_settings.py.example local_settings.py

编辑local_settings.py,务必重新设置SECRET_KEY,根据需要调整TIME_ZONE(TIME_ZONE='Asia/Shanghai')和其它参数。

3.启动一个Carbon进程

Carbon安装自带了默认的端口和很多其他的配置文件,拷贝已经存在的示例文件。

cd /opt/graphite/conf
cp carbon.conf.example carbon.conf
cp storage-schemas.conf.example storage-schemas.conf
cp storage-aggregation.conf.example storage-aggregation.conf

编辑carbon.conf,并添加以下内容:

$ vim /opt/graphite/conf/carbon.conf
[cache]
LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_PORT = 2003PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_PORT = 2004CACHE_QUERY_INTERFACE = 0.0.0.0
CACHE_QUERY_PORT = 7002

编辑storage-schemas,并添加以下内容:

vim storage-schemas.conf
[system_1min]
pattern = ^system\..*
priority = 100
retentions = 60s:31d,5m:90d

编辑storage-aggregation.conf,并添加以下内容:

vim storage-aggregation.conf
[system_1min]
pattern = ^system\..*
xFilesFactor = 0.5
aggregationMethod = sum

如果我们的Whisper文件xFilesFactor值是0.5,这意味着仅仅只有至少50%数据点被呈现的时候,它才将聚集数据点。如果超过50%数据点是null,Whisper将创建一个null聚合。在我们的示例中(60s=1m)5m/1m=5也即至少有3个点才开始聚合,因为3/5=0.6才满足xFilesFactor=0.5的聚合条件。你可以给xFilesFactor设置0-1之间的任何值。0表明了即使只有一个数据点非空,聚合就应该被完成。1 表明了只有所有的数据非空,集合才能完成。

4.制造一些测试数据

cd /opt/graphite/bin
./carbon-cache.py start
cd /opt/graphite/examples
python example-client.py

最后,你可以检索关于 Whisper 文件的元数据信息,使用 whisper-info 脚本:

[root@VMS04798 examples]# whisper-info.py /opt/graphite/storage/whisper/system/loadavg_1min.wsp
maxRetention: 604800
xFilesFactor: 0.5
aggregationMethod: sum
fileSize: 120988Archive 0
retention: 604800
secondsPerPoint: 60
points: 10080
size: 120960
offset: 28

whisper-dump脚本是一个更完整的脚本,其可以输出所有存储保留时期的原始数据以及关于 Whisper 文件的元数据信息:

[root@VMS04798 examples]#whisper-dump.py /opt/graphite/storage/whisper/system/loadavg_1min.wsp
Meta data:aggregation method: summax retention: 86400xFilesFactor: 0.5Archive 0 info:offset: 28seconds per point: 60points: 1440retention: 86400size: 17280Archive 0 data:
0: 1400609220, 1
1: 0,          0
2: 0,          0
3: 0,          0
4: 0,          0
5: 0,          0
...
1437: 0,          0
1438: 0,          0
1439: 0,          0

如果Metrics与storage-aggregation.conf中的pattern没有匹配上,默认的aggregation方法是average,xFilesFactor=0.5

5.安装nginx与uwsgi

graphite-web是基于django开发的

5.1 nginx安装

tar -zxvf nginx-1.2.8.tar.gz
cd nginx-1.2.8
./configure --prefix=/usr/local/nginx
make
make install

5.2 uwsgi安装

pip install uwsgi

配置uwsgi:

/opt/graphite/webapp
vim graphite.ini 

uWSGI的配置如下:

[uwsgi]
post-buffering = 32768
buffer-size = 32768
chdir=/opt/graphite/conf/
module=graphite.wsgi
master=true
pidfile=/tmp/graphite.pid
vacuum=true
max-requests=10000
daemonize=/var/log/graphite/access_graphite.log
processes=15
socket=127.0.0.1:49156
stats=127.0.0.1:1716
listen=1024

配置Nginx:

cd /usr/local/nginx/conf/sites-enabled
vim graphite.conf

以下是Nginx虚拟主机的配置

server {listen 8080;server_name 127.0.0.1charset utf-8;access_log /var/log/nginx/graphite.access.log;error_log  /var/log/nginx/graphite.error.log;location / {include uwsgi_params;uwsgi_pass 127.0.0.1:49156;}
}

7.启动graphite

至此所有全部搞定,先开carbon,再开uwsgi,最后nginx。

/opt/graphite/bin/carbon-cache.py start
/opt/graphite/webapp
uwsgi graphite.ini
/usr/local/nginx/sbin/nginx

打开浏览器,输入http://ip:8080就能看到效果了。

参考文档:
http://segmentfault.com/a/1190000002533877
http://segmentfault.com/a/1190000002573509

Linux下Graphite的安装及部署相关推荐

  1. Linux下redis的安装及部署

    Linux下redis的安装及部署 一.安装 1. 下载redis安装包 可去官网http://redis.io ,也可通过wget命令, wget http://download.redis.io/ ...

  2. Linux下nginx的安装及部署

    Linux下nginx的安装及部署 一. nginx的安装 1. nginx安装需要很多依赖包(并不知道是干神马的,连接好网络,敲命令直接安便是了) 安装GCC 和GCC-C++(若没有安装gcc) ...

  3. redis linux 文件位置,Linux下Redis的安装和部署

    一.Redis介绍 Redis是当前比较热门的NOSQL系统之一 它是一个key-value存储系统.和Memcache类似,但很大程度补偿了Memcache的不足,它支持存储的value类型相对更多 ...

  4. Linux下Redis的安装和部署

    一.Redis介绍 Redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcache类似,但很大程度补偿了Memcache的不足,它支持存储的value类型相对更多 ...

  5. php redius,Linux下Redius的安装与部署详解

    1.下载源代码 下载redis-1.2.6.tar.gz 将下载包拷贝到/usr/local/webserver/redis-1.2.6/下 2.安装 tar -zxvf redis-1.2.6.ta ...

  6. Linux下Tomcat的安装部署

    Linux下Tomcat的安装部署 一. linux下安装JDK1.6 JDK(Java Development Kit)是Sun Microsystems针对Java开发员的产品.自从Java推出以 ...

  7. Linux下使用docker安装部署Sonar Qube

    文章目录 Linux下使用docker安装部署Sonar Qube 一.环境准备 二.部署步骤 三.使用 四.结束 Linux下使用docker安装部署Sonar Qube 一.环境准备 本文默认会使 ...

  8. Linux下MongoDB的安装,通过配置文件启动Mongodb的方式研究,mongodb自启动脚本(Linux),Windows下安装MongoDB服务,集群部署,数据导出和恢复

    关于MongoDB的windows的 安装,可以参考: http://www.runoob.com/mongodb/mongodb-window-install.html 关于Linux的安装可以参考 ...

  9. Linux下Tomcat的安装配置

    Linux下Tomcat的安装配置 一.下载安装对应的jdk,并配置Java环境. 官网下载地址: http://www.oracle.com/technetwork/java/javase/down ...

最新文章

  1. 又有两所一流高校加入“不返校”阵营,非毕业年级学生,开学时间待定!
  2. 中国桑叶市发展态势分析与前景动态预测报告场2022-2028年版
  3. Resin 优化配置
  4. python 获取当前是星期几_基金定投选星期几更划算?[python统计分析]
  5. 求助pycharm里import pandas遇到No module named pandas怎么办
  6. 抖音电商发布创作者管理总则 近八万名带货达人因违规被罚
  7. C语言线性表之顺序表
  8. 变步长的梯形求积法matlab,基于MATLAB的变步长梯形数值积分法的研究与实验
  9. latex怎么打区间_涨出天际的安阳房价,这个月怎么样了?
  10. erdas几何校正_erdas图像几何校正操作步骤指南.doc
  11. 多进程爬取Unsplash网站图片
  12. 不必学会写代码 轻松建立个人博客网站
  13. 攻破Administrator权限--破解SAM文件法
  14. 新时代动画电影的互联网宣传
  15. zcmu Problem C: kirito's 星爆气流斩(背包+二进制优化)
  16. C语言 输入一个整数n,求出其阶乘
  17. 在 EXCEL 中,“插入已剪切单元格”的快捷键
  18. the king of fighter
  19. 计算机网络知识梳理总结(For 考研复试面试)
  20. SAS初学者笔记---001

热门文章

  1. 业务中台、技术中台、数据中台、AI中台
  2. 区块链+大数据:万物互联时代的“CP组合”
  3. 给LINUX安装JDK
  4. 主动降噪耳机那些事儿(一)
  5. SaaS、PaaS、DaaS、IaaS四种云系统说明
  6. 南宁市计算机技术专业学校,南宁电脑技术学校有哪些
  7. 【educoder】头歌 数据结构与算法 答案
  8. vtkOBBTree——包围盒
  9. fgets()函数的使用分析
  10. nRF24L01+不能接收或接收偶尔异常等问题实战分享