部署两台JBoss4.0.3SP1 修改了cluster-service.xml & jboss-service.xml的配置 但是启动JBoss,日志中是这样的信息 ------------------------------------------------------- GMS: address is sztp02:32850 ------------------------------------------------------- 2007-12-05 09:54:07,912 INFO [org.jboss.cache.TreeCache] viewAccepted(): new members: [sztp02:32845] 2007-12-05 09:54:07,919 INFO [org.jboss.cache.TreeCache] state could not be retrieved (must be first member in group) ......
GMS: address is sztp02:32847 (additional data: 18 bytes) ------------------------------------------------------- 2007-12-05 09:54:12,547 INFO [org.jboss.ha.framework.interfaces.HAPartition.test] Number of cluster members: 1 2007-12-05 09:54:12,550 INFO [org.jboss.ha.framework.interfaces.HAPartition.lifecycle.test] New cluster view for partition test (id: 0, delta: 0) : [192.168.0.238:1099] 2007-12-05 09:54:12,551 INFO [org.jboss.ha.framework.interfaces.HAPartition.test] Other members: 0 2007-12-05 09:54:12,552 INFO [org.jboss.ha.framework.interfaces.HAPartition.test] Fetching state (will wait for 30000 milliseconds):
<!-- Name of the partition being built --> <attribute name="PartitionName">test </attribute>
和HANaming部分: <mbean code="org.jboss.ha.jndi.HANamingService" name="jboss:service=HAJNDI"> <depends>jboss:service=test </depends> <!-- Name of the partition to which the service is linked --> <attribute name="PartitionName">test </attribute> ...... <attribute name="AutoDiscoveryBindAddress">192.168.100.9 </attribute>
jboss-service.xml中增加了节点 <hosts> <host> <!-- The URL to use to connect the host. URLs like http://www.xx.yy:8080/ are also allowed --> <host-url>http://192.168.0.238/ </host-url> </host> <host> <host-url>http://192.168.0.16/ </host-url> </host>
关掉一台Jboss,在另外一台可以看到 2007-12-06 16:06:34,179 INFO [org.jboss.ha.framework.server.DistributedReplicantManagerImpl.test] I am (192.168.0.16:1099) received membershipChanged event: 2007-12-06 16:06:34,179 INFO [org.jboss.ha.framework.server.DistributedReplicantManagerImpl.test] Dead members: 1 ([192.168.0.238:1099]) 2007-12-06 16:06:34,179 INFO [org.jboss.ha.framework.server.DistributedReplicantManagerImpl.test] New Members : 0 ([]) 2007-12-06 16:06:34,179 INFO [org.jboss.ha.framework.server.DistributedReplicantManagerImpl.test] All Members : 1 ([192.168.0.16:1099])
再启动之后都又可以看到对方 2007-12-06 16:14:32,463 INFO [org.jboss.cache.TreeCache] viewAccepted(): new members: [sztp01:32905, sztp02:32945]
<!-- Name of the partition being built --> <attribute name="PartitionName">test </attribute> <!-- The address used to determine the node name --> <attribute name="NodeAddress">${jboss.bind.address} </attribute> <!-- Determine if deadlock detection is enabled --> <attribute name="DeadlockDetection">False </attribute> <!-- Max time (in ms) to wait for state transfer to complete. Increase for large states --> <attribute name="StateTransferTimeout">30000 </attribute> <!-- The JGroups protocol configuration --> <attribute name="PartitionConfig"> <Config> <UDP mcast_addr="${jboss.partition.udpGroup:228.1.2.3}" mcast_port="45566" ip_ttl="8" ip_mcast="true" mcast_send_buf_size="800000" mcast_recv_buf_size="150000" ucast_send_buf_size="800000" ucast_recv_buf_size="150000" loopback="false"/> <PING timeout="2000" num_initial_members="3" up_thread="true" down_thread="true"/> <MERGE2 min_interval="10000" max_interval="20000"/> <FD shun="true" up_thread="true" down_thread="true" timeout="2500" max_tries="5"/> <VERIFY_SUSPECT timeout="3000" num_msgs="3" up_thread="true" down_thread="true"/> <pbcast.NAKACK gc_lag="50" retransmit_timeout="300,600,1200,2400,4800" max_xmit_size="8192" up_thread="true" down_thread="true"/> <UNICAST timeout="300,600,1200,2400,4800" window_size="100" min_threshold="10" down_thread="true"/> <pbcast.STABLE desired_avg_gossip="20000" up_thread="true" down_thread="true"/> <FRAG frag_size="8192" down_thread="true" up_thread="true"/> <pbcast.GMS join_timeout="5000" join_retry_timeout="2000" shun="true" print_local_addr="true"/> <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/> </Config> <!-- Alternate TCP stack: customize it for your environment, change bind_addr and initial_hosts --> </attribute> <depends>jboss:service=Naming </depends> </mbean>
<!-- ==================================================================== --> <!-- HA Session State Service for SFSB --> <!-- ==================================================================== -->
<mbean code="org.jboss.ha.hasessionstate.server.HASessionStateService" name="jboss:service=HASessionState"> <!-- Name of the partition to which the service is linked --> <attribute name="PartitionName">${jboss.partition.name:DefaultPartition} </attribute> <!-- JNDI name under which the service is bound --> <attribute name="JndiName">/HASessionState/Default </attribute> <!-- Max delay before cleaning unreclaimed state. Defaults to 30*60*1000 => 30 minutes --> <attribute name="BeanCleaningDelay">0 </attribute> <depends>jboss:service=Naming </depends> <depends>jboss:service=${jboss.partition.name:DefaultPartition} </depends> </mbean>
<!-- ==================================================================== --> <!-- HA JNDI --> <!-- ==================================================================== -->
<mbean code="org.jboss.ha.jndi.HANamingService" name="jboss:service=HAJNDI"> <depends>jboss:service=test </depends> <!-- Name of the partition to which the service is linked --> <attribute name="PartitionName">test </attribute> <!-- Bind address of bootstrap and HA-JNDI RMI endpoints --> <attribute name="BindAddress">${jboss.bind.address} </attribute> <!-- Port on which the HA-JNDI stub is made available --> <attribute name="Port">1100 </attribute> <!-- RmiPort to be used by the HA-JNDI service once bound. 0 => auto. --> <attribute name="RmiPort">1101 </attribute> <!-- Accept backlog of the bootstrap socket --> <attribute name="Backlog">50 </attribute> <!-- The thread pool service used to control the bootstrap and auto discovery lookups --> <depends optional-attribute-name="LookupPool" proxy-type="attribute">jboss.system:service=ThreadPool </depends>
<!-- A flag to disable the auto discovery via multicast --> <attribute name="DiscoveryDisabled">false </attribute> <!-- Set the auto-discovery bootstrap multicast bind address. If not specified and a BindAddress is specified, the BindAddress will be used. --> <attribute name="AutoDiscoveryBindAddress">192.168.0.238 </attribute> <!-- Multicast Address and group port used for auto-discovery --> <attribute name="AutoDiscoveryAddress">${jboss.partition.udpGroup:230.0.0.4} </attribute> <attribute name="AutoDiscoveryGroup">1102 </attribute> <!-- The TTL (time-to-live) for autodiscovery IP multicast packets --> <attribute name="AutoDiscoveryTTL">16 </attribute> </mbean>
<!-- The name of the session-cookie to use --> <sticky-session-cookie-name>JBoss_LB_ID </sticky-session-cookie-name>
<!-- The list of the target hosts --> <hosts> <host> <!-- The URL to use to connect the host. URLs like http://www.xx.yy:8080/ are also allowed --> <host-url>http://192.168.0.16/ </host-url> </host> <host> <host-url>http://192.168.0.238/ </host-url> </host>
</hosts> </scheduler> </attribute> </mbean>
<mbean code="org.jboss.web.loadbalancer.LoadbalancerService" name="jboss.web.loadbalancer:service=Loadbalancer"> <depends optional-attribute-name="Scheduler">jboss.web.loadbalancer:service=Scheduler </depends> <!-- The timeout for a connection from the loadbalancer to a target host in ms --> <attribute name="ConnectionTimeout">20000 </attribute> </mbean>
<!-- Monitor Services --> <!-- A monitor that only checks that a given path is reachable <mbean code="org.jboss.web.loadbalancer.monitor.SimpleMonitorService" name="jboss.web.loadbalancer:service=Monitor"> <depends optional-attribute-name="Scheduler">jboss.web.loadbalancer:service=Scheduler </depends> <attribute name="Interval">15000 </attribute> <attribute name="Timeout">20000 </attribute> <attribute name="Path">/ </attribute> </mbean> --> <!-- Another monitor that tries to match a regular expression against the server response <mbean code="org.jboss.web.loadbalancer.monitor.ECVMonitorService" name="jboss.web.loadbalancer:service=Monitor"> <depends optional-attribute-name="Scheduler">jboss.web.loadbalancer:service=Scheduler </depends> <attribute name="Interval">15000 </attribute> <attribute name="Timeout">20000 </attribute> <attribute name="Path">/index.html </attribute> <attribute name="RegExp">JBOSS </attribute> </mbean> --> </server>
按照集群配置指南的说明,上面的测试结果没有问题。因为HAJNDI的lookup原则是只要集群中有一个节点提供命名服务就会返回。英文说明如下: There is no load balancing behavior in the JNP client lookup process. It just goes through the provider list and use the first available server. 是不是ejb的集群配置可能有问题?
1、因为修改了集群partition的名称,所以ejb3的定义为: @Stateless @Clustered(partition="test") public class ServiceInvokerBean implements IServiceInvokerRemote{ } 如果使用的ejb3是rc9版本,最好是在自己应用的/META-INFO目录下创建一个jboss.xml文件,在该文件里进行集群的配置
之后,客户端会报错如下: {java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, jnp.partitionName=test, java.naming.factory.url.pkgs=jboss.naming:org.jnp.interfaces} java.lang.IndexOutOfBoundsException: Index: 3, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.get(ArrayList.java:322) at com.a8.tptm.ice.mo.server.MoServerI$TimeOutThread.doEvent(MoServerI.java:331) at com.a8.tptm.ice.mo.server.MoServerI$TimeOutThread.sendMoMsg2(MoServerI.java:292) at com.a8.tptm.ice.mo.server.MoServerI$TimeOutThread.run(MoServerI.java:276) javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1302) at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1419) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572) at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.a8.tptm.ice.mo.server.MoServerI.init(MoServerI.java:93) at com.a8.tptm.ice.mo.server.MoServerI. <init>(MoServerI.java:55) at com.a8.tptm.ice.mo.server.MoServer.main(MoServer.java:91) Caused by: java.net.SocketTimeoutException: Receive timed out at java.net.PlainDatagramSocketImpl.receive0(Native Method) at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136) at java.net.DatagramSocket.receive(DatagramSocket.java:712) at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1272) ... 7 more