lvs主备NAT模式上课用例(keepalived)

本文涉及的产品
公网NAT网关,每月750个小时 15CU
简介:

主节点配置

! Configuration File for keepalived

global_defs {
   notification_email {
admin@163.com
   }
   notification_email_from sender@163.com
   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 {
admin@163.com
   }
   notification_email_from sender@163.com
   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,如需转载请自行联系原作者
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
基于阿里云,构建一个企业web应用上云经典架构,让IT从业者体验企业级架构的实战训练。
目录
相关文章
|
1月前
|
运维 负载均衡 网络协议
LVS详解(六)——LVS DR模式实战
LVS详解(六)——LVS DR模式实战
26 5
|
1月前
|
运维 负载均衡 应用服务中间件
LVS详解(五)——LVS NAT模式实战
LVS详解(五)——LVS NAT模式实战
23 3
|
5月前
|
网络协议 Linux 网络架构
Linux三种网络模式 | 仅主机、桥接、NAT
Linux三种网络模式 | 仅主机、桥接、NAT
209 0
|
1月前
|
Linux 虚拟化
VMware workstation 中centos7虚拟机在nat模式下怎么配置网卡,指定我想要的IP并且可以联网
https://blog.csdn.net/2302_78534730/article/details/132825156?spm=1001.2014.3001.5502
137 0
|
16天前
|
运维 负载均衡 监控
keepalived+LVS实现高可用性集群
通过结合keepalived和LVS,你可以创建一个高可用性的负载均衡集群,确保服务器的稳定性和性能。这对于托管Web服务、应用服务器等关键服务的服务器集群非常有用。
26 1
|
20天前
|
负载均衡 监控 Linux
CentOS6.5高可用集群LVS+Keepalived(DR模式)
CentOS6.5高可用集群LVS+Keepalived(DR模式)
|
4月前
|
网络协议 虚拟化 网络架构
桥接模式和NAT模式的区别
桥接模式和NAT模式的区别
110 0
|
4月前
|
网络安全 虚拟化 Windows
RHEL7-NAT模式连接外部网络
RHEL7-NAT模式连接外部网络
24 1
|
7天前
|
安全 数据安全/隐私保护 网络架构
ensp中nat地址转换(静态nat 动态nat NAPT 和Easy IP)配置命令
ensp中nat地址转换(静态nat 动态nat NAPT 和Easy IP)配置命令
|
7天前
ENSP Nat地址转换(配置命令 )
ENSP Nat地址转换(配置命令 )