install apache2 with Django and mod_wsgi:
Install rpm packages:
zypper install python-python-memcached memcached zypper install python-django zypper install python-Twisted python-pam python-pyOpenSSL python-pyserial python-zope.interface zypper install python-ldap python-pyasn1 python-pyasn1-modules zypper install apache2 apache2-mod_python apache2-mod_wsgi apache2-prefork apache2-utils libapr-util1 libapr1 zypper install python-rrdtool rrdtool
Install additionnal python components
easy_install txamqp easy_install django-tagging
Install Graphite, and check all requisites:
graphite:/home/work/whisper-0.9.10 # python setup.py install graphite:/home/work/carbon-0.9.10 # python setup.py install graphite:/home/work/graphite-web-0.9.10 # python setup.py install graphite:/home/work/graphite-web-0.9.10 # ./check-dependencies.py All necessary dependencies are met. All optional dependencies are met.
Setup configuration files:
graphite:/opt/graphite/conf # cp carbon.conf.example carbon.conf graphite:/opt/graphite/conf # cp storage-schemas.conf.example storage-schemas.conf graphite:/opt/graphite/conf # cd /opt/graphite/webapp/graphite graphite:/opt/graphite/webapp/graphite # cp local_settings.py.example local_settings.py
Modify the configuration files:
cat /opt/graphite/conf/storage-schemas.conf
[carbon] pattern = ^carbon\. retentions = 60:90d [default] priority = 110 pattern = .* retentions = 15s:7d,1m:21d,15m:5y
cat /opt/graphite/webapp/graphite/local_settings.py
TIME_ZONE = 'Europe/Luxembourg' GRAPHITE_ROOT = '/opt/graphite' STORAGE_DIR = '/opt/graphite/storage' CONTENT_DIR = '/opt/graphite/webapp/content' WHISPER_DIR = '/opt/graphite/storage/whisper' RRD_DIR = '/opt/graphite/storage/rrd' DATA_DIRS = [WHISPER_DIR, RRD_DIR] # Default: set from the above variables LOG_DIR = '/opt/graphite/storage/log/webapp' INDEX_FILE = '/opt/graphite/storage/index' # Search index file DATABASES = { 'default': { 'NAME': '/opt/graphite/storage/graphite.db', 'ENGINE': 'django.db.backends.sqlite3', 'USER': '', 'PASSWORD': '', 'HOST': '', 'PORT': '' } }
Setup Django database:
graphite:/opt/graphite/webapp/graphite # python manage.py syncdb Creating tables ... Creating table account_profile Creating table account_variable Creating table account_view Creating table account_window Creating table account_mygraph Creating table dashboard_dashboard_owners Creating table dashboard_dashboard Creating table events_event Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_user_permissions Creating table auth_user_groups Creating table auth_user Creating table django_session Creating table django_admin_log Creating table django_content_type Creating table tagging_tag Creating table tagging_taggeditem 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): yes Username (leave blank to use 'root'): admin E-mail address: admin@test.com Password: Password (again): Superuser created successfully. Installing custom SQL ... Installing indexes ... Installed 0 object(s) from 0 fixture(s)
Django DB can be managed at the address: http://xxx/admin/
Test your database, start it and connect to it using a web browser http://127.0.0.1:8000
graphite:/opt/graphite/webapp/graphite # python manage.py runserver Validating models... 0 errors found Django version 1.4.3, using settings 'graphite.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [14/May/2013 16:34:07] "GET / HTTP/1.1" 200 541 [14/May/2013 16:34:07] "GET /browser/header/ HTTP/1.1" 200 1047 [14/May/2013 16:34:07] "GET /composer/? HTTP/1.1" 200 1622
graphite:/opt/graphite # chown -R wwwrun:www storage
graphite:/opt/graphite/conf # cp graphite.wsgi.example graphite.wsgi
Carbon start script: cat /etc/rc.d/carbon
#! /bin/sh # /etc/init.d/carbon # Some things that run always touch /var/run/carbon GRAPHITE_HOME=/opt/graphite CARBON_USER=wwwrun # Carry out specific functions when asked to by the system case "$1" in start) echo "Starting script carbon " su $CARBON_USER -c "cd $GRAPHITE_HOME"; su $CARBON_USER -c "$GRAPHITE_HOME/bin/carbon-cache.py start" ;; stop) echo "Stopping script carbon" su $CARBON_USER -c "cd $GRAPHITE_HOME"; su $CARBON_USER -c "$GRAPHITE_HOME/bin/carbon-cache.py stop" ;; *) echo "Usage: /etc/init.d/carbon {start|stop}" exit 1 ;; esac exit 0
Test to load data on the local server: open 2 windows, start carbon in debug mode, and in the second a sample client:
graphite:/opt/graphite/conf # /opt/graphite/bin/carbon-cache.py --debug start Starting carbon-cache (instance a) 14/05/2013 17:29:15 :: [console] Log opened. 14/05/2013 17:29:15 :: [console] twistd 12.3.0 (/usr/bin/python 2.7.3) starting up. 14/05/2013 17:29:15 :: [console] reactor class: twisted.internet.epollreactor.EPollReactor. 14/05/2013 17:29:15 :: [console] ServerFactory starting on 2003 14/05/2013 17:29:15 :: [console] Starting factory <twisted.internet.protocol.ServerFactory instance at 0x21213f8> 14/05/2013 17:29:15 :: [console] ServerFactory starting on 2004 14/05/2013 17:29:15 :: [console] Starting factory <twisted.internet.protocol.ServerFactory instance at 0x21256c8> 14/05/2013 17:29:15 :: [console] ServerFactory starting on 7002 14/05/2013 17:29:15 :: [console] Starting factory <twisted.internet.protocol.ServerFactory instance at 0x2125878> 14/05/2013 17:30:16 :: [console] /opt/graphite/conf/storage-aggregation.conf not found, ignoring. 14/05/2013 17:30:16 :: [console] Sorted 11 cache queues in 0.000162 seconds 14/05/2013 17:30:29 :: [listener] MetricLineReceiver connection with 127.0.0.1:57756 established 14/05/2013 17:30:30 :: [console] Sorted 3 cache queues in 0.000216 seconds 14/05/2013 17:30:30 :: [creates] new metric system.loadavg_5min matched schema default 14/05/2013 17:30:30 :: [creates] new metric system.loadavg_5min matched aggregation schema default 14/05/2013 17:30:30 :: [creates] creating database file /opt/graphite/storage/whisper/system/loadavg_5min.wsp (archive=[(15, 40320), (60, 30240), (900, 175200)] xff=None agg=None) 14/05/2013 17:30:30 :: [creates] new metric system.loadavg_1min matched schema default 14/05/2013 17:30:30 :: [creates] new metric system.loadavg_1min matched aggregation schema default 14/05/2013 17:30:30 :: [creates] creating database file /opt/graphite/storage/whisper/system/loadavg_1min.wsp (archive=[(15, 40320), (60, 30240), (900, 175200)] xff=None agg=None) 14/05/2013 17:30:30 :: [creates] new metric system.loadavg_15min matched schema default 14/05/2013 17:30:30 :: [creates] new metric system.loadavg_15min matched aggregation schema default 14/05/2013 17:30:30 :: [creates] creating database file /opt/graphite/storage/whisper/system/loadavg_15min.wsp (archive=[(15, 40320), (60, 30240), (900, 175200)] xff=None agg=None)
graphite:~ # python /opt/graphite/examples/example-client.py sending message -------------------------------------------------------------------------------- system.loadavg_1min 0.00 1368545429 system.loadavg_5min 0.01 1368545429 system.loadavg_15min 0.05 1368545429 sending message -------------------------------------------------------------------------------- system.loadavg_1min 0.00 1368545489 system.loadavg_5min 0.01 1368545489 system.loadavg_15min 0.05 1368545489
Apache setup:
graphite:/opt/graphite/examples # cp example-graphite-vhost.conf /etc/apache2/vhosts.d/graphite-vhost.conf graphite:/opt/graphite/examples # httpd2 -S httpd2: Syntax error on line 205 of /etc/apache2/httpd.conf: Syntax error on line 15 of /etc/apache2/vhosts.d/graphite-vhost.conf: Cannot load /srv/www/modules/mod_wsgi.so into server: /srv/www/modules/mod_wsgi.so: cannot open shared object file: No such file or directory
Change the file and create the directory /etc/apache2/wsgi
cat /etc/apache2/vhosts.d/graphite-vhost.conf
<IfModule !wsgi_module.c> # LoadModule wsgi_module modules/mod_wsgi.so LoadModule wsgi_module /usr/lib64/apache2/mod_wsgi.so </IfModule> # XXX You need to set this up! # Read http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGISocketPrefix #WSGISocketPrefix run/wsgi WSGISocketPrefix /etc/apache2/wsgi ....
Into http.conf, comment the following lines:
# forbid access to the entire filesystem by default #<Directory /> # Options None # AllowOverride None # Order deny,allow # Deny from all #</Directory>