网络环境
LVS-VIP 192.168.1.200
LVS-MASTER-192.168.1.228
LVS-SLAVE-192.168.1.229
LVS-MASTER-192.168.1.228
wgethttp://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
wget http://www.keepalived.org/software/keepalived-1.2.23.tar.gz
yum -yinstall libnl* popt* gcc wget vim openssh-clients
tar -zxvf ipvsadm-1.26.tar.gz
cdipvsadm-1.26
ln-s /usr/src/kernels/2.6.18-164.el5-i686/ /usr/src/linux
make && make install
pvsadm
cd..
tar-zxvf keepalived-1.2.23.tar.gz
cdkeepalived-1.2.23
./configure --prefix=/usr/local/keepalived
yuminstall openssh* -y
yuminstall -y openssl*
./configure --prefix=/usr/local/keepalived
make && make install
cp/usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp/usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp/usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp/usr/local/keepalived/sbin/keepalived /usr/sbin
service keepalived start
chkconfig keepalived on
echo "1" > /proc/sys/net/ipv4/ip_forward
vim /etc/keepalived/keepalived.conf
service keepalived restart
vim/etc/keepalived/keepalived.conf
##################################################################
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
[email protected]
[email protected]
}
notification_email_from [email protected]
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL_TEST_WEB
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 55
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.200
}
}
#Manger server
virtual_server 192.168.1.200 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 192.168.1.231 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.1.232 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
##################################################################
service keepalived restart
ip addr
servicekeepalived restart
LVS-SLAVE-192.168.1.229
wgethttp://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
wget http://www.keepalived.org/software/keepalived-1.2.23.tar.gz
yum-y install libnl* popt*
tar -zxvf ipvsadm-1.26.tar.gz
cdipvsadm-1.26
ln-s /usr/src/kernels/2.6.18-164.el5-i686/ /usr/src/linux
make && make install
pvsadm
cd..
tar-zxvf keepalived-1.2.23.tar.gz
cdkeepalived-1.2.23
./configure --prefix=/usr/local/keepalived
yuminstall openssh* -y
yuminstall -y openssl*
./configure --prefix=/usr/local/keepalived
make && make install
cp/usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp/usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp/usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp/usr/local/keepalived/sbin/keepalived /usr/sbin
service keepalived start
chkconfig keepalived on
echo "1" > /proc/sys/net/ipv4/ip_forward
vim /etc/keepalived/keepalived.conf
service keepalived restart
vim/etc/keepalived/keepalived.conf
##################################################################
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
[email protected]
[email protected]
}
notification_email_from [email protected]
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL_TEST_WEB
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state SLAVE
interface eth0
virtual_router_id 55
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.200
}
}
#Manger server
virtual_server 192.168.1.200 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 192.168.1.231 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.1.232 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
##################################################################
service keepalived restart
ip addr
service keepalived restart