+ |
Figure 1 Network deployment of the test environment for the keepalived's VIP failover |
Ok, having the picture in mind let's get to work.
Test envrionment setup
The presented below points show how to configure it:
- Define additional Interconnect network. For doing that I used the virt-manager GUI: Edit->Connection Details and there should a window appear (just as the one presented on the Figure 2). In the Virtual Networks tab you should add a new network (a '+' button in the bottom of the window)
Figure 2 Interconnect virtual network - Install two machines (Host A and B) that will be hosting the keepalived. I already had one CentOS kvm which I cloned to have the Host B (using virt-manager it is very simple and can be done via main GUI)
- Install keepalived. CentOS does not have the keepalived in its repos so I had to download the latest sources from the web: http://www.keepalived.org/software/keepalived-1.2.2.tar.gz. After unpacking I did not have to download any additional dependencies and I just followed the INSTALL instructions - as usual steps: configure, make, make install ;) In order to build the keepalived only once (for two hosts) you might also install it before cloning the image (after the image has been cloned it has the keepalived).
- Configure sysctl. In the manual I read that one should enhance the sysctl configuration in order to allow the application to bind to non local addresses - add these line to /etc/sysctl.conf:
net.ipv4.ip_nonlocal_bind = 1
and execute:
sysctl -p - Reconfigure firewall. The keepalived utilizes multicast address (224.0.0.18) for exchanging information about the status of the nodes belonging to specific groups. What needs to be done is to allow the multicast traffic to go over the Interconnect network (eth0) interface. In my case for testing purposes I have just disabled the firewall (in Gnome: System->Administration->Security Level and Firewall)
- Configure the master host (Host A). One needs to adapt or create the /etc/keepalived/keepalived.conf file as follows:
[root@localhost ~]# cat /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 102
virtual_ipaddress {
192.168.122.50/24 brd 192.168.122.255 dev eth1 label eth1:0
}
}
where eth0 is the interface for interconnect and eth1 is the interface for communication with external world (VIP)
- Configure the backup host (Host B). The configuration file /etc/keepalived/keepalived.conf would be mostly the same for both hosts (as for host A) - what one has to remember is to set the Host B into backup mode with lower priority
[root@centos1-priv ~]# cat /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 101
virtual_ipaddress {
192.168.122.50/24 brd 192.168.122.255 dev eth1 label eth1:0
}
}
where eth0 is the interface for interconnect and eth1 is the interface for communication with external world (VIP)
- Startup keepalived on both hosts. The best way to start the keepalived is to use the init/startup scripts provided with the source package
# /etc/init.d/keepalived start
If you cannot find the script you can get it from the keepalived source package - Proceed to the test (see Part 2)
Brak komentarzy:
Prześlij komentarz