devops Graphite 完整安装流程

pablo · 2021年05月12日 · 1938 次阅读

安装笔记

最近在安装 Graphite 遇到了挺多坑的,市面上的文章,对于初次安装的用户不事特别优化,所以记录下安装全过程,方便后来人能比较舒心的安装

python 环境准备

#查看python版本-2.7为佳
python --version
#准备python虚拟环境
#安装必要的包
yum install cairo
yum install python-pip
pip install virtualenv
#激活虚拟环境
virtualenv /opt/graphite
source /opt/graphite/bin/activate
#安装包
pip install carbon 
pip install whisper
pip install cffi
pip install graphite-web
pip install https://github.com/graphite-project/ceres/tarball/master

文件移动和修改

使用上述方式安装会导致一个问题,一些包安装位置不对,导致,有些文件在执行过程中,找不到包

cp -r /opt/graphite/lib/python2.7/site-packages/opt/graphite/webapp/graphite  /opt/graphite/webapp/
cp -r /opt/graphite/lib/python2.7/site-packages/opt/graphite/lib/carbon /opt/graphite/lib/python2.7/site-packages/
cp -r /opt/graphite/lib/python2.7/site-packages/opt/graphite/lib/twisted /opt/graphite/lib/python2.7/site-packages/

#修改
cd /opt/graphite/webapp/graphite
cp local_settings.py.example local_settings.py
#vim local_settings.py 修改如下代码,文件夹不存在的新建即可:
#DEBUG= True
#CONF_DIR = '/opt/graphite/conf'
#STORAGE_DIR = '/opt/graphite/storage'
#STATIC_ROOT = '/opt/graphite/webapp/static'
#LOG_DIR = '/opt/graphite/storage/log/webapp'

STATIC_ROOT 需要注意将/opt/graphite/webapp/content 文件夹里的内容复制到 static

拷贝 graphite 的配置文件

cd /opt/graphite/conf/
cp carbon.conf.example carbon.conf
 #一般会改动这个文件里面的配置,达到自定义key存储周期
cp storage-schemas.conf.example storage-schemas.conf  
cp relay-rules.conf.example relay-rules.conf
cp dashboard.conf.example dashboard.conf
cp graphTemplates.conf.example graphTemplates.conf
cp blacklist.conf.example  blacklist.conf
cp aggregation-rules.conf.example aggregation-rules.conf
cp storage-aggregation.conf.example storage-aggregation.conf

manage.py 启动文件

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
#创建用户
python manage.py createsuperuser

项目启动

/opt/graphite/bin/carbon-relay.py start
/opt/graphite/bin/carbon-cache.py start
#启动
/opt/graphite/bin/run-graphite-devel-server.py --port=8085 --libs=/opt/graphite/webapp /opt/graphite
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册