On Sun, Sep 19, 2010 at 04:59:44PM +0200, Tomasz Chmielewski wrote: > Is it possible to load balance queries to localhost? > > Say, I have two servers - I'd like them to be both directors and realservers. > > > Application connecting to localhost:1111 should be connected to either one or > the other server. Despite many tries, I'm not able to achieve this. > > I had partial success with LVS-NAT rules: > > -A -t 127.0.0.1:1111 -s lc > -a -t 127.0.0.1:1111 -r 10.0.0.10:1111 -m -w 1 # same server as localhost, > works > -a -t 127.0.0.1:1111 -r 10.0.0.20:1111 -m -w 1 # remote server > > > Where the remote realserver receives the packet: > > 16:54:18.078365 IP (tos 0x10, ttl 64, id 52411, offset 0, flags [DF], proto > TCP (6), length 60) 127.0.0.1.50427 > 10.0.0.20.1111: S, cksum 0xc03d > (correct), 1282046761:1282046761(0) win 32792 <mss 16396,sackOK,timestamp > 178066 0,nop,wscale 7> > > > But I guess it's confused about what to do with it, since it appears to come > from 127.0.0.1.
Yes, I think that is is confused because it comes from 127.0.0.1. You need to make sure that the source address of that the client (application) uses is one that the real-server can route to. Typically the primary IP address on eth0. If you can't set the application up to use a different source address directly, then you may be better off to use a 10.0.0.x address as the VIP (instead of 127.0.0.1). Alternatively you may have some luck using the dnat feature which will be introduced in 2.6.35. http://www.spinics.net/lists/netdev/msg135919.html _______________________________________________ Please read the documentation before posting - it's available at: http://www.linuxvirtualserver.org/ LinuxVirtualServer.org mailing list - [email protected] Send requests to [email protected] or go to http://lists.graemef.net/mailman/listinfo/lvs-users
