JBoss+Apache集群配置.docx
- 文档编号:2604628
- 上传时间:2023-05-04
- 格式:DOCX
- 页数:12
- 大小:19.52KB
JBoss+Apache集群配置.docx
《JBoss+Apache集群配置.docx》由会员分享,可在线阅读,更多相关《JBoss+Apache集群配置.docx(12页珍藏版)》请在冰点文库上搜索。
JBoss+Apache集群配置
搭建环境
两台电脑//其实一台也够了,不过需要修改其中一个JBoss监听的端口,要不然有冲突
jboss-4.0.4.GA
apache_2.0.59//我使用的是apache_2.0.59-win32-x86-no_ssl,其实无所谓的
mod_jk-apache-2.0.59.so//Apache请求分发的模块,官网上可以找到
首先安装JBoss,我用的是zip格式的,直接解压缩就可以了,在两台电脑里分别安装。
接下来在其中一台电脑上(这里是192.168.0.2)安装Apache(其实应该再找一台电脑来安装的),很简单,
配置JBoss
假设两台电脑的IP分别为192.168.0.2和192.168.0.3。
我们这里使用JBoss的default目录。
将如下文件从%JBoss_Home%\server\all\lib里面拷到%JBoss_Home%\server\default\lib目录下:
jbossha.jar(加载org.jboss.ha.framework.server.ClusterPartition)
jgroups.jar(JBoss集群底层通信协议)
jboss-cache.jar(加载org.jboss.cache.aop.TreeCacheAop)
还要从%JBoss_Home%\server\all\deploy里把cluster-service.xml和tc5-cluster.sar拷贝到%JBoss_Home%\server\default\deploy里面。
编辑192.168.0.2的%JBoss_Home%\server\default\deploy\jbossweb-tomcat55.sar\server.xml
修改下面代码:
源码复制打印
1.
修改为:
源码复制打印
1.
其中jvmRoute是用来让apache识别的节点名称,一个节点一个名称,注意不要有重复的(可以结合IP设置)。
同理编辑192.168.0.3的%JBoss_Home%\server\default\deploy\jbossweb-tomcat55.sar\server.xml
注意把jvmRoute设置为node2,可以设置成别的只要和192.168.0.2的不重复就行,但是要和Apache的workers.properties(稍后介绍)下的配置一致。
在%JBoss_Home%\server\default\deploy\jbossweb-tomcat55.sar\ROOT.war\目录下添加一个新文件夹\test,并在里面添加如下3个jsp文件:
index.jsp
源码复制打印
1.<%@ page contentType="text/html;charset=ISO8859_1" %>
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.The host is :
<%=.InetAddress.getLocalHost().toString()%>
13.Your session id is :
<%=session.getId()%>
14.Your session detail is :
<%=session.toString()%>
15.Your session context is :
<%=session.getSessionContext()%>
16.Please input your name:
17.
21.
22.
23.
test_action.jsp
源码复制打印
1.<%@ page contentType="text/html;charset=ISO8859_1" %>
2.
3.
4.
5.
6.
7.
8.<%
9. String name = request.getParameter("name");
10. session.setAttribute("name",name);
11. String host = .InetAddress.getLocalHost().toString();
12.%>
13.
14.
15.
16.
17.The host is :
<%=host%>
18.Your session id is :
<%=session.getId()%>
19.Your session detail is :
<%=session.toString()%>
20.Your session context is :
<%=session.getSessionContext()%>
21.Your name is :
<%=name%>
22.This name is set into the session.
23.Please click here to check the session valid or not.
24.
25.
26.
session.jsp
源码复制打印
1.<%@ page contentType="text/html;charset=ISO8859_1" %>
2.
3.
4.
5.
6.
7.
8.<%
9. String name = null;
10. if(session.getAttribute("name")!
=null)
11. name = (String)session.getAttribute("name");
12. String host = .InetAddress.getLocalHost().toString();
13.%>
14.
15.
16.
17.
18.The host is :
<%=host%>
19.Your session id is :
<%=session.getId()%>
20.Your session detail is :
<%=session.toString()%>
21.Your session context is :
<%=session.getSessionContext()%>
22.<%
23. if(name!
=null){
24. out.print("Your name is "+name+"
");
25. out.print("The session is valid.");
26. }
27. else{
28. out.print("The session is invalid!
!
!
");
29. }
30.%>
31.Return!
32.
33.
34.<%
35. if(session.getAttribute("name")!
=null)
36. session.invalidate();
37.%>
38.
编辑%JBoss_Home%\server\default\deploy\jbossweb-tomcat55.sar\ROOT.war\WEB-INF\web.xml在
源码复制打印
1.
完成后web.xml代码如下:
源码复制打印
1.
xml version="1.0" encoding="ISO-8859-1"?
>
2.
3.
DOCTYPE web-app
4. PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
5. "
6.
7.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JBoss Apache 集群 配置