keepalived安装

  1. 官网下载源码安装包http://www.keepalived.org/
  2. 解压
  3. ./configure
  4. make
  5. make install

修改配置文件

! 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_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}

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.18.113.122
    }
}
virtual_server 172.18.113.122 80 {
    delay_loop 3
    lb_algo rr
    lb_kind NAT
    persistence_timeout 50
    protocol TCP

    real_server 172.18.113.120 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 10
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }


}

keepalived启动

./keepalived

验证是否启动成功

[root@localhost sbin]# ip a |grep eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 172.18.113.120/24 brd 172.18.113.255 scope global eth0
    inet 172.18.113.122/32 scope global eth0
[root@localhost sbin]# 

wums
9 声望0 粉丝

那日;丹桂梢头缀,黄花绽竹篱。抛情引墨顿成诗,情也依依,爱也依依。