一、概述

Graphite 是一个基于Django的企业级监控工具,能实时可视化和按时间序列存储数据。严格的说,Graphite只是一个根据数据实时绘图的工具,数据收集通常通过第三方工具(如Ganglia,Collectd,StatsD,Diamond,Bucky等)或者插件完成,还可根据其他协议选用别的数据源供其绘图。我们这里只是用它做数据库存储。
Graphite包含如下三个组件:
1、Carbon:基于Twisted的进程,接受时间序列数据。Twisted框架让它能够以很低的开销处理大量的客户端和流量。主要用于监控数据,默认端口2003,外部程序StatsD通过这个端口,向Graphite输送采样的数据
2、Whisper:专门存储时间序列类型数据的小型数据库。
3、Graphite-web:一个基于Django的可以高度扩展的实时画图系统,还提供查询数据的api

二、安装环境

ubuntu 14.04 64位

三、安装步骤

1、安装方式

从源文件安装:
Graphite-Web,Carbon和Whisper的最新源代码包可以从Graphite项目下载页面获取,或者可以从Github项目页面克隆最新的.

- Graphite-web: git clone https://github.com/graphite-project/graphite-web.git
- Carbon: git clone https://github.com/graphite-project/carbon.git
- Whisper: git clone https://github.com/graphite-project/whisper.git
- wget https://launchpadlibrarian.net/104073214/check-dependencies.py #检查Graphite依赖是否缺少的程序。

在默认位置安装:
要将Graphite安装到默认位置/ opt / graphite /,只需
在每个项目目录中为Graphite-web,Carbon,Whisper和Ceres执行python setup.py install。

注意:Graphite的默认安装位置是/opt/graphite/。

1.1 安装 graphite

1.1.1 修改文件权限

    chown -R lijiajia:lijiajia /opt

1.1.2 执行 下边命令

  cd /opt/graphite-web python setup.py install cd carbonpython setup.py installcd whisperpython setup.py install

出现以下报错

error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/whisper.py'

whisper需要root权限安装

cd whisper
sudo python setup.py install

1.1.3检查依赖

cd graphite-web
python check-dependencies.py

出现以下错误:

[REQUIRED] Unable to import the 'cairocffi' module, attempting to fall back to pycairo
[REQUIRED] Unable to import the 'pyparsing' module, do you have pyparsing module installed for python 2?
[REQUIRED] Unable to import the 'tagging' module, do you have django-tagging installed for python 2?
[OPTIONAL] Unable to import the 'memcache' module, do you have python-memcached installed for python 2? This feature is not required but greatly improves performance.
[OPTIONAL] Unable to import the 'ldap' module, do you have python-ldap installed for python 2? Without python-ldap, you will not be able to use LDAP authentication in the graphite webapp.
[OPTIONAL] Unable to import the 'txamqp' module, this is required if you want to use AMQP as an input to Carbon. Note that txamqp requires python 2.5 or greater.
[OPTIONAL] Unable to import the 'python-rrdtool' module, this is required for reading RRD.
[OPTIONAL] Unable to import the 'whitenoise' module. This is useful for serving static files.
[OPTIONAL] Unable to import the 'pyhash' module. This is useful for fnv1_ch hashing support.
6 optional dependencies not met. Please consider the optional items before proceeding.
2 necessary dependencies not met. Graphite will not function until these dependencies are fulfilled.

说明依赖包缺少,需要安装 REQUIRED为必须的依赖包,OPTIONAL为可选的依赖包

1.1.4 安装依赖

执行以下命令安装依赖包

sudo pip install cairocffi
sudo pip install pyparsing
sudo pip install tagging
sudo pip intall python-memcached
sudo pip  install ldap
sudo pip install txamqp
sudo apt-get install librrd-dev #安装rrdttol的依赖
sudo pip install python-rrdtool
sudo pip install whitenoise
#pyhash需要c++依赖,暂不安装,不影响使用。

1.2 安装后graphite的目录

graphite
├── bin       #二进制文件目录,可执行文件目录
├── conf      #配置文件目录
├── examples  #获取数据的例子
├── lib       #库目录
├── storage   #数据存放目录,包括log,whisper数据库,索引,rrd数据等
└── webapp    #webapp文件存放目录

1.3 配置graphite

执行以下命令

cd /opt/graphite/conf
cp carbon.conf.example carbon.conf
cp storage-schemas.conf.example storage-schemas.conf
cp graphite.wsgi.example  ../webapp/graphite/graphite_wsgi.py
cd /opt/graphite/webapp/graphite
cp local_settings.py.example local_settings.py

修改local_settings.py

SECRET_KEY = 'Hard to guess ' #此密钥用于验证授权令牌,CRSF中间件,cookie存储等中使用的哈希。如果在负载平衡器后面使用,则应该在所有节点中对其进行相同设置。
ALLOWED_HOSTS = [ '*' ]
TIME_ZONE = 'Asia/Shanghai'
DATABASES = {'default': {'NAME': 'youdb','ENGINE': 'django.db.backends.mysql','USER': 'youuser','PASSWORD': 'youpasswd','HOST': 'youhost','PORT': 3306}
}

1.4 初始化数据库

PYTHONPATH=/opt/graphite/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb

出现报错

File "/opt/graphite/webapp/graphite/events/models.py", line 4, in <module>from tagging.models import TagFile "/usr/local/lib/python2.7/dist-packages/tagging/models.py", line 5, in <module>from django.contrib.contenttypes import generic
ImportError: cannot import name generic

原因是没有安装Tag模块

sudo pip install django-tagging

再次初始化数据库出现报错:

ImportError: No module named scandir

安装缺少模块:

sudo pip install scandir

再次初始化数据库,成功。

四 启动graphite

cd /opt/graphite/webapp/graphite
gunicorn graphite_wsgi:application -b 0.0.0.0:12546

注:正式环境需要Nginx+gunicorn配置

五 访问graphite-web

http://192.168.1.89:12546/

六 启动cabon

  cd /opt/graphite/bincarbon-cache.py start

七 向Graphite发送数据

graphite默认接收数据的端口是2003。
/opt/graphite/examples目录下有个测试用例。
执行:

   python example-client.py   

显示:

system.loadavg_1min 0.16 1516773121
system.loadavg_5min 0.09 1516773121
system.loadavg_15min 0.06 1516773121()
sending message

对应在浏览器窗口中的显示为在system目录下,loadavg_15min、loadavg_5min、loadavg_1min这三条线就是example-client.py的数据产生的图形。
效果如下:

注意事项:默认显示24小时,因此可能好像没有图形出现,可以点击上图所示红色框范围选择时间范围。

样例所产生的数据在下边目录下:

/opt/graphite/storage/whisper/system
loadavg_15min.wsp  loadavg_1min.wsp  loadavg_5min.wsp

可以使用以下命令查看whisper中的数据:

whisper-dump.py loadavg_1min.wsp

Graphite的安装与部署相关推荐

  1. Linux下Graphite的安装及部署

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

  2. Qt最新版5.14在Windows环境静态编译安装和部署的完整过程 VS 2019-Qt static link build Windows 32 bit/64 bit

    文章目录 为什么要静态编译(static link) 1.源码下载/source code download 2. 编译工具下载/compiler download 编译环境选择:MinGW/MSVC ...

  3. Qt最新版5.13在Windows环境静态编译安装和部署的完整过程(VS 2017/VS 2019)

    文章目录 为什么要静态编译 1.源码下载 2. 编译工具下载 ActivePerl Python Ruby 编译环境选择 3.编译 1.修改源码里的qtbase\mkspecs\common\msvc ...

  4. Qt最新版5.12在Windows环境静态编译安装和部署的完整过程(VS2017)

    文章目录 为什么要静态编译 1.源码下载 2. 编译工具下载 ActivePerl Python Ruby 编译环境选择 3.编译 1.修改源码里的qtbase\mkspecs\common\msvc ...

  5. Ansible的安装及部署

    Ansible的安装及部署 1 实验环境 2 Ansible的安装 3 Ansible的基本信息 4 构建Ansible清单 4.1 全局清单 4.2 设定受控主机的组 4.2.1 清单查看 4.2. ...

  6. idea上传项目到码云_mall前端项目的安装与部署

    本文主要讲解mall前端项目mall-admin-web的在Windows和Linux环境下的安装及部署. Windows下的安装及部署 下载nodejs并安装 下载地址:https://nodejs ...

  7. Linux下Redis3.2的安装和部署

    redis简介: redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(so ...

  8. vSphere虚拟化之ESXi安装及部署

    vSphere虚拟化之ESXi的安装及部署(上) 一.什么是vSphere? vSphere是VNware公司在2001年基于云计算推出的一套企业级虚拟化解决方案.核心组件为ESXi.如今,经历了5个 ...

  9. 探讨微软团队开发利器VSTS之安装及部署篇

    一.引言Visual Studio 2005 Team System是微软结合MSF成功开发经验的基础上,首次由软件开发领域延伸至整个软件开发生命周期管理的开发工具.Visual Studio 200 ...

最新文章

  1. ACM公布2017年图灵奖,大卫·帕特森和约翰·轩尼诗获奖
  2. Java HttpClient 4.3.1 访问ASP.NET WebService
  3. Python中的eval(),exec()以及其相关函数
  4. Acegi 安全框架
  5. 5.7 Components — Sending Actions From Components to Your Application
  6. 分布式一致性算法2PC和3PC
  7. 计算机系统中的总线,计算机系统中的总线控制器及其方法
  8. MSSQL - SQL Server2008附加数据库失败 错误号:5120
  9. 1.8 其他正则化方法
  10. CSRF跨站点伪造请求攻击——脱库及密码修改
  11. orcale自定义数组并向数组中查询插入数据
  12. 百度手机输入法 android ctrl,百度手机输入法旧版本
  13. 小白如何自学后端开发
  14. Leetcode 刷题 - 排序(day2)_桶排序_Top K Frequent Elements
  15. 计算机二级考试office
  16. HDU2188——悼念512汶川大地震遇难同胞——选拔志愿者(Bash Game巴士博弈)(我去,名字肿么这么长)
  17. C#画K线实现画K线和截图保存
  18. HTML5前期学习准备(一)
  19. 卷毛机器人符文_卷毛S5风女辅助天赋符文教学攻略
  20. 最新版Xyplayer X4.0.8

热门文章

  1. 网球目标检测——基于Python-OpenCV
  2. Metasploit 渗透测试之制作隐藏后门
  3. [PHP响应式营销型万能H5建站系统源码] 免费开源建站利器+可视化自由布局页面
  4. 【太虚AR_v0.1】使用教程 | AR录屏
  5. tomcat服务器连接数问题解决
  6. 内部类以及匿名内部类
  7. EditPlus 3.12 序列号/注册码
  8. 【数据库篇】MySQL InnoDB ibd 文件格式解析
  9. uniapp适配pc_uni-app支持PC版!
  10. ESP32设备驱动-ADXL345三轴加速计驱动