keepalived双机热备配置

修改配置文件/etc/keepalived/keepalived.conf

1.state行主机填MASTRT备机为BACKUP
2.priority行备机比主机小
3.virtual_ipaddress 所有虚拟IP地址,与virtual_server一一对应.
4.virtual_server{}包含real_server的IP和端口.real_server中添加connect_port 80标示连接端口

----------------------------------------配置文件示例-------------------------------------------

! Configuration File for keepalived

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 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.16.253.230
    }
}

virtual_server 172.116.253.230 80 {
    delay_loop 6
    lb_algo rr
    lb_kind NAT
    nat_mask 255.255.255.0
    persistence_timeout 50
    protocol TCP

    real_server 172.16.253.231 80 {
        weight 1
        SSL_GET {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
    real_server 172.16.253.232 80 {
        weight 1
        SSL_GET {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}
原文地址:https://www.cnblogs.com/viator42/p/3517616.html