zoukankan      html  css  js  c++  java
  • CentOS7配置keepalived

    实验操作环境:CentOS7机器两台

    操作目的:实现飘逸ip

    1、关闭防火墙,关闭selinux

    2、下载相关依赖包,实验用nginx校验

    3、上传nginx包

    4、编译安装nginx

    5、修改nginx测试页面

    6、脚本修改keepalived配置文件=

    #!/bin/bash
    echo "firewalld"
    systemctl stop firewalld && setenforce 0
    yum -y install gcc gcc-c++ pcre-devel zlib-devel keepalived
    tar zxf nginx-1.16.1.tar.gz
    cd nginx-1.16.1/
    ./configure && make && make install
    sed -i '1a<h1>Test<h1>' /usr/local/nginx/html/index.html
    sed -i '14d' /etc/keepalived/keepalived.conf
    sed -i 's/MASTER/BACKUP/' /etc/keepalived/keepalived.conf
    sed -i 's/eth0/ens33/' /etc/keepalived/keepalived.conf
    sed -i '23s/100/60/' /etc/keepalived/keepalived.conf
    sed -i '30,32d' /etc/keepalived/keepalived.conf
    sed -i '29a10.0.0.100' /etc/keepalived/keepalived.conf
    sed -i -e $'30s/^/	/' /etc/keepalived/keepalived.conf
    sed -i '58,$d' /etc/keepalived/keepalived.conf
    sed -i '37s/NAT/DR/' /etc/keepalived/keepalived.conf
    

      

    配置文件代码如下:

    ! 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     //删除路由,详情见  sed -i '14d' /etc/keepalived/keepalived.conf
       vrrp_skip_check_adv_addr
       vrrp_garp_interval 0
       vrrp_gna_interval 0
    }
    
    vrrp_instance VI_1 {
        state MASTER
        interface ens33
        virtual_router_id 51
        priority 100
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass 1111
        }
        virtual_ipaddress {
            10.0.0.100
        }
    }
    
    virtual_server 10.0.0.100 80 {
        delay_loop 6
        lb_algo rr
        lb_kind NAT
        nat_mask 255.255.255.0
        persistence_timeout 50
        protocol TCP
    
        real_server 10.0.0.32 80 {
            weight 1
            TCP_CHECK {
                connect_timeout 3
                connect_port 80
                nb_get_retry 3
                delay_before_retry 3
            }
        }
        real_server 10.0.0.33 80 {
            weight 1
            TCP_CHECK {
                connect_timeout 3
                connect_port 80
                nb_get_retry 3
                delay_before_retry 3
            }
        }
    }
    

      

  • 相关阅读:
    TextField KeyUp事件
    extjs 弹出windowsurl
    coolite TreePanel CheckBox联动
    自动生成储存过程及.net代码(sql2000,sql2005,sql2008)
    ComboBox三级关联
    ext window关闭
    DLL编写教程
    阿里云笔试题
    c/c++复杂声明的理解
    malloc/free与new/delete的区别
  • 原文地址:https://www.cnblogs.com/security-guard/p/12209307.html
Copyright © 2011-2022 走看看