编译安装 keepalived


  • 编译安装
~]# yum install gcc pcre pcre-devel libnfnetlink-devel libnfnetlink ipvsadm  libnl libnl-devel libnl3 libnl3-devel lm_sensors-libs net-snmp-agent-libs net-snmp-libs  openssh-server openssh-clients openssl openssl-devel automake iproute -y
~]# cd /usr/local/src
src]# wget http://www.keepalived.org/software/keepalived-1.3.4.tar.gz
src]# tar xvf keepalived-1.3.4.tar.gz
src]# cd keepalived-1.3.4
keepalived-1.3.4]#  ./configure --prefix=/usr/local/keepalived --disable-fwmark
# 如下图确认无报错
编译安装 keepalived_第1张图片
image.png
keepalived-1.3.4]# make && amke install
编译安装 keepalived_第2张图片
image.png
  • 配置
keepalived-1.3.4]# cp /usr/local/src/keepalived-1.3.4/keepalived/etc/init.d/keepalived.rh.init /etc/sysconfig/keepalived.sysconfig
keepalived-1.3.4]# cp /usr/local/src/keepalived-1.3.4/keepalived/keepalived.service  /usr/lib/systemd/system/
keepalived-1.3.4]# ln -sv /usr/local/src/keepalived-1.3.4/bin/* /usr/sbin/

# 准备一个配置简单文件
~]# mkdir /etc/keepalived
~]# vim /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {
   notification_email {
     [email protected]
     [email protected]
     [email protected]
   }
   notification_email_from [email protected]
   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 80
    priority 100
    advert_int 1
    #unicast_src_ip 172.10.1.37
    #unicast_peer {
    #    172.10.1.38
    #}

    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.10.15 dev eth0 label eth0:0
    }
} 
  • 测试 keepalived 能否正常启动并绑定 VIP 到本地网卡


    编译安装 keepalived_第3张图片
    image.png

你可能感兴趣的:(编译安装 keepalived)