首页 > 学院 > 操作系统 > 正文

阿里云部署Tomcat运行shutdown.sh命令关闭时遇到的问题

2024-06-28 16:04:07
字体:
来源:转载
供稿:网友

接阿里云ECS下安装jdk1.8安装成功之后,接下来开始在阿里云部署Tomcat服务器,部署Tomcat和配置jdk类似

1、下载Tomcat,我下载的是apache-tomcat-7.0.75.tar.gz,通过FileZilla上传至/home/ftp目录,解压至/usr/lib/tomcat

sudo tar -zxvf apache-tomcat-7.0.75.tar.gz -C /usr/lib/jvm

2、修改~/.bashrc,增加Tomcat环境变量;

export java_HOME=/usr/lib/jvm/jdk1.8.0_121export JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/libexport PATH=${JAVA_HOME}/bin:$PATHexport TOMCAT_HOME=/usr/lib/tomcat/apache-tomcat-7.0.75

3、切换到/usr/lib/tomcat/apache-tomcat-7.0.75/bin/,使用./startup.sh,启动tomcat;

Using CATALINA_BASE: /usr/lib/tomcat/apache-tomcat-7.0.75Using CATALINA_HOME: /usr/lib/tomcat/apache-tomcat-7.0.75Using CATALINA_TMPDIR: /usr/lib/tomcat/apache-tomcat-7.0.75/tempUsing JRE_HOME: /usr/lib/jvm/jdk1.8.0_121/jreUsing CLASSPATH: /usr/lib/tomcat/apache-tomcat-7.0.75/bin/bootstrap.jar:/usr/lib/tomcat/apache-tomcat-7.0.75/bin/tomcat-juli.jarTomcat started.

启动成功;

4、使用./shutdown.sh关闭Tomcat,有时会关闭成功,有时会出现关闭错误;

Feb 09, 2017 11:58:42 PM org.apache.catalina.startup.Catalina stopServerSEVERE: Could not contact localhost:8005. Tomcat may not be running.Feb 09, 2017 11:58:42 PM org.apache.catalina.startup.Catalina stopServerSEVERE: 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/lib/tomcat/apache-tomcat-7.0.75/logs/查看catalina.out日志记录,发现8005端口号被绑定 INFO: Server startup in 1636696 ms

Feb 10, 2017 12:25:50 AM org.apache.catalina.core.StandardServer awaitSEVERE: StandardServer.await: create[localhost:8005]:java.net.BindException: Address already in use (Bind failed) at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387) at java.net.ServerSocket.bind(ServerSocket.java:375) at java.net.ServerSocket.<init>(ServerSocket.java:237) at org.apache.catalina.core.StandardServer.await(StandardServer.java:444) at org.apache.catalina.startup.Catalina.await(Catalina.java:781) at org.apache.catalina.startup.Catalina.start(Catalina.java:727) 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)

5、使用

ps -ef|grep tomcat

如显示以下内容,则说明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 startroot 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

6、最近修改下Tomcat内存,切换到bin目录下面,使用

vi 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即可。


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表