当前位置:网站首页>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,解决水平扩容的问题。

边栏推荐
- [figure data] how long does it take for the equity network to penetrate 1000 layers?
- Figure data * reconstruction subgraph
- Azure SQL db/dw series (14) -- using query store (3) -- common scenarios
- PHP import classes in namespace
- MapReduce internal execution principle
- MASA Auth - SSO與Identity設計
- Several functions in YAF framework controller
- MASA Auth - 从用户的角度看整体设计
- Coal industry database - coal price, consumption, power generation & Provincial Civil and industrial power consumption data
- Doris data import broker load
猜你喜欢

Quickly obtain the attributes of the sub graph root node

Prefecture level city - air flow coefficient data - updated to 2019 (including 10m wind speed, boundary height, etc.)

Masa auth - SSO and identity design

MASA Auth - 从用户的角度看整体设计

Neil eifrem, CEO of neo4j, interprets the chart data platform and leads the development of database in the next decade

(九)详解广播机制

Panel for measuring innovation efficiency of 31 provinces in China (using Malmquist method)

Environmental pollution, enterprises, highways, fixed assets, foreign investment in all prefecture level cities in China - latest panel data

On the career crisis of programmers at the age of 35

English grammar_ Mode adverb position
随机推荐
Isolation level, unreal read, gap lock, next key lock
Onnx+tensorrt+yolov5: yolov5 deployment based on trt+onnx 1
[azure data platform] ETL tool (7) - detailed explanation of ADF copy data
Three ways of scala string interpolation
Carbon neutralization & Patent Innovation: multi indicator data such as patent panels (original documents) of provinces, cities and counties, and the number of low-carbon patents authorized
Neo4j auradb free, the world's leading map database
Cross border M & a database: SDC cross border database, Thomson database, A-share listed company M & a database and other multi index data (4w+)
C语言程序设计——从键盘任意输入一个字符串(可以包含:字母、数字、标点符号,以及空格字符),计算其实际字符个数并打印输出,即不使用字符串处理函数strlen()编程,但能实现strlen()的功能。
Configuration and practice of shardingsphere JDBC sub database separation of read and write
年金险产品保险期满之后能领多少钱?
简述:分布式CAP理论和BASE理论
Doris outputs numbers in currency format. The integer part is separated by commas every three digits, and the decimal part is reserved for two digits
Sparksql of spark
Microservice practice based on rustlang
Get to know druid IO real time OLAP data analysis storage system
Azure SQL db/dw series (13) -- using query store (2) -- report Introduction (2)
How to Draw Useful Technical Architecture Diagrams
Time processing class in PHP
Least recently used cache (source force deduction)
Masa auth - SSO and identity design