このドキュメントで説明するソフトウェアは、Extended SupportまたはSustaining Supportのいずれかにあります。 詳細は、https://www.oracle.com/us/support/library/enterprise-linux-support-policies-069172.pdfを参照してください。
Oracleでは、このドキュメントに記載されているソフトウェアをできるだけ早くアップグレードすることをお薦めします。

機械翻訳について

17.7 NATモードでのKeepalivedを使用したロード・バランシングの構成

次の例では、NATモードでKeepalivedを使用して、2つのサーバー上に単純なフェイルオーバーおよびロード・バランシングの構成を実装します。 1つのサーバーがプライマリとして機能し、もう1つのサーバーがバックアップとして機能し、プライマリ・サーバーの優先度がバックアップ・サーバーより高くなります。 各サーバーには2つのネットワーク・インタフェースがあり、一方のインタフェースは外部ネットワーク(192.168.1.0/24)に接続され、もう一方のインタフェースは2つのwebサーバーにアクセス可能な内部ネットワーク(10.0.0.0/24)に接続されています。

「図17.3」は、Keepalivedプライマリ・サーバーにネットワーク・アドレス192.168.1.10192.168.1.1 (仮想)、10.0.0.10および10.0.0.100 (仮想)があることを示します。 Keepalivedバックアップ・サーバーには、192.168.1.11および10.0.0.11のネットワーク・アドレスがあります。 webサーバーwebsvr1およびwebsvr2には、それぞれ10.0.0.71および10.0.0.72 のネットワーク・アドレスがあります。

図17.3 NATモードでのロード・バランシングのためのKeepalived構成の例

この図は、Keepalivedプライマリ・サーバーがネットワーク・アドレス192.168.1.10と192.168.1.1 (仮想)、10.0.0.10と10.0.0.10 0 (仮想)を持つことを示しています。 Keepalivedバックアップ・サーバーには、192.168.1.11および10.0.0.11のネットワーク・アドレスがあります。 webサーバーwebsvr1およびwebsvr2には、それぞれ10.0.0.71および10.0.0.72のネットワーク・アドレスが割り当てられます。


プライマリ・サーバーで次の/etc/keepalived/keepalived.conf構成を行うことができます:

global_defs {
   notification_email {
     root@mydomain.com
   }
   notification_email_from svr1@mydomain.com
   smtp_server localhost
   smtp_connect_timeout 30
}

vrrp_sync_group VRRP1 {
#   Group the external and internal VRRP instances so they fail over together
    group {
        external
        internal
        }
}

vrrp_instance external {
    state MASTER
    interface eth0
    virtual_router_id 91
    priority 200
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1215
    }
#   Define the virtual IP address for the external network interface
    virtual_ipaddress {
        192.168.1.1/24
    }
}

vrrp_instance internal {
    state MASTER
    interface eth1
    virtual_router_id 92
    priority 200
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1215
    }
#   Define the virtual IP address for the internal network interface
    virtual_ipaddress {
        10.0.0.100/24
    }
}

# Define a virtual HTTP server on the virtual IP address 192.168.1.1
virtual_server 192.168.1.1 80 {
    delay_loop 10
    protocol TCP
#   Use round-robin scheduling in this example
    lb_algo rr
#   Use NAT to hide the back-end servers
    lb_kind NAT
#   Persistence of client sessions times out after 2 hours
    persistence_timeout 7200

    real_server 10.0.0.71 80 {
        weight 1
        TCP_CHECK {
          connect_timeout 5
          connect_port 80
        }
    }

    real_server 10.0.0.72 80 {
        weight 1
        TCP_CHECK {
          connect_timeout 5
          connect_port 80
        }
    }
}

この構成は、17.6項「Keepalivedを使用した単純な仮想IPアドレス・フェイルオーバーの構成」に示した構成に、ネットワーク・インタフェースがフェイルオーバー時にまとめて割り当てられるようにvrrp_sync_groupセクションの定義を追加し、Keepalivedがロード・バランシング用に使用する実バックエンド・サーバーを定義するvirtual_serverセクションを追加したものです。 lb_kindの値はNAT (ネットワーク・アドレス変換)に設定されており、Keepalivedサーバーがバックエンド・サーバーに代わってクライアントとの間のインバウンド・ネットワーク・トラフィックとアウトバウンド・ネットワーク・トラフィックの両方を処理します。

バックアップ・サーバーの構成は、notification_email_fromstatepriorityおよびinterface (システム・ハードウェア構成が異なる場合)の値を除けば同じです。

global_defs {
   notification_email {
     root@mydomain.com
   }
   notification_email_from svr2@mydomain.com
   smtp_server localhost
   smtp_connect_timeout 30
}

vrrp_sync_group VRRP1 {
#   Group the external and internal VRRP instances so they fail over together
    group {
        external
        internal
        }
}

vrrp_instance external {
    state BACKUP
    interface eth0
    virtual_router_id 91
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1215
    }
#   Define the virtual IP address for the external network interface
    virtual_ipaddress {
        192.168.1.1/24
    }
}

vrrp_instance internal {
    state BACKUP
    interface eth1
    virtual_router_id 92
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1215
    }
#   Define the virtual IP address for the internal network interface
    virtual_ipaddress {
        10.0.0.100/24
    }
}

# Define a virtual HTTP server on the virtual IP address 192.168.1.1
virtual_server 192.168.1.1 80 {
    delay_loop 10
    protocol TCP
#   Use round-robin scheduling in this example
    lb_algo rr
#   Use NAT to hide the back-end servers
    lb_kind NAT
#   Persistence of client sessions times out after 2 hours
    persistence_timeout 7200

    real_server 10.0.0.71 80 {
        weight 1
        TCP_CHECK {
          connect_timeout 5
          connect_port 80
        }
    }

    real_server 10.0.0.72 80 {
        weight 1
        TCP_CHECK {
          connect_timeout 5
          connect_port 80
        }
    }
}

さらに2つの構成変更が必要です。

Keepalivedをインストールおよび構成する方法の詳細は、17.5項「Keepalivedのインストールと構成」を参照してください。