Red Hat Training

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

第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)トポロジー が 理想的なソリューションとなります。