00-Ubuntu20.04下二进制部署keepalived

2021-09-13 10:20:10 浏览数 (1)

#sudo ufw disalbe

#sudo systemctl disalbe ufw

#sudo apt-get upgrade -y && apt-get update -y

#sudo apt-get install net-tools ntp make gcc libssl-dev openssl -y

#sudo cd /usr/src

#sudo tar -xf keepalived-2.2.4.tar.gz

#sudo cd keepalived-2.2.4/

#sudo ./configure //编译

#sudo make

#sudo make install

#sudo mkdir /etc/keepalived

#sudo cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf //根据模板修改配置文件

#sudo vim /etc/keepalived/keepalived.conf

代码语言:shell复制
! 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 master01.matrix.com  //路由id标识
   vrrp_skip_check_adv_add
   #vrrp_strict 
   vrrp_garp_interval 1
   vrrp_gna_interval 1
}
vrrp_instance VI_1 {
    state MASTER //角色标识,只起标识作用,BACKUP
    interface ens32 //接口
    virtual_router_id 51
    priority 100 //优先级,值越大越优先
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass matrix //邻居认证密码
    }
    virtual_ipaddress {
        192.168.63.151 dev ens32 label ens32:51 //虚拟IP
    }
}

#sudo cp /usr/src/keepalived-2.2.4/keepalived/keepalived.service /usr/lib/systemd/system/keepalived.service

#keepalived -t //测试keepalived配置

#sudo systemctl start keepalived.service

#sudo systemctl enable keepalived.service

使用命令验证

#systemctl status keepalived.service

#hostname -I //查看虚拟IP在哪个节点上

#ip a //查看网卡的IP

0 人点赞