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.

How to Configure Tomcat/JBoss and Apache HTTPD for Load Balancing and Failover的更多相关文章

  1. 如何配置Tomcat以使用Apache httpd?

    How to Connect Tomcat 6 to Apache HTTP Server 2 Tomcat can be run as a standalone server. Tomcat can ...

  2. Apache httpd和JBoss构建高可用集群环境

    1. 前言 集群是指把不同的服务器集中在一起,组成一个服务器集合,这个集合给客户端提供一个虚拟的平台,使客户端在不知道服务器集合结构的情况下对这一服务器集合进行部署应用.获取服务等操作.集群是企业应用 ...

  3. apache httpd, nginx, tomcat, jboss

    web上的server都叫web server,但是大家分工也有不同的. nginx常用做静态内容服务和代理服务器(不是你FQ那个代理),直面外来请求转发给后面的应用服务(tomcat,django什 ...

  4. 关于Apache/Tomcat/JBOSS/Neginx/lighttpd/Jetty等一些常见服务器的区别比较和理解

    先说Apache和Tomcat的区别: Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一. ...

  5. Apache/Tomcat/JBOSS/Nginx区别

    先说Apache和Tomcat的区别: Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一. ...

  6. 浅析Apache/Tomcat/JBOSS/Nginx之区别

    浅析Apache/Tomcat/JBOSS/Nginx服务器之区别 一.Apache和Tomcat的区别 Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上, ...

  7. Apache/Tomcat/JBOSS/Nginx区别(转)

    先说Apache和Tomcat的区别: Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一. ...

  8. Apache httpd + tomcat 简单集群

    集群其实很简单,我们就来说一下httpd+tomcat集群都要注意哪些部分: 首先使用的东西有 apache-tomcat-8.0.32      下载地址: http://tomcat.apache ...

  9. Apache Httpd通过mod_jk连接多个Tomcat

    一个tomcat能够配置多个web apps,这是众所周知的.当更改了一个web app,想要又一次启动的时候.因为全部的web apps都是放在同一个tomcat下的,所以别的web apps也在重 ...

随机推荐

  1. 多个fragment中重叠问题的解决方法

    这个方法适用性有限. 我的是一个mainActivity,然后下部四个按钮,点击时先隐藏所有的fragment,然后再new一个新的出来,如果存在,则直接显示出来,看上去一切都没有问题. 但是通过fr ...

  2. [转]Marshaling a SAFEARRAY of Managed Structures by P/Invoke Part 6.

    1. Introduction. 1.1 Starting from part 4 I have started to discuss how to interop marshal a managed ...

  3. Day3作业 .

    ,))::])]): :-])# 3,使用while和for循环分别打印字符串s=’asdfer’中每个元素. # 4,实现一个整数加法计算器:# 如:content = input(‘请输入内容:’ ...

  4. 864. Shortest Path to Get All Keys

    We are given a 2-dimensional grid. "." is an empty cell, "#" is a wall, "@& ...

  5. 80端口被system(pid=4)占用

    1.查看80端口被哪个进程占用,cmd->netstat -ano | findstr 80 2.cmd->tasklist列出当前运行中的进程,或在任务管理器中查看pid为4的进程. 经 ...

  6. loj #6013. 「网络流 24 题」负载平衡

    #6013. 「网络流 24 题」负载平衡 题目描述 G 公司有 n nn 个沿铁路运输线环形排列的仓库,每个仓库存储的货物数量不等.如何用最少搬运量可以使 n nn 个仓库的库存数量相同.搬运货物时 ...

  7. 洛谷P2774 方格取数问题(最小割)

    传送门 考虑一下,答案就是全局和减去舍弃和 不难发现,如果我们按行数+列数的奇偶性分为两类,那么每一类中的数必然互不相邻 那么我们把原图的点分为黑点和白点两类,原地向白点连边,黑点向汇点连边,容量为点 ...

  8. #首行输入数n,接下来输入n行数,以空格隔开

    #首行输入数n,接下来输入n行数,以空格隔开 n = int(raw_input())# print nL = []for i in range(n): L.append([int(x) for x ...

  9. Python——可变和不可变类型数据

    什么是不可变类型? 存储空间保存的数据不允许被修改,这种数据就是不可变类型. 常见的不可变类型有: 数字类型 int, bool, float, complex, long(2.x) 字符串 str ...

  10. PHP请求远程地址设置超时时间

    file_get_contents 请求超时设置 $timeout = array( 'http'=> array( 'timeout'=>5//设置一个超时时间,单位为秒 ) ); $c ...