JBOSS 5.0.0GA的集群搭建(一)

    最近看了一下JBOSS-5.0.0GA的集群搭建的文档,于是把自己的理解发上来和大家共享一下。不过还是有好多问题需要和大家,共同讨论一下

 

   下面的JBOSS-5.0.0GA的集群部署的官方文档,不过有点旧,和实际情况有些出入,

    http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Clustering_Guide/5/html/index.html

 

 我采用的是 apache2.27  JK_mod1.2.7

 apache的下载地址:

http://httpd.apache.org/download.cgi

 

 

JK_mod的下载地址:

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

 

安装完毕后开始进行配置

 

首先,编辑 apache的conf/http.conf 文件,保证apache加载jk_mod文件,再文件中加入下面的代码

Include conf/mod-jk.conf

 

然后再apache的conf/http.conf 创建一个新的文件 名字要和上面的 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

# 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
<Location /jkstatus/>
    JkMount status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Location>    

 

这里注意这句话,要把你下载的mod_jk的文件拷贝到 apache安装目录的modules/下 名字要和mod_jk.so一致

 

LoadModule jk_module modules/mod_jk.so

 

然后,我们再apache安装目录下的conf/创建uriworkermap.properties文件,来配置哪些请求由JK处理哪些请求让APACHE处理,再文件中加入下面的代码

 

/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
/web-console=loadbalancer
/web-console/*=loadbalancer

 

然后再 apache安装目录下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=192.168.1.188 
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= 192.168.1.100
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
            
 

到此 JK_mod 的配置就完成了,下面配置JBOSS的,这里注意这里文档说的有些问题,因为JBOSS-5.0.0GA的目录有些变化 文档上说的是下面的路径

 

JBOSS_HOME/server/all/deploy/jboss-web.deployer/server.xml

 

但正确的应该是

JBOSS_HOME/server/all/deploy /jbossweb.sar/server.xml

配置修改如下:注意 这里面的jvmRoute="node1"的名字要和jk_mod里面的一致否则会有问题

 

<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1">
... ...
</Engine>
 

 

到这里JBOSS的基本配置就完成了,JBOSS-5.0.0GA的session共享是默认的配置的

只要再APPLICATION中加入下面的代码就可以

<?xml version="1.0"?> 
<web-app  xmlns="http://java.sun.com/xml/ns/j2ee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
                              http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
          version="2.4">
    
               <distributable/>
            
    <!-- ... -->
</web-app>

 

这里还要注意一点:是JMS的ServerPeerId不能一样,否则启动时会报错,但不影响集群的正常运行(除JMS外)

要修改JBOSS_HOME/server/all/deploy/messaging/messaging-service.xml文件中的ID,要求是数字并且保证急群众每个JBOSS的ID不一样

 

<!-- The unique id of the server peer - in a cluster each node MUST have a unique value - must be an integer -->

      <attribute name="ServerPeerID">${jboss.messaging.ServerPeerID:0}</attribute>

 

 

启动的JBOSS

run.sh -c all -b 192.168.2.100 注意IP地址要和JK_MOD配置的一致

 

我把我写的简单的测试放入到 附件中,测试的时候先打开一个node1 做登陆

然后启动第二个node2 然后停掉node1 还是登陆状态 http://localhost/cluster-test/index2.jsp

 

JBOSS的配置 缺少了集群的hot-deploy 因为JBOSS5里面已经没有farm service 了,找了很多文档,没有找到解决的办法,希望和大家共同研究。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值