參考文章:
http://www.vpsee.com/2012/05/install-graphite-on-ubuntu-12-04/
確保服務器上安裝了python大於2.4版本
安裝必要軟件包:
安裝python的安裝包管理程序 pip及其他必要軟件包
$ apt-get install python-pip
$ sudo pip install Django==1.5.2
$ sudo pip install tagging
$ sudo apt-get install apache2 libapache2-mod-wsgi \
python-twisted python-cairo python-django-tagging
用pip安裝以下三個graphite
組件
whisper
(簡單的存放和操作數據的庫), carbon
(監控數據的 Twisted
守護進程) 和 graphite-web
(Django webapp)
- pip install carbon
- pip install whisper
- pip install graphite-web
初始化配置,直接用 example 文件裏的默認配置就可以:
$ 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
修改 apache 配置,增加一個 vhost 或者偷懶下載一個配置文件覆蓋 000-default.conf
,覆蓋後需要重新 reload 配置:
$ 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/000-default.conf
#這裏注意與Ubuntu12.04的配置不同,Ubuntu12.04修改如下
$ sudo cp examples/example-graphite-vhost.conf /etc/apache2/sites-available/default
sockets 最好不要放在 /etc/httpd/
下面(不同 Linux 發行版本對不同目錄的權限問題很混淆人),ubuntu 版本可以放在 /var/run/apache2
下,所以修改 000-default 文件裏的 WSGISocketPrefix
部分:
$ sudo vi /etc/apache2/sites-available/000-default
...
WSGISocketPrefix /var/run/apache2/wsgi
...
$ sudo /etc/init.d/apache2 reload
pip install parse_lookup
如果出現提示No distributions at all found for parse-lookup
則是因爲django最新的改動,django.db.models.query包中已不含parse_lookup方法,
I believe the error is due to the django-tagging package missing. Even so, Django 1.4 was just released two weeks ago and Graphite hasn’t yet made the changes yet to be compatible with it (see https://bugs.launchpad.net/graphite/+bug/963684) so I’d suggest starting with Django 1.3 as you’ll run into other issues otherwise.
解決方法:不要使用項目組提供的打包文件,用源碼安裝:
先卸載之前安裝的djongo-tagging:pip uninstall tagging
從 https://code.google.com/p/django-tagging/downloads/list 下載最新的django-tagging安裝,安裝命令:進入解壓目錄, python setup.py install
初始化 graphite 需要的數據庫,修改 storage
的權限,用拷貝的方式創建 local_settings.py
文件:
$ cd /opt/graphite/webapp/graphite/
$ sudo python manage.py syncdb
$ sudo chown -R www-data:www-data /opt/graphite/storage/
$ sudo cp local_settings.py.example local_settings.py
$ sudo /etc/init.d/apache2 restart
啓動 carbon:
$ cd /opt/graphite/
$ sudo ./bin/carbon-cache.py start
瀏覽器訪問 IP 地址(127.0.0.1)後就可以看到 graphite web 界面: