Menu

Sunday 17 June 2018

Apache Configure mod_proxy as load balancer (LB)- JBoss 7.1




Connector
Supports Sticky Sessions
Adapts to Deployment Status
Yes
Yes. Detects deployment and undeployment of applications and dynamically decides whether to direct client requests to a server based on whether the application is deployed on that server.
Yes
No. Directs client requests to the container as long as the container is available, regardless of application status.
Yes
No. Directs client requests to the container as long as the container is available, regardless of application status.
Yes
No. Directs client requests to the container as long as the container is available, regardless of application status.
Yes
No. Directs client requests to the container as long as the container is available, regardless of application status.


Software Details:
**  JBoss-as-7.1.1.Final**
** Apache HTTPServer 2.4.33 - WINDOWS**

Step 1: Enable list of modules for mod_proxy as load balancer.
  • ·         mod_proxy.so
  • ·         mod_proxy_balancer.so
  • ·         mod_proxy_connect.so
  • ·         mod_proxy_http.so


Step 2: Enable list of below modules for Load balancer scheduler algorithm.
  • ·         mod_lbmethod_bybusyness.so
  • ·         mod_lbmethod_byrequests.so
  • ·         mod_lbmethod_bytraffic.so
  • ·         mod_lbmethod_heartbeat.so


Step 3: Enable below module for balancer-manager status.
  • ·         mod_status.so  


Step 4: Edit httpd.conf file Add below configuration.

#################################################

<Proxy balancer://mybalancer>

BalancerMember http://192.168.0.103:8080   route=node1 loadfactor=1 ping=10 ttl=600 keepalive=On
BalancerMember http://192.168.0.103:8090   route=node2 loadfactor=1 ping=10 ttl=600 keepalive=On
proxyset lbmethod=bytraffic 

</Proxy>

########################################################

ProxyPreserveHost On

ProxyPass /sample   balancer://mybalancer/sample  stickysession=JSESSIONID|jsessionid timeout=10 nofailover=On
ProxyPassReverse /sample   balancer://mybalancer/sample

ProxyPass  /calendar   balancer://mybalancer/calendar  stickysession=JSESSIONID|jsessionid timeout=10 nofailover=On
ProxyPassReverse  /calendar     balancer://mybalancer/calendar

ProxyPass /hello   balancer://mybalancer/hello  stickysession=JSESSIONID|jsessionid timeout=10 nofailover=On
ProxyPassReverse /hello   balancer://mybalancer/hello

#######################################################



Where,
  • ·                        mybalancer (balancer variable name)
  • ·                       BalancerMember [IP]:[PORT]  
  • ·                        proxyset lbmethod=bytraffic   (load balancer scheduler algorithms)
  • ·                        stickysession=JSESSIONID|jsessionid (load balancer stickiness)
  • ·                        ProxyPass /App   balancer://mybalancer/app 
NOTE : Enable Sticky Sessions A sticky session means that if a client request originally goes to a specific JBoss worker, all future requests will be sent to the same worker, unless it becomes unavailable.




Screenshot:






Step 5: For balancer-manager status add below configuration in httpd.conf

Note: Enable mod_status module

####################################################
<Location "/balancer-manager">
    SetHandler balancer-manager
    Order deny,allow
    Deny from all
    Allow from localhost 192.168.0.103
</Location>

ProxyPass /balancer-manager !

####################################################


Screenshot:





















**************************************************
JBoss level Configuration :



Step 6 : Add the system-properties  to provide the jvmRoute and value.

             Note: Make same changes to another JBoss sever node2 - (standalone.xml)
      

  <system-properties>

        <property name="jvmRoute" value="node1"/>

  </system-properties> 








Reference link:



Thanks :-)




Thursday 14 June 2018

Apache mod_jk HTTP Connector - JBOSS AS 7.1

Connector
Supports Sticky Sessions
Adapts to Deployment Status
Yes
Yes. Detects deployment and undeployment of applications and dynamically decides whether to direct client requests to a server based on whether the application is deployed on that server.
Yes
No. Directs client requests to the container as long as the container is available, regardless of application status.
Yes
No. Directs client requests to the container as long as the container is available, regardless of application status.
Yes
No. Directs client requests to the container as long as the container is available, regardless of application status.
Yes
No. Directs client requests to the container as long as the container is available, regardless of application status.


**Software Details:**

(1)  Jboss-as-7.1.1.Final- (JBoss Community Based) 

(2)  Apache HTTPServer 2.4.33 - WINDOWS

**Apache level Configuration:**

Step 1: Download mod_jk.so module for Apache 2.4.33 from link.


Step 2: load the mod_jk module on \httpd-2.4.33-Win64\Apache24\modules  location.


Screenshot  :



   


Step 3:  Create a new file called  mod_jk.conf  on desired location and add the below configuration.


######################################################################


# Load mod_jk module

# Specify the filename of the mod_jk lib

LoadModule jk_module modules/mod_jk.so


# Where to find workers.properties

JkWorkersFile D:\httpd-2.4.33-Win64\Apache24\conf\extra\MODJK\workers.properties


# Where to put jk logs

JkLogFile logs/mod_jk.log


# Set the jk log level [debug/error/info]

JkLogLevel debug


# Select the log format

JkLogStampFormat  "[%a %b %d %H:%M:%S %Y]"


# JkOptions indicates to send SSK KEY SIZE

#JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories


# JkRequestLogFormat

JkRequestLogFormat "%w %V %T"


# Mount your applications

JkMount /* loadbalancer


###################

# Use external file for mount points.

# It will be checked for updates each 60 seconds.

# The format of the file is: /url=worker

# /examples/*=loadbalancer

#JkMountFile D:\httpd-2.4.33-  Win64\Apache24\conf\extra\MODJK\uriworkermap.properties


##############

# Add shared memory.

# This directive is present with 1.2.10 and

# later versions of mod_jk, and is needed for

# for load balancing to work properly

JkShmFile D:\httpd-2.4.33-Win64\Apache24\logs\jk.shm



###############################################################


Or use below link for reference https://access.redhat.com/documentation/
  




Step 4:  Create a new file called workers.properties  on desired location  add below configuration.& provide its location on mod_jk.conf file.


##############################################################

# Define list of workers that will be used

# for mapping requests

worker.list=loadbalancer

 

# Define Node1

# modify the host as your host IP or DNS name.

worker.node1.port=8009

worker.node1.host=192.168.XXX.XXX

worker.node1.type=ajp13

worker.node1.ping_mode=A

worker.node1.lbfactor=1

 

# Define Node2

# modify the host as your host IP or DNS name.

worker.node2.port=8019

worker.node2.host=192.168.XXX.XXX

worker.node2.type=ajp13

worker.node2.ping_mode=A

worker.node2.lbfactor=1

 

# Load-balancing behavior

worker.loadbalancer.type=lb

worker.loadbalancer.balance_workers=node1,node2

worker.loadbalancer.sticky_session=1

 


###############################################################

Screenshot
 



Step 5: (OPTIONAL) Create a new file called uriworkermap.properties on desired location and add below configuration.


###############################################################

 # Simple worker configuration file

 /*=loadbalancer 

############################################################### 



Step 6:  Add the JkMount application URls to httpd.conf & httpd-ssl.conf (Inside Virtualhost tag).
 

######################################################

 JkMount /* loadbalancer

######################################################

Screenshot:

  

Step 7 : Include  the mod_jk.conf file location in httpd.conf file. 

#################################################

 Include D:\httpd-2.4.33-Win64\Apache24\conf\extra\MODJK\*.conf

#################################################


 Screenshot:
  

NOTE:

The JkMount directive specifies which URLs Apache HTTP Server must forward to the mod_jk module.To serve static content directly and only use the load balancer for Java applications, the URL path must be JkMount  /application/*  [Worker.list name]
To use mod_jk as a load balancer, use the value /*, to forward all URLs to mod_jk.
JkMount   /*  [Worker.list name]  



*****************************************

**JBoss  level Configuration:**


Step 1:  Add the the AJP connector tag if not present in the standalone.xml file  or uncomment it .

 <connector name="ajp" protocol="AJP/1.3" scheme="http" socket- binding="ajp"/>



Screenshot: 
 


Step 2: Also check the socket-binding port.


 <socket-binding name="ajp" port="8009"/>


Screenshot:

 


Step 3 : Add the system-properties  to provide the jvmRoute and value.

     <system-properties>

        <property name="jvmRoute" value="node1"/>

  </system-properties> 

Screenshot: 





**Application –status:**

  

1: Check the application:


 Screenshot:









 
2: Check the mod-jk.log after Loglevel debug.

 Now, single application  equally routing the to node1 & node2 through LB for both JBoss JVM 

Screenshot: 
 






**ModJK status**

Step 1 : For Jk Status Manager status add below configuration in httpd.conf

Note: Enable mod_status module


####################################################

<Location "/jkstatus">
    JkMount status
    Order deny,allow
    Deny from all
    Allow from localhost 192.168.XXX.XXX
</Location>


JkMount   /jkstatus/*  status

####################################################






Step 2: Edit workers.properties file  and add (status)  on worker & worker.list


## Status worker for managing load balancer

       worker.status.type=status

# #Define list of workers that will be used
# #for mapping requests

      worker.list=loadbalancer,status






Step 3: Use https://192.168.XXX.XXX/jkstatus






mod jk troubleshooting pdf : 
https://access.redhat.com/sites/mod_jk_troubleshooting_1.pdf
https://access.redhat.com/doc

Reference link
Thanks :-)