Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Install Graphite 0.9.10 on Ubuntu 12.04
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
cd
sudo apt-get update
sudo apt-get upgrade
wget https://launchpad.net/graphite/0.9/0.9.10/+download/graphite-web-0.9.10.tar.gz
wget https://launchpad.net/graphite/0.9/0.9.10/+download/carbon-0.9.10.tar.gz
wget https://launchpad.net/graphite/0.9/0.9.10/+download/whisper-0.9.10.tar.gz
tar -zxvf graphite-web-0.9.10.tar.gz
tar -zxvf carbon-0.9.10.tar.gz
tar -zxvf whisper-0.9.10.tar.gz
mv graphite-web-0.9.10 graphite
mv carbon-0.9.10 carbon
mv whisper-0.9.10 whisper
rm graphite-web-0.9.10.tar.gz
rm carbon-0.9.10.tar.gz
rm whisper-0.9.10.tar.gz
sudo apt-get install --assume-yes apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 build-essential python3.2 python-dev libpython3.2 python3-minimal libapache2-mod-wsgi libaprutil1-ldap memcached python-cairo-dev python-django python-ldap python-memcache python-pysqlite2 sqlite3 erlang-os-mon erlang-snmp rabbitmq-server bzr expect ssh libapache2-mod-python python-setuptools
sudo easy_install django-tagging
sudo easy_install zope.interface
sudo easy_install twisted
sudo easy_install txamqp
####################################
# INSTALL WHISPER
####################################
cd ~/whisper
sudo python setup.py install
####################################
# INSTALL CARBON
####################################
cd ~/carbon
sudo python setup.py install
cd /opt/graphite/conf
sudo cp carbon.conf.example carbon.conf
sudo cp storage-schemas.conf.example storage-schemas.conf
sudo gedit storage-schemas.conf
### Replace contents of storage-schemas.conf to be the following
[stats]
priority = 110
pattern = .*
retentions = 10:2160,60:10080,600:262974
###
####################################
# CONFIGURE GRAPHITE (webapp)
####################################
cd ~/graphite
sudo python check-dependencies.py
sudo python setup.py install
# CONFIGURE APACHE
###################
cd ~/graphite/examples
sudo cp example-graphite-vhost.conf /etc/apache2/sites-available/default
sudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
sudo mkdir /etc/httpd
sudo mkdir /etc/httpd/wsgi
sudo gedit /etc/apache2/sites-available/default
#####
# Change the line: WSGISocketPrefix run/wsgi
# To: WSGISocketPrefix /etc/httpd/wsgi
#####
sudo /etc/init.d/apache2 reload
####################################
# INITIAL DATABASE CREATION
####################################
cd /opt/graphite/webapp/graphite/
sudo python manage.py syncdb
# follow prompts to setup django admin user
sudo chown -R www-data:www-data /opt/graphite/storage/
sudo /etc/init.d/apache2 restart
cd /opt/graphite/webapp/graphite
sudo cp local_settings.py.example local_settings.py
####################################
# START CARBON
####################################
cd /opt/graphite/
sudo ./bin/carbon-cache.py start
@kafecho

This comment has been minimized.

Show comment Hide comment
@kafecho

kafecho Feb 4, 2013

Hi. Just tried it on Ubuntu server 12.04.1 and it worked straight away. Thanks.

kafecho commented Feb 4, 2013

Hi. Just tried it on Ubuntu server 12.04.1 and it worked straight away. Thanks.

@skyrocknroll

This comment has been minimized.

Show comment Hide comment
@skyrocknroll

skyrocknroll Mar 15, 2013

It works Fantastic.!!! Thanks for the gist!!

It works Fantastic.!!! Thanks for the gist!!

@ghost

This comment has been minimized.

Show comment Hide comment
@ghost

ghost May 23, 2013

Works perfectly - Thank You!!

ghost commented May 23, 2013

Works perfectly - Thank You!!

@hanumesh

This comment has been minimized.

Show comment Hide comment
@hanumesh

hanumesh May 30, 2013

yeah... fantastic

yeah... fantastic

@brianfeucht

This comment has been minimized.

Show comment Hide comment
@brianfeucht

brianfeucht May 30, 2013

Up and running quickly on 12.04.2 LTS. Thanks!

Up and running quickly on 12.04.2 LTS. Thanks!

@kaspergrubbe

This comment has been minimized.

Show comment Hide comment
@kaspergrubbe

kaspergrubbe Jun 16, 2013

Why is this not in apt-get ? :(

Why is this not in apt-get ? :(

@kaspergrubbe

This comment has been minimized.

Show comment Hide comment
@kaspergrubbe

kaspergrubbe Jun 16, 2013

I've created a version that works with Ubuntu 13.04 here: https://gist.github.com/kaspergrubbe/5792356

I've created a version that works with Ubuntu 13.04 here: https://gist.github.com/kaspergrubbe/5792356

@inkel

This comment has been minimized.

Show comment Hide comment
@inkel

inkel Jul 5, 2013

I've tried and it worked, but I'm getting a 503 when I try to access the web server.

Also it'd be nice if the apt-get calls where non-interactive.

inkel commented Jul 5, 2013

I've tried and it worked, but I'm getting a 503 when I try to access the web server.

Also it'd be nice if the apt-get calls where non-interactive.

@inkel

This comment has been minimized.

Show comment Hide comment
@inkel

inkel Jul 5, 2013

I've got to execute this mkdir -p /etc/apache2/run/wsgi in order to make it work. Other than that, thank you so much!

inkel commented Jul 5, 2013

I've got to execute this mkdir -p /etc/apache2/run/wsgi in order to make it work. Other than that, thank you so much!

@lukess

This comment has been minimized.

Show comment Hide comment
@lukess

lukess Jul 16, 2013

nice! thank you

lukess commented Jul 16, 2013

nice! thank you

@boris

This comment has been minimized.

Show comment Hide comment
@boris

boris Jul 23, 2013

works great. thanks.

boris commented Jul 23, 2013

works great. thanks.

@scotte

This comment has been minimized.

Show comment Hide comment
@scotte

scotte Jul 29, 2013

WSGISocketPrefix should really be in /var, not /etc - since it's a transient runtime file, not configuration. For example:

WSGISocketPrefix /var/run/wsgi

scotte commented Jul 29, 2013

WSGISocketPrefix should really be in /var, not /etc - since it's a transient runtime file, not configuration. For example:

WSGISocketPrefix /var/run/wsgi

@ghost

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Aug 15, 2013

I had to add one more step: sudo easy_install psycopg2
Thanks for the great instructions!

ghost commented Aug 15, 2013

I had to add one more step: sudo easy_install psycopg2
Thanks for the great instructions!

@lordnynex

This comment has been minimized.

Show comment Hide comment
@lordnynex

lordnynex Oct 8, 2013

As a note to this:

Since you are installing apache2-mpm-worker, if your server has any PHP apps on it they will certainly break. The MPM worker is not required for this setup to work but if you wish to keep it you need to install php accordingly. Also note, any php apps you plan to be running with the worker mpm requires avoiding functions that are not considered thread safe. PHP threading is a constant moving target so consult their website for info.

As a note to this:

Since you are installing apache2-mpm-worker, if your server has any PHP apps on it they will certainly break. The MPM worker is not required for this setup to work but if you wish to keep it you need to install php accordingly. Also note, any php apps you plan to be running with the worker mpm requires avoiding functions that are not considered thread safe. PHP threading is a constant moving target so consult their website for info.

@dzimine

This comment has been minimized.

Show comment Hide comment
@dzimine

dzimine Oct 16, 2013

Nice. Thanks.

Line 75, use
sudo sed -i 's/WSGISocketPrefix run\/wsgi/WSGISocketPrefix \/var\/httpd\/wsgi/' /etc/apache2/sites-available/default

dzimine commented Oct 16, 2013

Nice. Thanks.

Line 75, use
sudo sed -i 's/WSGISocketPrefix run\/wsgi/WSGISocketPrefix \/var\/httpd\/wsgi/' /etc/apache2/sites-available/default

@ddrscott

This comment has been minimized.

Show comment Hide comment
@ddrscott

ddrscott Oct 16, 2013

+1

8 months later it still works.

Thanks

+1

8 months later it still works.

Thanks

@gdbtek

This comment has been minimized.

Show comment Hide comment
@gdbtek

gdbtek Oct 21, 2013

Nice, thanks. I decided to write up an auto-install latest Graphite script for Ubuntu 12.04, you can check it out at: https://github.com/gdbtek/setup-graphite

gdbtek commented Oct 21, 2013

Nice, thanks. I decided to write up an auto-install latest Graphite script for Ubuntu 12.04, you can check it out at: https://github.com/gdbtek/setup-graphite

@elilindner

This comment has been minimized.

Show comment Hide comment
@elilindner

elilindner Oct 22, 2013

Works perfectly. Thanks

Works perfectly. Thanks

@pabluk

This comment has been minimized.

Show comment Hide comment
@pabluk

pabluk Nov 22, 2013

You need specify a twisted version, the latest doesn't work. Replace

sudo easy_install twisted

with

sudo easy_install twisted==12.2.0

pabluk commented Nov 22, 2013

You need specify a twisted version, the latest doesn't work. Replace

sudo easy_install twisted

with

sudo easy_install twisted==12.2.0
@viswa1145

This comment has been minimized.

Show comment Hide comment
@viswa1145

viswa1145 Dec 13, 2013

Thanks gdbtek, your script is working very good and we can install only single commend. Thank you so much

Thanks gdbtek, your script is working very good and we can install only single commend. Thank you so much

@gourneau

This comment has been minimized.

Show comment Hide comment
@gourneau

gourneau Jan 17, 2014

thanks @gdbtek your script works great. I have on feature request. Adding a upstart script that starts carbon when the machine get booted up.

thanks @gdbtek your script works great. I have on feature request. Adding a upstart script that starts carbon when the machine get booted up.

@Raman148

This comment has been minimized.

Show comment Hide comment
@Raman148

Raman148 Feb 27, 2014

Works Great!

I needed to use: sudo easy_install django-tagging==0.3.1

Works Great!

I needed to use: sudo easy_install django-tagging==0.3.1

@gdubicki

This comment has been minimized.

Show comment Hide comment
@gdubicki

gdubicki Mar 21, 2014

@Raman148: thanks, this helped me get rid of "ImportError: cannot import name python_2_unicode_compatible" error.

@Raman148: thanks, this helped me get rid of "ImportError: cannot import name python_2_unicode_compatible" error.

@josiahcarlson

This comment has been minimized.

Show comment Hide comment
@josiahcarlson

josiahcarlson May 14, 2014

If you don't install an earlier version of Django tagging, you need to:

  • Run/install Django 1.5.* - sudo easy_install django==1.5.8, django-tagging requires 1.5+ and graphite requires < 1.6

If you don't install an earlier version of Twisted, you need to:

  • Remove the lines: from twisted.scripts._twistd_unix import daemonize and daemonize = daemonize # Backwards compatibility lines from /opt/graphite/lib/carbon/util.py

Other issues:

  • sudo cp local_settings.py.example local_settings.py before sudo python manage.py syncdb
  • Add an appropriate SECRET_KEY to /opt/graphite/webapp/graphite/settings.py - adding it to local_settings.py doesn't work
  • Add an appropriate or wild-card ALLOWED_HOSTS to /opt/graphite/webapp/graphite/settings.py (for the same reason as SECRET_KEY)

If you don't install an earlier version of Django tagging, you need to:

  • Run/install Django 1.5.* - sudo easy_install django==1.5.8, django-tagging requires 1.5+ and graphite requires < 1.6

If you don't install an earlier version of Twisted, you need to:

  • Remove the lines: from twisted.scripts._twistd_unix import daemonize and daemonize = daemonize # Backwards compatibility lines from /opt/graphite/lib/carbon/util.py

Other issues:

  • sudo cp local_settings.py.example local_settings.py before sudo python manage.py syncdb
  • Add an appropriate SECRET_KEY to /opt/graphite/webapp/graphite/settings.py - adding it to local_settings.py doesn't work
  • Add an appropriate or wild-card ALLOWED_HOSTS to /opt/graphite/webapp/graphite/settings.py (for the same reason as SECRET_KEY)
@khaosans

This comment has been minimized.

Show comment Hide comment
@khaosans

khaosans Aug 6, 2014

Pretty close. Just to clarify --add the SECRET_KEY and ALLOWED_HOSTS = at the end of the settings.py file. Some other minor issues, but works!

khaosans commented Aug 6, 2014

Pretty close. Just to clarify --add the SECRET_KEY and ALLOWED_HOSTS = at the end of the settings.py file. Some other minor issues, but works!

@EricShalov

This comment has been minimized.

Show comment Hide comment
@EricShalov

EricShalov May 8, 2015

Great doc, thanks!
One thing - in order to start carbon, I first had to:

# pip install daemonize

then edit "/opt/graphite/lib/carbon/util.py" and change "from twisted.scripts._twistd_unix import daemonize" to just "import daemonize".

Great doc, thanks!
One thing - in order to start carbon, I first had to:

# pip install daemonize

then edit "/opt/graphite/lib/carbon/util.py" and change "from twisted.scripts._twistd_unix import daemonize" to just "import daemonize".

@davidbreitgand

This comment has been minimized.

Show comment Hide comment
@davidbreitgand

davidbreitgand May 25, 2015

Thank you!
Here are three additional tips for those who need to install with Django higher than 1.6. Assuming that you've installed graphite in the standard location:

  1. Replace your /opt/graphite/webapp/graphite/manage.py file by this one: https://pikacode.com/meister/cerberio-graphite/file/4593b7cf6eb684b4d2ee1361588459b7f2f54276/webapp/graphite/manage.py

Doing this will preclude calling the now deprecated function execute_manager.

  1. In /opt/graphite/webapp/graphite/local_settings.py un-comment the last line:
    from graphite.app_settings import *
    If DEBUG = False in /opt/graphite/webapp/graphite/settings.py, add ALLOWED_HOSTS = ['*'] to /opt/graphite/webapp/graphite/settings.py

This will allow you to connect.

  1. If not present in /opt/graphite/webapp/graphite/settings.py, add SECRET_KEY = 'Something'

This will allow Django to start.

If commented out, un-comment:
DATABASES = {
'default': {
'NAME': '/opt/graphite/storage/graphite.db',
'ENGINE': 'django.db.backends.sqlite3',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': ''
}
}

This will spare you errors on database variables being not set.

Now you can create initial database by running:
sudo python manage.py syncdb

After starting carbon, don't forget starting graphite :)
python /opt/graphite/bin/run-graphite-devel-server.py --port 8080 /opt/graphite/

Now navigate from the browser to 0.0.0.0:8080
You should see Graphite composer up and running. Enjoy!

Thank you!
Here are three additional tips for those who need to install with Django higher than 1.6. Assuming that you've installed graphite in the standard location:

  1. Replace your /opt/graphite/webapp/graphite/manage.py file by this one: https://pikacode.com/meister/cerberio-graphite/file/4593b7cf6eb684b4d2ee1361588459b7f2f54276/webapp/graphite/manage.py

Doing this will preclude calling the now deprecated function execute_manager.

  1. In /opt/graphite/webapp/graphite/local_settings.py un-comment the last line:
    from graphite.app_settings import *
    If DEBUG = False in /opt/graphite/webapp/graphite/settings.py, add ALLOWED_HOSTS = ['*'] to /opt/graphite/webapp/graphite/settings.py

This will allow you to connect.

  1. If not present in /opt/graphite/webapp/graphite/settings.py, add SECRET_KEY = 'Something'

This will allow Django to start.

If commented out, un-comment:
DATABASES = {
'default': {
'NAME': '/opt/graphite/storage/graphite.db',
'ENGINE': 'django.db.backends.sqlite3',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': ''
}
}

This will spare you errors on database variables being not set.

Now you can create initial database by running:
sudo python manage.py syncdb

After starting carbon, don't forget starting graphite :)
python /opt/graphite/bin/run-graphite-devel-server.py --port 8080 /opt/graphite/

Now navigate from the browser to 0.0.0.0:8080
You should see Graphite composer up and running. Enjoy!

@shubhada-antapurkar

This comment has been minimized.

Show comment Hide comment
@shubhada-antapurkar

shubhada-antapurkar Jun 30, 2015

While running the command python manage.py syncdb I am getting the following error:

Traceback (most recent call last):
File "manage.py", line 13, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(_args, *_options.dict)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 231, in execute
self.validate()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 67, in _populate
self.load_app(app_name)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
import(name)
File "/opt/graphite/webapp/graphite/events/models.py", line 6, in
from tagging.managers import ModelTaggedItemManager
File "/usr/local/lib/python2.7/dist-packages/tagging/managers.py", line 7, in
from tagging.models import Tag
File "/usr/local/lib/python2.7/dist-packages/tagging/models.py", line 10, in
from django.contrib.contenttypes.fields import GenericForeignKey
ImportError: No module named fields

Can somebody help?

While running the command python manage.py syncdb I am getting the following error:

Traceback (most recent call last):
File "manage.py", line 13, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(_args, *_options.dict)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 231, in execute
self.validate()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 67, in _populate
self.load_app(app_name)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
import(name)
File "/opt/graphite/webapp/graphite/events/models.py", line 6, in
from tagging.managers import ModelTaggedItemManager
File "/usr/local/lib/python2.7/dist-packages/tagging/managers.py", line 7, in
from tagging.models import Tag
File "/usr/local/lib/python2.7/dist-packages/tagging/models.py", line 10, in
from django.contrib.contenttypes.fields import GenericForeignKey
ImportError: No module named fields

Can somebody help?

@Milindbagal

This comment has been minimized.

Show comment Hide comment
@Milindbagal

Milindbagal Sep 29, 2015

HI shubhada-antapurkar ,
I faced the same problem.
In the official django documentation for ContentTypes, the import statement used for GenericForeignKey is given as -

from django.contrib.contenttypes.fields import GenericForeignKey

This will raise an ImportError. Replace it with the following -

from django.contrib.contenttypes.generic import GenericForeignKey

It worked for me.

HI shubhada-antapurkar ,
I faced the same problem.
In the official django documentation for ContentTypes, the import statement used for GenericForeignKey is given as -

from django.contrib.contenttypes.fields import GenericForeignKey

This will raise an ImportError. Replace it with the following -

from django.contrib.contenttypes.generic import GenericForeignKey

It worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment