keepalived实验图:
实验环境介绍:
操作系统:Centos7.2
VIP:192.168.233.100
VIP:192.168.233.100
RIP:192.168.233.131
RIP:192.168.233.132
软件部署介绍:
lvs+keepalivd(1) (backup master)
一、环境检查:
关闭系统防火墙
systemctl stop firewalld.service
检查系统是否支持ip_vs
modprobe ip_vs 加载ip_vs模块
lsmod |grep ip_vs 查询模块
二、配置keepalived
(1)安装keepalived,并配置lvs
yum install keepalived -y
yum install ipvsadm -y
(2)主配置文件路径
vim /etc/keepalived/keepalived.conf
配置文件如下:
! Configuration File for keepalived
global_defs {
notification_email {
root@localhost
}
notification_email_from admin@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 10
router_id 51
}
vrrp_instance VI_1 {
state BACKUP
interface eno16777736
virtual_router_id 51
priority 90
advert_int 3
authentication {
auth_type PASS
auth_pass 123.com
}
virtual_ipaddress {
192.168.233.100
}
}
virtual_server 192.168.233.100 80 {
delay_loop 3
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 300
protocol TCP
real_server 192.168.233.131 80 {
weight 1
HTTP_GET {
url {
path /var/www/lighttpd/index.html
digest 389975d8d57ca94e672162998e06c017
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.233.132 80 {
weight 1
HTTP_GET {
url {
path /var/www/lighttpd/index.html
digest 389975d8d57ca94e672162998e06c017
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
vrrp_instance VI_2 {
state MASTER
interface eno16777736
virtual_router_id 52
priority 100
advert_int 3
authentication {
auth_type PASS
auth_pass qq.com
}
virtual_ipaddress {
192.168.233.101
}
}
virtual_server 192.168.233.101 80 {
delay_loop 3
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 300
protocol TCP
real_server 192.168.233.131 80 {
weight 1
HTTP_GET {
url {
path /var/www/lighttpd/index.html
digest 389975d8d57ca94e672162998e06c017
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.233.132 80 {
weight 1
HTTP_GET {
url {
path /var/www/lighttpd/index.html
digest 389975d8d57ca94e672162998e06c017
}
connect_timeout 3
nb_get_retry