1
Introduction:
I have following load balancing configuration:
10.0.1.31 - lb
10.0.1.32 - node1 (tomcat + mysql)
10.0.1.33 - node2 (tomcat + mysql)
I'm using keepalived which is redirecting packets to active nodes - shared ip address is 10.0.1.35
of course lb has required config:
echo "net.ipv4.ip_nonlocal_bind = 1" >> /etc/sysctl.conf
node1 and node2 to handle properly incoming packets needs to have 10.0.1.35 on lo
[root@lb-node1 ~]# ip addr list dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet 10.0.1.35/32 scope global lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
Problem:
Due to the fact that we have 10.0.1.35 on the lo if the locale tomcat is trying to connect to mysql via lb - connection is established to local instance.
I would like skipp lo for outgoing packets
Test
From node1 which has disabled mysql service and 10.0.1.35 ip on lo interface I'm trying to conenct to mysql on the node2
telnet 10.0.1.35 3306
unfortunately the result is
[root@lb-node1 ~]# telnet 10.0.1.35 3306
Trying 10.0.1.35...
telnet: connect to address 10.0.1.35: Connection refused
of course if I remove 10.0.1.35 IP from lo interface I'm able to connect to mysql instance on node2
Solution ?
I was trying do add routes with appropriate metrics but it doesn't help :/
[root@lb-node1 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.1.0 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
10.0.1.0 0.0.0.0 255.255.255.255 UH 100 0 0 lo
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
0.0.0.0 10.0.1.1 0.0.0.0 UG 0 0 0 eth0