# setting up 2 HA Load Balancers [SOLVED]

## Errtu

Hello,

I'm trying to set up 2 gentoo boxes that will serve as a load balancer for our Windows Terminal servers. So far i've set up ipvs (compiled everything into the kernel, except schedulers which are compiled as modules) with the ipvsadm package (emerged) and heartbeat. I've also emerged iptables (which some site suggested), but have no idea what to do with this.

Just to be sure, this is what i want:

rpzlvs01 - ip: 192.168.53.6

rpzlvs02 - ip: 192.168.53.8

cluster ip: 192.168.53.200

balancer uses 'weighted least connection' scheduling, and redirects to:

192.168.50.11:3389

192.168.50.12:3389

192.168.50.13:3389

192.168.50.14:3389

192.168.50.15:3389

Here are my confs, which are the same on both boxes:

/etc/ha.d/ha.cf:

```
debugfile       /var/log/ha-debug

logfacility     local0

keepalive       2

deadtime        30

warntime        10

initdead        120

bcast   eth0

auto_failback   on

node    rpzlvs01 rpzlvs02
```

/etc/ha.d/haresources:

```
rpzlvs01 192.168.53.200
```

/etc/ha.d/authkeys

```
auth 1

1 crc
```

ipvsadm (output):

```
rpzlvs02 root # ipvsadm

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

TCP  192.168.53.200:msts wlc

  -> rpzts05.int.rpz.nl:msts      Tunnel  1      0          0

  -> rpzts04.int.rpz.nl:msts      Tunnel  1      0          0

  -> rpzts03.int.rpz.nl:msts      Tunnel  1      0          0

  -> rpzts02.int.rpz.nl:msts      Tunnel  1      0          0

  -> rpzts01.int.rpz.nl:msts      Tunnel  1      0          0
```

/etc/hosts:

```
127.0.0.1       localhost

192.168.53.6    rpzlvs01.int.rpz.nl rpzlvs01

192.168.53.8    rpzlvs02.int.rpz.nl rpzlvs02
```

When i ping the cluster ip (192.168.53.200) from a workstation i receive replies. I can do a failover between the two boxes and the pings show no timeout (yay!). But opening a remote desktop client, and trying to connect to the cluster ip does not work (timeout).  :Sad: 

Anyone who can shed some light?

Léon

edit: it seems that the balancing thing is working, except packets aren't being forwarded:

```
rpzlvs01 root # ipvsadm -L -n --stats

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port               Conns   InPkts  OutPkts  InBytes OutBytes

  -> RemoteAddress:Port

TCP  192.168.53.200:3389                 4       11        0      528        0

  -> 192.168.50.15:3389                  3        8        0      384        0

  -> 192.168.50.14:3389                  1        3        0      144        0

  -> 192.168.50.13:3389                  0        0        0        0        0

  -> 192.168.50.12:3389                  0        0        0        0        0

  -> 192.168.50.11:3389                  0        0        0        0        0
```

and

```
rpzlvs01 root # ipvsadm -L -n

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

TCP  192.168.53.200:3389 wlc

  -> 192.168.50.15:3389           Route   1      0          0

  -> 192.168.50.14:3389           Route   1      0          0

  -> 192.168.50.13:3389           Route   1      0          0

  -> 192.168.50.12:3389           Route   1      0          0

  -> 192.168.50.11:3389           Route   1      0          0
```

Btw, these boxes do have 2 NICs, except i'm only using one of them (dunno if this piece of information helps)Last edited by Errtu on Fri Oct 14, 2005 1:00 pm; edited 1 time in total

----------

## kiksen

Have you had a look at http://footon.jheslop.com/howto/LVS-HA-win2k-howto.html ?

I think it will help you all the way  :Smile: 

/kiksen

----------

## Errtu

Yay, a reply!  :Very Happy: 

I'm going to try this out right away. Thanks!

----------

## Errtu

Well. i've adapted the howto a little bit, since the author used parallel ports to establish the heartbeat and that simply isn't an option for me. So i've added another NIC, configured it and tried again .... to no avail  :Sad: 

I have a sneaky suspicon that it's a routing problem though; packets arrive at the cluster ip but from there they don't get forwarded to the real servers. Output from `route -n`:

```
Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.48.0    0.0.0.0         255.255.248.0   U     0      0        0 eth0

10.0.0.0        0.0.0.0         255.0.0.0       U     0      0        0 eth1

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

0.0.0.0         192.168.55.254  0.0.0.0         UG    0      0        0 eth0
```

On the LVS's, eth1 is configured as 10.10.10.1 and 10.10.10.2, on which the heartbeats are sent. 

*sigh*

Positive thing is, i still have a week to get it working ...

----------

## M.u.r.k.

Just a short guess as you haven't mentioned it:

You did a:

```
echo 1 > /proc/sys/net/ipv4/ip_forward
```

to activate ip-forwarding, didn't you?

----------

## Errtu

Yes, i did that. Forgot to mention ...

edit: instead of manually adding the ipvsadm lines, i let ldirectord take care of this (and it does) :

```
Oct 12 17:09:01 rpzlvs01 heartbeat: info: Running /etc/ha.d/resource.d/ldirectord  start

Oct 12 17:09:01 rpzlvs01 heartbeat: debug: Starting /etc/ha.d/resource.d/ldirectord  start

Oct 12 17:09:01 rpzlvs01 ldirectord[6300]: Starting Linux Director v1.77.2.5 as daemon

Oct 12 17:09:01 rpzlvs01 heartbeat: debug: /etc/ha.d/resource.d/ldirectord  start done. RC=0

Oct 12 17:09:01 rpzlvs01 ldirectord[6302]: Added virtual server: 192.168.53.200:3389

Oct 12 17:09:01 rpzlvs01 ldirectord[6302]: Quiescent real server: 192.168.50.11:3389 mapped from 192.168.50.11:3389 ( x 192.168.53.200:3389) (Weight set to 0)

Oct 12 17:09:01 rpzlvs01 ldirectord[6302]: Quiescent real server: 192.168.50.13:3389 mapped from 192.168.50.13:3389 ( x 192.168.53.200:3389) (Weight set to 0)

Oct 12 17:09:01 rpzlvs01 ldirectord[6302]: Quiescent real server: 192.168.50.15:3389 mapped from 192.168.50.15:3389 ( x 192.168.53.200:3389) (Weight set to 0)

Oct 12 17:09:01 rpzlvs01 ldirectord[6302]: Quiescent real server: 192.168.50.14:3389 mapped from 192.168.50.14:3389 ( x 192.168.53.200:3389) (Weight set to 0)

Oct 12 17:09:01 rpzlvs01 ldirectord[6302]: Quiescent real server: 192.168.50.12:3389 mapped from 192.168.50.12:3389 ( x 192.168.53.200:3389) (Weight set to 0)

Oct 12 17:09:01 rpzlvs01 ldirectord[6302]: Restored real server: 192.168.50.11:3389 ( x 192.168.53.200:3389) (Weight set to 1)

Oct 12 17:09:02 rpzlvs01 ldirectord[6302]: Restored real server: 192.168.50.12:3389 ( x 192.168.53.200:3389) (Weight set to 1)

Oct 12 17:09:02 rpzlvs01 ldirectord[6302]: Restored real server: 192.168.50.13:3389 ( x 192.168.53.200:3389) (Weight set to 1)

Oct 12 17:09:02 rpzlvs01 ldirectord[6302]: Restored real server: 192.168.50.14:3389 ( x 192.168.53.200:3389) (Weight set to 1)

Oct 12 17:09:02 rpzlvs01 ldirectord[6302]: Restored real server: 192.168.50.15:3389 ( x 192.168.53.200:3389) (Weight set to 1)
```

----------

## Errtu

nobody knows?  :Sad: 

----------

## Janne Pikkarainen

Maybe you need to enable iptables masquerading? 

/sbin/iptables -t nat -A POSTROUTING -j MASQUERADE -s 192.168.53.0/24

Or something... other than that I can't figure out what's wrong with your setup, at least not without pondering about it lot longer.

----------

## Errtu

I did that too, yes  :Smile:   Thanks anyway for the reply. I'll keep on trying and maybe i'll stumble upon the solution, or some guru here has a clever insight ...

----------

## Errtu

 *kiksen wrote:*   

> Have you had a look at http://footon.jheslop.com/howto/LVS-HA-win2k-howto.html ?
> 
> I think it will help you all the way 
> 
> /kiksen

 

Why, oh why don't i LISTEN when somebody presents a possible solution? I have no idea, but the main thing is that i got it working now.  LVS-DR and a loopback device on all TS's and i now have a nice loadbalancing cluster  :Very Happy: 

Thanks!

And sorry for not listening immediately. I guess i'm stubborn and wanted to get it working without making changes to the current TS setup. Ah well ...

Léon

----------

