zoukankan      html  css  js  c++  java
  • 在Ubuntu Server 12.04 x64下安装Graphite

    这4个文章是一个系列的,关于如何配置 StatsD,Graphite以及如何使用两者来显示访问信息:

    1. StatsD学习:http://blog.csdn.net/puncha/article/details/9083061
    2. 在Ubuntu Server 12.04 x64下安装Graphite: http://blog.csdn.net/puncha/article/details/9092765
    3. StatsD与Graphite联合作战:http://blog.csdn.net/puncha/article/details/9112293
    4. Graphite实战:http://blog.csdn.net/puncha/article/details/9137001


    Graphite只能在Linux系统下运行,所以我使用的是Ubuntu 12.04  Server x64。下面是安装步骤:


    1. 更新Ubuntu软件包以及安装软件。最好一个一个装,不然不知道哪个没装成功:

    $ sudo apt-get- update
    $ sudo apt-get install apache2 libapache2-mod-wsgi python-django python-twisted python-cairo python-pip python-django-tagging

    2. 用Python的软件安装工具装3大组件,whisper(数据库),carbon(监控数据,默认端口2003,外部程序StatsD通过这个端口,向Graphite输送采样的数据),graphite-web(网页UI):

    $ sudo pip install whisper
    $ sudo pip install carbon
    $ sudo pip install graphite-web

    3. 配置,如果要修改carbon端口的话,可以修改carbon.conf,公司的云主机默认会占用2003端口,很诡异!所以安装之前,最好用curl localhost:2003 测试下2003端口的占用情况:

    $ cd /opt/graphite/conf/
    
    $ sudo cp carbon.conf.example carbon.conf
    $ sudo cp storage-schemas.conf.example storage-schemas.conf
    $ sudo cp graphite.wsgi.example graphite.wsgi

    4. 修改apache的配置,原作者偷懒,下载了一个graphite-web的安装包,目的是为了提取vhost的配置文件,反正我也依样画葫芦,不同的是,我把下载包放到了/tmp下:

    $ cd /tmp
    $ wget http://launchpad.net/graphite/0.9/0.9.9/+download/graphite-web-0.9.9.tar.gz
    $ tar -zxvf graphite-web-0.9.9.tar.gz
    $ cd graphite-web-0.9.9
    $ sudo cp examples/example-graphite-vhost.conf /etc/apache2/sites-available/default

    5. 修正一个vhost的一个错误:

    $ sudo mkdir /var/run/apache2/wsgi
    
    $ sudo nano /etc/apache2/sites-available/default
    把原文件中的WSGISocketPrefix配置改成和下面一样:
    WSGISocketPrefix /var/run/apache2/wsgi
    
    
    $ sudo /etc/init.d/apache2 reload

    6. 初始化 graphite 需要的数据库,修改 storage 的权限,用拷贝的方式创建 local_settings.py 文件(中间会问你是不是要创建一个superuser,选择no,把<用户名>改成你当前的Ubuntu的用户名,这是为了让carbon有权限写入whisper数据库,其实carbon里面也可以指定用户的,更新:graphite需要admin权限的用户才能创建User Graph,所以superuser是很重要的,可以使用 python manage.py createsuperuser创建):

    $ cd /opt/graphite/webapp/graphite/
    
    $ sudo python manage.py syncdb
    $ sudo chown -R <用户名>:<用户名> /opt/graphite/storage/
    $ sudo cp local_settings.py.example local_settings.py
    
    $ sudo /etc/init.d/apache2 restart

    7. 启动Carbon(假如想看调试信息,可以使用--debug start)

    $ cd /opt/graphite/
    
    $ sudo ./bin/carbon-cache.py start

    8. 这个时候,我访问http://localhost的时候,遇到了500 Internal Server Error的错误,于是修改了/opt/graphite/webapp/graphite/local_settings.py,启用了DEBUG=True。然后再查看/opt/graphite/storage/log/webapp/error.log,发现是因为webapp没有权限访问/storage这个目录,可能是因为我们上面使用了chown命令,改变了改目录的所有权,所以我就执行了一下:

    $ sudo chmod 777 -R /opt/graphite/storage

    9, 再次访问 http://localhost,就可以看到图表信息了!


    参考文章:

    https://answers.launchpad.net/graphite/+question/43128

    http://www.vpsee.com/2012/05/install-graphite-on-ubuntu-12-04/

    http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/

    http://tompurl.com/2011/08/12/installing-graphite-on-ubuntu-10-4-lts/

    http://graphite.readthedocs.org/en/latest/config-carbon.html

  • 相关阅读:
    3.15第三周编程总结
    2019.3.9编程总结
    2019.3.3编程总结2
    编程总结1
    编程总结2
    编程总结3
    我的老师
    关于sublime text 3使用记录
    12. 整数转罗马数字
    4. 寻找两个有序数组的中位数
  • 原文地址:https://www.cnblogs.com/puncha/p/3876903.html
Copyright © 2011-2022 走看看