当前位置:网站首页>LVS四层负载均衡集群(6)LVS工作模式
LVS四层负载均衡集群(6)LVS工作模式
2022-06-13 03:34:00 【51CTO】
NAT转发模式
Network Address Translation,网络地址转换
- CIP:客户端IP地址/发起方/源IP地址
- VIP:虚拟IP/lvs集群IP
- RIP:真实服务器IP/WEB集群IP/web服务器
工作原理
①.客户端将请求发往前端的负载均衡器,请求报文源地址是CIP(客户端IP),后面统称为CIP),目标地址为VIP(负载均衡器前端地址,后面统称为VIP)。
②.负载均衡器收到报文后,发现请求的是在规则里面存在的地址,那么它将客户端请求报文的目标IP地址改为了后端服务器的RIP地址并将报文根据算法发送出去。
③.报文送到Real Server后,由于报文的目标地址是自己,所以会响应该请求,并将响应报文返还给LVS。
④.然后lvs将此报文的源地址修改为本机并发送给客户端。
注意在NAT模式中,Real Server的网关必须指向LVS,否则报文无法送达客户端
优点
网络隔离更安全
节约IP地址
缺点
director很可能成为系统性能瓶颈,所有的请求director都需要处理应答
DR直接路由模式
工作原理
①.客户端将请求发往前端的负载均衡器,请求报文源地址是CIP,目标地址为VIP。
②.负载均衡器收到报文后,发现请求的是在规则里面存在的地址,那么它将客户端请求报文的源MAC地址改为自己DIP的MAC地址,目标MAC改为了RIP的MAC地址,并将此包发送给RS。
③.RS发现请求报文中的目的MAC是自己,就会将次报文接收下来,处理完请求报文后,将响应报文通过lo接口送给eth0网卡直接发送给客户端。
特点
- 集群节点和director必须在一个物理网络内
- RIP可以使用公网地址或私有地址
- director仅处理入站请求,director服务器的压力比较小
- 集群节点网关不指向director,故出站不经过director
- 不支持端口映射
- 大多数操作系统可以作为realserver,要支持隔离arp广播
ARP问题
通常,DR模式需要在Real-server上配置VIP,配置的方式为:
/sbin/ifconfig lo:0 inet VIP netmask 255.255.255.255
i) 原因在于,当LVS把client的包转发给Real-server时,因为包的目的IP地址是VIP,那么如果Real-server收到这个包后,发现包的目的IP不是自己的系统IP,那么就会认为这个包不是发给自己的,就会丢弃这个包,所以需要将这个IP地址绑到网卡上;当发送应答包给client时,Real-server就会把包的源和目的地址调换,直接回复给client。
ii) 关于ARP广播:
* 上面绑定VIP的掩码是”255.255.255.255″,说明广播地址是其本身,那么他就不会将ARP发送到实际的自己该属于的广播域了,这样防止与LVS上VIP冲突,而导致IP冲突。
* 另外在Linux的Real-server上,需要设置ARP的sysctl选项:
TUN-IP隧道模式
工作原理
①.客户端将请求发往前端的负载均衡器,请求报文源地址是CIP,目标地址为VIP。
②.负载均衡器收到报文后,发现请求的是在规则里面存在的地址,那么它将在客户端请求报文的首部再封装一层IP报文,将源地址改为DIP,目标地址改为RIP,并将此包发送给RS。
③.RS收到请求报文后,会首先拆开第一层封装,然后发现里面还有一层IP首部的目标地址是自己lo接口上的VIP,所以会处理次请求报文,并将响应报文通过lo接口送给eth0网卡直接发送给客户端。
特点
优点:
负载均衡器只负责将请求包分发给后端节点服务器,而RS将应答包直接发给用户。所以,减少了负载均衡器的大量数据流动,负载均衡器不再是系统的瓶颈,就能处理很巨大的请求量,这种方式,一台负载均衡器能够为很多RS进行分发。而且跑在公网上就能进行不同地域的分发。
缺点:
隧道模式的RS节点需要合法IP,这种方式需要所有的服务器支持”IP Tunneling”(IP Encapsulation)协议,服务器可能只局限在部分Linux系统上。
模式对比
FULL-NAT
Full-NAT由此而生,解决的是LVS和RS跨VLAN的问题,而跨VLAN问题解决后,LVS和RS不再存在VLAN上的从属关系,可以做到多个LVS对应多个RS,解决水平扩容的问题。
边栏推荐
- China Civil Aviation Statistical Yearbook (1996-2020)
- The use of curl in PHP
- Simulink code generation: table lookup module and its code
- Scala method and function notes
- C语言程序设计——从键盘任意输入一个字符串,计算其实际字符个数并打印输出,要求不能使用字符串处理函数strlen(),使用自定义子函数Mystrlen()实现计算字符个数的功能。
- Get to know druid IO real time OLAP data analysis storage system
- Common command records of redis client
- MySQL learning summary 7: create and manage databases, create tables, modify tables, and delete tables
- Yolov5 face+tensorrt: deployment based on win10+tensorrt8.2+vs2019
- [JVM series 8] overview of JVM knowledge points
猜你喜欢
[azure data platform] ETL tool (7) - detailed explanation of ADF copy data
Coal industry database - coal price, consumption, power generation & Provincial Civil and industrial power consumption data
MapReduce internal execution principle
Masa Auth - SSO and Identity Design
MySQL learning summary 12: system variables, user variables, definition conditions and handlers
A data modeling optimization solution for graph data super nodes
简述:分布式CAP理论和BASE理论
Spark Foundation
Economic panel topic 1: panel data of all districts and counties in China - more than 70 indicators such as population, pollution and agriculture (2000-2019)
Reading notes of effective managers
随机推荐
Feign based remote service invocation
Part II. S3. intuitionistic fuzzy multi-attribute decision-making method when attribute weight is intuitionistic fuzzy number
MySQL group commit
Brief introduction: distributed cap theory and base theory
MySQL transaction isolation level experiment
Understanding the ongdb open source map data foundation from the development of MariaDB
Use of compact, extract and list functions in PHP
Application scenarios of large arrows in Scala
Explode and implode in PHP
Complex network analysis capability based on graph database
Panel for measuring innovation efficiency of 31 provinces in China (using Malmquist method)
MySQL and PostgreSQL installation subtotal
Filters in PHP
MySQL learning summary Xi: detailed explanation of the use of stored procedures and stored functions
Transaction processing in PDO
Doris data import broker load
Yolov5 face+tensorrt: deployment based on win10+tensorrt8.2+vs2019
Simulink代码生成: 简单状态机及其代码
English语法_频率副词
MySQL learning summary 6: data type, integer, floating point number, fixed-point number, text string, binary string