按照官方文档的描述在server.xml的Engine元素中增加cluster子元素,配置如下:

Tomcat集群问题记录_tomcat集群


    但是,在我的linux虚拟机上面启动tomcat时总是如下错误:

信息: Starting Servlet Engine: Apache Tomcat/7.0.62

七月 07, 2015 10:15:38 上午 org.apache.catalina.ha.tcp.SimpleTcpCluster startInternal

信息: Cluster is about to start

七月 07, 2015 10:15:38 上午 org.apache.catalina.tribes.transport.ReceiverBase bind

信息: Receiver Server Socket bound to:/127.0.0.1:4000

七月 07, 2015 10:15:38 上午 org.apache.catalina.tribes.membership.McastServiceImpl setupSocket

信息: Setting cluster mcast soTimeout to 500

七月 07, 2015 10:15:38 上午 org.apache.catalina.tribes.membership.McastServiceImpl start

严重: Unable to join multicast group, make sure your system has multicasting enabled.

七月 07, 2015 10:15:38 上午 org.apache.catalina.ha.tcp.SimpleTcpCluster startInternal

严重: Unable to start cluster.

org.apache.catalina.tribes.ChannelException: java.net.SocketException: 没有那个设备; No faulty members identified.

        at org.apache.catalina.tribes.group.ChannelCoordinator.internalStart

(ChannelCoordinator.java:177)

at org.apache.catalina.tribes.group.ChannelCoordinator.start

(ChannelCoordinator.java:98)

at org.apache.catalina.tribes.group.ChannelInterceptorBase.start

(ChannelInterceptorBase.java:160)

at org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor.start

(MessageDispatchInterceptor.java:157)

at org.apache.catalina.tribes.group.ChannelInterceptorBase.start

(ChannelInterceptorBase.java:160)

at org.apache.catalina.tribes.group.ChannelInterceptorBase.start

(ChannelInterceptorBase.java:160)

at org.apache.catalina.tribes.group.GroupChannel.start

(GroupChannel.java:419)

at org.apache.catalina.ha.tcp.SimpleTcpCluster.startInternal

(SimpleTcpCluster.java:690)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1106)

at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:739)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.startup.Catalina.start(Catalina.java:689)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)

Caused by: java.net.SocketException: 没有那个设备

at java.net.PlainDatagramSocketImpl.join(Native Method)

at java.net.AbstractPlainDatagramSocketImpl.join(AbstractPlainDatagramSocketImpl.java:179)

at java.net.MulticastSocket.joinGroup(MulticastSocket.java:319)

at org.apache.catalina.tribes.membership.McastServiceImpl.start(McastServiceImpl.java:253)

at org.apache.catalina.tribes.membership.McastService.start(McastService.java:444)

at org.apache.catalina.tribes.group.ChannelCoordinator.internalStart(ChannelCoordinator.java:162)

... 22 more


七月 07, 2015 10:15:38 上午 org.apache.catalina.startup.Catalina start

严重: The required Server component failed to start so Tomcat is unable to start.

org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

at org.apache.catalina.startup.Catalina.start(Catalina.java:689)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:739)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 7 more

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 9 more

Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.ha.tcp.SimpleTcpCluster[Catalina]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1106)

at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 11 more

Caused by: org.apache.catalina.LifecycleException: org.apache.catalina.tribes.ChannelException: java.net.SocketException: 没有那个设备; No faulty members identified.

at org.apache.catalina.ha.tcp.SimpleTcpCluster.startInternal(SimpleTcpCluster.java:695)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 14 more

Caused by: org.apache.catalina.tribes.ChannelException: java.net.SocketException: 没有那个设备; No faulty members identified.

at org.apache.catalina.tribes.group.ChannelCoordinator.internalStart(ChannelCoordinator.java:177)

at org.apache.catalina.tribes.group.ChannelCoordinator.start(ChannelCoordinator.java:98)

at org.apache.catalina.tribes.group.ChannelInterceptorBase.start(ChannelInterceptorBase.java:160)

at org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor.start(MessageDispatchInterceptor.java:157)

at org.apache.catalina.tribes.group.ChannelInterceptorBase.start(ChannelInterceptorBase.java:160)

at org.apache.catalina.tribes.group.ChannelInterceptorBase.start(ChannelInterceptorBase.java:160)

at org.apache.catalina.tribes.group.GroupChannel.start(GroupChannel.java:419)

at org.apache.catalina.ha.tcp.SimpleTcpCluster.startInternal(SimpleTcpCluster.java:690)

... 15 more

Caused by: java.net.SocketException: 没有那个设备

at java.net.PlainDatagramSocketImpl.join(Native Method)

at java.net.AbstractPlainDatagramSocketImpl.join(AbstractPlainDatagramSocketImpl.java:179)

at java.net.MulticastSocket.joinGroup(MulticastSocket.java:319)

at org.apache.catalina.tribes.membership.McastServiceImpl.start(McastServiceImpl.java:253)

at org.apache.catalina.tribes.membership.McastService.start(McastService.java:444)

at org.apache.catalina.tribes.group.ChannelCoordinator.internalStart(ChannelCoordinator.java:162)

... 22 more


七月 07, 2015 10:15:38 上午 org.apache.coyote.AbstractProtocol pause

信息: Pausing ProtocolHandler ["http-bio-8080"]

七月 07, 2015 10:15:38 上午 org.apache.coyote.AbstractProtocol pause

信息: Pausing ProtocolHandler ["ajp-bio-8009"]

七月 07, 2015 10:15:38 上午 org.apache.catalina.core.StandardService stopInternal

信息: Stopping service Catalina

七月 07, 2015 10:15:38 上午 org.apache.coyote.AbstractProtocol destroy

信息: Destroying ProtocolHandler ["http-bio-8080"]

七月 07, 2015 10:15:38 上午 org.apache.coyote.AbstractProtocol destroy

信息: Destroying ProtocolHandler ["ajp-bio-8009"]



我猜测应该是组播的问题,本质上讲是我虚拟机的网络那块有问题,导致无法加入组播组。

后来,在网上搜集了一些资料,都没有什么好的方案

有人说将Receiver的address改成自己的ip地址,不要用auto

也有人说是hostname和/etc/hosts中配置不一致

更有人说是因为没有插网线

……

我都试过,无奈还是报这个错,即使我把SELinux和防火墙都关了亦是如此。

后来,我将tomcat放到我的win7上面可以启动成功(即使拔掉网线)

我想,放到win7下可以,放到linux上呢?,我将虚拟机中那个无法启动的tomcat又放到公司的

linux服务器上,竟然也能启动成功。我很困惑……

后来,我将虚拟机上的网卡eth0的广播地址改成228.0.0.4

ipconfig eth0 broadcast 228.0.0.4

再次启动tomcat,天呐,经常启动成功了,不知道为什么……

最后,我做了一个大胆的尝试

我将虚拟机的网络连接方式由“仅主机模式”改成“桥接模式”,让虚拟机能够联网

又一次在虚拟机中启动tomcat,结果启动成功了,很意外


    在网络连接方式为“仅主机模式”的虚拟机环境中启动tomcat,报错

    将虚拟机的广播地址改成228.0.0.4,启动tomcat,成功

    将虚拟机中的那个tomcat放到win7环境和真实的linux服务器上启动成功

    不改变虚拟机的广播地址,将网络连接方式改为“桥接模式”,启动tomcat,也成功


就这么稀里糊涂的,tomcat的就启动成功了,我也不知道这是为什么,看来虚拟机环境还是有问题啊!

这里也懒得往下深究了,总之,做实验就用桥接模式吧!

日后遇到高人再请教吧………………