Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am currently an intern in my company. My boss basically wants me to perform a failover from a JBoss AS to another just for a proof of concept. Load balancing is not required as i am only required to show 1 client connected to JBoss 1, perform a failover, and which the client will automatically connect to JBoss 2.

As of now, I am able to cluster the 2 JBoss AS by using a "ran.bat -c all" from different terminals both running Windows. And now, here are my questions

1) What should i do to configure a failover for the JBoss

2) What is the simplest and fastest application i should write to host it on JBoss, so that JBoss could perform a failover from 1 JBoss to another?

Any guidances would be greatly appreciated and MANY thanks in advance.

Kevin

share|improve this question

2 Answers 2

Jboss does not support http LB. Each node is listening on its own port. http session are replicated/distributed. If your boss insist, you can use the HAJNDI Smart client proxy rather then http. Simply initiate a naming context from your client application to the HAJNDI port (1101), lookup you EJB3 application and call any remote method. When the connected node is down the smart proxy will know to switch.

share|improve this answer

You need to have an apache or iis fronting the cluster.

Basically you use mod_jk, mod_proxy_ajp or mod_cluster to do manage the failover and stickyness of the sessions.

Now lets say you have 2 jboss servers (192.168.1.2 and 192.168.1.3) and 1 apache 2.2.x and you want to use mod_jk for the sake of simplicity (if you want 2 apaches to do HA at the http layer you need a load balancer of some kind).

The first thing is you download mod_jk 1.2.30 as it offers better capabilities for node failed node detection. and put it into the modules directory of the apache server_root.

then you go to the httpd.conf and add:

LoadModule jk_module modules/mod_jk-1.2.30-httpd-2.2.3.so

next thing you do is create a file called workers.properties with the following content

worker.list=loadbalancer,status
worker.template.port=8009
worker.template.type=ajp13
worker.template.ping_mode=A
worker.template.reply_timeout=90000
worker.template.socket_connect_timeout=10000
worker.template.connection_pool_size=150
worker.template.socket_keepalive=true

worker.node1.reference=worker.template
worker.node1.host=192.168.1.2

worker.node2.reference=worker.template
worker.node2.host=192.168.1.3

worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=True

worker.status.type=status

Then in the httpd.conf file you add the following lines:

JkWorkersFile conf/workers.properties
JkWatchdogInterval 60
JkMount /* loadbalancer
JkLogFile logs/mod_jk.log

then in go to the jboss config for 192.168.1.2

in the file JBOSS_HOME/server/all/deploy/jbossweb.sar/server.xml

<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1">

and replace or modify this:

<Connector protocol="AJP/1.3" port="8009" address="${jboss.bind.address}"
     redirectPort="8443" />

with this:

<Connector port="8009" address="${jboss.bind.address}" protocol="AJP/1.3"
emptySessionPath="true" enableLookups="false" redirectPort="8443"
maxThreads="200" connectionTimeout="600000" />

then in go to the jboss config for 192.168.1.3

in the file JBOSS_HOME/server/all/deploy/jbossweb.sar/server.xml

<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node2">

and replace or modify this:

<Connector protocol="AJP/1.3" port="8009" address="${jboss.bind.address}"
     redirectPort="8443" />

with this:

<Connector port="8009" address="${jboss.bind.address}" protocol="AJP/1.3"
emptySessionPath="true" enableLookups="false" redirectPort="8443"
maxThreads="200" connectionTimeout="600000" />

Explanation: The change in the connector tag limits the threads in the web container to 200 (i.e. it is the max amount of simultaneous requests is able to manage) the connectionTimeout makes sure that if the client closes the connection (this is "closes the browser") the thread expires after 600 seconds of no use.

You can find sizing for these parameters in this appspot app created by the jboss team: lbconfig.appspot.com

SECURITY CONSIDERATIONS: Secure or disable the jmx-console and/or the web-console by either deleting the jmx-console.war and management directories from the deploy folder or following the instructions in this document

You can find more info about load balancing, mod_jk, mod_cluster in the jboss wiki

share|improve this answer
    
Hi there. Sorry for the late reply. Can i just check with you, is it a must to have other software/hardware to do the failover?? Meaning to say JBoss itself is unable to perform the failover and it require another software/hardware to do the failover?? THanks alot for the reply!! –  Nivek Oct 28 '10 at 2:47
    
What do you mean? like without apache or something in front?? You need something that sends different requests to different jboss nodes. This is not like an active-passive failover (where the you have one node take over when the primary goes down), it is an active-active failover + also adding load balancing. –  feniix Oct 29 '10 at 4:53
    
Hi feniix, thanks once again. So am i right to say that JBoss is unable to perform failover itself, it needs a something infront of JBoss (ie: Apache)?? I got pretty confuse when i read this in the manual under 9.7.1 it says "If the supportsFailover attribute of the connection factory is set to true then automatic failover is enabled. This will automatically failover from one server to another, transparently to the user, in case of failure." I got the info from docs.jboss.org/jbossclustering/cluster_guide/5.1/pdf/… –  Nivek Nov 1 '10 at 1:52
    
Read 1.1.3 in that guide. Regardless of the load balancer(or http server in front) the session replication and all the internal mechanisms of failover happen even if you do not have the http server in front. Just happens it would be useless for the client. –  feniix Nov 1 '10 at 14:32
1  
Sorry if I sound harsh, but your boss is retarded. If you have a cluster, and nothing in front of it the most you can do is have the client access only one of the nodes of the cluster which buys you nothing. I am not saying a hardware load balancer, an apache web server can act as a load balancer. –  feniix Nov 13 '10 at 16:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.