このドキュメントで説明するソフトウェアは、Extended SupportまたはSustaining Supportのいずれかにあります。 詳細は、https://www.oracle.com/us/support/library/enterprise-linux-support-policies-069172.pdfを参照してください。
Oracleでは、このドキュメントに記載されているソフトウェアをできるだけ早くアップグレードすることをお薦めします。
次の例では、NATモードでKeepalivedを使用して、2つのサーバー上に単純なフェイルオーバーおよびロード・バランシングの構成を実装します。 1つのサーバーがプライマリとして機能し、もう1つのサーバーがバックアップとして機能し、プライマリ・サーバーの優先度がバックアップ・サーバーより高くなります。 各サーバーには2つのネットワーク・インタフェースがあり、一方のインタフェースは外部ネットワーク(192.168.1.0/24
)に接続され、もう一方のインタフェースは2つのwebサーバーにアクセス可能な内部ネットワーク(10.0.0.0/24
)に接続されています。
「図17.3」は、Keepalivedプライマリ・サーバーにネットワーク・アドレス192.168.1.10
、192.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
のネットワーク・アドレスがあります。
プライマリ・サーバーで次の/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_from
、state
、priority
および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つの構成変更が必要です。
第17.7.1項、「Keepalived NATモード・ロード・バランシングのためのファイアウォール・ルールの構成」で説明されているように、ロード・バランサとして構成する各Keepalivedサーバー(プライマリおよびバックアップ)にファイアウォール・ルールを構成します。
17.7.2項「Keepalived NATモード・ロード・バランシングのためのバックエンド・サーバー・ルーティングの構成」の説明に従って、Keepalivedロード・バランサで使用する各バックエンド・サーバーで、ロード・バランサの内部ネットワーク・インタフェースの仮想IPアドレスのデフォルト・ルートを構成します。
Keepalivedをインストールおよび構成する方法の詳細は、17.5項「Keepalivedのインストールと構成」を参照してください。