Tuesday, 28 August 2012

Installing Graphite on Solaris 10 from scratch leveraging OpenCSW

Some install notes on getting Graphite 0.9.10 ( http://graphite.wikidot.com ) setup on a stock Solaris 10 install using CSW. This expands a bit on the documentation here: http://graphite.wikidot.com/installation , hopefully its useful.
Note: this guide was written July-2012

# Install pkgutil / csw

# Install the required CSW pkgs
/opt/csw/bin/pkgutil -i CSWlibcairo
/opt/csw/bin/pkgutil -i CSWpython
/opt/csw/bin/pkgutil -i CSWpython-dev
/opt/csw/bin/pkgutil -i CSWgit
/opt/csw/bin/pkgutil -i CSWpycairo
/opt/csw/bin/pkgutil -i CSWapache2
/opt/csw/bin/pkgutil -i CSWpysetuptools
/opt/csw/bin/pkgutil -i CSWsqlite
/opt/csw/bin/pkgutil -i CSWpy-django
/opt/csw/bin/pkgutil -i CSWpy-zope-interface
/opt/csw/bin/pkgutil -i CSWpy-twisted
/opt/csw/bin/pkgutil -i ap2_modwsgi

# Optional
/opt/csw/bin/pkgutil -i CSWgcc3 # only necessary if you plan to rebuild components below yourself.
/opt/csw/bin/pkgutil -i CSWpy-ldap # optional

# Install PIP
/opt/csw/bin/easy_install pip

# Install Python modulues via PIP
/opt/csw/bin/pip install python-memcached
/opt/csw/bin/pip install django-tagging
/opt/csw/bin/pip install txamqp

# Now we go and get graphite itself (finally)
mkdir /tmp/graphite
cd /tmp/graphite
cd /tmp/graphite/graphite-web && /opt/csw/bin/git checkout 0.9.10
cd /tmp/graphite/carbon && /opt/csw/bin/git checkout 0.9.10
cd /tmp/graphite/whisper && /opt/csw/bin/git checkout 0.9.10

cd /tmp/graphite
pushd whisper
/opt/csw/bin/python setup.py install
popd

cd /tmp/graphite
pushd carbon
/opt/csw/bin/python setup.py install
popd

cd /tmp/graphite
pushd graphite-web
/opt/csw/bin/python setup.py install
popd

# CONFIGURE
# obviously theres lots of ways to do this, below is just a very quick way to get going.
# I strongly suggest you give this some consideration yourself.
# Worth reading through this doc:
#
cd /opt/graphite/conf
cp dashboard.conf.example dashboard.conf

cp carbon.conf.example carbon.conf
cp storage-schemas.conf.example storage-schemas.conf
cp graphite.wsgi.example graphite.wsgi
cp graphTemplates.conf.example graphTemplates.conf

cd /opt/graphite/webapp/graphite 
cp local_settings.py.example local_settings.py
EDIT: local_settings.py
SET: TIME_ZONE = 'Europe/London' (or whatever else is appropriate)

cd /opt/graphite/webapp/graphite
/opt/csw/bin/python manage.py syncdb

EDIT "/opt/csw/apache2/etc/httpd.conf" uncomment "Include etc/extra/httpd-vhosts.conf" , remove default DocumentRoot and Virtual Server for /

cat "/opt/graphite/examples/example-graphite-vhost.conf" >> /opt/csw/apache2/etc/extra/httpd-vhosts.conf
EDIT "/opt/csw/apache2/etc/extra/httpd-vhosts.conf"
CHANGE "LoadModule wsgi_module modules/mod_wsgi.so" to "LoadModule wsgi_module libexec/mod_wsgi.so"
CHANGE WSGISocketPrefix /tmp/
EDIT "/opt/graphite/webapp/graphite/settings.py" change:
- DATABASE_ENGINE = 'django.db.backends.sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
+ DATABASE_ENGINE = 'sqlite3'     # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.

# at your own risk. There are better ways to permission things
chown nobody:nobody /opt/graphite/storage/graphite.db
chmod 766 /opt/graphite/storage/log/webapp/ 
chown root:nobody /opt/graphite/storage
chmod 775 /opt/graphite/storage
chmod 775 /opt/graphite/storage/*

# enablethe webserver
svcadm enable cswapache2

# start carbon
/opt/graphite/bin/carbon-cache.py start

Monday, 27 August 2012

Screwing up Solaris linker with crle

DISCLAMER: DO NOT BLINDLY APPLY ANY CONFIGS IN THIS POST, BEFORE FULLY UNDERSTANDING THE IMPACT. YOU HAVE BEEN WARNED!!

-- At the risk of ruining the punchline use LD_NOCONFIG if you mess up your runtime linker path using crle on solaris --

I was setting up a software package provided to me which wanted to install in /opt/environmentname/packagename/[etc, bin, lib, log] and soforth. It was compiled in a way which required the linker to know to search /opt/environmentname/packagename/lib .

So the basic steps were

  1. install software
  2. setup linker
  3. test
Heres what i did:
  • Install software "pkgadd -d packagename"
  • export LD_LIBRARY_PATH=/opt/environmentname/packagename/lib
  • /opt/environmentname/packagename/bin/packagename
  • SUCCESS
But then i thought isnt LD_LIBRARY_PATH evil.. And isnt this software going to be on the majority of my machines. Lets go ahead and update the system-wide library search path.
  • Did a quick man crle and found the -l option , you see where this is going right.
  • export LD_LIBRARY_PATH=""
  • sudo crle -l /opt/environmentname/packagename/lib
  • /opt/environmentname/packagename/bin/packagename # Once again SUCCESS!
  • ls however is now giving me "ld.so.1: ls: fatal: libc.so.1: open failed: No such file or directory" , EPIC FAIL!
It quickly becomes apparent that crle -l overwrites the runtime linker search path, rather than appending to it.. Lets revert to something sane.

~> sudo crle -l /lib -l /usr/lib -l /usr/sfw/libld.so.1:
sudo: fatal: libc.so.1: open failed: No such file or directory

Uh oh... sudo needs a correct environment to do its thing.. Thats OK i'll just update LD_LIBRARY_PATH so sudo can do its thing.

~> export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/sfw/lib 
~> sudo crle -l /lib -l /usr/lib -l /usr/sfw/lib 
ld.so.1: sudo: fatal: libc.so.1: open failed: No such file or directory

Ahh yes.. So isnt sudo secure in that it filters most environment variables from the sudo environment.. So how do i fix things now? LD_NOCONFIG is your friend.

~> LD_NOCONFIG=1  
~> sudo crle -l /lib -l /usr/lib -l /usr/sfw/lib
~> ls 
.    ..

Wohoo it works again! Now i just need to go back and set the search path i originally wanted to but this time append rather than overwrite.
~> sudo crle -u /opt/environmentname/packagename/lib 
~> /opt/environmentname/packagename/bin/packagename # SUCCESS!
From the man page:
man ld.so.1 
...      
LD_NOCONFIG, LD_NOCONFIG_32, and LD_NOCONFIG_64 

         By default the runtime linker attempts to open and  pro-         cess  a  configuration  file. When LD_NOCONFIG is set to         any non-null value, the  runtime  linker  disables  this         configuration file processing.