美文网首页
用源码包安装Graphite

用源码包安装Graphite

作者: 刘小六2000 | 来源:发表于2018-11-07 10:31 被阅读0次

    1.新建虚拟环境dev.

    新建目录source, 用于存放源码包.

    新建目录graphite, 程序目录.

    2.创建虚拟环境

    virtualenv ~/dev --python=/usr/bin/python3

    第二项参数:虚拟环境的路径 第三项参数:python的路径,用python3.

    出现:Installing setuptools, pip,

    wheel...done.则虚拟环境创建成功.

    进入虚拟环境,生效

    source ~/dev/bin/ activate

    3.进入路径/home/xxxx/source,获取源码包

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

    git clonehttps://github.com/graphite-project/graphite-web.git

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

    git clonehttps://github.com/graphite-project/carbon.git

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

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

    4.依次进入source目录下的carbon graphite-web  whisper,分别

    # pip3 install -r requirements.txt

    每个python项目中都包含requirements.txt 文件,该文件用于记录所有依赖包及其精确的版本号,以便部署新环境。安装或升级包后,最好更新这个文件。

    5.安装Carbon

    进入Carbon源码包的所在目录,~/source/carbon

    python setup.py install--prefix=~/graphite

    --install-lib=~/dev/lib/python3.5/site-packages

    --prefix=  要写入carbon安装的位置。即~/graphite

    --install-lib=  安装Python modules的位置,放在虚拟环境中python所在lib下的site-packages。

    6.改Carbon的配置文件

    进入Carbon安装的目录,进入~/graphite/conf重命名该目录下的配置文件

    rename 's/.example//g'~/graphite/conf/*

    7.启动carbon

    ~/graphite/bin/carbon-cache.py start

    显示Starting carbon-cache (instance a)

    查看日志有无错误,在路径~/graphite/storage/log/carbon-cache/carbon-cache-a/*下,

    tail -f console.log

    不看tagdb.log日志错误.

    测试carbon:

    echo"foo.bar 1 `date +%s`" | nc localhost 2003

    查看验证

    ll ~/graphite/storage/whisper/foo

    是否会自动生产foo目录

    启动Carbon,报错:Import Error:No module named twisted.python.util

    ~/graphite/carbon/bin$~/graphite/carbon/bin/carbon-cache.py start

    Starting carbon-cache (instance a)

    An error has occurred:b"Cannot Listen Error: Couldn't listen on 0.0.0.0:7002: [Errno 98] Address already in use."

    Please look at log file for more information.

    原因:端口被占用

    # netstat -nlpt|grep 7002    CACHE_QUERY_PORT = 7002

    Kill掉占用该端口的进程,再启动Carbon。

    启动指令:#/~/graphite/carbon/bin/carbon-cache.py start

    启动成功:Starting carbon-cache (instance a)

    8. 进入~/dev/lib/python3.5/site-packages/graphite

    cp local_settings.py.example local_settings.py

    A.修改local_settings.py

    STORAGE_DIR = '~/graphite/storage/'

    STATIC_ROOT = '~/graphite/webapp/content'

    LOG_DIR = '~/graphite/webapp/'

    INDEX_FILE = '~/graphite/storage/index'

    DATABASES = {

        'default':{

           'NAME': '~/graphite2/storage/graphite.db',

           'ENGINE': 'django.db.backends.sqlite3',

            'USER': '',

           'PASSWORD': '',

           'HOST': '',

           'PORT': ''

        }

    }

    DEBUG= True     #不设置 页面不能正常显示

    TIME_ZONE = 'Asia/Shanghai'  #设置时区

    B.同步数据库

    在~/graphite目录下新建manage.py

    内容

    #!/usr/bin/env python

    import os

    import sys

    if __name__ == "__main__":

       os.environ.setdefault("DJANGO_SETTINGS_MODULE","graphite.settings")

       os.environ.setdefault('GRAPHITE_SETTINGS_MODULE','graphite.local_settings')

       from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

    在该目录下执行

    python manage.py migrate --run-syncdb

    问题:OSError: dlopen()failed to load a library: cairo / cairo-2 / cairo-gobject-2

    在该目录下安装依赖包:

    sudo apt-get install libpango1.0-0

    sudo apt-get install libcairo2

    sudo apt-get install libpq-dev

    再执行python manage.py

    migrate --run-syncdb

    9.安装Whisper

    python setup.py install--prefix=~/graphite --install-lib

    =~/dev/lib/python3.5/site-packages

    10.安装graphite-web

    python setup.py install --prefix=~/graphite --install-lib

    =~/dev/lib/python3.5/site-packages

    11.启动graphite-web服务

    进入目录~/graphite/bin

    ~/graphite/bin/run-graphite-devel-server.py --port=8085 ~/graphite/

    上述启动无误后后台运行

    ~/graphite/bin/run-graphite-devel-server.py  --port=8085 ~/graphite/ >/dev/null 2>&1 &

    初始化超级用户

    cd~/graphite

    执行

    python manage.py createsuperuser

    登陆界面http://ip:8085/

    12.安装Grafana

    在/etc/apt/sources.list中,最末端写入:

    debhttps://packagecloud.io/grafana/stable/debian/ stretch main

    替换源,如下所示:

    debhttp://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse

      deb http://mirrors.163.com/ubuntu/xenial-security main restricted universe multiverse

      deb http://mirrors.163.com/ubuntu/xenial-updates main restricted universe multiverse

      deb http://mirrors.163.com/ubuntu/xenial-proposed main restricted universe multiverse

      deb http://mirrors.163.com/ubuntu/xenial-backports main restricted universe multiverse

      deb-src http://mirrors.163.com/ubuntu/ xenialmain restricted universe multiverse

      deb-src http://mirrors.163.com/ubuntu/xenial-security main restricted universe multiverse

      deb-src http://mirrors.163.com/ubuntu/xenial-updates main restricted universe multiverse

      deb-src http://mirrors.163.com/ubuntu/xenial-proposed main restricted universe multiverse

      deb-src http://mirrors.163.com/ubuntu/xenial-backports main restricted universe multiverse

    debhttps://packagecloud.io/grafana/stable/debian/ stretch main

    添加Package Cloud密钥,这允许你安装签名包

    curlhttps://packagecloud.io/gpg.key | sudo apt-key add

    更新你的Apt存储库并安装Grafana:

    sudoapt-get update

    启动服务

    sudo/etc/init.d/grafana-server restart

    访问界面http://ip:3000

    相关文章

      网友评论

          本文标题:用源码包安装Graphite

          本文链接:https://www.haomeiwen.com/subject/uyumxqtx.html