<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:192.168.244.133}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:192.168.244.133}"/>
</interface>
<interface name="unsecure">
<!-- Used for IIOP sockets in the standard configuration.
To secure JacORB you need to setup SSL -->
<inet-address value="${jboss.bind.address.unsecure:192.168.244.133}"/>
</interface>
</interfaces>
如果现在你启动master以后,再去启动slave,会发现如下报错,因为我们还没有配置slave和master之间的认证。
[Host Controller] 20:31:24,575 ERROR [org.jboss.remoting.remote] (Remoting "endpoint" read-1) JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
[Host Controller] 20:31:24,579 WARN [org.jboss.as.host.controller] (Controller Boot Thread) JBAS010900: Could not connect to remote domain controller 192.168.244.132:9999
[Host Controller] 20:31:24,582 ERROR [org.jboss.as.host.controller] (Controller Boot Thread) JBAS010901: Could not connect to master. Aborting. Error was: java.lang.IllegalStateException: JBAS010942: Unable to connect due to authentication failure.
此时,我们需要在master中添加2个user,可以通过 wildfly-9.0.2s\bin\add-user.bat 来添加,具体过程在这里不再描述,过程中需要注意一点就是需要记住password的64位加密后的码,人员类型选择 “ManagementRealm”。我在这里添加2个用户 master 和 slave,密码都为123456。
在slave找到刚才编辑过的 host.xml,添加<secret value="MTIzNDU2" /> ,“MTIzNDU2”为123456的64位加密码,配置如下:
<server name="server-three" group="other-server-group" auto-start="false">
<!-- server-three avoids port conflicts by incrementing the ports in
the default socket-group declared in the server-group -->
<socket-bindings port-offset="250"/>
</server>
port-offset 是 250, 所以 8080 + 250 = 8330
<server name="server-three" group="other-server-group" auto-start="true">
<!-- server-three avoids port conflicts by incrementing the ports in
the default socket-group declared in the server-group -->
<socket-bindings port-offset="250"/>
</server>
slave
<server name="server-three-slave" group="other-server-group" auto-start="true">
<!-- server-three avoids port conflicts by incrementing the ports in
the default socket-group declared in the server-group -->
<socket-bindings port-offset="250"/>
</server>
完成如上配置以后,接下来我们就需要配置httpd 和 mod_cluster 来完成集群配置。
3、mod_cluster 集群的配置
解压我们下载的mod_cluster安装文件到某个目录,然后执行 D:\httpd-2.4\bininstallconf.bat 命令(这里要注意,需要使用管理员权限启动),然后会发现在目录D:\httpd-2.4\conf 下面会看到httpd.conf 文件,接下来的主要配置就是修改这个文件。然后安装httpd服务:httpd.exe -k install -n httpd2.4(安装的service需要使用管理员启动,默认是本地系统)
# MOD_CLUSTER_ADDS
# Adjust to you hostname and subnet.
<IfModule manager_module>
Listen 192.168.244.1:8888
#ManagerBalancerName mycluster
<VirtualHost 192.168.244.1:8888>
# / 标示拦截所有类型的请求 Require ip 192.168.244 标示拦截特定的IP
<Location />
Require ip 192.168.244
</Location>
KeepAliveTimeout 60
MaxKeepAliveRequests 0
EnableMCPMReceive
# don't use multicast
ServerAdvertise Off
#AdvertiseFrequency 5
#AdvertiseSecurityKey secret
#AdvertiseGroup 224.0.1.105:23364
<Location /status>
SetHandler mod_cluster-manager
#Require ip 192.168.244
Order deny,allow
Deny from all
Allow from all
AllowDisplay on
</Location>
#设置代理转发,这里为将所有请求类型都转发至mycluster负载均衡器
#ProxyPass / balancer://mycluster/
</VirtualHost>
</IfModule>
然后启动service