今天遇到个很郁闷的问题,使用catalina.sh stop 或者 shutdown.sh 关闭tomcat总是失败,总提示连接超时。

开始以为是自己tomcat配置的问题,重新部署上没更改过配置的tomcat,结果依然是失败。

后来使用telnet 127.0.0.1 到shutdown的端口 发现失败;

tomcat停止的时候将SHUTDOWN指令发送给127.0.0.1:8005端口执行;

问题原来出在自己之前测试的时候把配置有127.0.0.1 IP的lo网卡给禁用了;

启用lo网卡,然后重新停止tomcat成功。o(∩_∩)o

解决步骤:

tomcat监听端口如下:

[root@node1~]#netstat-napt|grepjava|grepLISTENtcp00:::8080:::*LISTEN1317/javatcp00::ffff:127.0.0.1:8005:::*LISTEN1317/javatcp00:::8009:::*LISTEN1317/java

报错如下:

[root@node1~]#/usr/local/tomcat/bin/catalina.shstopUsingCATALINA_BASE:/usr/local/tomcatUsingCATALINA_HOME:/usr/local/tomcatUsingCATALINA_TMPDIR:/usr/local/tomcat/tempUsingJRE_HOME:/usr/local/jdkUsingCLASSPATH:/usr/local/tomcat/bin/bootstrap.jar六月25,20144:29:37下午org.apache.catalina.startup.CatalinastopServer严重:Catalina.stop:java.net.ConnectException:连接超时atjava.net.PlainSocketImpl.socketConnect(NativeMethod)atjava.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)atjava.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)atjava.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)atjava.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)atjava.net.Socket.connect(Socket.java:589)atjava.net.Socket.connect(Socket.java:538)atjava.net.Socket.<init>(Socket.java:434)atjava.net.Socket.<init>(Socket.java:211)atorg.apache.catalina.startup.Catalina.stopServer(Catalina.java:422)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:483)atorg.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338)atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416)

Telnet 本地8005端口:

[root@node1~]#telnet127.0.0.18005Trying127.0.0.1...telnet:connecttoaddress127.0.0.1:Connectiontimedout

查看IP配置:

[root@node1~]#ipa1:lo:<LOOPBACK>mtu16436qdiscnoqueuestateDOWN##状态为down的link/loopback00:00:00:00:00:00brd00:00:00:00:00:00inet127.0.0.1/8scopehostlo2:eth2:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000link/ether00:0c:29:32:0c:53brdff:ff:ff:ff:ff:ffinet192.168.1.44/24brd192.168.1.255scopeglobaleth2inet6fe80::20c:29ff:fe32:c53/64scopelinkvalid_lftforeverpreferred_lftforever

启用lo网卡:

[root@node1~]#ifuplo

重新停止Tomcat成功:

[root@node1~]#/usr/local/tomcat/bin/catalina.shstopUsingCATALINA_BASE:/usr/local/tomcatUsingCATALINA_HOME:/usr/local/tomcatUsingCATALINA_TMPDIR:/usr/local/tomcat/tempUsingJRE_HOME:/usr/local/jdkUsingCLASSPATH:/usr/local/tomcat/bin/bootstrap.jar[root@node1~]#netstat-napt|grepjava|grepLISTEN