目录
调整master和backup的ARP参数(一致)全都安装一遍
启动master和backup的keepalived与ipvsadm
1、 Keepalived 是一个基于 VRRP 协议来实现的 LVS 服务高可用方案,可以解决静态路由出现的单点故障问题。
一、keepalived+lvs作用
使用keepalived解决lvs的单点故障
高可用集群
二、调度器配置
lvs的配置是一主一从和两台WEB服务器分别IP为
mgt192.168.28.3
master 192.168.28.4
slave1 192.168.28.5
slave2 192.168.28.6
部署LVS主备调度器
调整master和backup的ARP参数(一致)全都安装一遍
vim /etc/sysctl.conf
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects=0
net.ipv4.conf.ens33.send_redirects = 0
sysctl -p
安装keepalived
安装ipvsadm
yum install -y keepalived
yum install -y ipvsadm
modprobe ip_vs
配置keepalived
主配置完毕直接传送给从
scp keepalived.conf 192.168.28.4:/etc/keepalived/keepalived.conf
global_defs {
router_id NGINX1
}vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.28.200
}
}virtual_server 192.168.28.200 80 {
delay_loop 6
lb_algo rr
global_defs {
router_id NGINX1
}vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.28.200
}
}virtual_server 192.168.28.200 80 {
delay_loop 6
lb_algo rr
lb_kind DR
#persistence_timeout 50
protocol TCPreal_server 192.168.28.5 80 {
weight 1
HTTP_GET {
url {
path /
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.28.6 80 {
weight 1
HTTP_GET {
url {
path /
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
从
global_defs {
router_id NGINX1
}vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.28.200
}
}virtual_server