阿里云Tomcat运行shutdown.sh命令关闭时遇到的问题
1.安装完成jdk之后,然后安装tomcat.
tomcat安装成功后,进入tomcat的安装目录,找到bin所在的目录。
使用./startup.sh,启动tomcat;
使用./shutdown.sh关闭Tomcat,有时会关闭成功,有时会出现关闭错误;
Feb 09, 2017 11:58:42 PM org.apache.catalina.startup.Catalina stopServer SEVERE: Could not contact localhost:8005. Tomcat may not be running. Feb 09, 2017 11:58:42 PM org.apache.catalina.startup.Catalina stopServer SEVERE: Catalina.stop: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at java.net.Socket.<init>(Socket.java:434) at java.net.Socket.<init>(Socket.java:211) at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:498) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:343) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:430)
切换/usr/local/tomcat/tomcat/logs/查看catalina.out日志记录,发现8005端口号被绑定
INFO: Server startup in 1636696 ms
出现这种情况我们可以使用命令ps -ef | grep tomcat 来查看tomcat是否还在允许
ps -ef | grep tomcat
root 2993 1 0 20:07 pts/1 00:00:04 /usr/lib/jvm/jdk1.8.0_121/jre/bin/java -Djava.util.logging.config.file=/usr/lib/tomcat/apache-tomcat-7.0.75/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/usr/lib/tomcat/apache-tomcat-7.0.75/endorsed -classpath /usr/lib/tomcat/apache-tomcat-7.0.75/bin/bootstrap.jar:/usr/lib/tomcat/apache-tomcat-7.0.75/bin/tomcat-juli.jar -Dcatalina.base=/usr/lib/tomcat/apache-tomcat-7.0.75 -Dcatalina.home=/usr/lib/tomcat/apache-tomcat-7.0.75 -Djava.io.tmpdir=/usr/lib/tomcat/apache-tomcat-7.0.75/temp org.apache.catalina.startup.Bootstrap start root 3042 2838 0 20:17 pts/1 00:00:00 grep --color=auto tomcat
如果你想直接杀死Tomcat进程,你可以使用kill命令,直接杀死Tomcat进程
kill -9 2993
继续查看Tomcat是否关闭,如出现以下信息则说明Tomcat已关闭
root 3044 2838 0 20:20 pts/1 00:00:00 grep --color=auto tomcat
修改下Tomcat内存,切换到bin目录下面,使用
vim catalina.sh
修改catalina.sh文件,在位置cygwin=false前,插入以下内容
# OS specific support. $var _must_ be set to either true or false. JAVA_OPTS="-Xms256m -Xmx512m -Xss1024K -XX:PermSize=128m -XX:MaxPermSize=256m" cygwin=false
重启Tomcat即可。
文章来源于:https://blog.csdn.net/ksksjipeng/article/details/54973827。感谢博客分享