Vous êtes sur la page 1sur 23

5/21/2015

ClusterJBoss

RSSFeed
Home
Apache&Cluster
Security
JMS
EJB&JPA
Utility
WebService
GeneralJBoss
MBeans
OpenShift
JDBC
Disclaimer
WeblogictoJBossMigration

Cluster
4
Sep/12

HowtogetAllClusterNodeDetailsusingJMXinJBossAS7.1.2
byAuthor_1underCluster,JbossAS7,JBossAS7,MBeans
Hi,

InJBossEAP5orAS6orpreviousreleasestherewasaconceptofPartitionNamewhichcouldbeused
to get the list of active cluster members, However in JBoss AS7 there is no concept of PartitionName
ratherinUDPmodethelusteringhappensbasedonthemulticastasddress(Clusteringcanbeachieved
usingTCPmodeofcommunicationaswell).Howevermanydeveloperswanttolistthenumberofactive
membersrunningaspartofaJBossAs7clusterprogramatically.
So in this example we will see how to write a simple JMX Code in order to access the cluster node
http://middlewaremagic.com/jboss/?cat=8

1/23

5/21/2015

ClusterJBoss

details.

NOTE:
Point1).InJBossAS7untilyoudeployanapplicationwhichrequiresclusteringtheJBosswillnow
starttheclusteringservices.SoincaseofwebApplicationsyoushoulddeployatleastoneapplicationon
yourClustermemberswhichhas<distributable/>tagspecifiedinitsWEBINF/web.xmlfile.
Point2).IfyouareusingEJBs(andnotwebapplicationtodeployonyourcluster)makesurethatthe
EJBsareclusteredinordertostartClusterservices.EJBscanbeannotatedusingthefollowing
annotationinordertobeclustered.@org.jboss.ejb3.annotation.Clustered
Point3).InCaseofWebBasedclustertheObjectNameoftheClusteredinstancewillbe
jgroups:type=channel,cluster=webbydefaultwhichcanbeusedintheJMXCodeinordertolook
querytheMBean.
Point3).InCaseofEJBBasedclustertheObjectNameoftheClusteredinstancewillbe
jgroups:type=channel,cluster=ejbbydefaultwhichcanbeusedintheJMXCodeinordertolook
querytheMBean.
Point5).IfyouarerunningyourServerinDomainModethenyoushouldnotusetheNative
ManagementPort9999inordertoquerytheMBeansratheryoushouldusetheindividualservers
RemotingPort4447inyourJMXCode.byaddingthefollowingconfigurationonyourJBossProfile
insidedomain.xmlyoucanallowaccessingtheMBeansviaRemotingport4447ratherthan(native
managementport9999)
1
2
3
4

<subsystemxmlns="urn:jboss:domain:jmx:1.1">
<showmodelvalue="true"/>
<remotingconnectorusemanagementendpoint="false"/>
</subsystem>

Point6).IfyouareusingNativeManagementInterfaceport9999inordertoqueryyourClusterMBean
(instandalonemode)thenyoushouldusetheCredentials(username/password)forauserbelongingto
ManagementRealm,ButinDomainmodeasweneedtoconnecttoserverusingRemotingPort(4447)so
youshouldcreateaApplicationRealmuser.inalltheclusterHosts.

WritingtheJMXcodcetoqueryClusterMBean
01
02
03
04
05
06
07
08
09
10
11
12
13

importjava.util.Hashtable;
importjavax.management.MBeanServerConnection;
importjavax.management.ObjectName;
importjavax.management.remote.JMXConnector;
importjavax.management.remote.JMXConnectorFactory;
importjavax.management.remote.JMXServiceURL;

publicclassAS7ClusterView{
publicstaticvoidmain(String[]args)throwsException{

Stringhost="10.10.10.10";//YourJBossNativeInterfaceBinAdd
intport=9999;//managementport//InDomainMo
StringurlString="service:jmx:remotingjmx://"+host+":"+por

http://middlewaremagic.com/jboss/?cat=8

2/23

5/21/2015

ClusterJBoss

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

System.out.println("\n\n\t****urlString:"+urlString);
StringwebClusterObjectName="jgroups:type=channel,cluster=\
//StringejbClusterObjectName="jgroups:type=channel,cluster

JMXServiceURLserviceURL=newJMXServiceURL(urlString);

Hashtableh=newHashtable();
String[]credentials=newString[]{"admin","admin123"};
h.put("jmx.remote.credentials",credentials);

JMXConnectorjmxConnector=JMXConnectorFactory.connect(serviceURL,
MBeanServerConnectionconnection=jmxConnector.getMBeanServerConne
ObjectNameobjectName=newObjectName(webClusterObjectName);
StringclusterView=(String)connection.getAttribute(objectName,
LongreceivedMessages=(Long)connection.getAttribute(objectName,
Stringname=(String)connection.getAttribute(objectName,"Name"
StringclusterName=(String)connection.getAttribute(objectName,

System.out.println("clusterView="+clusterView);
System.out.println("receivedMessages="+receivedMessages);
System.out.println("name="+name);
System.out.println("clusterName="+clusterName);
jmxConnector.close();
}

NowopenaTerminalwhereweneedtosetthePAThandCLASSPATHlikefollowingandthencompile
andruntheprogram:
01
02
03
04
05
06
07
08
09
10

ForUNIXBasedOperatingSystem:

exportPATH=/home/userone/jdk1.6.0_21/bin:$PATH
exportCLASSPATH=/home/userone/jbossas7.1.2.Final/bin/client/jbossclient

++++++++++++++++++++++++++++++++
ForWindowsBasedOperatingSystem

setPATH=C:\jdk1.6.0_21\bin;%PATH%
setCLASSPATH=c:\jbossas7.1.2.Final\bin\client\jbossclient.jar;%CLASSPAT
.
.
Thanks
MiddlewareMagicTeam
Cluster,JbossAS7,JBossAS7,MBeansLeaveaCommentmore...
3
Jul/12

http://middlewaremagic.com/jboss/?cat=8

3/23

5/21/2015

ClusterJBoss

Usingmod_clusterwithJBossAS7.1cluster
byAuthor_2underApache,Cluster,JbossAS7,mod_cluster,WebServer

Wehaveseenhowtocreateclustersinstandalone,domainwithmulticastand
unicastprotocolsalsowhichhavebeenlistedbelow.Howeverinthisarticlewewouldbeseeinghowto
usemod_clusterwithourcreatedclustersinbothstandaloneanddomainmode.
FollowingarethelistofarticlewehavecreatedtillnowforcreatingaclusterinJBossAS7.1.1Finaltill
now
1.
2.
3.

HowtocreateclusterinJBossAS7.1instandalonemode?
HowtocreateclusterinJBossAS7.1indomainmode?
CreatingTCPclusterinJBossAS7.1instandalonemode?

AgainwewouldbeusingJBossAS7.1.1.Finalforthisarticleaswellsothatweareallonthesame
page,asfewthingshavebeenchangefromJBossAS7.0toJBossAS7.1.

Changestakenplace:
1. AJPconnectorisenabledbydefaultinstandaloneha.xml,standalonefullha.xmlanddomain.xml
forhaandfullhaprofile.
2.
InsteadofJVMRoute,nowwehavetouseinstanceid

Usingmod_clusterwithJBossAS7.1cluster
ForthiswewouldhavetomodifyfrombothsideApacheaswellasJBossAS7side,henceletsseethe
configurationoneatatime

Apachesideconfiguration
LetsseewhatallconfigurationhastobemadefromApacheside
1.

Youcanconfiguremod_clusterfromthebelowarticle,justfollowtheApacheside
configurationpartonly
Howtoconfiguremod_clusterwithJBoss?

2.

IntheabovearticleyoucanjustaddtheIP_ADDRESSoftheboxonwhichApacheisrunning
whichisintheStep3somethingasshownbelow

http://middlewaremagic.com/jboss/?cat=8

4/23

5/21/2015

ClusterJBoss

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23

###############mod_clusterSettingSTARTED###############
LoadModuleslotmem_modulemodules/mod_slotmem.so
LoadModulemanager_modulemodules/mod_manager.so
LoadModuleproxy_cluster_modulemodules/mod_proxy_cluster.so
LoadModuleadvertise_modulemodules/mod_advertise.so

Listen1.1.1.1:80

<VirtualHost1.1.1.1:80>
<Directory/>
Orderdeny,allow
Allowfromall
</Directory>
<Location/mod_clustermanager>
SetHandlermod_clustermanager
Orderdeny,allow
Allowfromall
</Location>
KeepAliveTimeout60
ManagerBalancerNamemycluster
ServerAdvertiseOn
</VirtualHost>
###############mod_clusterSettingENDED###############

JBosssideconfiguration
NowwewouldseewhatallchangeswehavetobedonefromJBossendinstandaloneanddomainfiles

Standalone
1. FirstyouwouldhavetofollowallthestepsgiveninthelinkHowtocreateclusterinJBossAS
7.1instandalonemode?andthenmakethebelowchangesinallthestandaloneservers.
2.
Giveauniquenameintheserverelement,asshownbelow.
standalonenode1
1 <servername="standalonenode1"xmlns="urn:jboss:domain:1.2">
standalonenode2
1 <servername="standalonenode2"xmlns="urn:jboss:domain:1.2">
3. Astoldearlieryouwouldhavetoaddtheinstanceidattributeinwebsubsystemasshownbelow
inboththestandalonenodes.
1
2
3
4
5
6

<subsystemxmlns="urn:jboss:domain:web:1.1"defaultvirtualserver
<connectorname="http"protocol="HTTP/1.1"scheme="http"socketbin
<connectorname="ajp"protocol="AJP/1.3"scheme="http"socketbindi
.
.
.

http://middlewaremagic.com/jboss/?cat=8

5/23

5/21/2015

ClusterJBoss

7 </subsystem>
4.

Lastyoujusthavetoaddtheproxylistintheattributeinmodclusterconfigofmodcluster
subsystem,whichwouldbehavingIPAddressandPortonwhichyourApacheserverisrunningso
thatJBossservercancommunicatewithit,asshownbelowinboththestandalonenodes.
1
2
3
4
5
6
7

<subsystemxmlns="urn:jboss:domain:modcluster:1.0">
<modclusterconfigadvertisesocket="modcluster"proxylist="1.1.1
.
.
.
</modclusterconfig>
</subsystem>

IfeverythingisconfiguredproperlyyoucanhittheURL=http://1.1.1.1/mod_clustermanagerwhich
wouldshowsimilarbelowscreen.Belowimageisshowingwhenclusterisbeenmadeinonthesame
boxusingstandalonemode

mod_clusterforStandaloneonthesamebox

Domain
1. FirstyouwouldhavetofollowallthestepsgiveninthelinkHowtocreateclusterinJBossAS
7.1indomainmode?andthenmakethebelowchangesinyourdomainfile.
2. Wewouldhavetoaddtheinstanceidattributeinwebsubsystemasshownbelowindomain.xml
fortherespectiveprofilehaandfullhawhichisbeenused.
1
2
3
4
5
6
7
3.

<subsystemxmlns="urn:jboss:domain:web:1.1"defaultvirtualserver
<connectorname="http"protocol="HTTP/1.1"scheme="http"socketbin
<connectorname="ajp"protocol="AJP/1.3"scheme="http"socketbindi
.
.
.
</subsystem>

Lastyoujusthavetoaddtheproxylistintheattributeinmodclusterconfigofmodcluster
subsystem,whichwouldbehavingIPAddressandPortonwhichyourApacheserverisrunningso

http://middlewaremagic.com/jboss/?cat=8

6/23

5/21/2015

ClusterJBoss

thatJBossservercancommunicatewithit,asshownbelowindomain.xmlfortherespective
profilehaandfullhawhichisbeenused.
1
2
3
4
5
6
7

<subsystemxmlns="urn:jboss:domain:modcluster:1.0">
<modclusterconfigadvertisesocket="modcluster"proxylist="1.1.1
.
.
.
</modclusterconfig>
</subsystem>

IfeverythingisconfiguredproperlyyoucanhittheURL=http://1.1.1.1/mod_clustermanagerwhich
wouldshowsimilarbelowscreen.Belowimageisshowingwhenclusterisbeenmadeinonthesame
boxaswellasinremoteboxusingdomainmode.
SameBox

mod_clusterforDomainmodeonthesamebox
RemoteBox

mod_clusterforDomainmodeonRemotebox

Testing
InallourpreviousarticlewehadaskedyoutouseoneofourapplicationcalledClusterWebAp,thisis
thetimewhenwewouldbetestingifourclusterisworkingproperlywithmod_clusterconfiguration.
http://middlewaremagic.com/jboss/?cat=8

7/23

5/21/2015

1.

ClusterJBoss

Onceeverythingthingisbeenconfiguredandhavebeenstartedupproperlyyoucanhitthe
applicationusingApacheURLasshownbelowandyouwouldseesomethinglikeinthesnapshot
1 http://1.1.1.1/ClusterWebApp

ClusterWebApp
2.

Supposethefirstrequestgoestostandalonenode2,youcanseethereisasessionidwhichis
beengenerated.Nowyoujusthavetoshutdownyourstandalonenode2andthenclickonthelink
ClickHeretomovetonextPagesessionCheck.jsponthesamepage.
3. Onceyouclickonthelink,youwillnoticethattherequesthasbeenservedbythestandalone
node1thistimeasnode2hadbeenbroughtdown,butthesessionidremainsthesamewhichwas
createdearlierhavingthesametimestampasshownbelow

SessionReplication
Withthistestitisclearthatourclusterisworkingfineasthesessionreplicationishappeningproperlyon
JBossusingmod_cluster.

Issuesyoumightface
Ifyouhavenotgiventheinstanceidinthedomain.xmlfileforhaorfullhaandhaveastepupa
clusterwhichishavingamod_clusterinfrontofthemyoumightgetthefollowingerrorinthelogs.
1
2
3
4

[Server:haserver1]20:29:36,429ERROR[org.jboss.modcluster.mcmp.impl.Def
[Server:haserver2]20:29:37,426ERROR[org.jboss.modcluster.mcmp.impl.Def
[Server:haserver2]20:29:47,432ERROR[org.jboss.modcluster.mcmp.impl.Def
[Server:haserver1]20:29:56,441ERROR[org.jboss.modcluster.mcmp.impl.Def

http://middlewaremagic.com/jboss/?cat=8

8/23

5/21/2015

ClusterJBoss

Forthisyoujusthavetofollowthestep2ofDomainconfiguration,whichwouldfixthisissue.
Apache,Cluster,JbossAS7,JBossAS7,mod_cluster2Commentsmore...
11
Jun/12

CreatingTCPclusterinJBossAS7.1instandalonemode?
byAuthor_2underCluster,JbossAS7,JBossAS7

InmypreviousarticlewehadseenHowtocreateclusterinJBossAS7.1in
standalonemode?whichwasusingUDPprotocol.
BydefaultJBossAS7usesUDPprotocol,butforsecurityconstrainssomecompaniesdonotopen/allow
touseUDPprotocolormulticastaddresses,henceduringthattimeTCPprotocolorunicastaddresscan
beusedtocreateaclusterwhichisalsosupportedbyJBossAS7.
InthisarticlewewouldbeshowingyouhowyouusestandalonemodetocreateaclusterusingTCP
protocol.Howeverasweallknowinstandalonemodewehavedifferentxmlfilesunderthe
configurationfolderfromwhichclusterisenabledinstandaloneha.xmlandstandalonefullha.xml,
thusmakesureyouwouldbeusingthemandnototherxmlfiles.
InthisarticlewewouldbeusingJBossAS7.1.1FinalwhichisthelatestversionofJBossincommunity
version.

StepstocreateaTCPclusterinJBossAS7.1instandalonemode
Wewouldbeseeingtwoscenarioshereonewouldbecreatingaclusteronthesameboxandsecond
whencreatingaclusterbetweendifferentboxes.

Scenario1:Clusteronsamebox
1.

Onceyouhaveunzippedjbossas7.1.1.Final.zip,youwouldhavetocreatetwocopiesof
standalonefolderandrenamethemasstandalonenode1andstandalonenode2asshownbelow
1 /home/user/jbossas7.1.1.Final/standalonenode1
2 /home/user/jbossas7.1.1.Final/standalonenode2
Note:Makesureyoukeeptheoriginalcopyforstandalonefolderasitisforfutureusage.

http://middlewaremagic.com/jboss/?cat=8

9/23

5/21/2015

2.

ClusterJBoss

Inboththestandalonenodexyouwouldhavetomakethefollowingchangesinstandalone
ha.xmlfilestotellJBosstostarttheclusterinTCPprotocol
From:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23

<subsystemxmlns="urn:jboss:domain:jgroups:1.1"defaultstack="udp"
<stackname="udp">
.
.
.
</stack>
<stackname="tcp">
<transporttype="TCP"socketbinding="jgroupstcp"
<protocoltype="MPING"socketbinding="jgroupsmping"
<protocoltype="MERGE2"/>
<protocoltype="FD_SOCK"socketbinding="jgroupstcpfd
<protocoltype="FD"/>
<protocoltype="VERIFY_SUSPECT"/>
<protocoltype="BARRIER"/>
<protocoltype="pbcast.NAKACK"/>
<protocoltype="UNICAST2"/>
<protocoltype="pbcast.STABLE"/>
<protocoltype="pbcast.GMS"/>
<protocoltype="UFC"/>
<protocoltype="MFC"/>
<protocoltype="FRAG2"/>
</stack>
</subsystem>
To:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21

<subsystemxmlns="urn:jboss:domain:jgroups:1.1"defaultstack="tcp"
<stackname="udp">
.
.
.
</stack>
<stackname="tcp">
<transporttype="TCP"socketbinding="jgroupstcp"
<protocoltype="TCPPING">
<propertyname="initial_hosts">10.10.10.10[7600],10
<propertyname="num_initial_members">2</property
<propertyname="port_range">0</property>
<propertyname="timeout">2000</property>
</protocol>
<protocoltype="MERGE2"/>
<protocoltype="FD_SOCK"socketbinding="jgroupstcpfd
<protocoltype="FD"/>
<protocoltype="VERIFY_SUSPECT"/>
<protocoltype="BARRIER"/>
<protocoltype="pbcast.NAKACK"/>
<protocoltype="UNICAST2"/>

http://middlewaremagic.com/jboss/?cat=8

10/23

5/21/2015

ClusterJBoss

22
23
24
25
26
27
28

<protocoltype="pbcast.STABLE"/>
<protocoltype="pbcast.GMS"/>
<protocoltype="UFC"/>
<protocoltype="MFC"/>
<protocoltype="FRAG2"/>
</stack>
</subsystem>
Note:Followingarethechangesmade

1.
2.

Wehavereplaceddefaultstack=udptodefaultstack=tcpinthesubsystemelement.
AndaddedTCPPINGprotocolelementwithitssubelements

Where:
initial_hosts=isalistofcommaseperatedcomboofIP_ADDRESSandPORTforpinging.
num_initial_members=specifiesthemaximumnumberofresponsestowaitfor.
port_range=specifiestherangeofportstopingoneachhostintheinitial_hostslist.
timeout=specifiesthemaximumnumberofmillisecondstowaitforanyresponses.
3.

NowyouwouldhavetorunthebelowcommandtostartboththeJBossnodeinacluster
Node1

1 ./standalone.shcstandaloneha.xmlb10.10.10.10Djboss.server.base
Node2

1 ./standalone.shcstandaloneha.xmlb10.10.10.10Djboss.server.base
Where:
c=isforserverconfigurationfiletobeused
b=isforbindingaddress
Djboss.server.base.dir=isforthepathfromwherenodeispresent
Djboss.node.name=isforthenameofthenode
Djboss.socket.binding.portoffset=isfortheportoffsetonwhichnodewouldberunning
Note:Howeverweneedtokeepinmindthefollowingthings
1.
Boththenodesshouldhaveuniquenodenames
2. Boththenodesshouldhaveuniquesocketbindingportoffsetsastheyarerunningonthe
samebox
4. Onceboththenodecomesupproperlyyouwouldnotseethemincluster,hencetomakesureif
bothofthenodesareinaclusterthenyouwouldneedtodeploytheanapplicationwhichhasthe
distributabletaginweb.xml.Youcandownloadoneofoursampleclusteredapplicationby:
clickinghere
5. AfterdownloadingtheClusterWebApp.waryoujusthavetokeepitin(/home/user/jbossas
7.1.1.Final/standalonenodeX/deployments)bothnodesdeploymentsfolder,justafterthatyou
wouldseesimilarbelowmessagesinboththenodesprompt,havingbothnodenamesinthere
clusterview.
http://middlewaremagic.com/jboss/?cat=8

11/23

5/21/2015

ClusterJBoss

1
2
3
4
5
6
7

21:49:11,988INFO[stdout](pool14thread1)
21:49:11,989INFO[stdout](pool14thread1)GMS:address=node2/web,
21:49:11,989INFO[stdout](pool14thread1)
.
.
21:49:15,954INFO[org.infinispan.remoting.transport.jgroups.JGroupsTr
.

Scenario2:Clusterondifferentboxes
1.

AfterunzippingJBossAS7inboththeboxes[i.e.box1=10.10.10.10andbox2=20.20.20.20]
thenyoucancreatejustasinglecopiesofstandalonefolderinrespectiveboxes
Box1:10.10.10.10
1 /home/user/jbossas7.1.1.Final/standalonenode1
Box2:20.20.20.20
1 /home/user/jbossas7.1.1.Final/standalonenode2

2. InboththestandalonenodexyouwouldhavetofollowthesameStep2ofScenario1,however
onlyonechangewouldbethereininitial_hostsyouwouldhavetogivebothboxes
IP_ADDRESSasshownbelow
1
2
3
4
5
6
3.

<protocoltype="TCPPING">
<propertyname="initial_hosts">10.10.10.10[7600],20.20.20.20[7600]<
.
.
.
</protocol>

NowyouwouldhavetorunthebelowcommandtostartboththeJBossnodeinacluster
Node1onBox1[10.10.10.10]

1 ./standalone.shcstandaloneha.xmlb10.10.10.10Djboss.server.base
Node2onBox2[20.20.20.20]

1 ./standalone.shcstandaloneha.xmlb20.20.20.20Djboss.server.base
Note:Howeverweneedtokeepinmindthefollowingthings
1.
2.

Boththenodesshouldhaveuniquenodenames
BoththenodesshouldberunningontheIP_ADDRESSorHOST_NAMEofthebox

Herewewouldnothavetoworryabouttheportconflictsaswearerunningboththenodeson
http://middlewaremagic.com/jboss/?cat=8

12/23

5/21/2015

ClusterJBoss

differentboxeshavingdifferentbindingaddress.
4. Repeatthesamestep4andstep5ofScenario1andyouwouldthenseethesameclusterviewin
eachrunningnodesprompts.
Cluster,JbossAS7,JBossAS71Commentmore...
11
Jun/12

HowtocreateclusterinJBossAS7.1indomainmode?
byAuthor_2underCluster,JbossAS7,JBossAS7

InmylastarticlewehadseenHowtocreateclusterinJBossAS7.1in
standalonemodenowinthisarticlewewouldbedoingthesamebutindomainmode.
Indomainmodewewouldbeusingtwomainxmlfilescalleddomain.xmlandhost.xmlfileswhichhas
tobeusedforcreatingthiscluster.
InthisarticlewewouldbeusingJBossAS7.1.1FinalwhichisthelatestversionofJBossincommunity
version.NowletsseehowcanwecreateclusterinJBossAS7.1indomainmode.

StepstocreateaclusterinJBossAS7.1indomainmode
Wewouldbeseeingtwoscenarioshereonewouldbecreatingaclusteronthesameboxandsecond
whencreatingaclusterbetweendifferentboxes.

Scenario1:Clusteronsamebox

1.
Downloadandunzippedjbossas7.1.1.Final.zip
2. Nowin/home/user/jbossas7.1.1.Final/domain/configuration/domain.xmlfilemakethebelow
changes,whichisjustaddinganewservergroup(i.e.haservergroup)whichwouldbeusing
haprofileandhasocketssocketbindinggroup,wherehaisforclusterenabled.
01 <servergroups>
http://middlewaremagic.com/jboss/?cat=8

13/23

5/21/2015

ClusterJBoss

02
03
04
05
06
07
08
09
10

<servergroupname="haservergroup"profile="ha">
<jvmname="default">
<heapsize="64m"maxsize="512m"/>
</jvm>
<socketbindinggroupref="hasockets"/>
</servergroup>
.
.
</servergroups>
Where:

1.
2.
3.

profile:tellswhichtypeofprofileisbeenused(i.e.web,messaging,cluster,full)
socketbindinggroup:tellswhichalltypeofprotocolsisbeenused(i.e.web[http,ajp],
messaging,jgroups[udp,tcp],full)
servergroup:tellswhatprofileisbeenusedandwhattypeofsocketsisbeenused

3.

Afterthatyouwouldhavetomakethebelowchangesin/home/user/jbossas
7.1.1.Final/domain/configuration/host.xmlfilewhichisjustaddingtwonewJBossnodeswiththe
namehaserver1andhaserver2whichareusingthehaservergroupservergroupcreatedin
thepervioussetpandmakingthisserversclusterdenabled
01
02
03
04
05
06
07
08
09
10

<servers>
<servername="haserver1"group="haservergroup"autostart
<socketbindingsportoffset="100"/>
</server>
<servername="haserver2"group="haservergroup"autostart
<socketbindingsportoffset="200"/>
</server>
.
.
</servers>

Note:Youaregivinguniquenameandportoffsetfortheseservers,asboththeserversare
runningonthesamebox.
4. CreateaManagementUserusingtheadduser.shscriptasshownbelow.Thisisdonesothatwe
canaccessadminconsole.
01
02
03
04
05
06
07
08
09
10
11

bin]$./adduser.sh

Whattypeofuserdoyouwishtoadd?
a)ManagementUser(mgmtusers.properties)
b)ApplicationUser(applicationusers.properties)
(a):a

Enterthedetailsofthenewusertoadd.
Realm(ManagementRealm):
Username:testuser
Password:testpassword

http://middlewaremagic.com/jboss/?cat=8

14/23

5/21/2015

ClusterJBoss

12
13
14
15
16

ReenterPassword:testpassword
Abouttoadduser'testuser'forrealm'ManagementRealm'
Isthiscorrectyes/no?yes
Addeduser'testuser'tofile'/home/user/jbossas7.1.1.Final/standalo
Addeduser'testuser'tofile'/home/user/jbossas7.1.1.Final/domain/c

5. Onceeverythingisdonestartyourserverbyusingthebelowcommand,howeveryouwouldnot
seethatthenodeshaserver1andhaserver2areinaclusterforthatyouwouldhavetodeploy
anapplicationwhichhasthedistributabletaginweb.xml.
1 ./domain.sh
6. Nowyoucandownloadoneofoursampleclusteredapplicationby:clickinghereanddeployit
fromadminconsolefromtheURLhttp://localhost:9990/console

Addingtheapplication

Choosingapplicationfile

http://middlewaremagic.com/jboss/?cat=8

15/23

5/21/2015

ClusterJBoss

Verifyingthedeployedapplicaitonname

Addingthedeployedapplicaitontoaserver
group

Selectinghaservergroupforgettingthe
applicationdeployed
7. Justafterdeployingapplicationandaddingittohaservergroupyouwouldseethebelowcluster
viewinthepromptinwhichthedomainisrunning.
1
2
3
4
5
6

[Server:haserver2]15:12:33,971INFO[org.jboss.web](MSCserviceth
[Server:haserver2]15:12:34,239INFO[org.jboss.as.clustering.impl.C
[Server:haserver2]15:12:34,242INFO[org.infinispan.remoting.transp
.
.
[Server:haserver1]15:12:34,377INFO[org.infinispan.remoting.transp

http://middlewaremagic.com/jboss/?cat=8

16/23

5/21/2015

ClusterJBoss

7 [Server:haserver1]15:12:34,378INFO[org.infinispan.remoting.transp

Scenario2:Clusterondifferentboxes
1.

AfterunzippingJBossAS7inboththeboxes[i.e.box1=10.10.10.10andbox2=20.20.20.20]
choosewhichoneoftheboxeswouldbeworkingasadomaincontrollerandotherashost
controller
2. Supposeyouchoosebox1[10.10.10.10]asdomaincontrollerthenyouwouldhavetofollow
Step2andStep3ofScenario1,creatingonlyoneJBossserverwhichishaserver1
3. Forthebox2[20.20.20.20]whichwouldbeworkingasahostcontrollerhavingthenamehost1,
nowonlyfollowStep3ofScenario1,thisisbecausewewouldbeusingdomain.xmlofthe
domaincontrollerandcreatingtheotherJBossserverwhichishaserver2.
4. Onceyouhavedonewiththeabovechangesyouwouldhavetofollowthestepsgiveninthearticle
HowtostartJBossAS7.1indomainmode?andthebelowimagewouldgiveyouabetter
understandingofthearchitecture

5.
6.

Nowthelastthingwhichyouwouldhavetodoistodeploytheapplicationusingtheconsole
whichwouldberunninginthedomaincontrollerhenceyouwouldbeusingtheURL
http://10.10.10.10:9990/consoleandrepeattheStep6ofScenario1
Onceeverythingisdoneproperlyyouwouldseesimilarbelowlinesinrespectivepromptsof
domainandhostcontroller

1 [Server:haserver1]19:39:29,458INFO[org.jboss.as.clustering.impl.C
Cluster,JbossAS7,JBossAS72Commentsmore...
6
Jun/12

HowtocreateclusterinJBossAS7.1instandalonemode?
byAuthor_2underCluster,JBossAS7

http://middlewaremagic.com/jboss/?cat=8

17/23

5/21/2015

ClusterJBoss

WehaveseenthatJBossAS7istotallydifferentthentheearlierversionsof
JBoss,henceifyouwanttocreateaclusterinJBossAS7therearefewthingswhichhasbeenchange
andhastobeknownorelseyouwouldfaceissues.
InJBossAS7wehavebydefaulttwomodeswhicharedomainmodeandstandalonemode,inthis
articlewewouldbeusingstandalonemode.Howeverinstandalonemodealsowehavedifferentxml
filesundertheconfigurationfolderfromwhichclusterisenabledinstandaloneha.xmlandstandalone
fullha.xml,thusmakesureyouwouldbeusingthemandnototherxmlfiles.
InthisarticlewewouldbeusingJBossAS7.1.1FinalwhichisthelatestversionofJBossincommunity
version.NowletsseehowcanwecreateclusterinJBossAS7.1

StepstocreateaclusterinJBossAS7.1
Wewouldbeseeingtwoscenarioshereonewouldbecreatingaclusteronthesameboxandsecond
whencreatingaclusterbetweendifferentboxes.

Scenario1:Clusteronsamebox
1.

Onceyouhaveunzippedjbossas7.1.1.Final.zip,youwouldhavetocreatetwocopiesof
standalonefolderandrenamethemasstandalonenode1andstandalonenode2asshownbelow
1 /home/user/jbossas7.1.1.Final/standalonenode1
2 /home/user/jbossas7.1.1.Final/standalonenode2
Note:Makesureyoukeeptheoriginalcopyforstandalonefolderasitisforfutureusage.

2.

NowyouwouldhavetorunthebelowcommandtostartboththeJBossnodeinacluster
Node1

1 ./standalone.shcstandaloneha.xmlb10.10.10.10u230.0.0.4Djbos
Node2

1 ./standalone.shcstandaloneha.xmlb10.10.10.10u230.0.0.4Djbos
Where:
c=isforserverconfigurationfiletobeused
b=isforbindingaddress
http://middlewaremagic.com/jboss/?cat=8

18/23

5/21/2015

ClusterJBoss

u=isformulticastaddress
Djboss.server.base.dir=isforthepathfromwherenodeispresent
Djboss.node.name=isforthenameofthenode
Djboss.socket.binding.portoffset=isfortheportoffsetonwhichnodewouldberunning
Note:Howeverweneedtokeepinmindthefollowingthings
1.
Boththenodesshouldhavesamemulticastaddress
2.
Boththenodesshouldhavedifferentnodenames
3.
Boththenodesshouldhavedifferentsocketbindingportoffsets
3. Onceboththenodecomesupproperlyyouwouldnotseethemincluster,hencetomakesureif
bothofthenodesareinaclusterthenyouwouldneedtodeploytheanapplicationwhichhasthe
distributabletaginweb.xml.Youcandownloadoneofoursampleclusteredapplicationby:
clickinghere
4. AfterdownloadingtheClusterWebApp.waryoujusthavetokeepitin(/home/user/jbossas
7.1.1.Final/standalonenodeX/deployments)bothnodesdeploymentsfolder,justafterthatyou
wouldseesimilarbelowmessagesinboththenodesprompt,havingbothnodenamesinthere
clusterview.
1
2
3
4
5
6
7

18:32:46,863INFO[stdout](pool13thread1)
18:32:46,863INFO[stdout](pool13thread1)GMS:address=node1/web,
18:32:46,863INFO[stdout](pool13thread1)
18:32:47,572INFO[org.infinispan.configuration.cache.EvictionConfigur
18:32:47,581INFO[org.infinispan.configuration.cache.EvictionConfigur
18:32:47,771INFO[org.infinispan.remoting.transport.jgroups.JGroupsTr
18:32:47,791INFO[org.infinispan.remoting.transport.jgroups.JGroupsTr

Scenario2:Clusterondifferentboxes
1.

AfterunzippingJBossAS7inboththeboxes[i.e.box1=10.10.10.10andbox2=20.20.20.20]
thenyoucancreatejustasinglecopiesofstandalonefolderinrespectiveboxes
Box1:10.10.10.10
1 /home/user/jbossas7.1.1.Final/standalonenode1
Box2:20.20.20.20
1 /home/user/jbossas7.1.1.Final/standalonenode2

2.

NowyouwouldhavetorunthebelowcommandtostartboththeJBossnodeinacluster
Note:Howeverweneedtokeepinmindthefollowingthings
1.
2.
3.

Boththenodesshouldhavesamemulticastaddress
Boththenodesshouldhavedifferentnodenames
BoththenodesshouldberunningontheIP_ADDRESSorHOST_NAMEofthebox
Node1onBox1[10.10.10.10]

1 ./standalone.shcstandaloneha.xmlb10.10.10.10u230.0.0.4Djbos
http://middlewaremagic.com/jboss/?cat=8

19/23

5/21/2015

ClusterJBoss

Node2onBox2[20.20.20.20]

1 ./standalone.shcstandaloneha.xmlb20.20.20.20u230.0.0.4Djbos
Herewewouldnothavetoworryabouttheportconflictsaswearerunningboththenodeson
differentboxeshavingdifferentbindingaddress.
3. Repeatthesamestep3andstep4ofScenario1andyouwouldthenseethesameclusterviewin
eachrunningnodesprompts.
Ifyouarelookingforrunningmultipleclusters,thenyouwouldhavetomakesureyougiveadifferent
setofmulticastaddress(i.euoption)foreachcluster.
Cluster,JbossAS7,JBossAS75Commentsmore...
24
Dec/11

HowtofixWARNING
[org.hornetq.core.server.impl.HornetQServerImpl](MSCservice
thread15)Securityrisk!inJBossAS7
byAuthor_2underBignners,Cluster,HornetQ,JbossAS7,JBossAS7,JMS,security

IfyouhavestartedJBossAS7.1.0.CR1standalonefull.xmlprofileyoumusthavenoticedthatyou
wouldbegettingthebelowWARNINGmessage.Howeverasthisjustawarningmessageandwouldnot
hamperyoursetupbutwarningisawarning,henceIhadtolookwhythiswascomingupwhenIwas
startingthedefaultstandalonefull.xmlprofilethusstartedmyinvestigation,ifyouguysrememberthat
inearlierversionsofJBosshadasimilarwarningwhichwassuckerpasswordwhichcanbefixedby
goingthroughthisarticleHowtosetJBossMessageSuckerPasswordinJBossAS6,similarlywecan
evenfixthiswarningmessagebyfollowingthebelowsteps.
.

WarningMessage:
1
2
3
4

22:34:54,728INFO[org.apache.coyote.http11.Http11AprProtocol](MSCservic
22:34:54,876WARNING[org.hornetq.core.server.impl.HornetQServerImpl](MSC
22:34:55,045INFO[org.jboss.as.jacorb](MSCservicethread18)CORBAORB
22:34:55,276INFO[org.jboss.as.jacorb](MSCservicethread16)CORBANam

http://middlewaremagic.com/jboss/?cat=8

20/23

5/21/2015

ClusterJBoss

Stepstofixthiswarningmessage:
ByjustfollowingthewarningmessagesaysandaddtheclusteruserandpasswordfortheHornetqto
overcomethisissue
1.
Stopyourrunningserver
2.
Open/jbossas7.1.0.CR1/standalone/configuration/standalonefull.xmlfile
3. Nowjustaddclusteruserandclusterpasswordtagswithitsvalueunderhornetqserveras
shownbelow
01
02
03
04
05
06
07
08
09
10

<hornetqserver>
<clusteruser>admin</clusteruser><!Addedthisline>
<clusterpassword>admin1</clusterpassword><!Addedthisline
<!disablemessagingpersistence>
<persistenceenabled>false</persistenceenabled>
<!Defaultjournalfilesizeis10Mb,reducedhereto100kforfast
<journalfilesize>102400</journalfilesize>
<journalminfiles>2</journalminfiles>
.
.

4.

Restartyourserverusingthebelowcommand
1 ./standalone.shcstandalonefull.xml
Youwouldnoticenowthewarningmessagewhichwascomingearlierhasbeenfixed.
Regards,
MiddlewareMagic
HornetQ,JbossAS7,JBossAS7,securityLeaveaCommentmore...
Search

Searchkeywords

ReceiveFREEUpdates

FREEEmailupdatesofournewposts

Enteryouremailaddress:
Subscribe

http://middlewaremagic.com/jboss/?cat=8

21/23

5/21/2015

ClusterJBoss

MiddlewareMagic
Like

1,815peoplelikeMiddlewareMagic.

Facebooksocialplugin

MagicAccount
Register
Login
EntriesRSS
CommentsRSS
WordPress.org

TopMagicUsers
nikhilmone(Magic705)
MarilynMc(Magic145)
AlbertoTh(Magic125)
FeliciaMcGregor(Magic110)
sumitbhat(Magic100)
acewin(Magic90)
CharlineB(Magic90)
NewtonGower(Magic90)
MarylynJ5(Magic85)
BennieEaster(Magic80)

MagicArchives
SelectMonth

RecentTech.Discussion
http://middlewaremagic.com/jboss/?cat=8

22/23

5/21/2015

ClusterJBoss

Author_2onHowtostartJBossAS7.1indomainmode?
godpusaonHowtostartJBossAS7.1indomainmode?
mabonInstallandRunTomcatonOpenshift
cguZZmanonConfiguringHttpsConnectorusingCLIonJBossAS7.1.2&TestingwithJava
TestClient
Author_2onApache&Cluster
amitvronSimplifiedwayofEJBRemoteLookupinJBossAS7.1.0.Final
Author_2onHowtocreateclusterinJBossAS7.1indomainmode?
skyrocketonHowtocreateclusterinJBossAS7.1indomainmode?
WhyI#39mgettingERR_TOO_MANY_REDIRECTSinmyapplicationhostedonOPENSHIFT|
CodeandProgrammingonInstallandRunTomcatonOpenshift
kanthionApache&Cluster
vpnonHowtorunmultipleJBossAS7.1asaserviceonsingleboxinLinux
vpnonHowtorunmultipleJBossAS7.1asaserviceonsingleboxinLinux
Author_2onApache&Cluster
Author_2onHowtorunmultipleJBossAS7.1asaserviceonsingleboxinLinux
kanthionApache&Cluster

RecentPosts
HowtolistallthedeploymentsbelongstoanyservergroupinWildFly8.2usingjavacode?
HowtofindServerStateinWildFly8.2usingModelControllerClient?
JBossAS7ClusteringonOpenShift
IntegrateyourEclipseJunoIDEwithOpenshift
HowtoloadjarsresidingoverNFSinJBossAS7classpath?

Tags

JbossAS7

ApacheCLI Cluster CXF DatabaseDatasourceejb3HornetQjbossJBossAS6JBossAS6

JBossAS7JBossMessagingJMSJMXJSP/ServletsloggingMBeansMDBmonitoringOpenShiftsecurity
WebService

Copyright20102012MiddlewareMagic.Allrightsreserved.|Disclaimer

http://middlewaremagic.com/jboss/?cat=8

23/23