Red Hat Training

A Red Hat training course is available for Red Hat Ceph Storage

2.11.4. HAProxy のインストールおよび設定

少なくとも 2 つの HAProxy ノードで以下の手順を実行します。

  1. haproxy をインストールします。

    [root@haproxy]# yum install haproxy
  2. 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
  3. 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
  4. 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/
  5. haproxy を設定します。

    [root@haproxy]# vim /etc/haproxy/haproxy.cfg

    global および defaults は変更しない可能性があります。defaults セクションの後に、frontend セクションおよび backend セクションを設定する必要があります。以下に例を示します。

    frontend http_web *: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 設定 を参照してください。

  6. haproxy の有効化/起動

    [root@haproxy]# systemctl enable haproxy
    [root@haproxy]# systemctl start haproxy