博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
graphite 安装使用
阅读量:7141 次
发布时间:2019-06-28

本文共 4159 字,大约阅读时间需要 13 分钟。

hot3.png

简介:

 是一款开源的监控绘图工具。

Graphite 可以实时收集、存储、显示时间序列类型的数据(time series data)。它主要有三个部分构成:

  1.  —— 基于  的进程,用来接收数据;

  2.  —— 专门存储时间序列类型数据的小型数据库;

  3.  —— 基于 Django 的网页应用程序。

下面主要说明一下graphite的安装:

一、使用pip 安装graphite:

1.安装Graphite所依赖的一些软件:

1)安装系统依赖

yum install cairo-devel.x86_64 fontconfig.x86_64 python-devel libffi-devel.x86_64 mysql-devel.x86_64

2)安装pip:

3)安装graphite依赖的一些python包:

      pip install -r requirements.txt

14

15

cairocffi==0.7.2

cffi==1.5.2

Django==1.6.8

django-tagging==0.3.6

MySQL-python==1.2.3

pycparser==2.14

pyparsing==1.5.6

python-memcached==1.57

pytz==2015.7

six==1.10.0

Twisted==16.0.0

txAMQP==0.6.2

uWSGI==2.0.12

whisper==0.9.15

zope.interface==4.1.3

 

2.利用源码安装graphite(源码安装是最新的版本):

graphite默认的安装路径是/opt/graphite:

1)Graphite-web: git clone https://github.com/graphite-project/graphite-web.git

2)Carbon: git clone https://github.com/graphite-project/carbon.git

3)Whisper: git clone https://github.com/graphite-project/whisper.git

4)Ceres: git clone https://github.com/graphite-project/ceres.git

 

3.安装graphite web:

1)安装配置 nginx

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

[root graphite]# cat /etc/nginx/conf.d/graphite.conf

server {

        listen        8000;

        server_name   10.13.40.216;

        charset       utf-8;

        access_log    /var/log/nginx/graphite.access.log;

        error_log     /var/log/nginx/graphite.error.log;

        location / {

            add_header Access-Control-Allow-Origin $http_origin;

            add_header 'Access-Control-Allow-Credentials' 'true';

            add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';

            add_header 'Access-Control-Allow-Headers' 'origin, authorization, accept';

            uwsgi_pass 127.0.0.1:3031;

            include uwsgi_params;

        }

        location /static {

            alias /opt/graphite/webapp/content;

        }

        location /content {

            alias /opt/graphite/webapp/content;

            gzip off;

            include uwsgi_params;

            uwsgi_pass      127.0.0.1:3031;

        }

}

2)配置uwsgi.

1

2

3

4

5

6

7

8

9

10

11

12

13

[root graphite]# cat /opt/graphite/webapp/graphite.ini

[uwsgi]

processes = 2

socket = 0.0.0.0:3031

gid = nginx

uid = nginx

chdir = /opt/graphite/webapp/graphite

module = wsgi

buffer-size = 65536

pidfile = /var/run/uwsgi.pid

chmod-socket = 666

pythonpath = /opt/graphite/webapp

daemonize = /var/log/uwsgi.log

4.初始化一些目录,数据目录放在/data1/graphite:

1

2

mkdir -p /data1/graphite/storage/log/webapp/

chown nginx.nginx /data1/graphite/storage/log/webapp/

 

5.配置文件配置见附件。

 

二、使用virtualenv安装graphite:

virtualenv是一个python工具. 它可以创建一个独立的python环境. 这样做的好处是你的python程序运行在这个环境里, 不受其它的 python library的版本问题影响. 比如说centos6默认的python版本是2.6,但是现在python2.6在python核心团队已经不再提供支持,想使用python2.7而不影响其他使用python2.6,就用到了virtualenv。对于后期环境的迁移也很方便。

 

1.首先在centos6.x系统上安装python2.7.x

1)源码安装Python 2.7.x

1

2

3

4

5

6

7

8

# wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz

# xz -d Python-2.7.8.tar.xz

# tar -xvf Python-2.7.8.tar

# cd Python-2.7.8

# 安装在/usr/local下

# ./configure --prefix=/usr/local && make && make altinstall

# /usr/local/bin/python -V

# Python 2.7.8

2.创建virtualenv python2.7环境

1)首先使用easy_install安装virtualenv:

1

# easy_install virtualenv

2)创建python2.7环境到/opt/graphite(由于graphite默认安装在/opt/graphite,方面后期迁移)

1

# virtualenv -p /usr/local/bin/python2.7 /opt/graphite

3.安装graphite:

1)进入到virtualenv环境中:

1

2

# cd /opt/graphite && source ./bin/activate

# (graphite) [root graphite]#     #这说明已经进入到虚拟环境中。

2)剩下的安装graphite可按照上述使用pip安装graphite进行操作。

 

4.启动graphite:

在virtualenv安装的graphite启动时不必每次都进入到虚拟环境中(cd /opt/graphite && source ./bin/activate)

只需要使用虚拟环境中的python即可,然后它会找到这个python的所有依赖。

1

2

3

# /opt/graphite/bin/python /opt/graphite/bin/carbon-relay.py start

# /opt/graphite/bin/python /opt/graphite/bin/carbon-aggregator.py start

# /opt/graphite/bin/python /opt/graphite/bin/carbon-cache.py --instance=a start

5.环境迁移

以后需要重新创建同样配置的graphite,只需要在新机器上安装上基础环境和virtualenv即可。

然后把原来的创建的虚拟环境/opt/graphite copy过来,修改配置文件即可上线使用。

 

三、使用monit进行监控:

monit是一个用于监视进程、文件、目录和设备等,可以修复停止运作或运作异常的程序,适合处理那些由于多种原因导致的软件错误,用于自动重新启动服务并发送报警。

例如:

1

2

3

4

check process carbon-cache-a whit pidfile /data1/graphite/storage/carbon-cache-a.pid

    start program = "/opt/graphite/bin/python /opt/graphite/bin/carbon-cache.py --instance=a start"

    stop program = "/opt/graphite/bin/python /opt/graphite/bin/carbon-cache.py --instance=a stop"

    if cpu is greater than 90% for 2 cycles then alert

转载于:https://my.oschina.net/mickelfeng/blog/93043

你可能感兴趣的文章
Node+express+mongoose 基础笔记
查看>>
利用angular4和nodejs-express构建一个简单的网站(十)—好友模块
查看>>
极光大数据告诉你,程序员们都在"愁"些啥?
查看>>
python写一个简单的图形化记事本
查看>>
从Hash到散列表到HashMap
查看>>
前端基础知识学习记录(三)
查看>>
原型链类原理
查看>>
YYWebImage,SDWebImage和PINRemoteImage比较
查看>>
Docker之旅——实例: 使用verdaccio搭建私服npm(二)
查看>>
Gin实践 连载五 使用JWT进行身份校验
查看>>
我的订单
查看>>
解决微信二次分享bug
查看>>
2017文章总结
查看>>
C3踩坑2--css选择器
查看>>
分类算法之决策树(理论篇)
查看>>
LeanCloud + Ionic3 迅速重构应用
查看>>
vue-cli解析
查看>>
python进行毫秒级计时时遇到的一个精度问题
查看>>
tweak
查看>>
Innodb索引以及查询优化的一些见解
查看>>