标签:keepalived
vm1:192.168.10.51 80
vm2:192.168.10.52 80
vip:192.168.10.55 80
一、下载安装
1)、wget http://www.keepalived.org/software/keepalived-1.2.9.tar.gz
tar zxf keepalived-1.2.9.tar.gz
./confifure --prefix=/usr/local/services/keepalived
make&&make install
2)、修改文件路径
sudo cp /usr/local/services/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
sudo cp /usr/local/services/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
sudo mkdir /etc/keepalived
sudo cp /usr/local/services/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
sudo cp /usr/local/services/keepalived/sbin/keepalived /usr/sbin/
二、配置
vim keepalived.conf
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER //BACKUP
interface eth0
virtual_router_id 51
priority 100 //90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.10.55
}
}
virtual_server 192.168.10.55 80 {
delay_loop 3
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 192.168.10.51 80 {
weight 1
TCP_CHECK {
connection_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 192.168.10.52 80 {
weight 1
TCP_CHECK {
connection_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
三、启动
sudo /etc/init.d/keepalived start
四、验证
ip add
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:8e:7e:4b brd ff:ff:ff:ff:ff:ff
inet 192.168.10.51/24 brd 192.168.10.255 scope global eth0
inet 192.168.10.55/32 scope global eth0
inet6 fe80::20c:29ff:fe8e:7e4b/64 scope link
valid_lft forever preferred_lft forever
浏览器访问http://192.168.10.55
标签:keepalived
原文地址:http://leyin01.blog.51cto.com/9062123/1705272