You are on page 1of 4

4/26/2016

LoadbalancingGlassfishServer4usingApacheHTTPServerwithmod_jkpluginManvs.Technology

Manvs.Technology
Catchingupwithtechnology

LoadbalancingGlassfishServer4usingApacheHTTP
Serverwithmod_jkplugin
Afterguringoutfromvarioussources,Inallymadeit.Afullyfunctionalloadbalancingsetup
forGlassshServer4withApacheasthefrontend,withthehelpofthebackbone,themod_jk
plugin.ThisisincontinuationwiththeclusteringtutorialwhichIrebloggedearlier.Readonto
seehowitwascongured
Firston,thesetupwhichIhad:
1.TwoVMs
UbuntuServer15.04
UbuntuDesktop15.04
2.OracleGlassshServer4.1OpenSourceEdition
Ihadsetupmydevelopmentenvironmentsuchthattheservermachinehostedallthemain
congurationwhileallowingthedesktoponetoactasabackupincaseIdonotneedalltheserver
capabilities(likewhenIamsimplybrowsingorperformingmaintenanceonthemachine).Ihad
madeaclusternamedc1withatotaloftwoinstances(i1andi2),oneontheserverandotheron
thedesktop.InaGlassshcluster,replicationofsessiondatahappensbydefaultonenablingload
balancingsupport.
Withoutloadbalancing,shouldoneoftheinstancesfail,Ihadtomanuallychangethehostname 1/4

https://geekyvivek.wordpress.com/2015/08/16/loadbalanceglassfish4withmodjk/

4/26/2016

LoadbalancingGlassfishServer4usingApacheHTTPServerwithmod_jkpluginManvs.Technology

Withoutloadbalancing,shouldoneoftheinstancesfail,Ihadtomanuallychangethehostname
ofthewebapplicationtobetested.Thiswasnotveryprey,sohavingaloadbalancerwaswhatI
needed.Letsgettothesteps:

StartGlassfishserver
1
2
3

asadmin
startdomain
startclusterc1

Configurecluster
Enableloadbalanceronallinstancesofthecluster.Thisenablessessionreplicationbetween
instancessothatyoudonthavetologinagainintoyourwebapplicationifoneinstancegets
downandyouareredirectedtotheotherone.
enablehttplbserverc1
Denesomesystemvariablessothatitiseasiertochangelateronandyougetridoftypos.
1
2
3
4

createsystempropertiestargeti1AJP_PORT=8011
createsystempropertiestargeti1AJP_INSTANCE_NAME=c1i1
createsystempropertiestargeti2AJP_PORT=8012
createsystempropertiestargeti2AJP_INSTANCE_NAME=c1i2

mod_jkusesaprotocolknownasAJPwhichconsistsofallrequiredlogictodetectworkers
(instances)andaccordinglydecidewhethertoredirectarequest.Thisdecisionismadebasedon
the AJP_INSTANCE_NAME propertyfortheworkerwhichmod_jkaccesses.Itstorestheworker
informationusing AJP_INSTANCE_NAME asthekey. AJP_PORT istheHTTPlistenerofthe
concernedGlassshinstancetowhichtherequestswillberouted.
CreateJVMoptionsforeachinstanceoftheclusterbyissuingthecommandtothecluster:
createjvmoptionstargetc1DjvmRoute=${AJP_INSTANCE_NAME}
CreateAJPenabledHTTPlistenerfortheclusternamedjklistenersothatrequestsarehandledvia
AJP_PORT :
createnetworklistenerprotocolhttplistener1targetc1listenerport
${AJP_PORT}jkenabledtruejklistener

NotethatthedefaultHTTPlistenerswillstillbeactive.Youcanuseitifforsomereasonyourload2/4

https://geekyvivek.wordpress.com/2015/08/16/loadbalanceglassfish4withmodjk/

4/26/2016

LoadbalancingGlassfishServer4usingApacheHTTPServerwithmod_jkpluginManvs.Technology

NotethatthedefaultHTTPlistenerswillstillbeactive.Youcanuseitifforsomereasonyourload
balancergoesdownorisnotconguredforanewapplication.

InstallApache2Serverwithmod_jk
1

sudoaptgetinstallapache2libapache2modjk

Moveontothenextpagefortherealbulkofthework.
Abouttheseads

Pages:12

GeekyVivek
ExperiencedsoftwareengineerdealingwithRESTfulwebservices,Windows/Linuxsystems,
Dockerandrevampinglegacycodebases.Likediggingoutoftheordinarywaysandtryingout
newtechnologiestohelpimprovecurrentconditions.Notafraidtotackleanewthingifitsolves
theproblemathandeasilythanotherknownsolutions.
Authorarchive Authorwebsite
August16,2015
Java,Servers,Web
Ubuntu,Glasssh,Apache,modjk,clustering,loadbalancing

https://geekyvivek.wordpress.com/2015/08/16/loadbalanceglassfish4withmodjk/

3/4

4/26/2016

LoadbalancingGlassfishServer4usingApacheHTTPServerwithmod_jkpluginManvs.Technology

2thoughtsonLoadbalancingGlassfishServer4using
ApacheHTTPServerwithmod_jkplugin
1.Kristofer
April25,2016at8:29am
Reply
Dude,youdontknowhowhelpfulthiswas!Igiveyouamillionthanks!

1Pingback
1.LoadbalancingGlassshServer4usingApacheHTTPServerwithmod_jkplugin|Dinesh
RamKali.

CREATEAFREEWEBSITEORBLOGATWORDPRESS.COM.|THEBASKERVILLE
THEME.
UP

https://geekyvivek.wordpress.com/2015/08/16/loadbalanceglassfish4withmodjk/

4/4

You might also like