JBoss7.1.1 Final+mod_cluster-1.2.0.Final集群配置
项目需求,需要JBoss在windows下集群,记录一下以备后查
JDK:1.7
服务器环境:个人电脑windows xp
jboss版本:7.1.1 Final
mode_cluster:1.2.0 Final
1、配置mode_cluster
下载mode_cluster 1.2.0 Final windows 32位版本(测试电脑为32位,生产环境依据服务器而定)和Jboss7.1.1 Final
解压mode_cluster 压缩包到目录D:\mySoftware\httpd_mod_cluster\
运行D:\mySoftware\httpd_mod_cluster\bin\下的installconf.bat文件生成默认配置
修改conf\httpd.conf
修改#Listen 12.34.56.78:80 为 Listen 8085,端口随意
修改#ServerName 12.34.56.78:80为ServerName 192.168.196.114:8085
在末尾修改<IfModule manager_module>为以下部分
<IfModule manager_module>
Listen 192.168.196.114:7777
ManagerBalancerName mycluster
<VirtualHost *:7777>
<Location />
Order deny,allow
Deny from all
Allow from all
</Location>
KeepAliveTimeout 300
MaxKeepAliveRequests 0
#ServerAdvertise on http://127.0.0.1:6666
AdvertiseFrequency 5
AdvertiseSecurityKey 1234567890
#AdvertiseGroup 224.0.1.105:23364
EnableMCPMReceive
AllowDisplay On
<Location /mod_cluster_manager>
SetHandler mod_cluster-manager
Order deny,allow
Deny from all
Allow from all
</Location>
</VirtualHost>
</IfModule>
ListenListen 192.168.196.114:8085是监听IP和端口,这样httpd才会处理访问访问这个IP端口的请求,
ServerName Listen 192.168.196.114:8085是对外的访问地址,当服务器有DNS功能时,可以改成ServerName www.example.com:80,由DNS来解析域名的IP
Listen 192.168.196.114:7777是jboss集群模块连接httpd cluster的ip和接口,同时也是管理页面访问的地址
2、配置jboss7.1.1
解压jboss压缩包到目录D:\mySoftware\jboss7
配置环境变量JBOSS_HOME为D:\mySoftware\jboss7
删除standalone\configuration\standalone.xml(删除前最好备份)
复制standalone-full-ha.xml并重命名为standalone.xml
修改文件内容
修改<serverxmlns="urn:jboss:domain:1.2">为
<server name="standalone-node1" xmlns="urn:jboss:domain:1.2">
server name是每个jboss的名称,在使用httpd cluster集群时名称不能重复
修改<mod-cluster-configadvertise-socket="modcluster">为
<mod-cluster-config advertise-socket="modcluster" proxy-list="192.168.196.114:7777" advertise-security-key="1234567890">
ps:proxy-list="192.168.196.114:7777"为mod_cluster中Listen 192.168.196.114:7777
advertise-security-key="1234567890"与mod_cluster中AdvertiseSecurityKey 1234567890要一致
我参考的两篇博客都是在Linux下配置的,没有配置proxy-list="192.168.196.114:7777,我在windows下没有配置proxy-list时mod_cluster和jboss始终无法取得联系,
在windows下配置时proxy-list一定要配上
修改<subsystem xmlns="urn:jboss:domain:web:1.1"default-virtual-server="default-host" native="false">为
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" instance-id="${jboss.node.name}" native="false">
修改<interfaces></interfaces>标记中的内容为
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:0.0.0.0}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:0.0.0.0}"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>
</interfaces>
ps:修改<interfaces></interfaces>中红色标记的IP内容,IP填写0.0.0.0表示所有ip都能访问。
修改
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" auto-deploy-exploded="true"/>
<deployment-scanner name="fileSource" path="D:/mySoftware/jboss7/source" scan-enabled="true" scan-interval="0" auto-deploy-zipped="false" auto-deploy-exploded="false" deployment-timeout="60"/>
</subsystem>
添加红色标记项,设置auto-deploy-exploded="true",在windows和Linux下部署xxx.war文件夹才能被识别
添加一个虚拟目录用于保存上传的资源文件,真实地址为D:/mySoftware/jboss7/source
scan-interval="0"设置为0时扫描器仅会在jboss启动时扫描一次,热部署会失效。某些程序上传文件时会引起项目重部署,设置为0可以避免,适用于存放资源的虚拟目录
访问虚拟目录下的文件,如访问资源文件http://192.168.120.11:8085/appStoreUpload/screenshotImgs/2191427708892421.png,
需要在虚拟目录下创建一个appStoreUpload.war的文件夹和appStoreUpload.war.dodeploy的空文件,稍后JBOSS会自动部署(scan-interval设为0需要重启jboss)
启动mod_cluster目录bin\httpd.exe
部署web项目到\standalone\deployments\
启动jboss目录下bin\standalone.bat
浏览器输入http://192.168.196.114:7777/mod_cluster_manager看到如下画面表示配置成功
访问http://192.168.196.114:8085/项目名/index.html就能通过httpd mode_cluster进行访问了
当有新的服务器节点加入集群时,各个服务器节点能收到新节点加入的信息
先启动node2服务器再启动node1服务器,在node2的控制台能看到如下信息:
参考博客:
https://docs.jboss.org/author/display/AS71/AS7+Cluster+Howto
http://docs.jboss.org/mod_cluster/1.1.0/html/Quick_Start_Guide.html
http://docs.jboss.org/mod_cluster/1.1.0/html/java.AS7config.html
http://blog.csdn.net/xixixi9988/article/details/21651449
http://yang-min.iteye.com/blog/1961574
http://wenku.baidu.com/link?url=bteMg0-59v44fnB7T85n9lRgT8ARikkERacGkYp3qWP05Ib977_1lZ2QJGEUyEW7YYU7RdYL6IlOVPuPobZ_00DKc-9tYm3daxUcopBgT83