Apache and JBoss AS 5 HTTP cluster configuration

Source: Internet
Author: User
Required Components
  • Apache 2.2.22
  • Mod_jk 1.2.3
  • JBOSS 5.1.0GA
Installation Steps
  1. InstallApache2.2.22
  2. Setmod_jk-1.2.30-httpd-2.2.3.soRenamemod_jk.so, Copy%APACH_HOME%/modules
  3. Extractjboss 5.1.0.GA
Configuration

In%APACHE_HOME%\conf\http.confAdd 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.propertiesFile 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, ModifyEngineNode:

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

Similarly, in node2EngineChange node:

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

By default, JBOSS sessions are shared.

When deploying a Web applicationweb.xmlJoin<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.ServerPeerIDValue, which must be unique in the cluster.

Test

Createtest.warFolder.index.jspFile andWEB-INFFolder. InWEB-INFCreate a folder as shown in the preceding figureweb.xmlFile. Inindex.jspAdd 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/deployTo restart all JBOSS instances in a cluster.

Enterhttp://localhost:8080/test.

References
  • UsingMod_jk1.2WithJBoss
  • Testing Cluster Formation with JGroups

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.