How to Configure Tomcat/JBoss and Apache HTTPD for Load Balancing and Failover
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.)
How to Configure Tomcat/JBoss and Apache HTTPD for Load Balancing and Failover的更多相关文章
- 如何配置Tomcat以使用Apache httpd?
How to Connect Tomcat 6 to Apache HTTP Server 2 Tomcat can be run as a standalone server. Tomcat can ...
- Apache httpd和JBoss构建高可用集群环境
1. 前言 集群是指把不同的服务器集中在一起,组成一个服务器集合,这个集合给客户端提供一个虚拟的平台,使客户端在不知道服务器集合结构的情况下对这一服务器集合进行部署应用.获取服务等操作.集群是企业应用 ...
- apache httpd, nginx, tomcat, jboss
web上的server都叫web server,但是大家分工也有不同的. nginx常用做静态内容服务和代理服务器(不是你FQ那个代理),直面外来请求转发给后面的应用服务(tomcat,django什 ...
- 关于Apache/Tomcat/JBOSS/Neginx/lighttpd/Jetty等一些常见服务器的区别比较和理解
先说Apache和Tomcat的区别: Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一. ...
- Apache/Tomcat/JBOSS/Nginx区别
先说Apache和Tomcat的区别: Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一. ...
- 浅析Apache/Tomcat/JBOSS/Nginx之区别
浅析Apache/Tomcat/JBOSS/Nginx服务器之区别 一.Apache和Tomcat的区别 Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上, ...
- Apache/Tomcat/JBOSS/Nginx区别(转)
先说Apache和Tomcat的区别: Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一. ...
- Apache httpd + tomcat 简单集群
集群其实很简单,我们就来说一下httpd+tomcat集群都要注意哪些部分: 首先使用的东西有 apache-tomcat-8.0.32 下载地址: http://tomcat.apache ...
- Apache Httpd通过mod_jk连接多个Tomcat
一个tomcat能够配置多个web apps,这是众所周知的.当更改了一个web app,想要又一次启动的时候.因为全部的web apps都是放在同一个tomcat下的,所以别的web apps也在重 ...
随机推荐
- C# 高性能对象映射(表达式树实现)
前言 上篇简单实现了对象映射,针对数组,集合,嵌套类并没有给出实现,这一篇继续完善细节. 开源对象映射类库映射分析 1.AutoMapper 实现原理:主要通过表达式树Api 实现对象映射 优点: . ...
- C# WinForm Webbrowser 强制所有网页链接在同一页面打开或者在TabControl中弹出新窗口(续)
上面那个文写的如同粑粑一样 效果图 Winfrom 中添加这个类就好了 using System; using System.Collections.Generic; using System.Com ...
- 《C#多线程编程实战》2.6 ManualResetEventSlim
这个比较好理解的. 正如书上所言,如同一直在打开的大门的屋子,谁要进去,谁就自己的关门,出来的时候在开开. 常用的方法 有三个: Set() //设置为有信号,也就是让等待的线程不用继续等待,唤醒等 ...
- python-判断语句介绍
1.生活中的判断场景 1.1 火车站安检 1.2 上网吧 2.开发中的判断场景 2.1 密码判断 2.2 重要日期判断 if 今天是周六或者周日: 约妹子 if 今天是情人节: 买玫瑰 if 今天发工 ...
- 深入 Nginx:我们是如何为性能和规模做设计的
NGINX 在网络应用中表现超群,在于其独特的设计.许多网络或应用服务器大都是基于线程或者进程的简单框架,NGINX突出的地方就在于其成熟的事件驱动框架,它能应对现代硬件上成千上万的并发连接. NGI ...
- Codeforces Round #551 (Div. 2)A. Serval and Bus
A. Serval and Bus time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Java面向对象之USB接口实例
一.需求: 1.在电脑上设置一个USB接口. 2.电脑运行时,将鼠标连接到接口上,鼠标可以使用自己的功能. 3.电脑运行时,将键盘连接到接口上,键盘可以使用自己的功能.(使用接口的作用:减低鼠标.键盘 ...
- Java设计模式之单例设计模式 入门实例
一.基础概念 (1).单例设计模式:保证一个类在内存中的对象唯一性. (2).应用场景:数据都存储在配置文件的对象中,多个程序对同一个配置文件的对象进行操作.一个程序要基于另一个程序操作后的结果进行操 ...
- ssh免密码登录、secureCRT免密码登录详解
再放一张真机实现图: 接下来就详细讲述实现细节. 实现过程中吃了不少苦头,这个不对,那个不通.好在慢慢一点点摸索出来了,经验分享在这里. 希望能终结网上ssh免密码登录,以及SecureCRT免密码登 ...
- RUCM简介
一.动机 UCM:用例建模,主要用于结构化和文档需求方面. UCSs:用例规格说明书,通常是文本文档,所以描述中不可避免含有歧义. RUCM:限制性用例建模.目标 G1.使UCMs更加可理解并且更精确 ...