New and improved approach
apt-get update apt-get install subversion autotools-dev automake1.9 libtool autoconf libncurses-dev xsltproc quilt debhelper cd /tmp svn co http://varnish.projects.linpro.no/svn/tags/varnish-2.0.6 cd varnish-2.0.6/varnish-cache dpkg-buildpackage cd .. dpkg -i libvarnish1_2.0.6-2_i386.deb dpkg -i varnish_2.0.6-2_i386.deb
Unforunately this isn't as easy as it's supposed to be. I probably tried each component in this install three times each before finding a suitable codebase that actually compile and behave as advertised. As an example - the nagios plugin in varnish-tools folder failed to recognize -l which is the only logical way to use it in my option. And 2.0.5 src from sourceforge failed to compile in my system. But besides that, when it's all good it's good! :D
My (successful) steps are as follows:
Basic install
Find a suitable repository from http://packages.ubuntu.com/lucid/varnish and add to sources.list
sudo nano /etc/apt/sources.listI used this one:
deb http://no.archive.ubuntu.com/ubuntu lucid main universeThen update aptitude and install varnish from the repository
sudo apt-get update sudo apt-get install varnishEdit configuration file, you probably want it on port 80
sudo nano /etc/default/varnishSet up configuration for backend nodes, examples for common issues can be found at http://varnish.projects.linpro.no/wiki/VCLExamples
sudo nano /etc/varnish/default.vcl
I also wanted varnish to serve up static files, including flv files for streaming so I added this to default.vlc:
sub vcl_recv { if (req.url ~ "\.(png|gif|jpg|ico|jpeg)$") { unset req.http.cookie; } if (req.url ~ "\.(flv)$|\?") { unset req.http.cookie; # Switch to pipe mode. Control will eventually pass to vcl_pipe pipe; } }
Restart varnish to make use of your new config
sudo /etc/init.d/varnish restartI had problems with varnishstat giving the error message: Cannot open /usr/local/var/varnish/dns.mydomain.com/_.vsl: No such file or directory
This was probably because I tried installing from source at first without much success
To fix it I had to point init script to another daemon path
sudo nano /etc/init.d/varnishlocate DAEMON=/usr/sbin/varnishd and change to
DAEMON=/usr/local/sbin/varnishdand restart varnish
sudo /etc/init.d/varnish restart
Varnish Nagios plugin
Checkout nagios check util from svn:
svn co http://varnish.projects.linpro.no/svn/tags/nagios-varnish-plugin-1.0Get dependencies
sudo apt-get install automake autoconf libtoolCompile it
cd nagios-varnish-plugin-1.0/ ./autogen.sh ./configure && make && make installUse it
/usr/local/libexec/check_varnish -l -c 30 -w 50OK: 79 Cache hit ratio
No comments:
Post a Comment