图片 9

Linux虚拟服务器,负载均衡器的可用性也显得至关重要

     
 图片 1

LVS1 LVS2 RS1 RS2
ens4:193.168.140.79 ens4:193.168.140.83 ens4:193.168.140.152
ens4:193.168.140.224

1、编写好本子

本子主要内容:检查实验到宗旨产生变化,或错误,给何人发邮件;邮件内容是:在怎么日子,哪个人暴发了怎么变动

vim /etc/keepalived/notify.sh

#!/bin/bash
# Author: www.magedu.com
contact='root@localhost'
notify() {
        mailsubject="$(hostname) to be $1: vip floating"
        mailbody="$(date +'%F %H:%M:%S'): vrrp transition, $(hostname) changed to be $1"
        echo $mailbody | mail -s "$mailsubject" $contact
}
case $1 in
master) 
        notify master
        exit 0
;;
backup)
        notify backup
        exit 0
;;
fault)
        notify fault
        exit 0
;;
*)
        echo "Usage: $(basename $0) {master|backup|fault}"
        exit 1
;;
esac

本子加权限 chmod +x /etc/keepalived/notify.sh

 

修改DR1和DR2:

[root@DR1 ~]# vim /etc/keepalived/keepalived.conf   #修改DR1的配置文件,添加新的实例,配置服务器组
    ...
    vrrp_instance VIP_2 {
        state BACKUP
        interface eno16777736
        virtual_router_id 2
        priority 90
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass UU**99^^
        }
        virtual_ipaddress {
            192.168.4.121/24 dev eno16777736 label eno16777736:1
        }
    }

    virtual_server_group ngxsrvs {
        192.168.4.120 80
        192.168.4.121 80
    }
    virtual_server group ngxsrvs {
        ...
    }
[root@DR1 ~]# systemctl restart keepalived.service   #重启服务
[root@DR1 ~]# ifconfig   #此时可以看到eno16777736:1,因为DR2还未配置
    eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.4.116  netmask 255.255.255.0  broadcast 192.168.4.255
            inet6 fe80::20c:29ff:fe93:270f  prefixlen 64  scopeid 0x20<link>
            ether 00:0c:29:93:27:0f  txqueuelen 1000  (Ethernet)
            RX packets 54318  bytes 5480463 (5.2 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 38301  bytes 3274990 (3.1 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    eno16777736:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.4.120  netmask 255.255.255.0  broadcast 0.0.0.0
            ether 00:0c:29:93:27:0f  txqueuelen 1000  (Ethernet)

    eno16777736:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.4.121  netmask 255.255.255.0  broadcast 0.0.0.0
            ether 00:0c:29:93:27:0f  txqueuelen 1000  (Ethernet)
[root@DR1 ~]# ipvsadm -ln
    IP Virtual Server version 1.2.1 (size=4096)
    Prot LocalAddress:Port Scheduler Flags
      -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
    TCP  192.168.4.120:80 rr
      -> 192.168.4.118:80             Route   1      0          0         
      -> 192.168.4.119:80             Route   1      0          0         
    TCP  192.168.4.121:80 rr
      -> 192.168.4.118:80             Route   1      0          0         
      -> 192.168.4.119:80             Route   1      0          0

[root@DR2 ~]# vim /etc/keepalived/keepalived.conf   #修改DR2的配置文件,添加实例,配置服务器组
    ...
    vrrp_instance VIP_2 {
        state MASTER
        interface eno16777736
        virtual_router_id 2
        priority 100
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass UU**99^^
        }
        virtual_ipaddress {
            192.168.4.121/24 dev eno16777736 label eno16777736:1
        }
    }

    virtual_server_group ngxsrvs {
        192.168.4.120 80
        192.168.4.121 80
    }
    virtual_server group ngxsrvs {
        ...
    }
[root@DR2 ~]# systemctl restart keepalived.service   #重启服务
[root@DR2 ~]# ifconfig
    eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.4.117  netmask 255.255.255.0  broadcast 192.168.4.255
            inet6 fe80::20c:29ff:fe3d:a31b  prefixlen 64  scopeid 0x20<link>
            ether 00:0c:29:3d:a3:1b  txqueuelen 1000  (Ethernet)
            RX packets 67943  bytes 6314537 (6.0 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 23250  bytes 2153847 (2.0 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    eno16777736:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.4.121  netmask 255.255.255.0  broadcast 0.0.0.0
            ether 00:0c:29:3d:a3:1b  txqueuelen 1000  (Ethernet)
[root@DR2 ~]# ipvsadm -ln
    IP Virtual Server version 1.2.1 (size=4096)
    Prot LocalAddress:Port Scheduler Flags
      -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
    TCP  192.168.4.120:80 rr
      -> 192.168.4.118:80             Route   1      0          0         
      -> 192.168.4.119:80             Route   1      0          0         
    TCP  192.168.4.121:80 rr
      -> 192.168.4.118:80             Route   1      0          0         
      -> 192.168.4.119:80             Route   1      0          0 

3.2.2 LVS
vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
qingean@163.com #故障选择联系人
}
notification_email_from admin@test.com #故障发赠给外人
smtp_server 127.0.0.1 #本机发送邮件
smtp_connect_timeout 30
router_id LVS_MASTER #BACKUP上纠正为LVS_BACKUP
}
vrrp_instance VI_1 {
state MASTER #BACKUP上修改正改为BACKUP
interface ens4
virtual_router_id 51 #虚构路由标记,主从相近
priority 100 #BACKUP上改换为90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111 #主导认证密码必须生机勃勃律
}
virtual_ipaddress {
193.168.140.80 #虚拟IP(VIP)
}
}
vrrp_instance LAN_GATEWAY { #概念网关
state MASTER #BACKUP上改换为BACKUP
interface ens3
virtual_router_id 62 #虚构路由ID,主从相仿
priority 100 #BACKUP上修改过改为90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress { #ens3网关设想IP
192.168.102.165
}
}
virtual_server 192.168.102.165 80 { #概念内网网关设想IP和端口
delay_loop 6 #检查RS时间,单位秒
lb_algo rr
#安装负载调治算法,轮叫(rr)、加权轮叫(wrr)、最小连接(lc)、加权最小连接(wlc)、基于局地性最小连接(lblc)、带复制的依赖局地性起码链接(lblcr)、目之处散列(dh)和源地址散列(sh)
lb_kind NAT #安装LVS负载均衡NAT情势
persistence_timeout 50
#同意气风发IP的接连60秒内被分配到相似台实在服务器(测量检验时建议改为0)
protocol TCP #运用TCP合同检查QashqaiS状态
real_server 192.168.102.161 80 { #第三个网关节点
weight 3 #节点权重值
TCP_CHECK { #健康检查方式
connect_timeout 3 #接连超时
nb_get_retry 3 #重试次数
delay_before_retry 3 #重试间隔/S
}
}
real_server 192.168.102.162 80 { #第二个网关节点
weight 3
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
virtual_server 193.168.140.80 80{ #概念虚构IP
delay_loop 6
lb_algo rr
lb_kind NAT
persistence_timeout 50
protocol TCP
real_server 192.168.102.163 80 { #第一个RS
weight 3
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 192.168.102.164 80 { #第二个RS
weight 3
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
3.2.3 RS
为富有EscortS增添网关为192.168.102.165:
vim /etc/sysconfig/network-scripts/ifcfg-ens3
GATEWAY=192.168.102.165
重启; 使用route –n查看是不是中标
IPVS connection entries
pro expire state source virtual destination
TCP 01:54 FIN_WAIT 10.167.225.60:53882 193.168.140.80:80
192.168.102.163:80
TCP 00:37 NONE 10.167.225.60:0 193.168.140.80:80 192.168.102.163:80

4、在real server 上

(1卡塔 尔(阿拉伯语:قطر‎ 开启事前构思好的web服务

systemctl start nginx

systemctl start mariadb

systemctl start php-fpm

 

(2)因为是NAT模式,需在rs上设置

只需把网关指向DIP

route add default gw 192.168.30.100

 

参照EvoqueS1的配备搭建大切诺基S2。

3.3.2 LVS
vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
qingean@163.com
}
notification_email_from admin@test.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_MASTER
}
vrrp_instance VI_1 {
state MASTER #BACKUP上校勘为BACKUP
interface ens4
virtual_router_id 51
priority 100 #BACKUP上改良为90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
193.168.140.80
}
}
virtual_server 193.168.140.80 80 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.255
protocol TCP
real_server 193.168.140.152 80 {
weight 10
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 193.168.140.224 80 {
weight 10
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}

 

图片 2

 

实验四:完成keeaplived 故障通报机制

DSportage1和D中华V2铺排keepalived和lvs作主从架构或主主架构,RubiconS1和凯雷德S2配置nginx搭建web站点。

1 Keepalived是怎样,有何样成效?
1.1 Keepalived的定义
Keepalived 是叁个基于V奇骏RP协议来落实的LVS高可用方案
1.2 Keepalived的作用
1.2.1 通过IP漂移落成高可用
主副LVS分享三个杜撰IP,同时独有二个LVS据有VIP并对外提供劳务,若该LVS不可用,则VIP漂移至另风姿洒脱台LVS并对外提供服务;
1.2.2 对锐界S集群实增势况监察和控制
若宝马X5S不可用,则keepalived将其从集群中摘除,若MuranoS苏醒,则keepalived将其重新参预集群中。
2 Keepalived有三种方式,种种格局的相符点和分裂点是何许?
2.1 Keepalived的形式种类
Keepalived有3种形式:NAT(地址调换卡塔 尔(阿拉伯语:قطر‎;DMurano(直接路由卡塔尔国;TUN(隧道卡塔尔国
2.2 Keepalived的各样方式的介绍
2.2.1 NAT
可取:集群中的CRUISERS能够利用此外来帮衬助TCP/IP操作系统,瑞鹰S能够分配Internet的保留私有地址,独有LVS要求三个法定的IP地址。
症结:增添性有限。当迈凯伦540CS节点增进到拾柒个或越来越多时,LVS将成为任何系统的瓶颈,因为有着的央浼包和回复包都亟待通过LVS再生。
2.2.2 TUN
咱俩开采,多数Internet服务(比如WEB服务器卡塔尔的乞求包非常的短小,而应答包平时不小。
可取:LVS只担当将号令包分发给RubiconS,而TucsonS将回应包直接发放用户。所以,LVS能管理很伟大的恳求量,这种方法,生机勃勃台载荷均衡能为超越100台的奇骏S服务,LVS不再是系统的瓶颈。
缺陷:不过,这种措施亟待具备的服务器扶持”IP Tunneling”(IP
Encapsulation)合同,作者仅在Linux系统上完结了这几个。
2.2.3 DR
亮点:和TUN相符,LVS也只是散发央求,应答包通过独立的路由方法重回给客商端。与TUN比较,DQX56这种实现方式不必要隧道结构,因而可以利用大多数操作系统做为SportageS。
不足:供给LVS的网卡必需与哈弗S的网卡在一个网段上
3 不相同方式的布署情势,验证形式分别是何等?
3.1 基本的条件必要
需要2台LVS和n(n>=2)台RS
3.1.1 LVS
设置ipvsadm(LVS管理工科具卡塔 尔(阿拉伯语:قطر‎和keepalived;
开启路由转载成效:
vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
验证:
sysctl -p
net.ipv4.ip_forward = 1
3.1.2 RS
安装httpd(用于最终测量检验卡塔 尔(阿拉伯语:قطر‎
3.2 NAT形式配置
3.2.1 遭受概述
操作系统 负载均衡格局 VIP NVIP
RHEL7.4 NAT 193.168.140.80 192.168.102.165

实验三:完结keepalived主从章程高可用基于LVS-NAT方式的行使实战:

试验原理:

主从:风华正茂主生龙活虎从,主的在办事,从的在休养;主的宕机了,VIP和DIP都漂移到从上,由从提供劳动,因为DIP需被rs作为网关,所以也需上浮

keepalived的中央架构

3.3 DEnclave格局配置
3.3.1 情形概述
操作系统 负载均衡情势 VIP
RHEL7.4 DR 193.168.140.80

2、在lvs-server-master 主上

(1)vim keepalived.conf

global_defs {
   notification_email {
        root@localhost
   }
   notification_email_from root@along.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id keepalived_lvs
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass along
    }
    virtual_ipaddress {
       172.17.100.100
192.168.30.100
    }
}

virtual_server 172.17.100.100 80 {
    delay_loop 6
    lb_algo wrr
    lb_kind NAT
    nat_mask 255.255.255.255
    persistence_timeout 100
    protocol TCP

    real_server 192.168.30.107 80 {
        weight 1
        HTTP_GET {
            url {
              path /
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }

    real_server 192.168.30.7 80 {
        weight 2
        HTTP_GET {
            url {
              path /
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

 

(2卡塔 尔(英语:State of Qatar)因为是NAT模式,所以需开启路由转载效率

vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

 

sysctl -p 读一些,使参数生效

 

(3)开启keepalived 服务

service keepalived start

能看见网卡别名 和 负载均衡计策已经设置好了

图片 3

ipvsadm -Ln

图片 4

 

(4卡塔尔国因为是中央情势,所以从上的布局和主只有某个差距;所以能够把这一个布局文件拷过去

scp /etc/keepalived/keepalived.conf @172.17.11.11:

 

3、在lvs-server-backup
从上

(1卡塔尔只需改②实例段,别的都不要变,保险千篇一律

vrrp_instance VI_1 {
    state BACKUP
    interface eth1
    virtual_router_id 51
    priority 99
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass along
    }

 

 

(2卡塔 尔(阿拉伯语:قطر‎因为是NAT方式,所以需开启路由转载功效

① vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

② sysctl -p 读一些,使参数生效

 

(3)开启keepalived 服务

service keepalived start

负载均衡战术已经安装好了,注意:主director未有宕机,从上就不会有VIP

ipvsadm -Ln 恐怕过一会才展览会示

图片 5

 

搭建DR1:

[root@DR1 ~]# yum -y install ipvsadm keepalived   #安装ipvsadm和keepalived
[root@DR1 ~]# vim /etc/keepalived/keepalived.conf   #修改keepalived.conf配置文件
    global_defs {
       notification_email {
         root@localhost
       }
       notification_email_from keepalived@localhost
       smtp_server 127.0.0.1
       smtp_connect_timeout 30
       router_id 192.168.4.116
       vrrp_skip_check_adv_addr
       vrrp_mcast_group4 224.0.0.10
    }

    vrrp_instance VIP_1 {
        state MASTER
        interface eno16777736
        virtual_router_id 1
        priority 100
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass %&hhjj99
        }
        virtual_ipaddress {
          192.168.4.120/24 dev eno16777736 label eno16777736:0
        }
    }

    virtual_server 192.168.4.120 80 {
        delay_loop 6
        lb_algo rr
        lb_kind DR
        protocol TCP

        real_server 192.168.4.118 80 {
            weight 1
            HTTP_GET {
                url {
                  path /index.html
                  status_code 200
                }
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 3
            }
        }
        real_server 192.168.4.119 80 {
            weight 1
            HTTP_GET {
                url {
                  path /index.html
                  status_code 200
                }
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 3
            }
         }
    }
[root@DR1 ~]# systemctl start keepalived
[root@DR1 ~]# ifconfig
    eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.4.116  netmask 255.255.255.0  broadcast 192.168.4.255
            inet6 fe80::20c:29ff:fe93:270f  prefixlen 64  scopeid 0x20<link>
            ether 00:0c:29:93:27:0f  txqueuelen 1000  (Ethernet)
            RX packets 14604  bytes 1376647 (1.3 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 6722  bytes 653961 (638.6 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    eno16777736:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.4.120  netmask 255.255.255.0  broadcast 0.0.0.0
            ether 00:0c:29:93:27:0f  txqueuelen 1000  (Ethernet)
[root@DR1 ~]# ipvsadm -ln
    IP Virtual Server version 1.2.1 (size=4096)
    Prot LocalAddress:Port Scheduler Flags
      -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
    TCP  192.168.4.120:80 rr
      -> 192.168.4.118:80             Route   1      0          0         
      -> 192.168.4.119:80             Route   1      0          0

LVS1 LVS2 RS1 RS2
ens3:192.168.102.161 ens3:192.168.102.162 ens3:192.168.102.163
ens3:192.168.102.164
ens4:193.168.140.79 ens4:193.168.140.83 网关:192.168.102.165
网关:192.168.102.165

yum -y install keepalived

实例拓扑图:


LVS(Linux Virtual
Server):Linux设想服务器,这里透过keepalived作为负载均衡器
LANDS(Real Server):真实服务器
V奥迪Q3RP(Virtual Router Redundancy Protocol): 虚构路由冗余钻探,
祛除局域网中配置静态网关出现单点失效现象的路由公约
图片 6

3、在lvs-server2 上,基本同1,正是把实例的主导沟通一下

(1)vim /etc/keepalived/keepalived.conf

① vrrp_instance VI_1 {
    state BACKUP
    interface eth1
    virtual_router_id 51
    priority 98
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass along
    }
    virtual_ipaddress {
        172.17.100.100
    }
}
② vrrp_instance VI_2 {
    state MASTER
    interface eth1
    virtual_router_id 52
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass along
    }
    virtual_ipaddress {
        172.17.100.101
    }
}

 

(2)开启keepalived 服务

service keepalived start

能看见网卡别名 和 负载均衡战术已经安装好了,显示结果会等段时日再显示

图片 7

ipvsadm -Ln,展现结果会等段时间再呈现

图片 8

 

客商端实行测量试验:

[root@client ~]# for i in {1..20};do curl http://192.168.4.120;done   #客户端正常访问
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>

[root@DR1 ~]# systemctl stop keepalived.service   #关闭DR1的keepalived服务

[root@DR2 ~]# systemctl status keepalived.service   #观察DR2,可以看到DR2已经进入MASTER状态
● keepalived.service - LVS and VRRP High Availability Monitor
   Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-09-04 11:33:04 CST; 7min ago
  Process: 12983 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 12985 (keepalived)
   CGroup: /system.slice/keepalived.service
           ├─12985 /usr/sbin/keepalived -D
           ├─12988 /usr/sbin/keepalived -D
           └─12989 /usr/sbin/keepalived -D

Sep 04 11:37:41 happiness Keepalived_healthcheckers[12988]: SMTP alert successfully sent.
Sep 04 11:40:22 happiness Keepalived_vrrp[12989]: VRRP_Instance(VIP_1) Transition to MASTER STATE
Sep 04 11:40:23 happiness Keepalived_vrrp[12989]: VRRP_Instance(VIP_1) Entering MASTER STATE
Sep 04 11:40:23 happiness Keepalived_vrrp[12989]: VRRP_Instance(VIP_1) setting protocol VIPs.
Sep 04 11:40:23 happiness Keepalived_vrrp[12989]: Sending gratuitous ARP on eno16777736 for 192.168.4.120
Sep 04 11:40:23 happiness Keepalived_vrrp[12989]: VRRP_Instance(VIP_1) Sending/queueing gratuitous ARPs on eno16777736 for 192.168.4.120
Sep 04 11:40:23 happiness Keepalived_vrrp[12989]: Sending gratuitous ARP on eno16777736 for 192.168.4.120
Sep 04 11:40:23 happiness Keepalived_vrrp[12989]: Sending gratuitous ARP on eno16777736 for 192.168.4.120
Sep 04 11:40:23 happiness Keepalived_vrrp[12989]: Sending gratuitous ARP on eno16777736 for 192.168.4.120
Sep 04 11:40:23 happiness Keepalived_vrrp[12989]: Sending gratuitous ARP on eno16777736 for 192.168.4.120

[root@client ~]# for i in {1..20};do curl http://192.168.4.120;done   #可以看到客户端正常访问
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>
<h1> 192.168.4.119 RS2 server</h1>
<h1> 192.168.4.118 RS1 server </h1>

3.3.3 RS
为所有RS修改sysctl.conf
net.ipv4.conf.lo.arp_ignore= 1
net.ipv4.conf.lo.arp_announce= 2
net.ipv4.conf.all.arp_ignore= 1
net.ipv4.conf.all.arp_announce= 2
net.ipv4.ip_forward= 1
执行/sbin/ifconfig lo:0 193.168.140.80 broadcast 193.168.140.80 netmask
255.255.255.255
可用route –n查看是还是不是中标
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 193.168.1.1 0.0.0.0 UG 100 0 0 ens4
193.168.0.0 0.0.0.0 255.255.0.0 U 100 0 0 ens4
193.168.140.80 0.0.0.0 255.255.255.255 UH 0 0 0 lo
若不成事实行/sbin/route add -host 193.168.140.80 dev lo:0
3.4 验证方式
3.4.1 全体机器关闭防火墙:
systemctl stop firewalld
3.4.2 全体昂科雷S写入测量试验页和开启httpd服务
RS1:echo “RS1″ > /var/www/html/index.html
RS2:echo “RS2″ > /var/www/html/index.html
systemctl start httpd
3.4.3 主副LVS开启keepalived服务
systemctl start keepalived
3.4.4 访问
浏览器采访
刷新会轮换体现CRUISERS1或中华VS2
3.4.5 查看当前测量试验机的访谈乞求被转正到哪些服务器
ipvsadm –lcn
IPVS connection entries
pro expire state source virtual destination
TCP 01:54 FIN_WAIT 10.167.225.60:53882 193.168.140.80:80
192.168.102.163:80
TCP 00:37 NONE 10.167.225.60:0 193.168.140.80:80 192.168.102.163:80
3.4.6 测试
仿照宕掉主LVS,服务器照常工作,再宕掉Web1,那个时候只会显得Web2,那样就落实IP负载均衡,高可用集群。当主LVS恢复生机后,会切换到主动服务器,尽管Keepalived监控模块检验web故障复苏后,苏醒的主机又将此节点参加集群系统中。

  情状:随着职业的前行,网址的访问量越来越大,网址访谈量已经从原先的1000QPS,变为3000QPS,近年来专门的职业已经通过集群LVS框架结构可达成任何时候开展,后端节点已经经过集群手艺保证了可用性,但对于前端负载均衡器来说,是个非常大的安全祸患,因为近年来端负载均衡器现身故障时,整个集群就处在瘫痪状态,因而,负载均衡器的可用性也体现重要,那么怎么来消除负载均衡器的可用性难点啊?

keepalived的主主架构

3、在lvs-server-backup 从上

(1卡塔尔国只需改②实例段,别的都不要变,保障一模一样

vrrp_instance VI_1 {
    state BACKUP
    interface eth1
    virtual_router_id 51
    priority 99
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass along
    }

 

(2)开启keepalived 服务

service keepalived start

负载均衡战术已经设置好了,注意:主director未有宕机,从上就不会有VIP

ipvsadm -Ln 恐怕过一会才博览会示

图片 9

 

经过命令ifconfig能够查见到是或不是张开了MULTICAST:

 总项目流程图,详见 

发表评论

电子邮件地址不会被公开。 必填项已用*标注

相关文章