Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

Virtual Server Administration

Red Hat Enterprise Linux 5

Linux Virtual Server (LVS) for Red Hat Enterprise Linux

エディッション 5

Logo

概要

Building a Linux Virtual Server (LVS) system offers highly-available and scalable solution for production services using specialized routing and load-balancing techniques configured through the PIRANHA. This book discusses the configuration of high-performance systems and services with Red Hat Enterprise Linux and LVS for Red Hat Enterprise Linux 5.

Introduction

This document provides information about installing, configuring, and managing Red Hat Virtual Linux Server (LVS) components. LVS provides load balancing through specialized routing techniques that dispatch traffic to a pool of servers. This document does not include information about installing, configuring, and managing Red Hat Cluster software. Information about that is in a separate document.
The audience of this document should have advanced working knowledge of Red Hat Enterprise Linux and understand the concepts of clusters, storage, and server computing.
This document is organized as follows:
For more information about Red Hat Enterprise Linux 5, refer to the following resources:
  • Red Hat Enterprise Linux Installation Guide』 — Provides information regarding installation of Red Hat Enterprise Linux 5.
  • Red Hat Enterprise Linux Deployment Guide』 — Provides information regarding the deployment, configuration and administration of Red Hat Enterprise Linux 5.
For more information about Red Hat Cluster Suite for Red Hat Enterprise Linux 5, refer to the following resources:
  • Red Hat Cluster Suite Overview』 — Provides a high level overview of the Red Hat Cluster Suite.
  • Configuring and Managing a Red Hat Cluster』 — Provides information about installing, configuring and managing Red Hat Cluster components.
  • Logical Volume Manager Administration』 — Provides a description of the Logical Volume Manager (LVM), including information on running LVM in a clustered environment.
  • Global File System: Configuration and Administration』 — Provides information about installing, configuring, and maintaining Red Hat GFS (Red Hat Global File System).
  • Global File System 2: Configuration and Administration』 — Provides information about installing, configuring, and maintaining Red Hat GFS2 (Red Hat Global File System 2).
  • Using Device-Mapper Multipath』 — Provides information about using the Device-Mapper Multipath feature of Red Hat Enterprise Linux 5.
  • Using GNBD with Global File System』 — Provides an overview on using Global Network Block Device (GNBD) with Red Hat GFS.
  • Red Hat Cluster Suite Release Notes』 — Provides information about the current release of Red Hat Cluster Suite.
Red Hat Cluster Suite documentation and other Red Hat documents are available in HTML, PDF, and RPM versions on the Red Hat Enterprise Linux Documentation CD and online at http://www.redhat.com/docs/.

1. Feedback

If you spot a typo, or if you have thought of a way to make this manual better, we would love to hear from you. Please submit a report in Bugzilla (http://bugzilla.redhat.com/bugzilla/) against the component Documentation-cluster.
Be sure to mention the manual's identifier:
Virtual_Server_Administration(EN)-5 (2010-02-08T16:55)
By mentioning this manual's identifier, we know exactly which version of the guide you have.
If you have a suggestion for improving the documentation, try to be as specific as possible. If you have found an error, please include the section number and some of the surrounding text so we can find it easily.

第1章 Linux 仮想サーバー(Linux Virtual Server)の概要

Linux 仮想サーバー(LVS) は実サーバーのセット全体に渡って IP ロード(負荷)のバランスを 取る為の統合型ソフトウェアコンポーネントのセットです。LVS は同様に設定された一対の コンピュータ上で稼働します: その1つがアクティブ LVS router であり、 もう1つがバックアップ LVS router です。このアクティブ LVS router は 以下の二つの役目を持ちます:
  • 実サーバー中で負荷のバランスを取る
  • それぞれの実サーバー上でサービスの一貫性をチェックする
バックアップ LVS router はアクティブ LVS router を監視して、アクティブ LVS router が 故障した場合には、それに入れ替わります。
この章では、LVS のコンポーネントと機能の概要を提供しており、以下のようなセクションで 構成されています:

1.1. A Basic LVS Configuration

図1.1「A Basic LVS Configuration」 shows a simple LVS configuration consisting of two layers. On the first layer are two LVS routers — one active and one backup. Each of the LVS routers has two network interfaces, one interface on the Internet and one on the private network, enabling them to regulate traffic between the two networks. For this example the active router is using Network Address Translation or NAT to direct traffic from the Internet to a variable number of real servers on the second layer, which in turn provide the necessary services. Therefore, the real servers in this example are connected to a dedicated private network segment and pass all public traffic back and forth through the active LVS router. To the outside world, the servers appears as one entity.
A Basic LVS Configuration

図1.1 A Basic LVS Configuration

Service requests arriving at the LVS routers are addressed to a virtual IP address, or VIP. This is a publicly-routable address the administrator of the site associates with a fully-qualified domain name, such as www.example.com, and is assigned to one or more virtual servers. A virtual server is a service configured to listen on a specific virtual IP. Refer to VIRTUAL SERVERS for more information on configuring a virtual server using the Piranha Configuration Tool. A VIP address migrates from one LVS router to the other during a failover, thus maintaining a presence at that IP address (also known as floating IP addresses).
VIP アドレスは、LVS router をインターネットに接続する同じデバイスにエイリアス化することが 可能です。例えば、eth0 がインターネットに接続されている場合、複数の仮想サーバーが eth0:1 としてエイリアス化することが出来ます。別の方法としては、 各仮想サーバーがサービス毎に別々のデバイスに関連付けされることも可能です。例えば、 HTTP トラフィックは eth0:1 上で処理され、FTP トラフィックは eth0:2 で処理されるように出来ます。
Only one LVS router is active at a time. The role of the active router is to redirect service requests from virtual IP addresses to the real servers. The redirection is based on one of eight supported load-balancing algorithms described further in 「LVS スケジューリングの概要」.
アクティブ router は、簡単な 送信/期待スクリプトを通じて 実サーバー上の特定サーバーの健全性を動的に監視もします。HTTPS や SSL などの 動的データを必要とするサービスの健全性検知を援助する為、管理者は外部の実行ファイルを コールすることもできます。実サーバー上のサービスが異常動作した場合、アクティブ router は 正常な運営が復帰するまでそのサーバーへのジョブの送信を停止します。
バックアップ router はスタンバイシステムの役目をします。定期的に LVS router 達は、 主要外部公共インターフェイスを通じて、及びフェイルオーバーの 状態になった場合には、 プライベートインターフェイスを通じて、ハートビートのメッセージを交換します。バックアップ ノードが想定した期間内にハートビートメッセージを受け取らない場合、それはフェイルオーバーを 開始してアクティブ router の役目を受け持ちます。フェイルオーバーの期間中はバックアップ router が ARP spoofing と言う技術を使用して故障した router でサービスされている VIP アドレスを取り込みます。ARP spoofing では、バックアップ router が 故障した router 宛に出された IP パケット にとって自分が目的地であることを表明します。故障したノードが アクティブなサービスを復元すると、バックアップノードは再度、そのバックアップ役目を取り戻します。
The simple, two-layered configuration used in 図1.1「A Basic LVS Configuration」 is best for serving data which does not change very frequently — such as static webpages — because the individual real servers do not automatically sync data between each node.

1.1.1. 実サーバー間のデータ複製とデータ共有

実サーバー間で同じデータを共有するような埋め込み型のコンポーネントが LVS 内にないため、 管理者は以下の二つのオプションを持ちます:
  • 実サーバー群内でデータを同期化
  • 共有データアクセス用のトポロジーに三番目のレイヤーを追加
一番目のオプションは、実サーバー上で多数のユーザーがデータをアップロードしたり変更したり することを許可しないサーバーに適しています。e-commerce ウェブサイトなどのように設定が多数の ユーザーにデータの修正を許可する場合は、三番目のレイヤーの追加が望ましくなります。

1.1.1.1. データ同期化の為に実サーバーを設定

管理者が実サーバーの集合体中に渡ってデータを同期化する為に選択できる方法は沢山あります。 例えば、ウェブデザイナーがページを更新した時には、シェルスクリプトを使用してページが 全てのサーバーに同時に記載されるようにすることが出来ます。またシステム管理者は rsync などのプログラムを使用して任意の時間間隔で全てのノードに 渡って変更されたデータを複製することができます。
しかし、このタイプのデータ同期化は、ユーザーが常時ファイルをアップロードしたり、 データベーストランザクションを発行して設定に過大な負荷がかかると、最適機能を 発揮できません。高い負荷を持つ設定には、三層(three-tier)トポロジー が 理想的なソリューションとなります。

1.2. A Three-Tier LVS Configuration

図1.2「A Three-Tier LVS Configuration」 shows a typical three-tier LVS topology. In this example, the active LVS router routes the requests from the Internet to the pool of real servers. Each of the real servers then accesses a shared data source over the network.
A Three-Tier LVS Configuration

図1.2 A Three-Tier LVS Configuration

この設定は頻繁に稼働する FTP サーバー用に理想的であり、そこではアクセス可能なデータは 中央の高度可用性サーバーに保存されており、エキスポートされた NFS ディレクトリや Samba 共有などを介してそれぞれの実サーバーからアクセスを受けます。このトポロジーは また、トランザクション用の中央高度可用性データベースにアクセスするウェブサイトの為に 推薦できるものです。更には、Red Hat Cluster Manager でアクティブ/アクティブ設定を使用すると、管理者は これらの役目を両方共同時にサービスできる高度可用性クラスタを構成することができます。
上記の例で、三番目の層は Red Hat Cluster Manager を使用する必要がありませんが、高度可用性の ソリューションを使用しそこなうと重大な単一故障箇所の発生を招く可能性が出てきます。

1.3. LVS スケジューリングの概要

LVS を使用する利点の1つとして、実サーバー群で柔軟な IP レベルのロードバランシングを実行できる能力があります。この柔軟性は、管理者が LVS を設定している時に選択できるスケジューリングアルゴリズムの多様性によるものです。LVS ロードバランシングは、クライアントマシンによる DNS の階級的性格とそのキャッシングがロードのアンバランスになり易い、ラウンドロビン(Round-Robin) DNS などの他の柔軟性の低いメソッドに比べて優れています。更に、ネットワークパケットレベルでのロードバランシングは少々の演算負担と なる代わりに、より大きな拡張性を与えるため、LVS router で使用される低レベルのフィルタリングはアプリケーションレベルの要求転送よりも優れています。
Using scheduling, the active router can take into account the real servers' activity and, optionally, an administrator-assigned weight factor when routing service requests. Using assigned weights gives arbitrary priorities to individual machines. Using this form of scheduling, it is possible to create a group of real servers using a variety of hardware and software combinations and the active router can evenly load each real server.
LVS 用のメカニズムは IP 仮想サーバー いわゆる IPVS モジュールと呼ばれるカーネルパッチの集合によって提供されます。これらのモジュールは 単独 IP アドレス上で複数のサーバーとうまく動作するように設計されている レイヤー(layer) 4 (L4)トランスポートレイヤーを有効にします。
パケットを見つけて実サーバーまで効率的に回送する為に、 IPVS はカーネル内に IPVS 表 を構成します。この表はアクティブ LVS router が 仮想サーバーアドレスからの要求を実サーバー群とやり取りするのに使用されます。 IPVS 表は ipvsadm と呼ばれるユーティリティで常時更新 されており、使用可能状態に応じてクラスタメンバーを追加したり削除したりします。

1.3.1. スケジューリングアルゴリズム

The structure that the IPVS table takes depends on the scheduling algorithm that the administrator chooses for any given virtual server. To allow for maximum flexibility in the types of services you can cluster and how these services are scheduled, Red Hat Enterprise Linux provides the following scheduling algorithms listed below. For instructions on how to assign scheduling algorithms refer to 仮想サーバー サブセクション」.
Round-Robin Scheduling
それぞれの要求を連続的に実サーバーの集合体を回って分配します。このアルゴリズムを 使用すると、全ての実サーバーは能力や負荷に関係なく、平等に取り扱われます。 このスケジューリングモデルは、ラウンドロビン DNS に似ていますが、それがネットワーク接続 ベースでありホストベースでないと言う事実で、より小粒状になっています。LVS ラウンドロビン スケジューリングはまた、キャッシュ化した DNS クエリによって起こるアンバランスの害を 受けません。
Weighted Round-Robin Scheduling
Distributes each request sequentially around the pool of real servers but gives more jobs to servers with greater capacity. Capacity is indicated by a user-assigned weight factor, which is then adjusted upward or downward by dynamic load information. Refer to 「サーバー能力分別とスケジューリング」 for more on weighting real servers.
実サーバーの集合体の中でその能力に重要な格差がある場合は、能力別ラウンドロビンスケジューリングが 優先されるべきです。しかし、要求ロードが劇的に変化する場合、より大きな能力を持つサーバーが 要求の分担以上に対応する可能性があります。
Least-Connection
少ないアクティブ接続を持つ実サーバーにより多くの要求が分配されます。 IPVS 表を通じて実サーバーへの活動中接続の記録を取るため、最低稼働機接続は 動的スケジューリングアルゴリズムの一種であり、要求負荷に大幅な変化がある 状況にはより良い選択になります。これは各メンバーノードがおよそ同様な 能力を持つ実サーバー群に最適なものです。サーバー群が異なる能力を持つ場合、 能力別最低稼働機接続スケジューリングがより良い選択となります。
Weighted Least-Connections (default)
Distributes more requests to servers with fewer active connections relative to their capacities. Capacity is indicated by a user-assigned weight, which is then adjusted upward or downward by dynamic load information. The addition of weighting makes this algorithm ideal when the real server pool contains hardware of varying capacity. Refer to 「サーバー能力分別とスケジューリング」 for more on weighting real servers.
Locality-Based Least-Connection Scheduling
目的地 IP に関連してより少ないアクティブ接続を持つサーバーにより多くの要求が 分配されます。このアルゴリズムはプロキシキャッシュサーバークラスタ内での使用に 設計されています。ある IP アドレス用のサーバーがその能力超過になっていなくて、 負荷が半分のサーバーがない場合、そのアドレス用のパケットをそのアドレスのサーバーに 回送します。その状況では、 IP アドレスは最低稼働の実サーバーに割り当てられます。
Locality-Based Least-Connection Scheduling with Replication Scheduling
目的地 IP に関連してより少ないアクティブ接続を持つサーバーにより多くの要求を 分配します。このアルゴリズムもプロキシキャッシュサーバークラスタ内での 使用の為に設計されています。これは、目的地 IP を実サーバーノードのサブセットに マップすることでローカリティベース最低稼働機接続スケジューリングと区別されます。 要求は、最低数の接続を持つサブセット内のサーバーに回送されます。目的地 IP の 全てのノードが能力を超過している場合、実サーバー群の全集合体の中から最低接続を持つ サーバーを、目的地 IP 用の実サーバーサブセットに追加することにより、その IP アドレス 用に新規サーバーを再生します。最大負荷を持つノードはその後、実サーバーサブセットから 排除されて過剰再生を防止します。
Destination Hash Scheduling
静的ハッシュ表内で目的地 IP を見つけることにより実サーバーの集合体に要求を 分配します。このアルゴリズムはプロキシキャッシュサーバークラスタ内での使用に 設計されています。
Source Hash Scheduling
静的ハッシュ表内でソース IP を見つけることにより実サーバーの集合体に要求を分配 します。このアルゴリズムは複数ファイアウォールを持つ LVS router 用に設計されて います。

1.3.2. サーバー能力分別とスケジューリング

LVS の管理者は 能力値 を実サーバー群内の各サーバーに割り当てることができます。この能力値とは、能力分別 スケジューリング アルゴリズム(能力別最低稼働機接続など)への要素となる整数値であり、異なる能力を持つ ハードウェアに対して LVS router が均一的に負荷を与えることに寄与します。
能力値は互いを比較した比率です。例えば、1台の実サーバーが能力値 1を持ち、他のサーバーが 能力値 5 を持つならば、能力値 5 のサーバーは能力値 1 のサーバーが1つの接続を持つ度に 5つの接続を持つことになります。デフォルトでは実サーバーの能力値は 1です。
実サーバー群内で異なるハードウェア設定に能力値を追加することは、クラスタのロードバランシングを 効率的にする手助けになりますが、1台の実サーバーが実サーバー群に追加されて、仮想サーバーが 能力別最低稼働機接続を使用する計画がある場合には、一時的なアンバランスの原因になる可能性があります。 例えば、実サーバー群内に3つのサーバーがあると想定します。サーバーA と B は能力 1とし、三番目の サーバー C は能力 2 とします。サーバーC が何かの理由で落ちた場合、サーバー A と B が平等に その負荷を分担します。しかし、サーバー C が復帰した時点で、LVS router はそのゼロ接続を発見して、 サーバー A と B と同じレベルになるまで、来信する要求をサーバー C に集中します。
この現象を防止するために、管理者は仮想サーバーを quiesce(一時休止)サーバーに することができます。新規の実サーバーノードがオンラインに入る時にはいつでも最低稼働機接続表はゼロに リセットされて、LVS router は、まるで全ての実サーバーがクラスタに新規に追加された実サーバーで あるかのように要求を回送します。

1.4. Routing (経路回送)の方法

Red Hat Enterprise Linux は LVS 用 にネットワークアドレス解決(Network Address Translation) いわゆる NAT routing を使用します。これにより、管理者は存在するハードウェアを 活用し、既存のネットワークに LVS を統合する場合に格別の柔軟性を得ることが出来ます.

1.4.1. NAT Routing

図1.3「LVS Implemented with NAT Routing」, illustrates LVS utilizing NAT routing to move requests between the Internet and a private network.
LVS Implemented with NAT Routing

図1.3 LVS Implemented with NAT Routing

この例では、アクティブ LVS router に二つの NIC があります。インターネット用の NIC は eth0 上に 実 IP アドレスを持ち、eth0:1 にエイリアス化された 浮動 IP アドレスを持ちます。プライベートネットワークインターフェイス用の NIC は eth1 上に 実 IP アドレスを持ち、eth1:1 にエイリアス化された浮動 IP アドレスを持ちます。フェイルオーバーの 状態になると、インターネットに面している仮想サーバーと仮想インターフェイスに面している プライベートネットワークは、同時にバックアップ LVS router により受け継がれます。プライベートネットワーク上に ある全ての実サーバーは、NAT router 用の浮動 IP をそのデフォルト経路として使用して、アクティブ LVS router と通信をします。そのため、インターネットからの要求に反応する能力は低減しません。
In this example, the LVS router's public LVS floating IP address and private NAT floating IP address are aliased to two physical NICs. While it is possible to associate each floating IP address to its own physical device on the LVS router nodes, having more than two NICs is not a requirement.
このトポロジーを使用すると、アクティブ LVS router は要求を受け付けて、それを 該当するサーバーに回送します。実サーバーはその後、要求を処理してパケットを、 LVS router に返送し、それがネットワークアドレス解決を使用してパケット内の実サーバーの アドレスを LVS router の公共 IP アドレスに入れ替えます。実サーバーの 実 IP アドレスが要求しているクライアントには隠されているため、このプロセスは IP マスカレーディング(変装) と呼ばれます。
この NAT routing を使用すると、実サーバーは諸々のオペレーティングシステムを実行している 如何なるマシンでも良いことになります。主な不都合は、LVS router が来信と発信の両方の要求を 処理する必要があるため、大量のクラスタ導入では LVS router が流通のネックになる可能性がある ことです。

1.4.2. ダイレクト Routing

ダイレクト routing を使用する LVS セットアップを構築することは、他の LVS ネットワーキング トポグラフィーに比べて向上したパフォーマンスの利点を提供できます。ダイレクト routing により、 実サーバーは、全ての出向くパケットを LVS router を介して通過させる代わりに、直接処理して要求側の ユーザーに回送することが出来ます。ダイレクト routing は、LVS router のジョブを来信のパケットのみの 処理にすることでネットワークパフォーマンス問題の可能性を低減します。
LVS Implemented with Direct Routing

図1.4 LVS Implemented with Direct Routing

標準的なダイレクト routing LVS セットアップでは、LVS router は到来するサーバー要求を 仮想 IP (VIP)を通じて受け取り、スケジューリングアルゴリズムを使用して要求を実サーバーに 回送します。実サーバーは要求を処理してその反応を LVS router を飛び越えて、直接クライアントに返します。 この routing の方法により、実サーバーからクライアントへの発信パケットを回送し、大量のネットワーク負荷状態では流通ネックとなり得る LVS router に、余計な負担を与えずに実サーバーを追加できると言う拡張性を持てるように なります。

1.4.2.1. ダイレクト Routing と ARP の限度

LVS でダイレクト routing を使用することに多くの利点がありますが、そこには限度があります。 ダイレクト routing を持つ LVS での最も一般的な問題は、アドレス解決プロトコル (Address Resolution Protocol)(ARP) にあります。
In typical situations, a client on the Internet sends a request to an IP address. Network routers typically send requests to their destination by relating IP addresses to a machine's MAC address with ARP. ARP requests are broadcast to all connected machines on a network, and the machine with the correct IP/MAC address combination receives the packet. The IP/MAC associations are stored in an ARP cache, which is cleared periodically (usually every 15 minutes) and refilled with IP/MAC associations.
ダイレクト routing LVS セットアップ内の ARP 要求での問題は、IP アドレスへのクライアント 要求は、要求処理の為に MAC アドレスとの関連付けが必要であるため、LVS システムの仮想 IP アドレスも また、 MAC に関連している必要があることです。しかし、LVS router と実サーバーの両方が全て 同じ IP を持つ為、ARP 要求は VIP に関連している全てのマシンにブロードキャストされます。これが 実サーバーの1つに関連付けのある VIP が要求を直接処理して、LVS router を完全に飛び越えて LVS セットアップの目的を無駄にすると言うようないくつかの問題の原因になります。
この問題を解決するには、到来する要求が、実サーバーの1つにではなく、常に LVS router に 送られるようにすることです。これは、以下のような理由で、 arptables_jf か又は iptables パケットフィルタリングツールを使用することで達成されます:
  • arptables_jf は ARP が VIP を実サーバーに関連付けるのを 阻止します。
  • iptables メソッドは、最初から実サーバー上で VIP を設定しないことに より、完全に ARP 問題を回避します。
For more information on using arptables or iptables in a direct routing LVS environment, refer to 「ダイレクト Routing 及び arptables_jf or 「ダイレクト Routing 及び iptables.

1.5. 固執とファイアウォールマーク

特定の状況では、LVS ロードバランシングアルゴリズムに要求を使用可能な最善の サーバーに送らせるよりも、クライアントが同一の実サーバーに繰り返して再接続することが 望ましくなります。そのような状況の例としては、複数画面のウェブページ、クッキー、SSL、 及び FTP 接続などがあります。これらのケースでは、トランザクションがそのコンテキストを維持する為に 同じサーバーで処理されない限りは、クライアントは正しく動作しない場合があります。LVS はこれに 対処するために二つの異なる機能を持っています: 固執 ファイアウォールマーク です。

1.5.1. 固執

有効になっていると、固執はタイマーのような働きをします。クライアントがサービスに 接続すると、LVS はある指定時間の間、最後の接続を記憶しています。同じクライアント IP アドレスがその時間内に再度接続すると、それは以前に接続したのと同じサーバーに送られます。 — ロードバランシングのメカニズムを飛び越えます。接続がその時間外に発生すると、 それは、設定してあるスケジューリング規則に従って処理されます。
固執により、管理者はサブネットマスクを指定して、接続をそのサブネットに 収束することによりどのアドレスが高レベルの固執を持つか を制御する為のツールとしてクライアント IP アドレステストへ適用出来ます。
異なるポートに向けられた接続を収束することは、FTP など通信の為に複数のポートを 使用するプロトコルに重要になります。しかし、固執は、異なるポートに宛てられた接続を 収束する時の問題に対処するのには最も効率的な方法ではありません。これらの状況には、 ファイアウォールマーク が最適です。

1.5.2. ファイアウォールマーク

ファイアウォールマークはプロトコルや関連したプロトコルの集合の為に使用される ポートをグループ化するのに簡単で効率の良い方法です。例えば、LVS が e-commerce サイトを 実行する為に導入された場合、ファイアウォールマークはポート 80 上で HTTP 接続を収束し、 ポート 443 上で安全な HTTPS 接続を収束するのに使用できます。同じファイアウォールマークを 各プロトコル用の仮想サーバーに割り当てることにより、LVS router が全ての要求を接続が開いた 後に同じ実サーバーに転送するため、トランザクション用の状況情報は保存されます。
この効率と簡単な使用法の為に、LVS の管理者は接続を収束するのに可能な限りいつでも 固執の代わりにファイアウォールマークを使用すべきです。しかし、管理者はファイアウォール マークとの併用で仮想サーバーへ固執を使用して、クライアントが適切な長さの期間は同じサーバーに 再接続されることを確実にする必要があります。

1.6. LVS — ブロック図表

LVS routers use a collection of programs to monitor cluster members and cluster services. 図1.5「LVS Components」 illustrates how these various programs on both the active and backup LVS routers work together to manage the cluster.
LVS Components

図1.5 LVS Components

pulse デーモンはアクティブとバックアップの両方の LVS router 上で稼働します。バックアップ router 上では pulseハートビート をアクティブ router の公共インターフェイスに送り、 アクティブ router がまだ、正常に機能していることを確認します。アクティブ router 上では、 pulse は、lvs デーモンを開始して、 バックアップ LVS router からの ハートビートクエリに応答します。
開始されると、lvs デーモンは ipvsadm ユーティリティをコールして、カーネル内の IPVS routing 表の設定と維持をし、 各実サーバー上の各設定済仮想サーバー用に nanny プロセスを開始します。 各 nanny プロセスは1つの実サーバー上の1つの設定済サービスの状況を チェックして lvs デーモンに実サーバー上のサービスが異常かどうかを 伝えます。異常が検出された場合、lvs デーモンは ipvsadm に指示を出して IPVS routing 表からその実サーバーを取り除きます。
バックアップ router がアクティブ router から応答を受け取らない場合、それは、send_arp をコールしてフェイルオーバーを開始し、全ての 仮想 IP アドレスをバックアップノードの NIC ハードウェアアドレス(MACアドレス) に 再割り当てします。そして公共とプライベートの両方のネットワークインターフェイスを通じて アクティブ router にコマンドを送り アクティブ router 上の lvs デーモンを シャットダウンします。その後はバックアップノード上の lvs デーモンが設定済 仮想サーバーの為に要求を受け付けます。

1.6.1. LVS Components

pulse shows a detailed list of each software component in an LVS router.

1.6.1.1. pulse

This is the controlling process which starts all other daemons related to LVS routers. At boot time, the daemon is started by the /etc/rc.d/init.d/pulse script. It then reads the configuration file /etc/sysconfig/ha/lvs.cf. On the active router, pulse starts the LVS daemon. On the backup router, pulse determines the health of the active router by executing a simple heartbeat at a user-configurable interval. If the active router fails to respond after a user-configurable interval, it initiates failover. During failover, pulse on the backup router instructs the pulse daemon on the active router to shut down all LVS services, starts the send_arp program to reassign the floating IP addresses to the backup router's MAC address, and starts the lvs daemon.

1.6.1.2. lvs

lvs デーモンは、pulse でコールされると アクティブ LVS router 上で稼働します。lvs デーモンは設定ファイル /etc/sysconfig/ha/lvs.cf を読み込み、ipvsadm ユーティリティを コールして IPVS routing 表の構成と維持をし、それぞれの設定済み LVS サービス用に nanny プロセスを割り当てます。nanny が、実サーバーの障害を報告した場合は、lvsipvsadm ユーティリティに指示をして IPVS routing 表からその実サーバーを取り除くようにします。

1.6.1.3. ipvsadm

このサービスはカーネル内の IPVS routing 表を更新します。lvs デーモンは IPVS routing 表内のエントリの追加、変更、削除をするのに ipvsadm を コールし、LVS をセットアップして管理します。

1.6.1.4. nanny

nanny 監視デーモンはアクティブ LVS router 上で稼働します。このデーモンを通じて、アクティブ router は各実サーバーの健全性を判定し、オプション として その稼働負担を監視します。別のプロセスが、各実サーバー上で定義されている各サービスの為に実行されます。

1.6.1.5. /etc/sysconfig/ha/lvs.cf

これが LVS の設定ファイルです。直接的に、又は間接的に全てのデーモンはその設定情報を このファイルから取得します。

1.6.1.6. Piranha Configuration Tool

これはウェブベースの監視、設定、そして LVS 管理用のツールです。これが /etc/sysconfig/ha/lvs.cf LVS 設定ファイルを維持する為のデフォルトツールです。

1.6.1.7. send_arp

このプログラムは、浮動 IP アドレスがフェイルオーバー時に1つのノードから別のノードに 移動する時に ARP ブロードキャストを送信します。
2章LVS の初期設定 reviews important post-installation configuration steps you should take before configuring Red Hat Enterprise Linux to be an LVS router.

第2章 LVS の初期設定

Red Hat Enterprise Linux のインストールの後、基本的な手順を追って LVS router と実サーバーの両方をセットアップする必要があります。この章では、これらの手順について詳しく説明しています。

注記

LVS がスタートしたらアクティブノードになる LVS router ノードは、主要ノード(primary node) とも呼ばれます。 LVS を設定する場合は、この主要ノード上で Piranha Configuration Tool を使用してください。

2.1. LVS Router 上でサービスの設定

Red Hat Enterprise Linux のインストールプログラムは LVS のセットアップに必要な全ての コンポーネントをインストールしますが、LVS の設定をする前に該当するサービスをアクティベートしておく必要があります。両方の LVS router の為に該当のサービスが 起動時にスタートするようにセットします。Red Hat Enterprise Linux には起動時にアクティベートするための サービスのセッティングに使用できる主要ツールが三つあります: コマンドラインプログラムの chkconfig、ncurses ベースプログラムの ntsysv、 グラフィカルツールの Services Configuration Tool です。これら全てのツールには root アクセスが必要です。

注記

root アクセスを取得するには、シェルプロンプトを開いて、su - コマンド入力して、その後に root パスワードを入力します。例えば:
$ su - root password
LVS router 上には、起動時にアクティベートされるべき三つのサービスがあります:
  • piranha-gui サービス (主要ノードのみ)
  • pulse サービス
  • sshd サービス
複数ポートサービスのクラスタリングを構成したり、ファイアウォールマークを使用したり している場合は、iptables サービスも有効にする必要が あります。
これらのサービスは、ランレベル 3 とランレベル 5 の両方でアクティベートするようにセットするのが 最適です。 chkconfig を使用してこれを達成するには、それぞれのサービス用に 以下のコマンドを入力します:
/sbin/chkconfig --level 35 daemon on
上記のコマンドで daemon の部分を、アクティベートする サービスの名前で入れ替えます。システム上のサービスの一覧とそれらがアクティベートするように セットされているランレベルを取得するには、以下のコマンドを発行します:
/sbin/chkconfig --list

警告

Turning any of the above services on using chkconfig does not actually start the daemon. To do this use the /sbin/service command. See Piranha Configuration Tool サービスの開始」 for an example of how to use the /sbin/service command.
For more information on runlevels and configuring services with ntsysv and the Services Configuration Tool, refer to the chapter titled 『"Controlling Access to Services"』 in the 『Red Hat Enterprise Linux System Administration Guide』.

2.2. Piranha Configuration Tool 用のパスワードの設定

主要 LVS router 上で初めて Piranha Configuration Tool を使用する前に、 パスワードを作成してそのアクセスを制限する必要があります。これを実行するには、root として 次のコマンドを発行します:
/usr/sbin/piranha-passwd
このコマンドを入力した後は、催促された時に管理者パスワードを作成します。

警告

パスワードをより安全にするには、代名詞や通常使用される略語や、あるいはどんな言語にしても 辞書にあるような単語は含んではいけません。システム上ではどの場所でもパスワードを暗号化 のない状態で放置しないで下さい。
アクティブ Piranha Configuration Tool セッションの間にパスワードが変更になった 場合は、管理者は新規のパスワードを提供するように催促されます。

2.3. Piranha Configuration Tool サービスの開始

Piranha Configuration Tool の為のパスワードを設定したら、次には /etc/rc.d/init.d/piranha-gui 内にある piranha-gui を 開始、又は再開始します。これを実行するには、root として以下のコマンドを入力します:
/sbin/service piranha-gui start
or
/sbin/service piranha-gui restart
Issuing this command starts a private session of the Apache HTTP Server by calling the symbolic link /usr/sbin/piranha_gui -> /usr/sbin/httpd. For security reasons, the piranha-gui version of httpd runs as the piranha user in a separate process. The fact that piranha-gui leverages the httpd service means that:
  1. Apache HTTP Server がシステム上にインストールしてある必要があります。
  2. service コマンドを使って Apache HTTP Server を停止したり再開始したりすると piranha-gui サービスが停止します。

警告

LVS router 上で /sbin/service httpd stop 又は /sbin/service httpd restart のコマンドが発行された場合、以下のコマンドを発行して piranha-gui を開始する必要があります:
/sbin/service piranha-gui start
The piranha-gui service is all that is necessary to begin configuring LVS. However, if you are configuring LVS remotely, the sshd service is also required. You do not need to start the pulse service until configuration using the Piranha Configuration Tool is complete. See 「LVS の開始」 for information on starting the pulse service.

2.3.1. Piranha Configuration Tool Web サーバーポートの設定

Piranha Configuration Tool はデフォルトで、ポート 3636 上で稼働します。 このポート番号を変更するには、piranha-gui Web サーバー設定ファイル、 /etc/sysconfig/ha/conf/httpd.conf のセクション 2 内で Listen 3636 の行を変更します。
Piranha Configuration Tool を使用するには、最低でもテキスト Web ブラウザが 必要になります。主要 LVS router 上で Web ブラウザを開始する場合は、ロケーション http://localhost:3636 を開きます。 localhost の部分を主要 LVS router の ホスト名、又は IP アドレスで 入れ替えることにより Web ブラウザを通じてどこからでも Piranha Configuration Tool に 到達できます。
ブラウザが Piranha Configuration Tool に接続すると、ログインして設定 サービスに アクセスします。ユーザー名(Username) フィールドに piranha と入力して パスワード(Password) フィールドに piranha-passwd で設定したパスワードを入力します。
Piranha Configuration Tool が稼働している状態になると、ネットワーク上で このツールにアクセスできるメンバーを制限するのが良いでしょう。次のセクションでは、この タスクを達成する方法を説明します。

2.4. Piranha Configuration Tool へのアクセスを制限

Piranha Configuration Tool は正当なユーザー名とパスワードの組み合わせを 要求してきます。しかし、Piranha Configuration Tool に渡されるすべての データは平文であるため、アクセスを許可するのは信頼できるネットワークかローカルマシンに 制限すべきです。
The easiest way to restrict access is to use the Apache HTTP Server's built in access control mechanisms by editing /etc/sysconfig/ha/web/secure/.htaccess. After altering the file you do not have to restart the piranha-gui service because the server checks the .htaccess file each time it accesses the directory.
デフォルトでは、このディレクトリ用のアクセス制御は誰にでもディレクトリの内容を 表示させるようになっています。デフォルトのアクセスは以下のように見えます:
Order deny,allow
Allow from all
Piranha Configuration Tool へのアクセスをローカルホストだけに制限する には、ループバックデバイス (127.0.0.1) のみにアクセスを許可するように .htaccess ファイルを変更します。ループバックデバイスに関する詳細情報には、『Red Hat Enterprise Linux Reference Guide』 にある 『ネットワークスクリプト(Network Scripts)』 と言う章をご覧下さい。
Order deny,allow
Deny from all
Allow from 127.0.0.1
この例に示してあるように特定のホストやサブネットを許可することも出来ます:
Order deny,allow
Deny from all
Allow from 192.168.1.100
Allow from 172.16.57
この例では、IP アドレス 192.168.1.100 を持つマシンと、172.16.57/24 ネットワーク上の マシンからの Web ブラウザのみが Piranha Configuration Tool にアクセス 出来ます。

警告

Piranha Configuration Tool .htaccess ファイルの 編集により、/etc/sysconfig/ha/web/secure/ ディレクトリ内の設定ページへの アクセスを制限できますが、/etc/sysconfig/ha/web/ のログインとヘルプページ にはアクセス制限が出来ません。このディレクトリへのアクセスを制限するには、/etc/sysconfig/ha/web/secure/.htaccess と同じように orderallowdeny の 行を持つ .htaccess ファイルを /etc/sysconfig/ha/web/ ディレクトリ内に作成します。

2.5. パケット転送をオンにする

LVS router が実サーバーに正常にネットワークパケットを転送するためには、各 LVS router ノードは カーネル内で IP 転送をオンにしている必要があります。root としてログインして /etc/sysctl.conf 内で net.ipv4.ip_forward = 0 となっている行を 以下のように変更します:
net.ipv4.ip_forward = 1
変更はシステムを再起動した時点で反映されます。
IP 転送がオンになっていることをチェックするには、root として次のコマンドを発行します :
/sbin/sysctl net.ipv4.ip_forward
上記のコマンドが 1 を返してくれば、IP 転送は 有効になっています。コマンドが 0 を返して来た場合は 以下のコマンドを使用して、手動でオンにすることができます:
/sbin/sysctl -w net.ipv4.ip_forward=1

2.6. 実サーバー上でサービスの設定

実サーバーが Red Hat Enterprise Linux システムであれば、該当するサーバーデーモンを設定して 起動時にアクティベートするようにします。これらのデーモンは Web サービス用の httpd 又は FTP や Telnet サービス用の xinetd を含むことができます。
実サーバーにリモートでアクセスすることも便利になります。その為には sshd デーモンもインストールして実行している必要があります。

第3章 LVS のセットアップ

LVS は二つの基本グループで構成されています: LVS router と実サーバーです。ネックとなり得る単一故障箇所を防止する為にそれぞれのグループには、少なくとも二つのメンバー システムが含まれています。
LVS router グループは、Red Hat Enterprise Linux を実行している同一の、又は近似の二つのシステムで構成 する必要があります。その1つは、アクティブ LVS router として機能し、他の 1つはホット スタンバイモードで待機し、この二つが出来る限り同様な能力を維持する必要があります。
実サーバーグループ用にハードウェアを選択して設定をする前に、3 種類の LVS トポロジーの内のどれを使用するかを決定しなければなりません。

3.1. NAT LVS ネットワーク

NAT トポロジーを使用すると、既存のハードウェアの活用に大きな自由度を得ることができますが、サーバー群を出入りするパケットがすべて LVS router を通過すると言う事実により、大量のロードを処理するには限界があります。
ネットワークレイアウト
NAT routing を使用する LVS 用のトポロジーは、公共ネットワークへ 1つのみのアクセスポイントを 必要とするだけの為、ネットワークレイアウトの観点からは最も簡単に設定ができます。実サーバーは LVS router を通じて全ての要求を渡すため、それらは自身のプライベートネットワーク内にあることになります。
ハードウェア
実サーバーは正常に機能するためには Linux マシンである必要がない為、 NAT トポロジーはハードウェアに関しては最も柔軟性を持ちます。NAT トポロジー内では、 各実サーバーは、LVS router に反応するだけのため 1つの NIC を必要とするだけです。反面、 LVS router は2つのネットワークの間でトラフィックを回送するためにそれぞれ2つの NIC を持つ必要があります。このトポロジーでは LVS router の部分でネットワークのネックとなるため、gigabit イーサネット NIC を各 LVS router で使用することにより、 LVS router が処理できるバンド幅を 拡大することができます。gigabit イーサネットが LVS router で使用される場合、実サーバーを LVS router に接続しているスイッチはロードを効率的に処理するために少なくとも2つの gigabit イーサネットが必要になります。
ソフトウェア
NAT トポロジーは、一部の設定のために iptables の使用を必要とするため、 Piranha Configuration Tool の外部でかなりのソフトウェア設定があります。特に FTP サービスとファイアウォールマークの使用は、要求を正しく回送するために余分な手動の LVS router 設定を必要とします。

3.1.1. NAT のある LVS 用の Network インターフェイス設定

To set up LVS with NAT, you must first configure the network interfaces for the public network and the private network on the LVS routers. In this example, the LVS routers' public interfaces (eth0) will be on the 192.168.26/24 network (I know, I know, this is not a routable IP, but let us pretend there is a firewall in front of the LVS router for good measure) and the private interfaces which link to the real servers (eth1) will be on the 10.11.12/24 network.
So on the active or primary LVS router node, the public interface's network script, /etc/sysconfig/network-scripts/ifcfg-eth0, could look something like this:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.26.9
NETMASK=255.255.255.0
GATEWAY=192.168.26.254
LVS router 上のプライベートNAT インターフェイス用の /etc/sysconfig/network-scripts/ifcfg-eth1 は次のようになります:
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.11.12.9
NETMASK=255.255.255.0
In this example, the VIP for the LVS router's public interface will be 192.168.26.10 and the VIP for the NAT or private interface will be 10.11.12.10. So, it is essential that the real servers route requests back to the VIP for the NAT interface.

重要

The sample Ethernet interface configuration settings in this section are for the real IP addresses of an LVS router and not the floating IP addresses. To configure the public and private floating IP addresses the administrator should use the Piranha Configuration Tool, as shown in GLOBAL SETTINGS and 仮想サーバー サブセクション」.
After configuring the primary LVS router node's network interfaces, configure the backup LVS router's real network interfaces — taking care that none of the IP address conflict with any other IP addresses on the network.

重要

バックアップノード上の各インターフェイスが、主要ノード上のインターフェイスと 同じネットワークをサービスすることを確実にして下さい。例えば、eth0 が主要ノードの 公共ネットワークに接続するのであれば、それが、バックアップノードの公共ネットワークにも 接続するようにする必要があります。

3.1.2. 実サーバー上での Routing

NAT トポロジー内で実サーバーネットワークインターフェイスを設定する場合に忘れて ならないことは、LVS router の NAT 浮動 IP アドレス用にゲートウェイを設定することです。この例では、そのアドレスは 10.11.12.10 となります。

注記

Once the network interfaces are up on the real servers, the machines will be unable to ping or connect in other ways to the public network. This is normal. You will, however, be able to ping the real IP for the LVS router's private interface, in this case 10.11.12.8.
So the real server's /etc/sysconfig/network-scripts/ifcfg-eth0 file could look similar to this:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.11.12.1
NETMASK=255.255.255.0
GATEWAY=10.11.12.10

警告

実サーバーが GATEWAY= の行で設定してある 複数のネットワークインターフェイスを持つ場合、最初に出てくる設定がゲートウェイ用となります。 そのため、eth0eth1 の両方が設定されていて eth1 が LVS に使用されている場合は、 実サーバーは要求を正しく回送しないかも知れません。
/etc/sysconfig/network-scripts/ ディレクトリ内のネットワークスクリプトで ONBOOT=no とセットするか、又は ゲートウェイが 最初に出てくるインターフェイスの中で正しくセットされるのを確認して余分なネットワークインターフェイスを オフにするのが良策です。

3.1.3. LVS Router 上の NAT Routing を有効にする

In a simple NAT LVS configuration where each clustered service uses only one port, like HTTP on port 80, the administrator needs only to enable packet forwarding on the LVS routers for the requests to be properly routed between the outside world and the real servers. See 「パケット転送をオンにする」 for instructions on turning on packet forwarding. However, more configuration is necessary when the clustered services require more than one port to go to the same real server during a user session. For information on creating multi-port services using firewall marks, see 「複数ポートサービスと LVS 」.
Once forwarding is enabled on the LVS routers and the real servers are set up and have the clustered services running, use the Piranha Configuration Tool to configure LVS as shown in 4章Piranha Configuration Tool で LVS Router を設定.

警告

Do not configure the floating IP for eth0:1 or eth1:1 by manually editing network scripts or using a network configuration tool. Instead, use the Piranha Configuration Tool as shown in GLOBAL SETTINGS and 仮想サーバー サブセクション」.
When finished, start the pulse service as shown in 「LVS の開始」. Once pulse is up and running, the active LVS router will begin routing requests to the pool of real servers.

3.2. ダイレクト Routing 経由の LVS

As mentioned in 「ダイレクト Routing」, direct routing allows real servers to process and route packets directly to a requesting user rather than passing outgoing packets through the LVS router. Direct routing requires that the real servers be physically connected to a network segment with the LVS router and be able to process and direct outgoing packets as well.
ネットワークレイアウト
ダイレクト routing LVS のセットアップでは、LVS router は来信の要求を受け取り、それらを 処理の為に正しい実サーバーに回送する必要があります。実サーバーはそれから、その反応を 直接クライアントに回送しなければなりません。その例として、 クライアントがインターネット上に存在し、パケットを LVS router を通じて実サーバーに 送った場合、実サーバーはインターネットを通じて直接クライアントに到達できる必要が あります。これは、実サーバー用のゲートウェイがインターネットへパケットを送るように 設定することで達成できます。サーバー群の各実サーバーは独自の個別ゲートウェイ(及び、 各ゲートウェイがインターネットへの独自接続を持つ)を持つことが出来るため、最大の 処理能力と拡張性が可能になります。しかし、標準的な LVS 設定では、実サーバーは1つの ゲートウェイ(故に、1つのネットワーク接続)を通じて通信します。

重要

LVS router を実サーバーの為のゲートウェイとして使用することは推薦できません。 そのように使用した場合は、LVS router に不要な複雑性とネットワーク負荷を追加してしまい、それが NAT routing 内に存在するようなネットワークの問題点ネックを再導入してしまいます。
ハードウェア
ダイレクト routing を使用した LVS システムのハードウェア要件は、他の LVS トポロジーに 似ています。LVS router は来信する要求を処理する為に Red Hat Enterprise Linux を実行していて、 実サーバー用にロードバランシングを実行する必要がありますが、実サーバーは 正常に機能するかぎりは、Linux マシンである必要はありません。LVS router はそれぞれが 1つ、又は2つの NIC を必要とします。(バックアップ router の有無により決定)各設定用に 2つの NIC を使用し、完全にトラフィックを分割することが可能です。— 1 つの NIC で 来信要求を処理して、実サーバーへのパケット回送は2つめの NIC に任せることが出来ます。
実サーバーは LVS router を迂回して、出向くパケットを直接クライアントに送信するため、 インターネットへのゲートウェイが必要となります。最大パフォーマンスと可用性のためには、 各実サーバーはそれぞれ独自のゲートウェイに接続して、そのゲートウェイが更に独自にクライアントの接続されているキャリヤーネットワーク(インターネットやイントラネット)に接続するようにします。
ソフトウェア
There is some configuration outside of Piranha Configuration Tool that needs to be done, especially for administrators facing ARP issues when using LVS via direct routing. Refer to 「ダイレクト Routing 及び arptables_jf or 「ダイレクト Routing 及び iptables for more information.

3.2.1. ダイレクト Routing 及び arptables_jf

In order to configure direct routing using arptables_jf, each real server must have their virtual IP address configured, so they can directly route packets. ARP requests for the VIP are ignored entirely by the real servers, and any ARP packets that might otherwise be sent containing the VIPs are mangled to contain the real server's IP instead of the VIPs.
arptables_jf メソッドを使用すると、アプリケーションは 実サーバーがサービスをしている各個別の VIP 又は、ポートにバインドすることができます。 例えば、arptables_jf メソッドの使用により、Apache HTTP Server の複数のインスタンスは、システム上の異なる VIP に明示的にバインドして実行することができます。また、arptables_jf の使用には、iptables オプション以上の明確なパフォーマンス利点があります。
しかし、arptables_jf メソッドの使用では、VIP は。標準の Red Hat Enterprise Linux システム設定ツールを使用した起動時の開始が設定できません。
それぞれの仮想 IP アドレスの為の ARP 要求を無視するように 各実サーバーを設定するには、 以下の手順を実行します:
  1. 各実サーバー上で各仮想 IP アドレス用に ARP 表のエントリを作成します( real_ip とは実サーバーと通信するためにディレクタが使用する IP、多くの場合、これは eth0 にバインドされた IP ):
    arptables -A IN -d <virtual_ip> -j DROP
    arptables -A OUT -s <virtual_ip> -j mangle --mangle-ip-s <real_ip>
    
    これは実サーバーが仮想 IP アドレス用の全ての ARP 要求を無視するようにして、他の方法では、 仮想 IP を含むはずの出向する ARP 反応を変化させて、それらが代わりにサーバー用の実 IP を含むようになります。いずれかの VIP 用の ARP 要求に反応すべき唯一のノードは現在 アクティブな LVS ノードです。
  2. これが各実サーバー上で完了すると、実サーバー上で以下のコマンドを入力して ARP 表のエントリを保存します:
    service arptables_jf save
    chkconfig --level 2345 arptables_jf on
    chkconfig コマンドは システムが起動時に — ネットワークが開始する前にarptables 設定をリロードするようにします。
  3. ifconfig を使用して実サーバー上で仮想 IP アドレスを設定し、 IP エイリアスを作成します。例えば:
    # ifconfig eth0:1 192.168.76.24 netmask 255.255.252.0 broadcast 192.168.79.255 up
    又は、iproute2 のユーティリティ ip を使用します。 例えば:
    # ip addr add 192.168.76.24 dev eth0
    以前に記述してあるように、仮想 IP アドレスは、Red Hat システム設定ツールを使用しては、 起動時に開始するように設定はできません。この問題を迂回する1つの手段は /etc/rc.d/rc.local 内にこららのコマンドを配置することです
  4. Configure Piranha for Direct Routing. Refer to 4章Piranha Configuration Tool で LVS Router を設定 for more information.

3.2.2. ダイレクト Routing 及び iptables

iptables ファイアウォールルールを作成することにより、 ダイレクト routing メソッドを使用して ARP 問題を迂回することも出来ます。iptables を使用してダイレクト routing を設定するには、 VIP アドレスがシステム上に存在しなくても VIP アドレスに送信されたパケットを実サーバーが サービスするように透過的なプロキシーを作成するルールを追加する必要があります。
iptables メソッドは arptables_jf メソッドよりも 設定が 簡単です。仮想 IP アドレスがアクティブ LVS ディレクタ上にのみ存在するため、 このメソッドでは LVS ARP 問題も完全に回避します。
しかし、各パケットの転送/マスカレードでのオーバーヘッドがあるため、arptables_jf に 比較すると、iptables メソッドの 使用にはパフォーマンス問題があります。
また、iptables メソッドを使用してポートの再使用は出来ません。例えば、二つの別々の Apache HTTP Server サービスは 両方共、仮想 IP アドレスではなく、INADDR_ANY にバインドする必要があるため、ポート 80 にバインドされた二つの別々の Apache HTTP Server サービスは稼働できません。
iptables メソッドを使用してダイレクト routing を設定するには、以下の手順を 実行します:
  1. 各実サーバー上で、実サーバーの為に意図されたサービスの VIP 、ポート、プロトコル(TCP か UDP)の 全ての組み合わせ用に以下のコマンドを実行します:
    iptables -t nat -A PREROUTING -p <tcp|udp> -d <vip> --dport <port> -j REDIRECT
    このコマンドは実サーバーが VIP とその与えられたポートを目的地としたパケットを処理するように します。
  2. 各実サーバー上で設定を保存します:
    # service iptables save
    # chkconfig --level 2345 iptables on
    上記のコマンドは、システムが起動時に — ネットワークが開始する前に、iptables 設定を リロードするようにします。

3.3. 設定の収束

上記の routing メソッドのうち使用するものを決定した後は、ハードウェアは ネットワーク上で一緒にリンクしてある必要があります。

重要

LVS router 上のアダプタデバイスは、同じネットワークにアクセスするように設定しなければ なりません。例えば、eth0 が公共ネットワークに接続して、 eth1 がプライベートネットワークに接続する場合、バックアップ LVS router 上の同じデバイスは、同じネットワークに接続する必要があります。
また、起動時に最初に出現するインターフェイスにリストされているゲートウェイは、 routing 表に追加され、他のインターフェイスにリストされた結果的に出るゲート ウェイは無視されます。これは、実サーバーを設定する場合に特に考慮すべき 重要点です。
ハードウェアを物理的に接続した後は、主要 LVS router と バックアップ LVS router 上で ネットワークインターフェイスを設定します。これは、system-config-network などのグラフィカルアプリケーションを使用するか、又は手動でネットワークスクリプトを編集することで達成できます。system-config-network を使用した デバイスの追加に関する詳細情報には、『Red Hat Enterprise Linux 導入ガイド』 内にある 『ネットワーク設定』 を参照してください。この章の残りの部分では、 ネットワークインターフェイスへの変更の例は手動か、あるいは Piranha Configuration Tool を 介して実行されます。

3.3.1. 全般的 LVS ネットワーキングのヒント

Piranha Configuration Tool を使用して LVS の設定を試みる前に、 LVS router 上で、公共ネットワークとプライベートネットワークの両方用に実 IP アドレスを 設定します。各トポロジーのセクションはサンプルのネットワークアドレスを与えていますが、 本当のネットワークアドレスが必要になります。以下にネットワークインターフェイスの立ち上げと それらのステータスチェックに役に立つコマンドを示します。
実ネットワーキングインターフェイスの立ち上げ
実ネットワークインターフェイスを立ち上げるには、root として以下のコマンドを実行して、 N の部分をインターフェイスに相当する番号で入れ替えます。 (eth0eth1
/sbin/ifup ethN

警告

Do not use the ifup scripts to bring up any floating IP addresses you may configure using Piranha Configuration Tool (eth0:1 or eth1:1). Use the service command to start pulse instead (see 「LVS の開始」 for details).
実ネットワークインターフェイスの停止
実ネットワークインターフェイスを停止するには、root で以下のコマンドを使用して、 N の部分をインターフェイスに相当する番号で入れ替えます。 (eth0eth1)
/sbin/ifdown ethN
ネットワークインターフェイスのステータスチェック
任意の時点で起動しているネットワークインターフェイスをチェックするには、以下を 入力します:
/sbin/ifconfig
あるマシンの routing テーブルを表示するには、以下のコマンドを発行します:
/sbin/route

3.4. 複数ポートサービスと LVS

LVS routers under any topology require extra configuration when creating multi-port LVS services. Multi-port services can be created artificially by using firewall marks to bundle together different, but related protocols, such as HTTP (port 80) and HTTPS (port 443), or when LVS is used with true multi-port protocols, such as FTP. In either case, the LVS router uses firewall marks to recognize that packets destined for different ports, but bearing the same firewall mark, should be handled identically. Also, when combined with persistence, firewall marks ensure connections from the client machine are routed to the same host, as long as the connections occur within the length of time specified by the persistence parameter. For more on assigning persistence to a virtual server, see 仮想サーバー サブセクション」.
残念なことに、実サーバー上でロードのバランスを取るために使用するメカニズム — IPVS — は、パケットに割り当てたファイアウォールマークは認識できますが、自身でファイアウォールマークを割り当てる ことが出来ません。ファイアウォールマークを割り当てる 作業はネットワーク パケットフィルタ、iptables によって Piranha Configuration Tool の外部で実行される必要があります。

3.4.1. ファイアウォールマークの割り当て

ファイアウォールマークを、特定ポートに向けたパケットに割り当てるには、管理者は iptables を使用する必要があります。
This section illustrates how to bundle HTTP and HTTPS as an example; however, FTP is another commonly clustered multi-port protocol. If an LVS is used for FTP services, refer to 「FTP の設定」 for configuration details.
ファイアウォールマークの使用で記憶すべき基本ルールは、Piranha Configuration Tool で ファイアウォールを使用している全てのプロトコルに、ネットワークパケットにマークを割り当てる為の 同量の iptables ルールが存在すべきだと言うことです。
ネットワークパケットフィルタルールを作成する前に、既に他のルールが存在しないことを 確認してください。これを行うには、シェルプロンプトを開いて、root でログインして 以下を入力します:
/sbin/service iptables status
iptables が稼働していない場合、すぐにプロンプトが 再出現します。
iptables がアクティブな場合、ルールセットを表示します。 ルールが存在するならば、以下のコマンドを入力します:
/sbin/service iptables stop
既存のルールが重要な場合、/etc/sysconfig/iptables の内容を確認して、 保存する価値のあるルールを安全な場所にコピーしてから継続します。
同じファイアウォールマーク 80 を、 ポート80 と 443 上の浮動 IP アドレス n.n.n.n へ向けられたトラフィックへ割り当てるルールを以下に示します。
/sbin/modprobe ip_tables
/sbin/iptables -t mangle -A PREROUTING -p tcp -d n.n.n.n/32 --dport 80 -j MARK --set-mark 80
/sbin/iptables -t mangle-A PREROUTING -p tcp -d n.n.n.n/32 --dport 443 -j MARK --set-mark 80
For instructions on assigning the VIP to the public network interface, see 仮想サーバー サブセクション」. Also note that you must log in as root and load the module for iptables before issuing rules for the first time.
上述の iptables コマンドでは、n.n.n.n の部分は使用中の HTTP と HTTPS 仮想サーバーの浮動 IP で入れ替える必要が あります。これらのコマンドは、該当するポート上の VIP に向けられた全てのトラフィックを ファイアウォールマーク 80 に割り当てることと同様の効果を持ちます。これが結果として、 IPVS で認識され、適切に転送されます。

警告

The commands above will take effect immediately, but do not persist through a reboot of the system. To ensure network packet filter settings are restored upon reboot, refer to 「ネットワークパケットフィルター設定の保存」

3.5. FTP の設定

ファイル転送プロトコル(FTP) は旧式ながら複雑な複数ポートプロトコルで、LVS 環境に明白な挑戦を与えます。 これらの挑戦の性質を理解するには、まず FTP の動作に付いて基本事項を理解する必要があるでしょう。

3.5.1. FTP の動作

ほとんどのサーバー/クライアント関係では、クライアントマシンが特定のポート上でサーバーへの 接続を開いて、サーバーがそれからそのポートのクライアントに返答することになります。FTP クライアントが FTP サーバーに接続する場合、それは FTP 制御ポート 21 への接続を開きます。その後、その クライアントが FTP サーバーに対して、アクティブ パッシブ のどちらの接続を開くかを告げます。クライアントに よって選択された接続のタイプが、サーバーの対応の仕方とトランザクションが発生するポートを決定 します。
二つのタイプのデータ接続は以下のようになります:
アクティブ接続
アクティブ接続が確立されると、サーバーは、ポート20からクライアント マシン上の高い範囲のポートにクライアントへデータ接続を開きます。サーバーからの全てのデータは その後この接続を通じて渡されます。
パッシブ接続
パッシブ接続が確立されると、クライアントは、FTP サーバーに対して、 パッシブ接続ポートを確立するように依頼し、それは 10,000 より高いポートのいずれかになります。 サーバーはその後、この特定のセッション用に高い数値のポートをバインドしてこのポート番号を クライアントの伝えます。それからクライアントはデータ接続のために新規にバインドされたポートを 開きます。クライアントが作る各データ要求は別々のデータ接続となります。殆どのモダンな FTP クライアントは、 サーバーからデータを要求する場合、パッシブ接続を確立する試みをします。

注記

クライアント が接続のタイプを決定します。サーバーではありません。これは効率的に FTP を収束するために、アクティブ接続とパッシブ接続の両方を処理するように LVS router を設定する必要があることを意味します。
FTP クライアント/サーバーの組み合わせは、Piranha Configuration Tool と IPVS が認識していない多くのポートを開く可能性があります。

3.5.2. LVS Routing への影響

IPVS パケット転送は、それをベースにしたクラスタの内部と外部間の接続だけを許可し、 そのポート番号、又はファイアウォールマークを認識します。クラスタ外のクライアントが IPVS で処理するように設定されていないポートを開こうとした場合、接続は切られます。 同様に 実サーバーが、IPVS が認識できないポート上のインターネットへ接続を開こうと した場合も、接続は切られます。この事は、インターネット上の FTP クライアントからの 全ての接続は、それらに同じファイアウォールマークが割り当て られている必要があり、そして FTP サーバーからの全ての接続は、 ネットワークフィルタリングルールを使用して正しくインターネットに転送される 必要があることを意味します。

3.5.3. ネットワークパケットフィルタルールの作成

Before assigning any iptables rules for FTP service, review the information in 「ファイアウォールマークの割り当て」 concerning multi-port services and techniques for checking the existing network packet filtering rules.
Below are rules which assign the same firewall mark, 21, to FTP traffic. For these rules to work properly, you must also use the VIRTUAL SERVER subsection of Piranha Configuration Tool to configure a virtual server for port 21 with a value of 21 in the Firewall Mark field. See 仮想サーバー サブセクション」 for details.

3.5.3.1. アクティブ接続のルール

アクティブ接続のルールはカーネルに対して、ポート 20 — FTP データポート上にある 内部浮動 IP アドレスへ届く接続を受け付けて転送するように指示します。
以下の iptables コマンドにより、LVS router は、IPVS が認識していない 実サーバーからの外向けの接続を受け付けることが出来ます:
/sbin/iptables -t nat -A POSTROUTING -p tcp -s n.n.n.0/24 --sport 20 -j MASQUERADE
In the iptables command, n.n.n should be replaced with the first three values for the floating IP for the NAT interface's internal network interface defined in the GLOBAL SETTINGS panel of Piranha Configuration Tool.

3.5.3.2. パッシブ接続のルール

パッシブ接続のルールは、インターネットから広いポート範囲 — 10,000 から 20,000 までにあるサービス用の浮動 IP へ到来する接続へ適切なファイアウォールマークを 割り当てます。

警告

パッシブ接続用にポート範囲を制限している場合、一致するポート範囲を使用するように VSFTP サーバーも設定する必要があります。これは、/etc/vsftpd.conf に 以下の行を追加することで達成できます:
pasv_min_port=10000
pasv_max_port=20000
パッシブ FTP 接続のためにサーバーがクライアントに表示するアドレスを制御する 必要があります。NAT 回送の LVS システムでは、以下の行を /etc/vsftpd.conf に 追加して VIP への実サーバー IP アドレスを書き換えます。これをクライアントが接続時に認識します。 例えば:
pasv_address=n.n.n.n
n.n.n.n の部分は LVS システムの VIP アドレスで入れ替えます。
他の FTP サーバーの設定に関しては、それぞれのドキュメントを参照して下さい。
この範囲は多くの状況用に十分に広いはずです。しかし、以下のコマンド内の 10000:200001024:65535 に変更することにより安全対策のない全ての利用可能なポートを含むようにこの数字を拡大できます。
次の iptables コマンドは、適切なポート上の浮動 IP に向けられた トラフィックをファイアウォールマーク 21 に割り当てる実質効果を持ち、これが結果として IPVS で 認識されて正しく転送されます:
/sbin/iptables -t mangle -A PREROUTING -p tcp -d n.n.n.n/32 --dport 21 -j MARK --set-mark 21
/sbin/iptables -t mangle -A PREROUTING -p tcp -d n.n.n.n/32 --dport 10000:20000 -j MARK --set-mark 21
iptables コマンドでは、n.n.n.nPiranha Configuration Tool仮想サーバー サブセクション内で 定義されている FTP 仮想サーバー用の浮動 IP で入れ替える必要があります。

警告

The commands above take effect immediately, but do not persist through a reboot of the system. To ensure network packet filter settings are restored after a reboot, see 「ネットワークパケットフィルター設定の保存」
Finally, you need to be sure that the appropriate service is set to activate on the proper runlevels. For more on this, refer to 「LVS Router 上でサービスの設定」.

3.6. ネットワークパケットフィルター設定の保存

ユーザーの状況に応じた適切なネットワークパケットフィルタを設定した後は、 そのセッティングを保存して再起動後にそれが復帰するようにします。 iptables 用には以下のコマンドを使用します:
/sbin/service iptables save
これが /etc/sysconfig/iptables 内の設定を保存し、設定は起動時に 再度呼び出し可能になります。
Once this file is written, you are able to use the /sbin/service command to start, stop, and check the status (using the status switch) of iptables. The /sbin/service will automatically load the appropriate module for you. For an example of how to use the /sbin/service command, see Piranha Configuration Tool サービスの開始」.
Finally, you need to be sure the appropriate service is set to activate on the proper runlevels. For more on this, see 「LVS Router 上でサービスの設定」.
次の章では、Piranha Configuration Tool を使用して LVS router を設定する方法を説明し、LVS をアクティブにするのに必要な手順を案内しています。

第4章 Piranha Configuration Tool で LVS Router を設定

Piranha Configuration Tool は LVS 用の設定ファイル — /etc/sysconfig/ha/lvs.cf に必要となる設定ファイルを作成する為の 計画的アプローチを提供します。この章では、Piranha Configuration Tool の基本的 アプローチと、設定が完了した後にクラスタをアクティブにする方法を説明しています。

重要

LVS 用の設定ファイルは厳格なフォーマット規則に従います。Piranha Configuration Tool の 使用は、lvs.cf 内での構文エラーを防止し、またソフトウェア 失敗を防止する最善の手段となります。

4.1. 必要なソフトウェア

Piranha Configuration Tool を使用するためには、piranha-gui サービスが主要 LVS router 上で稼働している必要があります。LVS を 設定するには、最低でも links などのテキストベースのウェブブラウザが必要です。別のマシンから LVS router にアクセスしている 場合は、主要 LVS router まで root ユーザーとして ssh 接続が必要です。
主要 LVS router を設定している時に、ターミナルウィンドウ内で ssh 接続を 並行して維持するのが良いでしょう。この接続は pulse や他のサービスの再開始、 ネットワークパケットフィルタの設定、及びトラブルシューティングでの /var/log/messages の監視などをする為の安全な手段を提供します。
次の四つのセクションでは、Piranha Configuration Tool の設定ページのそれぞれを見ていき、 LVS のセットアップの為のその使用法を説明します。

4.2. Piranha Configuration Tool へのログイン

When configuring LVS, you should always begin by configuring the primary router with the Piranha Configuration Tool. To do this,verify that the piranha-gui service is running and an administrative password has been set, as described in Piranha Configuration Tool 用のパスワードの設定」.
If you are accessing the machine locally, you can open http://localhost:3636 in a Web browser to access the Piranha Configuration Tool. Otherwise, type in the hostname or real IP address for the server followed by :3636. Once the browser connects, you will see the screen shown in 図4.1「The Welcome Panel」.
The Welcome Panel

図4.1 The Welcome Panel

ログイン(Login) ボタンをクリックして ユーザー名(Username)piranha を入力し、パスワード(Password) には作成してある管理者パスワードを入力します。
Piranha Configuration Tool は四つの主要画面、いわゆる パネル で 構成されています。更に、仮想サーバー パネルには、四つのサブセクション が含まれています。制御/監視 パネルがログイン画面の後に出る 最初のパネルです。

4.3. CONTROL/MONITORING

制御/監視 パネルは LVS の制限付きランタイムステータスを与えます。 これは、pulse デーモンのステータス、LVS routing 表、及び LVS 派生の nanny プロセスを表示します。

注記

The fields for CURRENT LVS ROUTING TABLE and CURRENT LVS PROCESSES remain blank until you actually start LVS, as shown in 「LVS の開始」.
The CONTROL/MONITORING Panel

図4.2 The CONTROL/MONITORING Panel

Auto update
このページ上のステータス表示は、ユーザーの設定した間隔で自動的に更新ができます。 この機能を有効にするには、自動更新 チェックボックスを クリックして、秒単位の更新頻度 テキストボックス(デフォルトは 10 秒) 内の更新頻度をセットします。
この自動更新機能を 10 秒以下の間隔にセットすることは推奨できません。そうした場合、 ページが頻繁に更新して自動更新 の間隔の再設定が困難になります。 この問題に遭遇した場合は、別のパネル上でクリックしてから、制御/監視 に 戻ります。
自動更新 機能は Mozilla など、 全てのブラウザで動作するわけではありません。
Update information now
このボタンをクリックすると、ステータス情報を手動で更新することが出来ます。
CHANGE PASSWORD
このボタンをクリックすると、Piranha Configuration Tool 用の管理者 パスワードの変更に関する情報を持つヘルプ画面に移動します。

4.4. GLOBAL SETTINGS

The GLOBAL SETTINGS panel is where the you define the networking details for the primary LVS router's public and private network interfaces.
The GLOBAL SETTINGS Panel

図4.3 The GLOBAL SETTINGS Panel

The top half of this panel sets up the primary LVS router's public and private network interfaces. These are the interfaces already configured in 「NAT のある LVS 用の Network インターフェイス設定」.
Primary server public IP
このフィールドでは、主要 LVS ノード用の公共に回送できる実 IP アドレスを入力します。
Primary server private IP
Enter the real IP address for an alternative network interface on the primary LVS node. This address is used solely as an alternative heartbeat channel for the backup router and does not have to correlate to the real private IP address assigned in 「NAT のある LVS 用の Network インターフェイス設定」. You may leave this field blank, but doing so will mean there is no alternate heartbeat channel for the backup LVS router to use and therefore will create a single point of failure.

注記

ダイレクト Routing 設定には プライベート IP アドレスは 必要ありません。全ての実サーバーと LVS ディレクタが同じ 仮想 IP アドレスを共有し、 同じ IP route 設定を持つ必要があるからです。

注記

The primary LVS router's private IP can be configured on any interface that accepts TCP/IP, whether it be an Ethernet adapter or a serial port.
Use network type
NAT ボタンをクリックして NAT routing を選択します。
ダイレクト Routing ボタンをクリックして、ダイレクト routing を 選択します。
The next three fields deal specifically with the NAT router's virtual network interface connecting the private network with the real servers. These fields do not apply to the direct routing network type.
NAT Router IP
このテキストフィールドにプライベート浮動 IP を入力します。この浮動 IP は 実サーバー用のゲートウェイとして使用される必要があります。
NAT Router netmask
If the NAT router's floating IP needs a particular netmask, select it from drop-down list.
NAT Router device
このテキストフィールドを使用して、eth1:1 など、 浮動 IP アドレス用のネットワークインターフェイスのデバイス名を定義します。

注記

NAT 浮動 IP アドレスは、プライベートネットワークに接続されているイーサネットインターフェイスへ エイリアス化する必要があります。この例では、プライベートネットワークは、eth1 インターフェイスにあるため、eth1:1 が浮動 IP アドレスとなります。

警告

このページを完了した後は、確定(ACCEPT) ボタンをクリックして、新規のパネルを選択する時に、変更が維持されることを確実にします。

4.5. REDUNDANCY

冗長 パネルでは、バックアップ LVS router ノードの設定ができて、各種ハートビート監視オプションがセットできます。

注記

The first time you visit this screen, it displays an "inactive" Backup status and an ENABLE button. To configure the backup LVS router, click on the ENABLE button so that the screen matches 図4.4「The REDUNDANCY Panel」.
The REDUNDANCY Panel

図4.4 The REDUNDANCY Panel

Redundant server public IP
バックアップ LVS router 用の公共実 IP アドレスを入力します。
Redundant server private IP
Enter the backup node's private real IP address in this text field.
冗長サーバープライベート IP と言うフィールドが見えなければ、 グローバル設定 パネルに戻り、主要サーバーのプライベート IP アドレスを入力して、確定(ACCEPT)を クリックします。
パネルの残りの部分はハートビートチャンネルの設定に与えられて、ここはバックアップノードが 主要ノードの故障を監視する為に使用されます。
Heartbeat Interval (seconds)
このフィールドは、ハートビート間隔を秒数でセットする場所です。この間隔は バックアップノードが主要 LVS ノードの機能ステータスをチェックする間隔です。
Assume dead after (seconds)
主要 LVS ノードがある秒数の間、反応しない場合、バックアップ LVS router ノードはフェイルオーバーを 開始します。
Heartbeat runs on port
このフィールドは、ハートビートが主要 LVS ノードと通信する為のポートをセットします。 フィールドが空白の場合、デフォルトは 539 にセットされています。

警告

パネルでなんらかの変更をした後は 確定(ACCEPT) ボタンを確実にクリックして、新しいパネルを選択する時点にその変更が維持されるようにします。

4.6. VIRTUAL SERVERS

仮想サーバー パネルは現在定義されている各仮想サーバーの情報を 表示します。各表のエントリは仮想サーバーのステータス、サーバー名、サーバーに割り当て済の 仮想 IP、その仮想 IP のネットマスク、サーバーの通信先のポート番号、使用プロトコル、及び 仮想デバイスインターフェイスを表示します。
The VIRTUAL SERVERS Panel

図4.5 The VIRTUAL SERVERS Panel

仮想サーバー パネルに表示された各サーバーは、その中から出る画面、いわゆる サブセクション 上で設定できます。
サービスを追加するには、追加(ADD) ボタンをクリックします。 サービスを削除するには、仮想サーバー横のラジオボタンをクリックしてそのサービスを選択してから、 削除(DELETE) ボタンをクリックします。
表内の仮想サーバーを有効/無効にするには、そのラジオボタンをクリックしてから、 有効/無効((DE)ACTIVATE) ボタンをクリックします。
仮想サーバーを追加した後は、その左側のラジオボタンをクリックしてから、編集(EDIT) ボタンをクリックし、仮想サーバー サブセクションを表示することで設定できます。

4.6.1. 仮想サーバー サブセクション

The VIRTUAL SERVER subsection panel shown in 図4.6「The VIRTUAL SERVERS Subsection」 allows you to configure an individual virtual server. Links to subsections related specifically to this virtual server are located along the top of the page. But before configuring any of the subsections related to this virtual server, complete this page and click on the ACCEPT button.
The VIRTUAL SERVERS Subsection

図4.6 The VIRTUAL SERVERS Subsection

Name
仮想サーバーを識別できる説明的な名前を入力します。この名前は、マシン用のホスト名 ではありません ので、説明的で判り易くします。HTTP などの 仮想サーバーが使用するプロトコルを照合する名前も可能です。
Application port
サービスアプリケーションがそのポートを通じてリッスンするポート番号を入力します。 この例では、HTTP サービスであるため、ポート 80 が使用されます。
Protocol
ドロップダウンメニュー内で UDP か TCP を選択します。ウェブサーバーは標準的に TCP プロトコルを通じて通信します。それで、上記の例では TCP が選択されます。
Virtual IP Address
Enter the virtual server's floating IP address in this text field.
Virtual IP Network Mask
ドロップダウンメニューでこの仮想サーバー用のネットマスクを設定します。
Firewall Mark
複数ポートプロトコルを構築しているか、あるいは別種でも関連したプロトコル用に複数ポート仮想サーバーを 作成していない限りは、このフィールドにはファイアウォールマークの整数を入力しない で下さい。この例では、上記の仮想サーバーは、ポート 80 上の HTTP と ポート 443 上の HTTPS に接続を構築しているため、上記の仮想サーバーは ファイアウォールマーク を 80 としてあります。固執と組み合わせた場合、この技術は、不安全なウェブページと安全なウェブページ両方への ユーザーアクセスは同じ実サーバーに確実に回送されて、その状態を保存します。

警告

Entering a firewall mark in this field allows IPVS to recognize that packets bearing this firewall mark are treated the same, but you must perform further configuration outside of the Piranha Configuration Tool to actually assign the firewall marks. See 「複数ポートサービスと LVS 」 for instructions on creating multi-port services and 「FTP の設定」 for creating a highly available FTP virtual server.
Device
仮想 IP アドレス フィールドに定義してある浮動 IP アドレスにバインドしたいネットワークデバイスの名前を入力します。
公共浮動 IP アドレスは、公共ネットワークに接続されたイーサネットインターフェイスにエイリアス化 する必要があります。この例では、公共ネットワークは eth0 インターフェイス上で あるため、デバイス名として eth0:1 を入力することになります。
Re-entry Time
故障の後にアクティブ LVS router が実サーバーをサーバー群に戻すまでの時間の 秒数を定義する整数を入力します。
Service Timeout
実サーバーが復帰不能と判定されてサーバー群から削除されるまでの時間の秒数を定義する 整数を入力します。
Quiesce server
Quiesce (一時停止)サーバー ラジオボタンが選択されていると、新規の実サーバーノードが参加する時はいつでも最低稼働機接続(least-connections)表が ゼロにリセットされるため、まるでそれぞれの実サーバーがフレッシュにサーバー群に追加されたかのように、アクティブ LVS router は要求を全域に回送します。このオプションは、一台の新規サーバーがサーバー群に参加する時に大量接続を受け取ってダウンする可能性を防止します。
Load monitoring tool
rupruptime を使用すると、 各種実サーバー上のロードを LVS router で監視できるようになります。ドロップダウンメニューから rup を選択した場合は、各実サーバーは rstatd サービスを実行する必要があります。ruptime を選択した場合は、 各実サーバーは rwhod サービスを実行する必要があります。

警告

ロード監視はロードバランシングと同じではありません。そして能力別スケジューリングアルゴリズムと一緒に組み合わせた場合、予測困難なスケジューリングの動作になります。また、ロード監視を使用する場合、実サーバーは Linux マシンで なければなりません。
Scheduling
Select your preferred scheduling algorithm from the drop-down menu. The default is Weighted least-connection. For more information on scheduling algorithms, see 「スケジューリングアルゴリズム」.
Persistence
管理者が、クライアントトランザクションの間に仮想サーバーへの固執接続を必要と する場合は、このテキストフィールド内に接続がタイムアウトになる前に許容される 不活動の時間を秒数で入力します。

重要

If you entered a value in the Firewall Mark field above, you should enter a value for persistence as well. Also, be sure that if you use firewall marks and persistence together, that the amount of persistence is the same for each virtual server with the firewall mark. For more on persistence and firewall marks, refer to 「固執とファイアウォールマーク」.
Persistence Network Mask
固執を特定のサブネットに限定するには、ドロップダウンメニューから該当する ネットワークマスクを選択します。

注記

ファイアウォールの出現の前には、サブネット毎に限定された固執が接続を束ねる為の 基本的な手段でした。現在では、固執をファイアウォールマークとの関連で使用して 同様の目的を達成するのが最善の方法です。

警告

このパネルで何か変更した場合は、確定(ACCEPT) ボタンをクリック することを忘れないで下さい。これが新規のパネルを選択する時に変更が維持されることを確実にします。

4.6.2. 実サーバー サブセクション

パネル上部の 実サーバーサブセクションリンク上でクリックすると、 実サーバーの編集 サブセクションが表示されます。これは特定の 仮想サービス用の物理サーバーホストのステータスを表示するものです。
The REAL SERVER Subsection

図4.7 The REAL SERVER Subsection

Click the ADD button to add a new server. To delete an existing server, select the radio button beside it and click the DELETE button. Click the EDIT button to load the EDIT REAL SERVER panel, as seen in 図4.8「The REAL SERVER Configuration Panel」.
The REAL SERVER Configuration Panel

図4.8 The REAL SERVER Configuration Panel

このパネルは三つのエントリフィールドで構成されます:
Name
実サーバー用の説明的名前

注記

この名前はマシンのホスト名ではありません。そこで 説明的で判り易くしてください。
Address
The real server's IP address. Since the listening port is already specified for the associated virtual server, do not add a port number.
Weight
An integer value indicating this host's capacity relative to that of other hosts in the pool. The value can be arbitrary, but treat it as a ratio in relation to other real servers in the pool. For more on server weight, see 「サーバー能力分別とスケジューリング」.

警告

このパネル内でなんらかの変更をした後は 確定(ACCEPT) ボタンを確実に クリックして、新しいパネルを選択する時点にその変更が維持されるようにします。

4.6.3. EDIT MONITORING SCRIPTS Subsection

パネル上部の監視スクリプト リンク上でクリックします。 監視スクリプトの編集 サブセクションにより、管理者は 送信/期待 の文字列シーケンスを指定して、仮想サーバー用のサービスが各実サーバー上で 機能していることを確認できます。ここはまた、管理者がカスタム化したスクリプトを指定して 動的に変化しているデータを要求するサービスをチェックすることができます。
The EDIT MONITORING SCRIPTS Subsection

図4.9 The EDIT MONITORING SCRIPTS Subsection

Sending Program
より高度なサービス確認の為には、このフィールドを使用してサービスチェックスクリプトへの パスを指定することができます。この機能は特に、HTTPS や SSL などの動的に変化するデータを 要求するサービスに役に立ちます。
この機能を使用するには、テキスト応答を返し、それを実行ファイルになるようにセットし、 送信プログラム フィールド内にそのパスを入力するようなスクリプトを 書く必要があります。

注記

To ensure that each server in the real server pool is checked, use the special token %h after the path to the script in the Sending Program field. This token is replaced with each real server's IP address as the script is called by the nanny daemon.
外部サービスチェックスクリプトを書くときのガイドとして、使用できるサンプルスクリプトを 以下に示します:
#!/bin/sh

TEST=`dig -t soa example.com @$1 | grep -c dns.example.com

if [ $TEST != "1" ]; then
	echo "OK
else
	echo "FAIL"
fi

注記

外部プログラムが 送信プログラム フィールド内に入った場合、 送信 フィールドは無視されます。
Send
このフィールドに各実サーバーに送る為の nanny デーモン用ストリングを 入力します。デフォルトでは、送信フィールドは HTTP 用に完了しています。ニーズに応じてこの値を 変更することは可能です。このフィールドを空白のままにすると、nanny デーモンはポートを開く試みをして、それが成功した時はサービスが実行中だと想定します。
このフィールドには1つのみの送信シーケンスが許可されます。そしてそれは 表示可能物、ASCII 文字、それに以下のエスケープ文字のみを含むことが出来ます:
  • 新しい行用の \n
  • 改行用の \r
  • tab 用の \t
  • 次に続く文字をエスケープする \
Expect
正常に機能している場合にサーバーが返すべきテキスト応答を入力します。ユーザーが自身の 送信プログラムを書いている場合は、成功した時に送るように指示している応答を入力します。

注記

任意のサービス用に送るものを決定するには、実サーバー上のポートへの telnet 接続を開き、返ってくる応答を見ます。例えば、FTP は接続時に 220 を報告しますので、送信 フィールドにquit(終了) を入力し、期待フィールドには 220 を入力します。

警告

このパネル内でなんらかの変更をした後は 確定(ACCEPT) ボタンを確実に クリックして、新しいパネルを選択する時点にその変更が維持されるようにします。
Once you have configured virtual servers using the Piranha Configuration Tool, you must copy specific configuration files to the backup LVS router. See 「設定ファイルの同期化」 for details.

4.7. 設定ファイルの同期化

主要 LVS router を設定した後は、LVS を開始する前に数種の設定ファイルをバックアップ LVS router に コピーしなければなりません。
これらのファイルは以下を含みます:
  • /etc/sysconfig/ha/lvs.cf — LVS router 用の設定ファイル
  • /etc/sysctl — 動作の一つとして、カーネル内のパケット転送を オンにする設定ファイル
  • /etc/sysconfig/iptables — ファイアウォールマークを 使用している場合は、使用しているネットワークパケットを基にしてこれらのファイルの1つを 同期化する必要があります。

重要

Piranha Configuration Tool を使用して LVS を設定する場合は /etc/sysctl.conf ファイルと /etc/sysconfig/iptables ファイルは、変化しません。

4.7.1. lvs.cf の同期化

LVS 設定ファイル /etc/sysconfig/ha/lvs.cf が作成されるか、 更新される時は いつでも、それをバックアップ LVS router ノードにコピーする必要があります。

警告

アクティブとバックアップの両方の LVS router ノードは同一の lvs.cf ファイルを持っている必要があります。これらの LVS router ノード間で一致しない LVS 設定ファイルがある場合は、 フェイルオーバーを阻止する可能性があります。
これを実行する最善の方法は scp コマンドの使用です。

重要

To use scp the sshd must be running on the backup router, see 「LVS Router 上でサービスの設定」 for details on how to properly configure the necessary services on the LVS routers.
主要 LVS router から root として以下のコマンドを発行して、router ノード間で lvs.cf ファイルを同期化します:
scp /etc/sysconfig/ha/lvs.cf n.n.n.n:/etc/sysconfig/ha/lvs.cf
このコマンド内の、n.n.n.n はバックアップ LVS router の実 IP アドレスで 入れ替えます。

4.7.2. sysctl の同期化

sysctl ファイルは殆どのケースでは一度だけ修正されます。 このファイルは起動時に読み込まれて、カーネルにパケット転送をオンにするように 指示します。

重要

If you are not sure whether or not packet forwarding is enabled in the kernel, see 「パケット転送をオンにする」 for instructions on how to check and, if necessary, enable this key functionality.

4.7.3. ネットワークパケットフィルタリングルールの同期化

iptables を使用している場合、バックアップ LVS router 上で 該当する設定ファイルを同期化する必要があります。
いずれかのネットワークパケットフィルタルールを変更した場合は、主要 LVS router から root として以下のコマンドを入力します:
scp /etc/sysconfig/iptables n.n.n.n:/etc/sysconfig/
このコマンド内の、n.n.n.n はバックアップ LVS router の実 IP アドレスで 入れ替えます。
次に、バックアップ router へ ssh セッションを開くか、又は root としてマシンにログインして以下のコマンドを入力します:
/sbin/service iptables restart
Once you have copied these files over to the backup router and started the appropriate services (see 「LVS Router 上でサービスの設定」 for more on this topic) you are ready to start LVS.

4.8. LVS の開始

LVS を開始するには、二つの root ターミナルが同時に開くようにするか、又は 二つの同時 root が、主要 LVS router に対して ssh セッションを 開くようにするのが最適です。
ターミナルの1つで以下のコマンドを使用してカーネルログメッセージを見ます:
tail -f /var/log/messages
それから、他のターミナルに以下のコマンドを入力して LVS を開始します:
/sbin/service pulse start
Follow the progress of the pulse service's startup in the terminal with the kernel log messages. When you see the following output, the pulse daemon has started properly:
gratuitous lvs arps finished
/var/log/messages の表示を停止するには、 Ctrl+c を押します。
この時点以降、主要 LVS router はアクティブ LVS router でもあります。 この時点でも LVS に要求を出すことができますが、LVS をサービス開始状態に進める前に バックアップ LVS router を開始する必要があります。これを実行するには、上記にある工程を バックアップ LVS router ノード上で繰り返すだけです。
この最終手順を完了した後は、LVS が立ち上がり稼働します。

付録A Red Hat クラスタで LVS を使用

Red Hat クラスタのある LVS router を使用して、ロードバランシング、データ統合性、アプリケーション 可用性を提供するハイアベイラビリティ e-commerce サイトを導入することができます。
The configuration in 図A.1「LVS with a Red Hat Cluster」 represents an e-commerce site used for online merchandise ordering through a URL. Client requests to the URL pass through the firewall to the active LVS load-balancing router, which then forwards the requests to one of the Web servers. The Red Hat Cluster nodes serve dynamic data to the Web servers, which forward the data to the requesting client.
LVS with a Red Hat Cluster

図A.1 LVS with a Red Hat Cluster

Serving dynamic Web content with LVS requires a three-tier configuration (as shown in 図A.1「LVS with a Red Hat Cluster」). This combination of LVS and Red Hat Cluster allows for the configuration of a high-integrity, no-single-point-of-failure e-commerce site. The Red Hat Cluster can run a high-availability instance of a database or a set of databases that are network-accessible to the Web servers.
three-tier 設定は動的コンテンツを提供する為の必要事項となります。Web サーバーが 静的コンテンツ(あまり変化のない少量のデータからなるもの)のみをサービスする場合は、 two-tier LVS 設定が適切なものとなりますが、Web サーバーが動的コンテンツをサービスする 場合は、two-tier 設定は不適切です。動的コンテンツは製品在庫表、購入注文、あるいは顧客データベース 等を含むことがあり、これは顧客が最新で正確な情報にアクセスする為に確実に全ての Web サーバー上で 均一でなければなりません。
各 tier (層)では、以下の機能を提供します:
  • 一番目の tier — Web 要求を分配する為にロードバランシングを実行する LVS router
  • 二番目の tier — 要求に応える Web サーバーのセット
  • 三番目の tier — データを Web サーバーにサービスする Red Hat クラスタ
In an LVS configuration like the one in 図A.1「LVS with a Red Hat Cluster」, client systems issue requests on the World Wide Web. For security reasons, these requests enter a Web site through a firewall, which can be a Linux system serving in that capacity or a dedicated firewall device. For redundancy, you can configure firewall devices in a failover configuration. Behind the firewall are LVS load-balancing routers, which can be configured in an active-standby mode. The active load-balancing router forwards the requests to the set of Web servers.
Each Web server can independently process an HTTP request from a client and send the response back to the client. LVS enables you to expand a Web site's capacity by adding Web servers behind the LVS routers; the LVS routers perform load balancing across a wider set of Web servers. In addition, if a Web server fails, it can be removed; LVS continues to perform load balancing across a smaller set of Web servers.

付録B Revision History

改訂履歴
改訂 5-8.4002013-10-31Rüdiger Landmann
Rebuild with publican 4.0.0
改訂 5-82012-07-18Anthony Towns
Rebuild for Publican 3.0
改訂 2.0-0Mon Feb 08 2010Paul Kennedy
Resolves: 492000
Changes -d to -s in arptables "OUT" directive in "Direct Routing and arptables_jf" section.
改訂 1.0-0Tue Jan 20 2009Paul Kennedy
Consolidation of point releases

索引

シンボル

/etc/sysconfig/ha/lvs.cf file, /etc/sysconfig/ha/lvs.cf

C

chkconfig, LVS Router 上でサービスの設定
cluster
using LVS with Red Hat Cluster, Red Hat クラスタで LVS を使用
components
of LVS, LVS Components

D

direct routing
and arptables_jf, ダイレクト Routing 及び arptables_jf

F

feedback, Feedback
FTP, FTP の設定
(参照 LVS)

I

introduction, Introduction
other Red Hat Enterprise Linux documents, Introduction
iptables , LVS Router 上でサービスの設定
ipvsadm program, ipvsadm

L

least connections (参照 job scheduling, LVS)
LVS
/etc/sysconfig/ha/lvs.cf file, /etc/sysconfig/ha/lvs.cf
components of, LVS Components
daemon, lvs
date replication, real servers, 実サーバー間のデータ複製とデータ共有
direct routing
and arptables_jf, ダイレクト Routing 及び arptables_jf
requirements, hardware, ダイレクト Routing, ダイレクト Routing 経由の LVS
requirements, network, ダイレクト Routing, ダイレクト Routing 経由の LVS
requirements, software, ダイレクト Routing, ダイレクト Routing 経由の LVS
initial configuration, LVS の初期設定
ipvsadm program, ipvsadm
job scheduling, LVS スケジューリングの概要
lvs daemon, lvs
LVS routers
configuring services, LVS の初期設定
necessary services, LVS Router 上でサービスの設定
primary node, LVS の初期設定
multi-port services, 複数ポートサービスと LVS
FTP, FTP の設定
nanny daemon, nanny
NAT routing
enabling, LVS Router 上の NAT Routing を有効にする
requirements, hardware, NAT LVS ネットワーク
requirements, network, NAT LVS ネットワーク
requirements, software, NAT LVS ネットワーク
overview of, Linux 仮想サーバー(Linux Virtual Server)の概要
packet forwarding, パケット転送をオンにする
Piranha Configuration Tool , Piranha Configuration Tool
pulse daemon, pulse
real servers, Linux 仮想サーバー(Linux Virtual Server)の概要
routing methods
NAT, Routing (経路回送)の方法
routing prerequisites, NAT のある LVS 用の Network インターフェイス設定
scheduling, job, LVS スケジューリングの概要
send_arp program, send_arp
shared data, 実サーバー間のデータ複製とデータ共有
starting LVS, LVS の開始
synchronizing configuration files, 設定ファイルの同期化
three-tier
Red Hat Cluster Manager, A Three-Tier LVS Configuration
using LVS with Red Hat Cluster, Red Hat クラスタで LVS を使用
lvs daemon, lvs

M

multi-port services, 複数ポートサービスと LVS
(参照 LVS)

N

nanny daemon, nanny
NAT
enabling, LVS Router 上の NAT Routing を有効にする
routing methods, LVS, Routing (経路回送)の方法
network address translation (参照 NAT)

R

real servers
configuring services, 実サーバー上でサービスの設定
Red Hat Cluster
and LVS, Red Hat クラスタで LVS を使用
using LVS with, Red Hat クラスタで LVS を使用
round robin (参照 job scheduling, LVS)
routing
prerequisites for LVS, NAT のある LVS 用の Network インターフェイス設定

S

scheduling, job (LVS), LVS スケジューリングの概要
security
Piranha Configuration Tool , Piranha Configuration Tool へのアクセスを制限
send_arp program, send_arp
sshd service, LVS Router 上でサービスの設定
synchronizing configuration files, 設定ファイルの同期化

W

weighted least connections (参照 job scheduling, LVS)
weighted round robin (参照 job scheduling, LVS)

法律上の通知

Copyright © 2009 Red Hat, Inc.
This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.