Environment:
Centos 7
Keepalived
Machine I
enp0s3 –> 192.168.1.38 (connects to the outside world)
en0s8 –> 192.168.100.101 (connects to internal network)
Machine II
enp0s3 –> 192.168.100.102
default gw –> 192.168.100.101
Machine II
enp0s3 –> 192.168.100.103
default gw –> 192.168.100.101
I have followed the tutorial here step by step. And while everyone in the comments says it works beautifully for them, I can´t get the keepalived demon to listen to its config file. It's a really simple set up. All I want to do is:
- Machine I acts as virtual server to the outside world, connecting to two real web servers (Machine II and Machine III).
- Machine I will first try to serve Machine II's service, if Machine II goes down nothing should happen, clients shouldn´t notice, and Machine I should instantly start serving Machine III's service.
Point 2) is supposed to get done with Keepalived, but it just won´t work. Here's the config file from /etc/keepalived/keepalived.conf
global_defs{
notification_email{
fake@yahoo.es
}
notification_email_from keepalived@domain.com
smtp_server 193.145.147.51
smtp_connect_timeout 30
lvs_id LVS_MAIN
}
vrrp_instance VI_1 {
interface enp0s3
state MASTER
virtual_router_id 51
priority 150
advert_int 1
virtual_ipaddress {
192.168.100.105/24 dev enp0s8
}
}
virtual_server 192.168.100.105 80 { !This would hosted in Machine I enp0s8
delay_loop 3
lb_algo wrr
lb_kind NAT
nat_mask 255.255.255.0
protocol TCP
real_server 192.168.100.102 8000 { !Machine II
weight 1
TCP_CHECK {
connect_timeout 3
connect_port 8000
}
}
real_server 192.168.100.103 8000 { !Machine III
weight 1
TCP_CHECK {
connect_timeout 3
connect_port 8000
}
}
}
When I run keepalived, and do sudo ip addr show enp0s8
I can see that keepalived has given the interface the virtual IP address 192.168.100.105 but when I go to Machine I's browser and put in as URL the ip addrss 192.168.100.105 nothing is given back, just timeout connection. But if I put in 192.168.100.102:8000 or 192.168.100.103:8000 I am greeted with my web service.
What could I have wrong with keepalived?
I appreciate any help.
Best Answer
in my case, i use LVS-DR. If you're using LVS-DR
Based on http://www.austintek.com/LVS/LVS-HOWTO/HOWTO/LVS-HOWTO.ipvsadm.html
Change the virtual address to
Change default gateway on your real servers to router NOT Director.
Change
to
Also you need to add iptables rules on real-server.
http://www.centos.org/docs/5/html/Virtual_Server_Administration/s2-lvs-direct-iptables-VSA.html
On Real Server 192.168.100.102 and 192.168.100.103
In this case become: