This page covers configuration changes and steps to enable HA for Ranger KMS using load balancer. Steps given are of Apache HTTPD.

Load Balancer without SSL

Install httpd and dependent packages

  1. ssh to in your cluster where you want to setup the load-balancer.
  2. Go to /usr/local
    1. cd /usr/local
  3. Download latest httpd from https://httpd.apache.org/download.cgi and dependencies i.e apr and apr-util from http://archive.apache.org/dist/apr/, since I have downloaded latest httpd so I shall be using the latest apr and apr-util
    1. wget https://archive.apache.org/dist/httpd/httpd-2.4.25.tar.gz
    2. wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
    3. wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
  4. Untar them in the same location
    1. tar -xvf httpd-2.4.25.tar.gz
    2. tar -xvf apr-1.5.2.tar.gz
    3. tar -xvf apr-util-1.5.4.tar.gz
  5. Now we will move apr and apr-util to srclib directory of httpd.
    1. Rename apr-1.5.2 to apr:
      1. mv apr-1.5.2/ apr
      2. Move to httpd/srclib directory:
      3. mv apr httpd-2.4.25/srclib/
    2. Rename apr-util-1.5.4 to apr-util
      1. mv apr-util-1.5.4/ apr-util
    3. Move apr-util to httpd/srclib directory:
      1. mv apr-util httpd-2.4.25/srclib/
  6. Install PCRE (Perl-Compatible Regular Expressions Library)
    1. yum install pcre pcre-devel
      (here I am installing using yum however you can install latest bit from http://www.pcre.org/
  7. Install gcc (ANSI-C Compiler and Build System)
    1. yum install gcc
  8. Configuring the source tree
    1. cd /usr/local/httpd-2.4.25
    2. ./configure
  9. Make Build  
    1. make
  10. Install
    1. make install
  11. Now let's test the work done till now
    1. cd /usr/local/apache2/bin
    2. ./apachectl start
    3. curl localhost
      1. output: <html><body><h1>It works!</h1></body></html>

Load balancer Configurations :

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_http_module modules/mod_proxy_http.so

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

LoadModule slotmem_shm_module modules/mod_slotmem_shm.so

LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so

LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so

LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so


Ranger KMS config Changes


# This is the Apache server configuration file providing SSL support.

# It contains the configuration directives to instruct the server how to

# serve pages over an https connection. For detailing information about these

# directives see <URL:http://httpd.apache.org/docs/2.2/mod/mod_ssl.html>

#

# Do NOT simply read the instructions in here without understanding

# what they do.  They're here only as hints or reminders.  If you are unsure

# consult the online docs. You have been warned.

#Listen 80

<VirtualHost *:88>

       ProxyRequests off

       ProxyPreserveHost on

       Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED

       <Proxy balancer://rangercluster>

               BalancerMember http://ranger-kms-host1-fqdn:9292 loadfactor=1 route=1

               BalancerMember http://ranger-kms-host2-fqdn:9292 loadfactor=1 route=2

               Order Deny,Allow

               Deny from none

               Allow from all

               ProxySet lbmethod=byrequests scolonpathdelim=On stickysession=ROUTEID maxattempts=1 failonstatus=500,501,502,503 nofailover=Off

       </Proxy>

       # balancer-manager

       # This tool is built into the mod_proxy_balancer

       # module and will allow you to do some simple

       # modifications to the balanced group via a gui

       # web interface.

       <Location /balancer-manager>

               SetHandler balancer-manager

               Order deny,allow

               Allow from all

       </Location>

      ProxyPass /balancer-manager !

      ProxyPass / balancer://rangerkmscluster/

      ProxyPassReverse / balancer://rangerkmscluster/

</VirtualHost>


Load Balancer in SSL Env 

Install httpd and dependent packages

Follow steps 1 to 5 same as mentioned in earlier section to install httpd. Then follow below given steps. 

  1. Install other required packages
    1. yum groupinstall "Development Tools"

    2. yum install openssl-devel

    3. yum install pcre-devel

  2. Configuring the source tree
    1. cd /usr/local/httpd-2.4.25
    2. ./configure --enable-so --enable-ssl --with-mpm=prefork --with-included-apr
  3. Make Build  
    1. make
  4.  Install
    1. make install
  5. Now let's test the work done till now
    1. cd /usr/local/apache2/bin
    2. ./apachectl start
    3. curl localhost
      1. output: <html><body><h1>It works!</h1></body></html>

HTTPS/SSL Configuration changes


LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_http_module modules/mod_proxy_http.so

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so            

LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

LoadModule slotmem_shm_module modules/mod_slotmem_shm.so

LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so

LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so

LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so

LoadModule ssl_module modules/mod_ssl.so

Certificate Generation

Ranger KMS HA Configuration changes


<VirtualHost *:8443>

       SSLEngine On

       SSLProxyEngine On

       SSLCertificateFile /usr/local/apache2/conf/server.crt

       SSLCertificateKeyFile /usr/local/apache2/conf/server.key

       SSLVerifyClient optional

       SSLOptions +ExportCertData

       SSLProxyVerify none

       SSLProxyCheckPeerCN off

       SSLProxyCheckPeerName off

       SSLProxyCheckPeerExpire off

       ProxyRequests off

       Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED

       <Proxy balancer://rangercluster>

           BalancerMember http://ranger-kms-host1-fqdn:9292 loadfactor=1 route=1

BalancerMember http://ranger-kms-host1-fqdn:9292 loadfactor=1 route=2

       

               Order Deny,Allow

               Deny from none

               Allow from all

               ProxySet lbmethod=byrequests scolonpathdelim=On stickysession=ROUTEID maxattempts=1 failonstatus=500,501,502,503 nofailover=Off

       </Proxy>

       # balancer-manager

       # This tool is built into the mod_proxy_balancer

       # module and will allow you to do some simple

       # modifications to the balanced group via a gui

       # web interface.

       <Location /balancer-manager>

               SetHandler balancer-manager

               Order deny,allow

               Allow from all

       </Location>

      ProxyPass /balancer-manager !

      ProxyPass /balancer://rangerkmscluster/

      ProxyPassReverse /balancer://rangerkmscluster/

</VirtualHost>

Ranger KMS Plugin with HA