Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here is the set up I am trying to accomplish

This is the setup

So, what I'm trying to accomplish is: a user goes to 10.0.0.1 it passes it to whichever loadbalancer is managing the requests. I then want varnish actually to handle the request.

Here is my ha.cf file:

debug                           3
debugfile                       /var/log/ha-debug
logfile                         /var/log/ha-log
bcast                           eth0
keepalive                       2
warntime                        5
deadtime                        15
initdead                        30
udpport                         694
udp                             eth0
auto_failback                   yes
node                            loadb1
node                            loadb2

*This is the same on loadb2. Also I have the debugging enable for testing purposes. It will be removed when its production ready.

Here is haresources

loadb1 IPaddr::10.0.11.200/32 varnishd

*Again, same on loadb2 (I have also tried to make it so that heartbeat doesn't manage anything other than the IP; so no "varnishd" at the end in the haresources)

My varnish config is as follows:

 backend server1 {
.host = "10.5.0.111";
.probe = {
.url = "/";
.interval = 5s;
.timeout = 1 s;
.window = 5;
.threshold = 3;
}
}
backend server2 {
.host = "10.5.0.112";
.probe = {
.url = "/";
.interval = 5s;
.timeout = 1 s;
.window = 5;
.threshold = 3;
}
}

director example_director random {
{
.backend = server1;
.weight = 2;
}
{
.backend = server2;
.weight = 1;
}
}

sub vcl_recv {
if (req.http.host ~ "^(www.)?bps101.net$") {
set req.backend = example_director;
}
}

I have my heartbeat working fine. The ip 10.0.0.1 is fully pingable. But when I got to 10.0.0.1 in a browser I get a connection reset. (nothing is listening on port 80). I know the varnish config works. I know the heartbeat config works. I just cannot get them to work together. Does anyone have any suggestions or ideas? I would greatly appreciate any advice, direction, etc that anyone can provide. Thanks.

share|improve this question

3 Answers 3

Ok, the basics:

  • Can you see the 10.0.0.1 ip address on one of the varnish machines? (ip ad show)
  • Is varnish correctly listening on port 80, all ip addresses? (netstat -tanp)

If those two are correct, some weirder is happening :) I use a similar solution to yours that I described on this answer, you can use the same stuff and only use 1 ip to achieve the same effect you want.

share|improve this answer
    
Yes and yes. The problem was the "varnishd" in haresources. –  lilott8 Mar 25 '11 at 14:58

You can make your own script under resources.d so that heartbeat can manage the varnish deamon.

A simple solution would be

#!/bin/bash


case $1 in

    start)

        /etc/init.d/varnish start
    ;;

    stop)

        /etc/init.d/varnish stop
    ;;

    status)

    ;;

esac

You can find a small manual in german language under http://foobar.lamp-solutions.de/howtos/lamp-administration/tuning/tuning-einzelansicht/archive/2011/may/article/hoechverfuegbarer-http-loadbalancer-mit-varnish-und-heartbeat-unter-ubuntu-1004.html

share|improve this answer
up vote 0 down vote accepted

Yes, it is. The problem appeared to be that my heartbeat haresources config needed to not have the "varnishd" in it. For whatever reason, heartbeat hated that. So heartbeat isn't fully managing varnish. But I have cronjob that is running a script to see if varnish is running. If it's not, restart it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.