JBoss 系列五十:使用Apache httpd(mod_jk)和JBoss构架高可用集群环境

概述

前面 JBoss 系列二:使用Apache httpd(mod_cluster)和JBoss构架高可用集群环境中我们介绍了企业应用的目的的目的,负载均衡,容错等,并通过Apache httpd(mod_cluster)和JBoss构架高可用集群环境,我们这里在原有的环境中将mod_cluster换成mod_jk,其架构如下图所示:

JBoss 系列五十:使用Apache httpd(mod_jk)和JBoss构架高可用集群环境_第1张图片

本方案是在开源Linux操作系统Fedora 15上进行,我们列出本方案使用的硬件和软件,三台物理机器,内存4GB或以上,安装Fedora 15后IP地址分别为10.66.192.48,10.66.192.231,10.66.192.232,我们分别对这三台物理机器做相应的安装如下:

  • 10.66.192.231 – 安装JDK 1.6,JBoss 7,JBoss节点名称为node1
  • 10.66.192.232 – 安装JDK 1.6,JBoss 7,JBoss节点名称为node2
  • 10.66.192.48  – 安装Apache httpd,mod_jk
接下来我们给出使用Apache httpd(mod_jk)和JBoss构架高可用集群环境的步骤。

下载mod_jk相关安装包

从 http://tomcat.apache.org/download-connectors.cgi下载mod_jk.so包到本地(注意选择适合自己操作系统对应httpd的包)。

安装 Apache httpd

请参照系列一 Apache httpd 安装( http://blog.csdn.net/kylinsoong/article/details/12291173)

Apache httpd端配置

编辑httpd/conf/httpd.conf,让httpd监听在10.66.192.48:80上:

Listen 10.66.192.48:80 
拷贝mod_jk.so文件到httpd/modules目录:

cp mod_jk.so  /etc/httpd/modules 
在httpd/conf.d下创建mod_jk.conf文件,编辑内容如下:

# 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/workers.properties

# 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/uriworkermap.properties

# Where to put jk logs
JkLogFile logs/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info 
 
# Select the log format
JkLogStampFormat  "[%a %b %d %H:%M:%S %Y]"
 
# JkOptions indicates to send SSK KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
 
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
               
# Mount your applications
JkMount /application/* loadbalancer
 
# 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
JkShmFile logs/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>
在httpd/conf下创建workers.properties,并添加如下内容:

# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status

# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=10.66.192.231
worker.node1.type=ajp13
worker.node1.ping_mode=A
worker.node1.lbfactor=1 

# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host=10.66.192.232
worker.node2.type=ajp13
worker.node2.ping_mode=A
worker.node2.lbfactor=1

# Load-balancing behavior
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1

# Status worker for managing load balancer
worker.status.type=status
在httpd/conf下创建uriworkermap.properties,并添加如下内容:

# Simple worker configuration file

# Mount the Servlet context to the ajp13 worker
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
/web-console=loadbalancer
/web-console/*=loadbalancer
#/printSession=loadbalancer
#/printSession/*=loadbalancer
配置完成后重启Apache httpd,如果启动显示成功表明配置正确。

JBoss端配置

分别启动10.66.192.231,10.66.192.232 JBoss,到管理界面,Profile -> General Configuration -> System Properties,单击添加按钮,添加两组变量jvmRoute=node1,UseJK=true到10.66.192.231,以及jvmRoute=node2,UseJK=true到10.66.192.232.添加完成后,依次重启两个节点:

./standalone.sh -c standalone-ha.xml -b 10.66.192.231 -bmanagement 10.66.192.231 -u 239.255.100.100 -Djboss.node.name=node1

./standalone.sh -c standalone-ha.xml -b 10.66.192.232 -bmanagement 10.66.192.232 -u 239.255.100.100 -Djboss.node.name=node2

结束

至此,配置结束,我们可以部署测试应用测试高可用,负责均衡等,类似于 JBoss 系列二:使用Apache httpd(mod_cluster)和JBoss构架高可用集群环境





作者:kylinsoong 发表于2013-11-14 22:42:16 原文链接
阅读:0 评论:0 查看评论

你可能感兴趣的:(apache,jboss,系列)