Required Components
- Apache 2.2.22
- Mod_jk 1.2.3
- JBOSS 5.1.0GA
Installation Steps
- Install
Apache2.2.22
- Set
mod_jk-1.2.30-httpd-2.2.3.so
Renamemod_jk.so
, Copy%APACH_HOME%/modules
- Extract
jboss 5.1.0.GA
Configuration
In%APACHE_HOME%\conf\http.conf
Add the following content to the file:
LoadModule jk_module modules/mod_jk.so# Where to find workers.propertiesJkWorkersFile conf/workers.properties# where to find the log fileJkLogFile logs/mod_jk.log# set the log level set the log levelJkLogLevel info # map to the status serverJkMount /private/admin/mystatus mystatus# router the request to the right hostJkMount /* balance
Then%APACHE_HOME%\conf\
Createworkers.properties
File and add the following content:
# define list of workers that will be used# for mapping requestsworker.list=balance,mystatus# Define Node1worker.node1.port=8009worker.node1.host=xxx.xxx.xxx.xxxworker.node1.type=ajp13worker.node1.lbfactor=1worker.node1.socket_timeout=30worker.node1.socket_keepalive=1# Define Node2worker.node2.port=8009worker.node2.host=yyy.yyy.yyy.yyyworker.node2.type=ajp13worker.node2.lbfactor=1worker.node2.socket_timeout=30worker.node2.socket_keepalive=1# Load-balancing behaviourworker.balance.type=lbworker.balance.balance_workers=node1,node2worker.balance.sticky_session=1# Status worker for managing load balancerworker.mystatus.type=status
The above content is used to configure mod_jk so that it listens to two servlet containers (such as JBOSS instances) node1 and node2.
In node1, open%JBOSS_HOME%/server/all/deploy/jbossweb.sar/server.xml
, ModifyEngine
Node:
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1">
Similarly, in node2Engine
Change node:
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node2">
By default, JBOSS sessions are shared.
When deploying a Web applicationweb.xml
Join<distributable/>
Nodes:
<? Xml version = "1.0" encoding = "ISO-8859-1"?> <! DOCTYPE web-app PUBLIC "-// Sun Microsystems, Inc. // DTD Web Application 2.3 // "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name> Welcome to JBoss </display-name> <description> Welcome to JBoss </description> <distributable/> <! --...... Other configurations --> </web-app>
Start Apache
Open the console and go%APACHE_HOME%
Run the following command to start the Apache server:
httpd.exe -k start
Run the following command to disable the Apache server:
httpd.exe -k shutdown
Start JBOSS in cluster mode
The command to start JBOSS in cluster mode is as follows:
run -c all -g DocsPartition -u 239.255.100.100 -b 0.0.0.0 -Djboss.messaging.ServerPeerID=1
On other JBOSS instances of the cluster, modifyjboss.messaging.ServerPeerID
Value, which must be unique in the cluster.
Test
Createtest.war
Folder.index.jsp
File andWEB-INF
Folder. InWEB-INF
Create a folder as shown in the preceding figureweb.xml
File. Inindex.jsp
Add the following content to the file:
<% @ Page language = "java" contentType = "text/html; charset = UTF-8" pageEncoding = "UTF-8" %> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd"> <% @ page import = "java. util. * "%> <% @ page import =" java.net. inetAddress; "%>
Copy the folder to%JBOSS_HOME%/server/all/deploy
To restart all JBOSS instances in a cluster.
Enterhttp://localhost:8080/test
.
References
- UsingMod_jk1.2WithJBoss
- Testing Cluster Formation with JGroups