2.14. HAProxy/keepalived の設定
Ceph Object Gateway では、Object Gateway の多数のインスタンスを 1 つのゾーンに割り当てることができます。これにより、負荷が増大するとスケールアウトすることができます。つまり、同じゾーングループおよびゾーンとなりますが、HAProxy/keepalived
を使用するためにフェデレーションされたアーキテクチャーは必要ありません。各 Ceph Object Gateway インスタンスには独自の IP アドレスがあるため、HAProxy および keepalived
を使用して、Ceph Object Gateway サーバー全体で負荷のバランスを取ることができます。
HAProxy および keepalived
のもう 1 つのユースケースは、HAProxy サーバーで HTTPS を終了することです。HAProxy サーバーを使用して HAProxy サーバーで HTTPS を終了でき、HAProxy サーバーと Civetweb ゲートウェイインスタンスの間で HTTP を使用できます。
本セクションでは、Red Hat Enterprise Linux 7 向けの HAProxy および keepalived
の設定を説明します。
Red Hat Enterprise Linux 8 の場合は、keepalived
パッケージおよび haproxy
パッケージをインストールして、ロードバランサーをインストールします。How do we need any additional subscription for Load Balancing on Red Hat Enterprise Linux 8? を参照してください。詳細については、ナレッジベースアーティクルを参照してください。
2.14.1. HAProxy/keepalived の前提条件
Ceph Object Gateway で HA プロキシーを設定するには、以下が必要です。
- 稼働中の Ceph クラスター
-
ポート
80
で実行されるように設定している同じゾーン内の少なくとも 2 つの Ceph Object Gateway サーバー。簡単なインストール手順に従うと、ゲートウェイインスタンスはデフォルトで同じゾーングループおよびゾーンに置かれます。フェデレーションアーキテクチャーを使用している場合は、インスタンスが同じゾーングループとゾーンにあることを確認してください。 -
HAProxy および
keepalived
の場合は少なくとも 2 台のサーバー。
本セクションでは、少なくとも 2 つの Ceph Object Gateway サーバーが実行されていることを前提とし、ポート 80
でテストスクリプトを実行する際に、このいずれかのサーバーからの有効な応答を取得していることを前提としています。
HAProxy および keepalived
の詳細な説明は、ロードバランサーの管理 を参照してください。
2.14.2. HAProxy ノードの準備
以下の設定は、haproxy
と haproxy2
という名前の 2 つの HAProxy ノードと、rgw1
と rgw2
という名前の 2 台の Ceph Object Gateway サーバーを前提としています。希望の命名規則を使用できます。少なくとも 2 つの HAProxy ノードで以下の手順を実行します。
- Red Hat Enterprise Linux 7 をインストールします。
ノードを登録します。
[root@haproxy]# subscription-manager register
RHEL サーバーリポジトリーを有効にします。
[root@haproxy]# subscription-manager repos --enable=rhel-7-server-rpms
サーバーを更新します。
[root@haproxy]# yum update -y
-
必要に応じて管理ツール (
wget
、vim
など) をインストールします。 ポート
80
を開きます。[root@haproxy]# firewall-cmd --zone=public --add-port 80/tcp --permanent [root@haproxy]# firewall-cmd --reload
HTTPS の場合は、ポート
443
を開きます。[root@haproxy]# firewall-cmd --zone=public --add-port 443/tcp --permanent [root@haproxy]# firewall-cmd --reload
必要なポートに接続します。
[root@haproxy]# semanage port -m -t http_cache_port_t -p tcp 8081
2.14.3. keepalived のインストールと設定
少なくとも 2 つの HAProxy ノードで以下の手順を実行します。
前提条件
- 少なくとも 2 つの HAProxy ノード
- 少なくとも 2 つの Object Gateway ノード
手順
keepalived
をインストールします。[root@haproxy]# yum install -y keepalived
両方の HAProxy ノードで
keepalived
を設定します。[root@haproxy]# vim /etc/keepalived/keepalived.conf
設定ファイルには、
haproxy
プロセスを確認するスクリプトがあります。vrrp_script chk_haproxy { script "killall -0 haproxy" # check the haproxy process interval 2 # every 2 seconds weight 2 # add 2 points if OK }
次に、マスターロードバランサーとバックアップロードバランサーのインスタンスは、ネットワークインターフェイスとして
eno1
を使用します。また、仮想 IP アドレス (192.168.1.20
) も割り当てます。マスターロードバランサーノード
vrrp_instance RGW { state MASTER # might not be necessary. This is on the Master LB node. @main interface eno1 priority 100 advert_int 1 interface eno1 virtual_router_id 50 @main unicast_src_ip 10.8.128.43 80 unicast_peer { 10.8.128.53 } authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.1.20 } track_script { chk_haproxy } } virtual_server 192.168.1.20 80 eno1 { #populate correct interface delay_loop 6 lb_algo wlc lb_kind dr persistence_timeout 600 protocol TCP real_server 10.8.128.43 80 { # ip address of rgw2 on physical interface, haproxy listens here, rgw listens to localhost:8080 or similar weight 100 TCP_CHECK { # perhaps change these to a HTTP/SSL GET? connect_timeout 3 } } real_server 10.8.128.53 80 { # ip address of rgw3 on physical interface, haproxy listens here, rgw listens to localhost:8080 or similar weight 100 TCP_CHECK { # perhaps change these to a HTTP/SSL GET? connect_timeout 3 } } }
バックアップロードバランサーノード
vrrp_instance RGW { state BACKUP # might not be necessary? priority 99 advert_int 1 interface eno1 virtual_router_id 50 unicast_src_ip 10.8.128.53 80 unicast_peer { 10.8.128.43 } authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.1.20 } track_script { chk_haproxy } } virtual_server 192.168.1.20 80 eno1 { #populate correct interface delay_loop 6 lb_algo wlc lb_kind dr persistence_timeout 600 protocol TCP real_server 10.8.128.43 80 { # ip address of rgw2 on physical interface, haproxy listens here, rgw listens to localhost:8080 or similar weight 100 TCP_CHECK { # perhaps change these to a HTTP/SSL GET? connect_timeout 3 } } real_server 10.8.128.53 80 { # ip address of rgw3 on physical interface, haproxy listens here, rgw listens to localhost:8080 or similar weight 100 TCP_CHECK { # perhaps change these to a HTTP/SSL GET? connect_timeout 3 } } }
keepalived
サービスを有効にして開始します。[root@haproxy]# systemctl enable keepalived [root@haproxy]# systemctl start keepalived
関連情報
-
keepalived
の設定に関する詳しい説明は、Keepalived を使用した初期ロードバランサーの設定 を参照してください。
2.14.4. HAProxy のインストールおよび設定
少なくとも 2 つの HAProxy ノードで以下の手順を実行します。
haproxy
をインストールします。[root@haproxy]# yum install haproxy
SELinux および HTTP に対して
haproxy
を設定します。[root@haproxy]# vim /etc/firewalld/services/haproxy-http.xml
以下の行を追加します。
<?xml version="1.0" encoding="utf-8"?> <service> <short>HAProxy-HTTP</short> <description>HAProxy load-balancer</description> <port protocol="tcp" port="80"/> </service>
root
として、正しい SELinux コンテキストとファイルパーミッションをhaproxy-http.xml
ファイルに割り当てます。[root@haproxy]# cd /etc/firewalld/services [root@haproxy]# restorecon haproxy-http.xml [root@haproxy]# chmod 640 haproxy-http.xml
HTTPS を使用する場合は、SELinux および HTTPS に対して
haproxy
を設定します。[root@haproxy]# vim /etc/firewalld/services/haproxy-https.xml
以下の行を追加します。
<?xml version="1.0" encoding="utf-8"?> <service> <short>HAProxy-HTTPS</short> <description>HAProxy load-balancer</description> <port protocol="tcp" port="443"/> </service>
root
で、正しい SELinux コンテキストとファイルパーミッションをhaproxy-https.xml
ファイルに割り当てます。# cd /etc/firewalld/services # restorecon haproxy-https.xml # chmod 640 haproxy-https.xml
HTTPS を使用する場合は、SSL のキーを生成します。証明書がない場合は、自己署名証明書を使用できます。キーを生成するには、Red Hat Enterprise Linux 7 のシステム管理者のガイドの 新しい鍵および証明書の生成 セクションを参照してください。
最後に、証明書と鍵を PEM ファイルに格納します。
[root@haproxy]# cat example.com.crt example.com.key > example.com.pem [root@haproxy]# cp example.com.pem /etc/ssl/private/
haproxy
を設定します。[root@haproxy]# vim /etc/haproxy/haproxy.cfg
global
およびdefaults
は変更しない可能性があります。defaults
セクションの後に、frontend
セクションおよびbackend
セクションを設定する必要があります。以下に例を示します。frontend http_web bind *:80 mode http default_backend rgw frontend rgw-https bind *:443 ssl crt /etc/ssl/private/example.com.pem default_backend rgw backend rgw balance roundrobin mode http server rgw1 10.0.0.71:80 check server rgw2 10.0.0.80:80 check
HAProxy 設定の詳細な説明は、HAProxy 設定 を参照してください。
haproxy
の有効化/起動[root@haproxy]# systemctl enable haproxy [root@haproxy]# systemctl start haproxy
2.14.5. HAProxy 設定のテスト
HAProxy ノードで、keepalived
設定からの仮想 IP アドレスが表示されることを確認します。
[root@haproxy]# ip addr show
calamari ノードで、ロードバランサー設定経由でゲートウェイノードにアクセスできるかどうかを確認します。以下に例を示します。
[root@haproxy]# wget haproxy
上記のコマンドの結果は以下のコマンドと同じになるはずです。
[root@haproxy]# wget rgw1
以下の内容を含む index.html
ファイルを返す場合は、次のコマンドを実行します。
<?xml version="1.0" encoding="UTF-8"?> <ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Owner> <ID>anonymous</ID> <DisplayName></DisplayName> </Owner> <Buckets> </Buckets> </ListAllMyBucketsResult>
その後、設定が正常に機能します。