LVS DR+keepalived: Only the vip address is a floating resource
. LVS DR achieves high availability through keepalived
Install the development package corresponding to the kernel
yum install kernel-xen-devel installs the development package corresponding to the current kernel
Install Keepalived
Unzip the tar xvzf keepalived-1.2.1.tar.gz and
enter the unzip directory: cd keepalived-1.2.1
Compile and install: ./configure --prefix=/ --mandir=/usr/local/share/man/ --with- kernel-dir=/usr/src/kernels/2.6.18-308.el5xen-i686/
make && make install
uname -r should be consistent with the kernel directory in the path after --with-kernel-dir
configuration file
进入:/etc/keepalived
编辑:vim keepalived.conf
! Configuration File for keepalived
global_defs {
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface eth0 //dip网卡
virtual_router_id 51
priority 100
advert_int 1
unicast_src_ip 192.168.20.131
unicast_peer {
192.168.20.132
}
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress { //设置vip地址
192.168.122.10/24 dev eth1
}
}
virtual_server 192.168.122.10 80 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
protocol TCP
real_server 192.168.122.100 80 {
weight 1
TCP_CHECK { //健康检查
connect_timeout 3
}
}
real_server 192.168.122.200 80 {
weight 1
TCP_CHECK {
connect_timeout 3
}
}
}