JBoss7.1.1/EAP6.1+mod_cluster集群配置

由于使用WildFly时,遇见了无法解决的302Found问题(WildFly较JBoss7和EAP6.x,更换了web服务器为undertow,是引发问题的原因),故退而求其次,使用JBoss7.1.1进行集群配置。
但JBoss7.1.1有着天生的BUG(在使用domain模式部署项目时会发生未知错误),并由官方确认为BUG,并声明已在JBoss7.2中修复。由于JBoss并没有7.2版本提供下载,所以笔者这里使用了EAP6.1进行集群的配置,该配置方案与之前的《WildFly8.x+mod_cluster集群配置》类似。
《WildFly8.x+mod_cluster集群配置》参考地址:http://tylanbin.tk/65.html

系统环境:
Windows 7 SP1
软件环境:
JDK 7+
EAP 6.1(这个下载地址官方没有开放,需要上网搜一下,或使用JBoss 7.1.1)
mod_cluster 1.2.6(http://mod-cluster.jboss.org/downloads/1-2-6-Final-bin
注意:mod_cluster有两个windows httpd+ssl的版本下载,对应32位和64位

一、配置说明
由于与WildFly的配置基本上完全类似,所以这里仅仅列出不同点
1、需要手动指定节点的id:
修改master的domain.xml,加入instance-id属性:
<subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" instance-id="${jboss.node.name}" native="false">
2、需要手动指定mod_cluster的地址:
修改master的domain.xml,加入proxy-list属性:
<subsystem xmlns="urn:jboss:domain:modcluster:1.1">
    <mod-cluster-config proxy-list="127.0.0.1:6666" ...>
    </mod-cluster-config>
</subsystem>
3、其余配置参考《WildFly8.x+mod_cluster集群配置》。

二、配置JBoss7/EAP6.1为Windows服务
1、从官网下载JBoss Web Native Connectors
下载地址:http://jbossweb.jboss.org/downloads/jboss-native-2-0-10
2、解压后,将bin目录放置到JBoss7/EAP6.1目录下,与bin合并
3、修改service.bat文件,修改范例如下:
@echo off
REM JBoss, the OpenSource webOS
REM
REM Distributable under LGPL license.
REM See terms of license at gnu.org.
REM
REM -------------------------------------------------------------------------
REM JBoss Service Script for Windows
REM -------------------------------------------------------------------------


@if not "%ECHO%" == "" echo %ECHO%
@if "%OS%" == "Windows_NT" setlocal
set DIRNAME=%CD%

REM
REM VERSION, VERSION_MAJOR and VERSION_MINOR are populated
REM during the build with ant filter.
REM
set SVCNAME=JBAS7SVC
set SVCDISP=JBoss Application Server 7
set SVCDESC=JBoss Application Server 7 GA/Platform: Windows x64

set NOPAUSE=Y

REM Suppress killing service on logoff event
set JAVA_OPTS=-Xrs

REM Figure out the running mode

if /I "%1" == "install" goto cmdInstall
if /I "%1" == "uninstall" goto cmdUninstall
if /I "%1" == "start" goto cmdStart
if /I "%1" == "stop" goto cmdStop
if /I "%1" == "restart" goto cmdRestart
if /I "%1" == "signal" goto cmdSignal
echo Usage: service install^|uninstall^|start^|stop^|restart^|signal
goto cmdEnd

REM jbosssvc retun values
REM ERR_RET_USAGE 1
REM ERR_RET_VERSION 2
REM ERR_RET_INSTALL 3
REM ERR_RET_REMOVE 4
REM ERR_RET_PARAMS 5
REM ERR_RET_MODE 6

:errExplain
if errorlevel 1 echo Invalid command line parameters
if errorlevel 2 echo Failed installing %SVCDISP%
if errorlevel 4 echo Failed removing %SVCDISP%
if errorlevel 6 echo Unknown service mode for %SVCDISP%
goto cmdEnd

:cmdInstall
jbosssvc.exe -imwdc %SVCNAME% "%DIRNAME%" "%SVCDISP%" "%SVCDESC%" service.bat
if not errorlevel 0 goto errExplain
echo Service %SVCDISP% installed
goto cmdEnd

:cmdUninstall
jbosssvc.exe -u %SVCNAME%
if not errorlevel 0 goto errExplain
echo Service %SVCDISP% removed
goto cmdEnd

:cmdStart
REM Executed on service start
del .r.lock 2>&1 | findstr /C:"being used" > nul
if not errorlevel 1 (
echo Could not continue. Locking file already in use.
goto cmdEnd
)
echo Y > .r.lock
jbosssvc.exe -p 1 "Starting %SVCDISP%" > E:\Cluster_JBoss7\jboss-eap-6.1\log\run.log
call domain.bat < .r.lock >> E:\Cluster_JBoss7\jboss-eap-6.1\log\run.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> E:\Cluster_JBoss7\jboss-eap-6.1\log\run.log

del .r.lock
goto cmdEnd

:cmdStop
REM Executed on service stop
echo Y > .s.lock
jbosssvc.exe -p 1 "Shutting down %SVCDISP%" > E:\Cluster_JBoss7\jboss-eap-6.1\log\shutdown.log
call jboss-cli.bat --connect command=:shutdown >> E:\Cluster_JBoss7\jboss-eap-6.1\log\shutdown.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> E:\Cluster_JBoss7\jboss-eap-6.1\log\shutdown.log

del .s.lock
goto cmdEnd

:cmdRestart
REM Executed manually from command line
REM Note: We can only stop and start
echo Y > .s.lock
jbosssvc.exe -p 1 "Shutting down %SVCDISP%" >> E:\Cluster_JBoss7\jboss-eap-6.1\log\shutdown.log
call jboss-cli.bat --connect command=:shutdown >> E:\Cluster_JBoss7\jboss-eap-6.1\log\shutdown.log 2>&1

del .s.lock
:waitRun
REM Delete lock file
del .r.lock > nul 2>&1
REM Wait one second if lock file exist
jbosssvc.exe -s 1
if exist ".r.lock" goto waitRun
echo Y > .r.lock
jbosssvc.exe -p 1 "Restarting %SVCDISP%" >> E:\Cluster_JBoss7\jboss-eap-6.1\log\run.log
call domain.bat < .r.lock >> E:\Cluster_JBoss7\jboss-eap-6.1\log\run.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> E:\Cluster_JBoss7\jboss-eap-6.1\log\run.log

del .r.lock
goto cmdEnd

:cmdSignal
REM Send signal to the service.
REM Requires jbosssch.dll to be loaded in JVM
@if not ""%2"" == """" goto execSignal
echo Missing signal parameter.
echo Usage: service signal [0...9]
goto cmdEnd
:execSignal
jbosssvc.exe -k%2 %SVCNAME%
goto cmdEnd

:cmdEnd
4、修改完成后,执行service.bat install安装服务即可。

三、常见问题处理
1、配置根路径应用无效的问题
参考《WildFly8.1+mod_cluster的ROOT应用问题》:http://tylanbin.tk/67.html
除此之外,修改master的domain.xml配置,设置enable-welcome-root为false:
<subsystem xmlns="urn:jboss:domain:web:1.4" ...>
    <virtual-server name="default-host" enable-welcome-root="false">
    ...
    </virtual-server>
    ...
</subsystem>
2、部署应用启动后,出现JBAS011054和JBAS011006警告:
官方已经承认该警告为BUG,可以忽略,如果实在看着不习惯,可以配置log进行屏蔽:
修改matser的domain.xml的日志配置(有多个地方需要修改):
(1)EAP6.1屏蔽方式:
<console-handler name="CONSOLE">
    <filter value='not(match("JBAS011054|JBAS011006"))' />
    ...
</console-handler>
(2)JBoss7.1.1屏蔽方式:
<console-handler name="CONSOLE">
    <filter>
        <not>
            <match pattern="JBAS011054|JBAS011006"/>
        </not>
    </filter>
    ...
</console-handler>

你可能感兴趣的:(cluster)