首页 > 其他 > 详细

CentOS7操作keepalived

时间:2020-01-18 17:06:42      阅读:100      评论:0      收藏:0      [点我收藏+]

------------恢复内容开始------------

实验操作环境: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 ‘29a\10.0.0.100‘ /etc/keepalived/keepalived.conf
sed -i -e $‘30s/^/\t/‘ /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
        }
    }
}

  技术分享图片

CentOS7操作keepalived

原文:https://www.cnblogs.com/security-guard/p/12209307.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!