keepalived

2019-06-14  本文已影响0人  北疆07

keepalived高可用软件

1)VRRP协议,全称Virtual Router Redundancy Protocol,中文名为虚拟路由冗余协议,VRRP的出现是为了解决静态路由的单点故障。
3)VRRP是用过IP多播的方式(默认多播地址(224.0.0.18))实现高可用对之间通信的。
4)工作时主节点发包,备节点接包,当备节点接收不到主节点发的数据包的时候,就启动接管程序接管主节点的资源。备节点可以有多个,通过优先级竞选,但一般Keepalived系统运维工作中都是一对。

准备环境

准备机器lb01 lb02 web01 web02
lb01 lb02  安装软件
yum install keepalived  -y


[root@lb01 nginx]# rpm -qa keepalived 
keepalived-1.3.5-8.el7_6.x86_64

[root@lb02 ~]# rpm -qa keepalived 
keepalived-1.3.5-8.el7_6.x86_64

开启服务并设置开机自启动

lb01:
[root@lb01 nginx]# systemctl start keepalived.service 
[root@lb01 nginx]# systemctl enable keepalived.service 

lb02:
[root@lb02 ~]# systemctl start keepalived.service 
[root@lb02 ~]# systemctl enable keepalived.service

配置文件

#### 将以前的原文件备份
[root@lb01 nginx]# vim  /etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {
    router_id lb01
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 150
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
     10.0.0.3/24 dev eth0 label eth0:1  
    }
}


[root@lb02 nginx]# vim  /etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {
    router_id lb02
}

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
     10.0.0.3/24 dev eth0 label eth0:1  
    }
}
###然后去测试用抓包软件看一看
上一篇下一篇

猜你喜欢

热点阅读