LVS負荷等化中arp_ignoreとarp_annonuceパラメータ構成の意味

7642 ワード

まず簡単に紹介するLVS負荷等化について
LVS(Linux Virtual Server)Linuxサーバクラスタシステム
高伸縮性、高可用性サービスのニーズに対して、IP層とコンテンツ要求配布の負荷均衡スケジューリング解決方法を与え、Linuxのカーネルで実現し、1組のサーバを伸縮性、高可用性ネットワークサービスを実現する仮想サーバに構成する.
 
ふかへいこう
1.大量の兵法アクセス或いはデータ流量を多態ノード設備に分担して別々に処理し、ユーザーの待ち時間を減らす
2.単一重負荷の演算をマルチステートノードデバイスに分担して並列処理を行い、各ノードデバイス処理が終了した後、結果をまとめ、ユーザーに返す
 
ふかちょうせいき
1組のサーバは高速のローカルエリアネットワークあるいは地理分布の広域ネットワークを通じて互いに接続して、彼らの先端に1つの負荷均衡スケジューラ(Load Balancer)があって、負荷均衡スケジューラはシームレスにネットワーク要求を真実のサーバにスケジューリングすることができて、それによってサービスクラスタの構造はユーザーに対して透明で、ユーザーはクラスタシステムが提供するネットワークサービスにアクセスすることを通じて、高性能で高可用性のサーバにアクセスするように.
 
IP負荷等化技術(三種類)
1.VS/NAT(ネットワークアドレス変換)
ネットワークアドレス変換により、スケジューラは要求メッセージのターゲットアドレスを書き換え、予め設定されたスケジューリングアルゴリズムに基づいて、要求をバックエンドのリアルサーバに配布し、リアルサーバの応答メッセージがスケジューラを通過すると、メッセージのソースアドレスが書き換えられ、クライアントに戻り、スケジューリング全体のプロセスを完了する.
 
2.VS/TUN(IPトンネルモード)
スケジューラは要求したメッセージをIPトンネルを通じて真実のサーバーに転送し、真実のサーバーは直接結果をユーザーに返し、スケジューラは要求メッセージだけを処理し、一般的なネットワークサービスの応答が要求より大きいため、IPトンネルモードを採用し、クラスタシステムの最大スループットを10倍に高めることができる.
 
3.VS/DR(ダイレクトルーティング)
要求メッセージのMACアドレスを書き換えることによって、要求を真のサーバに送信し、真のサーバは応答を直接ユーザーに返す際、額ルーティングモードはクラスタシステムの伸縮性を極めて高めることができ、この方法はIPトンネルのオーバーヘッドがなく、クラスタ内の実際のサービスもIPトンネルプロトコルをサポートする必要がない.ただ、スケジューラが実際のサーバと同じ物理セグメントにネットワークカードを接続する必要があります.
 
この3つのIP負荷等化技術のうち、DRモードとTUNモードは、arp_ignoreとarp_announceパラメータは、主にVIPに対するARP要求への応答禁止を実現するように構成される.
lvs環境では、以下のパラメータを設定する必要があります.
 
echo "1">/proc/sys/net/ipv4/conf/all/arp_ignore echo "1">/proc/sys/net/ipv4/conf/lo/arp_ignore echo "2">/proc/sys/net/ipv4/conf/lo/arp_announce echo "2">/proc/sys/net/ipv4/conf/all/arp_announce
 
 
 
 
 
まずarpについて見てみましょうignoreとarp_announceの紹介
に関係
arp_ignoreに関する紹介:
arp_ignore - INTEGER
	Define different modes for sending replies in response to
	received ARP requests that resolve local target IP addresses:
	0 - (default): reply for any local target IP address, configured
	on any interface
	1 - reply only if the target IP address is local address
	configured on the incoming interface
	2 - reply only if the target IP address is local address
	configured on the incoming interface and both with the
	sender's IP address are part from same subnet on this interface
	3 - do not reply for local addresses configured with scope host,
	only resolutions for global and link addresses are replied
	4-7 - reserved
	8 - do not reply for all local addresses

	The max value from conf/{all,interface}/arp_ignore is used
	when ARP request is received on the {interface}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
arp_ignore:宛先アドレスがローカルIPであるARPに対して異なる応答パターンを問い合わせる定義0
0-(デフォルト):任意のネットワークインタフェース上の任意のローカルIPアドレスに対するarpクエリー要求に応答
1-アクセス先IPアドレスがアクセス先ネットワークインタフェースローカルアドレスであるARPクエリー要求のみ回答
2-アクセス先IPアドレスがアクセスネットワークインタフェースローカルアドレスであるARPクエリー要求のみに回答し、アクセスIPはそのネットワークインタフェースのサブネットセグメント内にある必要がある
3-ネットワークインタフェースのarpリクエストを返さず、設定された一意および接続アドレスのみに応答
4-7-未使用のまま
8-すべての(ローカルアドレス)のarpクエリに応答しない
arp_についてannounceに関する紹介:
arp_announce - INTEGER
	Define different restriction levels for announcing the local
	source IP address from IP packets in ARP requests sent on
	interface:
	0 - (default) Use any local address, configured on any interface
	1 - Try to avoid local addresses that are not in the target's
	subnet for this interface. This mode is useful when target
	hosts reachable via this interface require the source IP
	address in ARP requests to be part of their logical network
	configured on the receiving interface. When we generate the
	request we will check all our subnets that include the
	target IP and will preserve the source address if it is from
	such subnet. If there is no such subnet we select source
	address according to the rules for level 2.
	2 - Always use the best local address for this target.
	In this mode we ignore the source address in the IP packet
	and try to select local address that we prefer for talks with
	the target host. Such local address is selected by looking
	for primary IP addresses on all our subnets on the outgoing
	interface that include the target IP address. If no suitable
	local address is found we select the first local address
	we have on the outgoing interface or on all other interfaces,
	with the hope we will receive reply for our request and
	even sometimes no matter the source IP address we announce.

	The max value from conf/{all,interface}/arp_announce is used.

	Increasing the restriction level gives more chance for
	receiving answer from the resolved target while decreasing
	the level announces more valid sender's information.

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
arp_announce:ネットワークインタフェース、ローカルIPアドレスの発行、ARP応答、対応するレベルの制限を行う:異なる程度の制限を確定し、ローカルソースIPアドレスからArp要求を発行するインタフェースを宣言する
0-(デフォルト)任意のネットワークインタフェース(eth 0,eth 1,lo)上の任意のローカルアドレス
1-このネットワークインタフェースのサブネットセグメントのローカルアドレスにarp応答をできるだけ避ける.ARP要求を開始するソースIPアドレスがルーティングを介してこのネットワークインタフェースに到達ように設定場合に有用である.このとき、訪問IPがすべてのインタフェース上のサブセグメント内のipの1つであるか否かがチェックされる.来訪IPが各ネットワークインタフェース上のサブセグメント内に属さない場合は、レベル2の方式で処理する. 
2-クエリー・ターゲットに最適なローカル・アドレスを使用します.このモードでは、このIPパケットのソースアドレスを無視する、そのアドレスと通信可能なローカルアドレスの選択を試みる.主に、全てのネットワークインタフェースのサブネットにおいて、当該ターゲットIPアドレスを含むローカルアドレスに外出アクセスするサブネットを選択する.適切なアドレスが発見する場合には、現在の送信ネットワークインタフェースまたはARP応答を受ける可能性のある他のネットワークインタフェースを選択して送信.
対arp_についてannounce理解の少しの補充
 
Assume that a linux box X has three interfaces - eth0, eth1 and eth2. Each interface has an IP address IP0,  IP1 and IP2. When a local application tries to send an IP packet with IP0 through the eth2.  Unfortunately,  the target node’s mac address is not resolved. Thelinux box X will send the ARP request to know  the mac address of the target(or the gateway). In this case what is the IP source address of the  “ARP request message”? The IP0- the IP source address of the transmitting IP or IP2 - the outgoing  interface?  Until now(actually just 3 hours before) ARP request uses the IP address assigned to  the outgoing interface(IP2 in the above example) However the linux’s behavior is a little bit  different. Actually the selection of source address in ARP request is totally configurable  bythe proc variable “arp_announce”   If we want to use the IP2 not the IP0 in the ARP request, we should change the value to 1 or 2.  The default value is 0 - allow IP0 is used for ARP request.  
 
 
 
 
 
 
 
 
 
 
 
 
 
実はルータの問題で、ルータは一般的に動的にARPパケットを学習するので(一般的に動的にDHCPを配置するなら)、内網の機械が外部のipパケットを送信すると、それはルータのMacアドレスを要求して、arp要求を送信して、このarp要求の中に自分のipアドレスとMacアドレスが含まれています.linuxのデフォルトはipのソースipアドレスをarpの中のソースipアドレスとして使用し、送信装置の上を使用するのではなく、lvsのようなアーキテクチャの下で、すべての送信パケットが同じVIPアドレスであると、arp要求にはVIPアドレスとデバイスMacが含まれ、ルータがこのarp要求を受け取ると自分のarpキャッシュが更新され、ipがだまされます.VIPが奪われたので、問題が発生します.  
Arpキャッシュはなぜ更新されたのか、いつ更新されるのか、arpリクエストの回数を減らすために、ホストが自分のarpリクエストを受信すると、ソースipとソースMacを自分のarpテーブルに入れ、次の通信を便利にします.自分のパケットではない(arpはブロードキャストで、全員が受信)を受信すると、失われ、arpテーブルの不要なデータが多すぎて有用なレコードが削除されません.  
パラメータ設定時にarp_ignoreが1に設定されていることは、他の人のarpリクエストが来たときに、受信したデバイスにこのipがなければ応答しないことを意味し、デフォルトは0であり、このマシンの上のいずれかのデバイスにこのipがある限り、arpリクエストに応答し、macアドレスを送信する
 
 
 
 
その他の関連資料:
http://kb.linuxvirtualserver.org/wiki/Using_arp_announce/arp_ignore_to_disable_ARP
http://itnihao.blog.51cto.com/1741976/752472
転載先:https://www.cnblogs.com/fatt/p/4427691.html