博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
lvs主备NAT模式上课用例(keepalived)
阅读量:6890 次
发布时间:2019-06-27

本文共 1696 字,大约阅读时间需要 5 分钟。

主节点配置

! Configuration File for keepalived

global_defs {

   notification_email {
   }
   notification_email_from 
   smtp_server smtp.163.com
   smtp_connect_timeout 30
   router_id LVS_master
}

vrrp_instance VIlvs {

    state MASTER
    interface eth2
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1122
    }
    virtual_ipaddress {
        172.16.11.200
        192.168.7.1 dev eth1
    }
}

virtual_server 172.16.11.200 80 {

    delay_loop 6
    lb_algo rr
    lb_kind NAT
    nat_mask 255.255.255.0
    #persistence_timeout 50
    protocol TCP

real_server 192.168.7.156 80 {

        weight 100
        TCP_CHECK {
        connect_timeout 10
        nb_get_retry 3
        delay_before_retry 3
                }

    }

real_server 192.168.7.158 80 {

        weight 100
        TCP_CHECK {
        connect_timeout 10
        nb_get_retry 3
        delay_before_retry 3
                }

    }

 

备节点配置

! Configuration File for keepalived

global_defs {

   notification_email {
   }
   notification_email_from 
   smtp_server smtp.163.com
   smtp_connect_timeout 30
   router_id LVS_slave
}

vrrp_instance VIlvs {

    state SLAVE
    interface eth5
    virtual_router_id 51
    priority 90
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1122
    }
    virtual_ipaddress {
        172.16.11.200
        192.168.7.1 dev eth4
    }
}

virtual_server 172.16.11.200 80 {

    delay_loop 6
    lb_algo rr
    lb_kind NAT
    nat_mask 255.255.255.0
    #persistence_timeout 50
    protocol TCP

real_server 192.168.7.156 80 {

        weight 100
        TCP_CHECK {
        connect_timeout 10
        nb_get_retry 3
        delay_before_retry 3
                }

    }

real_server 192.168.7.158 80 {

        weight 100
        TCP_CHECK {
        connect_timeout 10
        nb_get_retry 3
        delay_before_retry 3
                }

    }

 

 

内核参数设置

echo 1 > /proc/sys/net/ipv4/ip_forward

 

-A POSTROUTING -s 192.168.7.0/24 -o eth2 -j SNAT --to-source 172.16.11.162

 

WEB服务器节点

只需开启WEB服务,默认网关指向LVS服务器即可

 

本文转自 jxwpx 51CTO博客,原文链接:http://blog.51cto.com/jxwpx/1371345,如需转载请自行联系原作者
你可能感兴趣的文章
职场上,你有没有真正爱过一个人
查看>>
java B2B2C springmvc mybatis多租户电子商城系统-Spring Cloud Ribbon
查看>>
Golang标准库之Buffer
查看>>
“H5移动跨平台开发”APICloud课程
查看>>
Linux之LAMP搭建
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
【ssi】增删改查六操作小框架(一)
查看>>
maven常用命令
查看>>
Eclipse配置DTD
查看>>
OSX下制作USB启动盘
查看>>
Python 学习笔记之动态类型(进阶)
查看>>
如何快速创建一个addon
查看>>
什么是JAVA编程思想?
查看>>
Wowza Media Server 入门系列--Wowza Media Server 介绍
查看>>
探寻从HDFS到Spark的高效数据通道:以小文件输入为案例(转)
查看>>
关于“\”和“/”的使用
查看>>
MySQL学习笔记(一):shell脚本安装配置mysql
查看>>
Web程序运行原理
查看>>