http://java.dzone.com/articles/how-configure-tomcatjboss-and

In this post we will see how to setup a load balanced JBoss or Tomcat environment with the fail-over capability.

This post assumes that both Jboss/Tomcat and Apache httpd are setup and running properly.

Configure Apache Httpd Step 1: Configure apache’s workers.properties

Go to /usr/local/apache2/conf/extra and open workers.properties and configure the properties indicated in bold.

# for mapping requests
# The configuration directives are valid
# for the mod_jk version 1.2.18 and later
#
worker.list=loadbalancer,status # Define node
# modify the host as your host IP or DNS name. worker.node.port=8009
worker.node.host=192.168.0.3 #(IP or DNS name of the server on which Jboss is running)

worker.node.type=ajp13
worker.node.lbfactor=1 worker.node2.port=8009
worker.node2.host=192.168.0.4 #(IP or DNS name of the server on which Jboss is running)

worker.node2.type=ajp13
worker.node2.lbfactor=1 # Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node,node2
worker.loadbalancer.sticky_session=1
worker.status.type=status

The property balance_workers is used to specify the nodes to load balance. For example, if we specify only ‘node’, all requests will be routed to the server named ‘node’. Modify this to test that requests are going to both servers.

Step 2: Configure mod-jk.conf

Go to /usr/local/apache2/conf/extra and open mod-jk.conf and configure the bold properties according to your requirements.

#Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so # Where to find workers.properties
JkWorkersFile conf/extra/workers.properties # Where to put jk logs
JkLogFile /var/apache/logs/mod_jk.log # Set the jk log level [debug/error/info]
JkLogLevel debug # Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" # JkOptions indicates to send SSK KEY SIZE
# Note: Changed from +ForwardURICompat.
# See http://tomcat.apache.org/security-jk.html
JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories
JkOptions +FlushPackets
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T" # Mount your applications
JkMount /* loadbalancer # You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
JkMountFile conf/extra/uriworkermap.properties # Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
# Note: Replaced JkShmFile logs/jk.shm due to SELinux issues. Refer to
# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225452
JkShmFile /var/run/jk.shm # Add jkstatus for managing runtime data
<Location /jkstatus/>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>

The JkMount /* loadbalancer indicates that all requests are to be routed through the load balancer.

Step 3: Go to /usr/local/apache2/conf and edit httpd.conf

Add

1.Include conf/extra/mod-jk.conf

to the end of the file.

Configure Tomcat/JBoss

These settings need to be made for each of the nodes we intend on placing behind the load balancer.

We need to modify the server.xml file which is located at

  • For Tomcat

    • ../apache-tomcat/conf/
  • For JBoss
    • ../jboss-5.1.0.GA/server/default/deploy/jbossweb.sar 

Edit the following tag:

1.&lt;Engine name="jboss.web" defaultHost="localhost" jvmRoute="node"&gt;

where the jvmRoute attribute is configured to ‘node’ (which is the name we gave the first worker while configuring workers.properties.)

Next, locate the following tag and edit the port to be the same as while configuring the workers.properties.

1.&lt;Connector protocol="AJP/1.3" port="8009"address="${jboss.bind.address}" redirectPort="8443" /&gt;

Configure the other node(s) accordingly.

Next, Start Apache httpd and the Jboss/tomcat node(s) that you  have configured.

 

Published at DZone with permission of Faheem Sohail, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Enterprise Integration is a huge problem space for developers, and with so many different technologies to choose from, finding the most elegant solution can be tricky. MuleSoft provides the #1 open source Enterprise Service Bus, Mule, along with SOA integration cloud services that are used by customers like eBay, Amazon, and Walmart. Learn More about SOA Best Practices,Mobile E-Commerce, and Legacy Integration.

最新文章

  1. Linux定时任务Crontab详解
  2. 在虚拟机中配置FastDFS+Nginx模块
  3. Java基础之OOP
  4. apache配置文件参数优化
  5. Hadoop之hive的drop table恢复
  6. js 函数和变量的提升
  7. c#关键字详解
  8. 查看Linux主机CPU及内存信息
  9. Java实战之02Hibernate-01简介、常用接口、CRUD操作
  10. 又一家自适应学习平台上线,大讲台主攻IT在线教育
  11. UVA 103 Stacking Boxes (dp + DAG上的最长路径 + 记忆化搜索)
  12. cocos2dx三种定时器使用
  13. 对C# 构造函数的理解
  14. Android 中单位讲解
  15. hexo部署github和gitment操作简单介绍
  16. SpringMVC(2)—SpringMVC整合Spring的HelloWorld
  17. 【python接口自动化框架-unittest】【一】unittest单元测试框架概念
  18. mongodb-MYSQL
  19. [20171220]toad plsql显示整形的bug.txt
  20. P2799国王的魔镜

热门文章

  1. 阿里云RDS外网无法访问解决办法
  2. [转]B+Tree图解
  3. 以太坊系列之十四: solidity特殊函数
  4. linux内存布局------深入理解计算机系统
  5. 快速搭建hadoop,学习使用
  6. linux下关闭防火墙命令
  7. Codeforces Round #545 (Div. 2)D(KMP,最长公共前后缀,贪心)
  8. utp
  9. Java中的Random()函数-----转载
  10. 洛谷P2501 bzoj1049 [HAOI2006]数字序列