编译安装 keepalived-2.0.16.tar.gz

一、下载安装包

wget https://www.keepalived.org/software/keepalived-2.0.16.tar.gz

 安装相关依赖

编译安装 keepalived-2.0.16.tar.gz_第1张图片

把所有的rpm包放在一个目录下。

rpm -Uvh --force --nodeps *rpm

、解压并安装

tar xf keepalived-2.0.16.tar.gz

cd keepalived-2.0.16

./configure --prefix=/usr/local/keepalived

make && make install

cp /root/keepalived-2.0.16/keepalived/etc/init.d/keepalived /etc/init.d/

cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

mkdir /etc/keepalived

cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/

cp /usr/local/keepalived/sbin/keepalived /usr/sbin/

 三、修改master配置文件

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 127.0.0.1
   smtp_connect_timeout 30
   router_id NGINX_MASTER
}

vrrp_script check_nginx {
    script "/usr/local/nginx/sbin/check_nginx.sh"
}

vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 51 # VRRP 路由 ID实例,每个实例是唯一的
    priority 100    # 优先级,备服务器设置 90
    advert_int 1    # 指定VRRP 心跳包通告间隔时间,默认1秒
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.247.188/24
    }
    track_script {
        check_nginx
    }
}

 四、启动服务

systemctl start keepalived
systemctl enables keepalived

 五、检查vip

ip addr

编译安装 keepalived-2.0.16.tar.gz_第2张图片

 

你可能感兴趣的:(编译安装 keepalived-2.0.16.tar.gz)