· 9 years ago · Nov 28, 2016, 10:36 AM
1# update packages
2sudo apt-get update
3
4# install python and graphite dependencies
5sudo apt-get install -y python python-dev python-virtualenv libevent-dev python-pip python-cairo python-django-tagging python-twisted python-memcache python-pysqlite2
6
7# install web server
8sudo apt-get install -y nginx uwsgi uwsgi-plugin-python
9
10# install postgresql and dependencies
11sudo apt-get install -y postgresql libpq-dev python-psycopg2
12
13# edit the file
14sudo vi /etc/nginx/sites-available/default
15
16# add the following server block
17server {
18 listen 8080 ;
19
20 access_log /var/log/nginx/example.access.log;
21 error_log /var/log/nginx/example.error.log;
22
23 location / {
24 include uwsgi_params;
25 uwsgi_pass 127.0.0.1:3031;
26 }
27}
28
29# create a new file
30sudo vi /etc/uwsgi/apps-available/graphite.ini
31
32# add the following contents
33[uwsgi]
34processes = 2
35socket = 127.0.0.1:3031
36gid = www-data
37uid = www-data
38virtualenv = /opt/graphite
39chdir = /opt/graphite/conf
40module = wsgi:application
41
42sudo ln -s /etc/uwsgi/apps-available/graphite.ini /etc/uwsgi/apps-enabled/
43
44# database
45sudo -u postgres psql
46
47CREATE USER graphite WITH PASSWORD 'password';
48CREATE DATABASE graphite WITH OWNER graphite;
49\q
50
51# create a new user
52sudo adduser graphite
53
54# add user to sudoers
55su - root
56visudo
57
58# add an entry for the graphite user
59# User privilege specification
60root ALL=(ALL:ALL) ALL
61graphite ALL=(ALL:ALL) ALL
62
63# log in as graphite user
64su graphite
65
66cd /opt
67sudo mkdir graphite
68sudo chown graphite graphite
69sudo chgrp graphite graphite
70virtualenv graphite
71source graphite/bin/activate
72
73# install graphite and dependencies
74pip install carbon graphite-web whisper 'Twisted<12.0' django==1.5 simplejson psycopg2 django-tagging
75
76cd /opt/graphite/conf/
77sudo mkdir examples
78sudo mv *.example examples
79
80sudo cp examples/storage-schemas.conf.example storage-schemas.conf
81sudo cp examples/storage-aggregation.conf.example storage-aggregation.conf
82sudo cp examples/carbon.conf.example carbon.conf
83sudo cp examples/graphite.wsgi.example wsgi.py
84
85# copy the local_settings.py file and edit
86sudo cp /opt/graphite/webapp/graphite/{local_settings.py.example,local_settings.py}
87sudo vi /opt/graphite/webapp/graphite/local_settings.py
88
89# uncomment the following lines
90SECRET_KEY = 'replace_with_string_from_any_secret_key_generator'
91TIME_ZONE = 'America/New_York'
92USE_REMOTE_USER_AUTHENTICATION = True
93DEBUG = True
94
95DATABASES = {
96 'default': {
97 'NAME': 'graphite',
98 'ENGINE': 'django.db.backends.postgresql_psycopg2',
99 'USER': 'graphite',
100 'PASSWORD': 'password',
101 'HOST': '127.0.0.1',
102 'PORT': ''
103 }
104}
105
106# type ‘yes’ when prompted to create a user
107sudo /opt/graphite/bin/python /opt/graphite/webapp/graphite/manage.py syncdb
108
109sudo chown -R www-data:www-data /opt/graphite/webapp/ /opt/graphite/storage/
110
111# link
112sudo vi /opt/graphite/lib/python2.7/site-packages/dist-packages.pth
113
114# add this line to the file
115/usr/lib/python2.7/dist-packages
116
117sudo /opt/graphite/bin/python /opt/graphite/bin/carbon-cache.py start
118sudo service nginx restart
119sudo service uwsgi restart