您好,欢迎来到九壹网。
搜索
您的当前位置:首页Jboss 4.2.3GA 集群配置指南

Jboss 4.2.3GA 集群配置指南

来源:九壹网


Jboss 4.2.3GA 集群配置指南

http://www.javaeye.com/topic/334934

1、环境准备:

a. 安装JDK 1.5 ,并配置环境变量;

b. 安装jboss 4.2.3.GA,下载地址:http://www.jboss.org/jbossas/downloads/ ;

c. 安装apache_2.2.10 ,下载地址:http://httpd.apache.org/ ;

d.下载apache mod_jk , 地址为:

http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/ ;

2、负载均衡配置:

a. 将下载的apache mod_jk重命名为mod_jk.so,复制到

APACHE_HOME/modules/中,修改 APACHE_HOME/conf/httpd.conf ,在文件末添加:

Property代码

# Include mod_jk's specific configuration file

Include conf/mod-jk.conf

b. 在APACHE_HOME/conf/目录创建新文件mod-jk.conf,内容如下:

Property代码

# 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

# 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

# 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

# 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

JkMount status

Order deny,allow

Deny from all

Allow from 127.0.0.1

c. 在 在APACHE_HOME/conf/目录创建新文件uriworkermap.properties,置为空,这个文件主要是做url 路由的,基本格式为/url=worker_name;

d. 在 在APACHE_HOME/conf/目录创建新文件workers.properties,内容如下:

Property代码

# 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=node1.mydomain.com

worker.node1.type=ajp13

worker.node1.lbfactor=1

worker.node1.cachesize=10

# Define Node2

# modify the host as your host IP or DNS name

worker.node2.port=8009

worker.node2.host= node2.mydomain.com

worker.node2.type=ajp13

worker.node2.lbfactor=1

worker.node2.cachesize=10

# Load-balancing behaviour

worker.loadbalancer.type=lb

worker.loadbalancer.balance_workers=node1,node2

worker.loadbalancer.sticky_session=1

#worker.list=loadbalancer

# Status worker for managing load balancer

worker.status.type=status

上面的文件中配置了两个节点,name分别为node1,node2,指定两个节点的IP,并在worker.loadbalancer.balance_workers

中指定所有的

node

列表,

worker.loadbalancer.sticky_session设置是否启用“粘着的”Session,sticky session是指来自同一IP的请求将被发送到同一个Jboss节点,sticky session设为0的话同一

session的不同请求会被负载均衡分发到不同的jboss节点上。

3、JBoss节点配置:

a . 修改JBOSS_HOME/server/all/deploy/jboss-web.deployer/server.xml文件,将Engine 修改如下:

Property代码

...

node1和node2分别对应相应ip的jboss;

b. 修改 JBOSS_HOME/server/all/deploy/ jboss-web.deployer

/META-INF/jbossservice.xml,找到该为:

Property代码

1. true

至此,jboss集群环境已经基本配置完成,启动先启动apache,然后启动jboss,可

测试,启动jboss时需指定run.bat -c all ,default配置是不支持集群的。

4、Session同步

a. 编辑

JBOSS_HOME/server/all/deploy/jbossweb-cluster.sar/META-INF/jboss-service.xml,找到,有udp和tcp两种方式,任选一种即可,将bind_addr改为本机ip,b. 修改应用程序的web.xml文件,如下所示:

Xml代码

...

c. 在web-inf中添加jboss-web.xml文件,内容如下:

Xml代码

\"-//JBoss//DTD Web Application 4.2//EN\"

\"http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd\">

SET_AND_NON_PRIMITIVE_GET

SESSION

true

/

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务