【概述】

keepalive是一种高可用反向代理的工具。它最早就是为vrrp存在的。所以它最通用的功能是做vrrp的负载均衡使用的。一般常见的模型主要是单主或多主模型。其区别就是在配置文件的Vrrp定义中,多定义几个主备和优先级。

wKiom1QgDfDxPuOxAAEMCU69Ct0032.jpg

-------------------------------------------------------------------------------------------

【单主模式配置】

【主】

yum install keepalived

vim /etc/keepalived/keepalived.conf

global_defs {//全局定义

  notification_email {//邮件通知

    acassen@firewall.loc

    failover@firewall.loc

    sysadmin@firewall.loc

  }

  notification_email_from Alexandre.Cassen@firewall.loc

  smtp_server 192.168.200.1

  smtp_connect_timeout 30

  router_id LVS_DEVEL

}


vrrp_instance VI_1 {

state MASTER

interface eth0

virtual_router_id 10

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass londey

}

virtual_ipaddress {

172.16.35.100

}

}

【备】

yum install keepalived

vim /etc/keepalived/keepalived.conf

global_defs {

  notification_email {

    acassen@firewall.loc

    failover@firewall.loc

    sysadmin@firewall.loc

  }

  notification_email_from Alexandre.Cassen@firewall.loc

  smtp_server 192.168.200.1

  smtp_connect_timeout 30

  router_id LVS_DEVEL

}


vrrp_instance VI_1 {

state BACKUP

interface eth0

virtual_router_id 10

priority 95

advert_int 1

authentication {

auth_type PASS

auth_pass londey

}

virtual_ipaddress {

172.16.35.100

}

}

【启】

service keepalived start

【测】

tail -f /var/log/messages

-------------------------------------------------------------------------------------------

【双主模式配置】

【主】

yum install keepalived

vim /etc/keepalived/keepalived.conf

global_defs {

  notification_email {

    acassen@firewall.loc

    failover@firewall.loc

    sysadmin@firewall.loc

  }

  notification_email_from Alexandre.Cassen@firewall.loc

  smtp_server 192.168.200.1

  smtp_connect_timeout 30

  router_id LVS_DEVEL

}


vrrp_instance VI_1 {

state MASTER

interface eth0

virtual_router_id 10

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass londey

}

virtual_ipaddress {

172.16.35.100

}


vrrp_instance VI_2 {

state BACKUP

interface eth0

virtual_router_id 20

priority 95

advert_int 1

authentication {

auth_type PASS

auth_pass liaria

}

virtual_ipaddress {

172.16.35.200

}

}

【备】

yum install keepalived

vim /etc/keepalived/keepalived.conf

global_defs {

  notification_email {

    acassen@firewall.loc

    failover@firewall.loc

    sysadmin@firewall.loc

  }

  notification_email_from Alexandre.Cassen@firewall.loc

  smtp_server 192.168.200.1

  smtp_connect_timeout 30

  router_id LVS_DEVEL

}


vrrp_instance VI_1 {

state BACKUP

interface eth0

virtual_router_id 10

priority 95

advert_int 1

authentication {

auth_type PASS

auth_pass londey

}

virtual_ipaddress {

172.16.35.100

}


vrrp_instance VI_2 {

state MASTER

interface eth0

virtual_router_id 10

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass liaria

}

virtual_ipaddress {

172.16.35.200

}

}

【启】

service keepalived start

【测】

tail -f /var/log/messages