keepalived安裝

wums發表於2017-12-06

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]# 

相關文章