HA集群(高可用集群)之keepalived+LVS/DR(详解二)

一、实验环境

keepalived+LVS-DR模式拓扑:
软件功能说明:
keepalived:实现中间件(代理服务器的高可用)。
LVS:是中间件软件(即代理服务器软件),是用来实现集群的负载均衡。

HA集群(高可用集群)之keepalived+LVS/DR(详解二)_第1张图片
1.client客户端:
ip:192.168.11.1

2.node11(master):
DIp:192.168.11.11
VIP:192.168.10.100
安装:keepalived ipvsadm

3.node12(back):
DIp:192.168.11.12
VIP:192.168.10.100
安装:keepalived ipvsadm

4.node13(real server):
绑定两个ip
192.168.11.13
192.168.11.14(不需要创建两台虚拟机)
安装httpd服务

二、实验部署

node11:
yum install -y keepalived ipvsadm
cp -av /etc/keepalived/keepalived.conf{,.bak}
yum -y install keepalived ipvsadm
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
}

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.11.100
192.168.11.111
}
}

virtual_server 192.168.11.100 80 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP

real_server 192.168.11.11 80 {
weight 1
SSL_GET {
url {
path /
digest ff20ad2481f97b1754ef3e12ecd3a9cc
}
url {
path /mrtg/
digest 9b3a0c85a887a256d6939da88aabd8cd
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

重启服务:
systemctl restart keepalived

cd /etc/keepalived
scp keepalived.conf 192.168.11.12:/etc/keepalived/(利用远程将keepalived文件复制到12机器上)

node12:
vim /etc/keepalived.kepealived.conf
找到并修改为:
state BACKUP
priority 90

重启服务:
systemctl restart keepalived

node13:
搭建http服务器,添加一个网卡,设置ip为192.168.11.14,利用apache基于ip的虚拟主机配置,搭建好服务器,就可以用你的192.168.11.1机器分别访问node11跟node12,查看返回结果(可以省略,直接在node11和node12可直接验证实验结果)

cat /etc/sysctl.conf
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.eth0.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2

sysct -p
ifconfig lo:0 192.168.11.100 netmask 255.255.255.255 broadcast 192.168.11.100 up

三、实验结果

node11(master)上的验证
ip a
HA集群(高可用集群)之keepalived+LVS/DR(详解二)_第2张图片
ipvsadm -Ln
在这里插入图片描述
node12
ip a
192.168.11.100的虚拟ip
然后停止
systemctl stop keepalived

node12(backup)上的验证

ip a
HA集群(高可用集群)之keepalived+LVS/DR(详解二)_第3张图片

ipvsadm -Ln
HA集群(高可用集群)之keepalived+LVS/DR(详解二)_第4张图片

你可能感兴趣的:(HA集群(高可用集群)之keepalived+LVS/DR(详解二))