lvs-dr模式

资讯 2024-06-24 阅读:109 评论:0
LVS-DR模式:每个Real Server上都有两个IP:VIP和RIP,但是VIP是隐藏的,就是不能提供解析等功能,只是用来做请求回复的源IP的,Director上只需要一个网卡,然后利用别名来配置两个IP:VIP和DIP,在DIR接收...
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

LVS-DR模式:每个Real Server上都有两个IP:VIP和RIP,但是VIP是隐藏的,就是不能提供解析等功能,只是用来做请求回复的源IP的,Director上只需要一个网卡,然后利用别名来配置两个IP:VIP和DIP,在DIR接收到客户端的请求后,DIR根据负载算法选择一台rs sever的网卡mac作为客户端请求包中的目标mac,通过arp转交给后端rs serve处理,后端再通过自己的路由网关回复给客户端。

LVS-DR mode: Each Real Server has two IPs: VIPs and RIPs, but VIPs are hidden and cannot provide functions such as parsing. Only one web card is needed on Director to make the request, and then two IPs are configured using aliases: VIPs and DIPs. After DIR receives the request from the client, DIR selects a rs sever web card, mac, as the target in the client's request package, and transmits it to the backend, rsserve, and the backend returns to the client via its own routing gateway.

image

CIP:192.168.1.13
VIP:192.168.1.100
DIR: 192.168.1.2
RS :192.168.1.10、192.168.1.11和192.168.1.12(提供http服务)

CIP: 192.168.1.13
VIP: 192.168.1.100
DIR: 192.168.1.2
RS: 192.168.1.10, 192.168.1.11 and 192.168.1.12 (Providing http services)

整个请求过程示意:

The entire request process suggests that:

这里假设CIP的mac地址为:00-50-56-C0-00-08 ,DIR的Eth0的mac地址为:00-50-56-C0-00-01, RIP1的mac地址为: D0-50-99-18-18-15。CIP在请求之前会发一个arp广播包,即请求“谁是VIP”,由于所有的DIR和RIP都在一个物理网络中,而DIR和RIP都有VIP地址,为了让请求发送到DIR上,所以必须让RIP不能响应CIP发出的arp请求(这也是为什么RIP上要把VIP配置在lo口以及要仰制arp查询和响应)这时客户端就会将请求包发送给DIR,接下来就是DIR的事情了:

This assumes that CIP's mac address is 00-50-56-C0-00-08, DIR's Eth0's mac's address is 00-50-56-C0-00-01, RIP1's mac's address is D0-50-99-18-18-15. CIP sends an arp radio package prior to the request, i.e., who's the VIP? Since all DIR and RIP are in a physical network, and DIR and RIP have a VIP address, and in order for the request to be sent to DIR, RIP must not be able to respond to the RIP's request (which is why the RIP's client will send the request to DIR when it's placed on the lo port and when it's looking and responding to the arp query), which is what the DIR does:

① client向目标vip发出请求,DiR接收。此时IP包头及数据帧头信息如下:

1 client sends a request to target vip, which is received by DiR. The information on the IP bag and the data frame is as follows:

image

② DIR根据负载均衡算法选择一台active的RS(RIP1),将此RIP1所在网卡的mac地址作为目标mac地址,发送到局域网里。此时IP包头及数据帧头信息如下:

2 DIR selects an active RS (RIP1) based on the load equilibrium algorithm and sends the Mac address of the RIP1 network card as the target mac address to the local area network. The information on the IP bag and the data frame is as follows:

[图片上传中...(image-5b420e-1637652520601-1)]

[photo uploading... (image-5b420e-1637652520601-1]

③RIP1(192.168.1.10)在局域网中收到这个帧,拆开后发现目标IP(VIP)与本地匹配,于是处理这个报文。随后重新封装报文,发送到局域网。此时IP包头及数据帧头信息如下:

3RIP1 (192.168.1.10) receives this frame in the local area network and untangles it and discovers that the target IP (VIP) matches it locally. The message is then repackaged and sent to the local area network. The information on the IP package and the data frame is as follows:

image

如果client与VS同一网段,那么client(192.168.10.13)将收到这个回复报文。如果跨了网段,那么报文通过gateway/路由器经由Internet返回给用户。在实际情况下,可能只有一个公网,其他都是内网,这时VIP绑定地址应该是公网那个ip,或者利用路由器静态NAT映射将公网与内网vip绑定也行。

If the client shares the same segment as the VS, the reply will be received. If you cross the section, the message returns to the user via the Gateway/ Router via the Internet. In practical terms, there may be only one public network, the rest being the intranet, where the VIP is supposed to be the public one, or where the router's static NAT map binds the public network to the inner web.

LVS负载均衡模式—DR模式特点:

LVS Load Balance Mode - DR Mode Characteristics:

各RIP 必须与 DIP 在同一个网络中(相同的广播域);
RS 的 RIP 可以使用私有地址,也可以使用公网地址,以方便配置;
不支持支持端口映射;
RS可以使用必须为uninx操作系统(OS);且RS需要仰制arp,需要在loopback配置vip;
Director 仅负责处理入站请求,响应报文由 Realserver 直接发往客户端;
Realserver 不能将网关指向 DIP,而直接使用前端网关响应请求报文;
优点:负载均衡器只负责将请求包分发给物理服务器,而物理服务器将应答包直接发给用户。所以,负载均衡器能处理很巨大的请求量,这种方式,一台负载均衡能为 超过100台的物理服务器服务,负载均衡器不再是系统的瓶颈。使用VS-DR方式,如果你的负载均衡器拥有100M的全双工网卡的话,就能使得整个 Virtual Server能达到1G的吞吐量。甚至更高;

RIPs must be available in the same network as DIPs (the same broadcast domain);
RS RIPs can use private addresses or public network addresses for ease of configuration;
do not support port mapping;
RS can use uninx operating systems (OS); RSs need to hold an arp, which needs to be equipped with vip on the loopback;
Director only handles station requests and responds to reports sent directly to clients by Realserver;
Realservers cannot point gateways to DIPs and load equalizers can use the front gateway directly to respond to requests;
Advantages: The load equalizer is responsible only for distributing the request package to the physical server, whereas the physical server should be equipped to the user directly.
Director only handles the large number of requests, in this way, a load equal can be directed to more than 100 physical server services, and the load equaler is no longer a bottle to the system.

不足:但是,这种方式需要所有的DIR和RIP都在同一广播域;不支持异地容灾。

Not enough: however, this approach requires that all DIRs and RIPs are in the same broadcasting area; there is no support for off-site accommodation.

总结:LVS-DR是三种模式中性能最高的一种模式,比LVS-NAT模式下负载的RS serve更多,通常在100台左右,对网络环境要求更高,也是日常应用的最多的一种工作模式。

Summing up: LVS-DR is one of the three models with the highest performance, more than RS service loads carried under the LVS-NAT model, usually around 100, more demanding of the network environment and the most commonly used mode of work.

关于lvs-dr模式下一些疑问:

There are some questions about the lvs-dr model:

1、LVS/DR如何处理请求报文的,会修改IP包内容吗?

1. Would the content of the IP package be modified if LVS/DR dealt with the request?

vs/dr本身不会关心IP层以上的信息,即使是端口号也是tcp/ip协议栈去判断是否正确,vs/dr本身主要做这么几个事:

vs/dr itself does not care about information above the IP level, and even the port number is the tcp/ip agreement counter to determine whether or not it is correct, vs/dr itself does a few things:

①接收client的请求,根据你设定的负载均衡算法选取一台realserver的ip;
②以选取的这个ip对应的mac地址作为目标mac,然后重新将IP包封装成帧转发给这台RS;
③在hash table中记录连接信息。

1 Receives the request of clieent to select a realserver's ip based on the load balance algorithm you set;
2 with the selected pi corresponding mac address as the target Mac, and then reassembles the IP package into frame to this RS;
3 records connection information in hash table.

vs/dr做的事情很少,也很简单,所以它的效率很高,不比硬件负载均衡设备差多少,数据包、数据帧的大致流向是这样的:client –> VS –> RS –> client

Vs/dr does very little and very simple, so it's very efficient, no less than hardware load balancing equipment, and the general flow of data packages and frames is as follows: clit – & gt; VS – & gt; RS – & gt; clit

2、RealServer为什么要在lo接口上配置VIP?在出口网卡上配置VIP可以吗?

2. Why would RealServer configure VIPs on the lo interface? Can you configure VIPs on the export network card?

既然要让RS能够处理目标地址为vip的IP包,首先必须要让RS能接收到这个包。在lo上配置vip能够完成接收包并将结果返回client。不可以将VIP设置在出口网卡上,否则会响应客户端的arp request,造成client/gateway arp table紊乱,以至于整个load balance都不能正常工作。

If RS is to be able to handle the IP package with the target address vip, it must first be able to receive the package. If you are to be able to complete the package and return the results to Client on lo, you cannot place the VIP on the export network card, otherwise it will respond to the client's arp recuest, causing a clit/gateway arptable disorder, so that the whole load barance is not working properly.

3、RealServer为什么要抑制arp帧?

Three. Why would RealServer suppress the arp frame?

我们知道仰制arp帧需要在server上执行以下命令,如下:

We know that the building of the Arp frame requires the following orders to be carried out on the server, as follows:

echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
1
2
3
4
因为arp对逻辑口没有意义。实际上起作用的只有以下两条:

& gt;/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" & gt;/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
1
2
3
4
because arp does not actually make sense to logic.

echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
1
2
即对所有的物理网卡设置arp仰制。对仰制所有的物理网卡设置arp仰制是为了让CIP发送的请求顺利转交给DIR以及防止整个LVS环境arp表混乱,不然容易导致整个lvs不能工作。

& gt;/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
1
2
for all physical network cards is an arp-backing system for all physical network cards.

4、LVS/DR load balancer(director)与RS为什么要在同一网段中?

4; LVS/DRload baller (director) and RS why are they in the same online segment?

lvs/dr它是在数据链路层来实现的,即RIP必须能够接受到DIR的arp请求,如果不在同一网段则会隔离arp,这样arp请求就不能转发到指定的RIP上,所以director必须和RS在同一网段里面。

Ivs/dr was achieved on the data chain level, i.e. RIP must be able to accept DIR arp requests, which would be isolated if they were not in the same section, so that the arp requests could not be forwarded to the designated RIPs, so that director would have to be in the same section as RS.

5、为什么director上eth0接口除了VIP另外还要配一个ip(即DIP)?

5. Why does the director Eth0 interface have to be accompanied by an ip (i.e. DIP) in addition to VIP?

如果是用了keepalived等工具做HA或者Load Balance,则在健康检查时需要用到DIP。 没有健康检查机制的HA或者Load Balance则没有存在的实际意义。

If you use tools like keepalived for HA or Load Balance, you need to use DIP for a health check.

6、LVS/DR ip_forward需要开启吗?

Does LVS/DR ip_forward need to be turned on?

不需要。因为director跟realserver是同一个网段,无需开启转发。

No need. Because Director and Realserver are the same segments of the network, there is no need to turn them on.

7、director的vip的netmask一定要是255.255.255.255吗?

Does the netmask of seven, director's vip be 255.255.255.255?

lvs/dr里,director的vip的netmask 没必要设置为255.255.255.255,director的vip本来就是要像正常的ip地址一样对外通告的,不要搞得这么特殊。

Ivs/drri, the netmask of director's vip need not be set at 255.255.255.255, and director's vip was intended to be communicated to the public like the normal ip address, so don't be so special.

原文:https://blog.csdn.net/liupeifeng3514/article/details/79038577

Original:

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 支付領域投下震撼彈!美國數位銀行Chime疑與GuardPay 神盾支付合作!

    支付領域投下震撼彈!美國數位銀行Chime疑與GuardPay 神盾支付合作!
    2020年,新冠肺炎(COVID-19)疫情加速數位貨幣進展。例如:2019年4月,國際清算銀行(BIS)的調查顯示,在全球66家中央銀行中,沒有一家計畫發行跨境支付的數位貨幣。惟到了2020年10月,BIS支付委員會主席康利夫(Jon Cunliffe)指出,肺炎疫情拉高民眾對無現金支付的需求,迫使各國加快數位貨幣的研發進程日本與韓國於2021年進入數位貨幣試驗階段。直到2019年12月,美國聯邦準備理事會(Fed)都尚無數位貨幣規劃,惟到了2020年2月,Fed已開始研擬...
  • 区块链:交易系统开发指南

    区块链:交易系统开发指南
    播报编辑《区块链:交易系统开发指南》使用通俗易懂的语言,从技术的角度详细介绍了区块链交易系统应有的功能架构及工作原理,让人们能够张开双臂轻松地拥抱区块链技术,享受区块链交易系统带来的惊喜与成就感。《区块链:交易系统开发指南》共分 7 章,第 1~2 章主要介绍区块链及数字货币的基本概念,以及各种公有链的 API 接口;第3~5 章主要介绍区块链交易系统的分类架构及功能; 6 章主要介绍区块链交易系统面临的问题及演进方向;第 7 章对全书做了总结。《区块链:交易系统开发指南》是...
  • 5.14加密货币价格:BTC突破6.2万美元以太坊和山寨币反映市场情绪

    5.14加密货币价格:BTC突破6.2万美元以太坊和山寨币反映市场情绪
    今天,随着比特币(BTC)的价格突破62 000美元的门槛,顶级加密货币的价格反弹了。 此外,以铁大幅上涨,维持在2 900美元的水平。 此外,其他顶尖山硬币,如索拉纳(SOL )、XRP、卡达诺(ADA )也大幅上涨。    今天密钥加密货币价格 1. 比特币价格    在5月14日星期二撰写本文时,比特币价格上升了2.57%,达到62 487.50美元。 另一方面,在过去24小时内,交易量从65.26 % 急剧上升至277亿美元。 与此同时,加密货币的市场价值为...
  • OKEx回应用户质疑:合约交易非期货 平台无机器人

    OKEx回应用户质疑:合约交易非期货 平台无机器人
       热点点 自选股份 数据中心 数据中心 研究和资料中心 资金流动 模拟交易 客户客户 具体来说,OKEx回答用户的问题:合同交易不是期货,平台不是机器人。 金融同步化,3月22日。    昨天下午,OKEx公司就维护先前用户线下的权利问题对同步财务公司作出了回应,指出OKEx公司提供的合同交易不是期货交易,在旗下的业务中没有正式的机器人。 同时,OKEX称,它不会以非法为由对任何投资损失索赔作出答复。 答复全文如下: 同步你的财务! 近日来,...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
标签列表