zhangkai 发表于 2023-6-29 14:46:45

keeplaived配置

本帖最后由 zhangkai 于 2023-7-13 11:57 编辑

精简版配置:
! Configuration File for keepalived
   
    global_defs {
      router_id lb01
    }
   
    vrrp_instance it {
      state MASTER
      interface eth0
      virtual_router_id 51
      priority 150
      advert_int 1
      authentication {
            auth_type PASS
            auth_pass 1111
      }
      virtual_ipaddress {
            10.0.0.100/24
      }
    }



第二版:
! Configuration File for keepalived
   global_defs {
       router_id lb01
    }

    vrrp_script check_web {
   script "/server/scripts/check_web.sh"
   interval 3   
   weight 2
    }

    vrrp_instance it {
      state MASTER
      interface eth0
      virtual_router_id 51
      priority 150
      advert_int 1
      authentication {
            auth_type PASS
            auth_pass 1111
      }
      virtual_ipaddress {
         10.0.0.100/24
      }
       track_script {
             check_web
       }
    }


#!/bin/bash
nginxpid=`ps -C nginx --no-header | wc -l`
if [ $nginxpid -eq 0 ];then
      systemctl stop keepalived
      pkill -9 keepalived   
fi


       

页: [1]
查看完整版本: keeplaived配置