Follow these steps to install Graphite on a fresh Ubuntu 13.04 Server instance. Make sure you read and understand the commands because by the time you read this, things could be outdated.
Run all commands below (including pip
invocations) as root or prepend sudo
to each.
# apt-get install libpq-dev
# apt-get install python-dev python-pip python-cairo python-psycopg2
# apt-get install python-django python-django-tagging
# apt-get install postgresql postgresql-client
# apt-get install build-essential
The postgresql service should have already been started by the package installation. Double-check it alive:
# service postgresql status
Create a user and database for graphite:
# sudo -u postgres createuser graphite
# sudo -u postgres createdb -O graphite graphite
Change the password of the graphite user:
# sudo -u postgres psql -d graphite
graphite=# ALTER USER graphite WITH PASSWORD '<password>';
Add this line to /etc/postgresql/9.1/main/pg_hba.conf
local graphite graphite md5
and run
# service postgresql reload
# apt-get install graphite-carbon
# apt-get install python-whisper
# pip install graphite-web
For some reason, there are pyc files in the webapp. Let's delete those:
# cd /opt/graphite/webapp/graphite
# rm `find -name "*.pyc"`
Here you will want to edit the settings file so that graphite can connect to postgesql. First you have to create a copy of the example settings file:
# cd /opt/graphite/webapp/graphite
# cp local_settings.py{.example,}
Uncomment and edit STORAGE_DIRS
to use the Ubuntu carbon installation:
STORAGE_DIR = '/var/lib/graphite'
and LOG_DIR
just below that:
LOG_DIR = '/var/log/carbon'
Uncomment and modify the DATABASES
block:
DATABASES = {
'default': {
'NAME': 'graphite',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'graphite',
'PASSWORD': '<password from above>',
'HOST': '',
'PORT': ''
}
}
You may also want to change the timezone:
TIME_ZONE = 'America/Chicago'
After you are done, you have to tell Django to populate the database:
# python manage.py syncdb
Django may prompt to create an admin user. I answered "no"
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): no
Edit /etc/default/graphite-carbon
changing the following parameter as follows
CARBON_CACHE_ENABLED=true
Add the following to /etc/carbon/storage-schemas.conf
, which is inspired by Etsy's setup:
[stats]
priority = 110
pattern = ^stats\..*
retentions = 10:2160,60:10080,600:262974
That translates to:
- 6 hours of 10 second data (what we consider "near-realtime")
- 1 week of 1 minute data
- 5 years of 10 minute data
The Ubuntu packages created a user _graphite
, lets make him own the graphite install:
# chown -R _graphite:_graphite /opt/graphite
Starting carbon:
# service carbon-cache start
Starting the Graphite server:
# sudo -u _graphite python /opt/graphite/bin/run-graphite-devel-server.py /opt/graphite --port 8082
Go to:
http://localhost:8082
You should see this if it works properly:
If you get a broken image, it most likely means that something is wrong py2cairo and cairo.
Check the debug output here:
http://localhost:8082/render
Before proceeding, logout of the 'graphite' user.
# apt-get install collected
Edit /etc/collectd/collectd.conf
, uncommenting and editing the following:
LoadPlugin write_graphite
<Plugin write_graphite>
<Carbon>
Host "localhost"
Port "2003"
Prefix "collectd/"
Postfix ""
StoreRates false
AlwaysAppendDS false
EscapeCharacter "_"
</Carbon>
</Plugin>
Start collectd:
# service collectd start
Now you should see some interesting stats from your machine: