解决tomcat shutdown时的地址被占用问题

老是在tomcat的启动脚本catalina.sh的一开始加上dubug参数,以供远程debug,原参数以下java

JAVA_OPTS='-XX:PermSize=728m -XX:MaxPermSize=728m -Xms1024m -Xmx1024m -DNode=DLOG4J 
-DProductMode=false -Dfile.encoding=utf-8 
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n'

 

可是这样作后,再运行tomcat的shutdown.sh脚本会报错:web

ERROR: transport error 202: bind failed: Address already in use ["transport.c",L41]
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) ["debugInit.c",L500]
JDWP exit error JVMTI_ERROR_INTERNAL(113): No transports initializedFATAL ERROR in native method: JDWP No transports initialized, jvmtiError=JVMTI_ERROR_INTERNAL(113)

之前老是懒得弄,直接killall -9 java 了事,可是如今同一台机器上装了不少服务,不能直接 killall了,用ps -ef | grep java去查又比较麻烦shell

因此查了一下google,获得结果
tomcat

You are trying to debug tomcat on startup, so it binds to port 5005 when the jvm starts.jvm

When you run catalina.sh stop, it starts up another jvm which also tries to bind to port 5005.socket

You need to move the debug args to the run and start arguments (in catalina.sh) of tomcat, putting them straight into the JAVA_OPTS is the cause of the issue you're having.google

最后有一个很是简单的解决方法:spa

CATALINA_OPTS 参数替代 JAVA_OPTS 参数 debug

把dubug参数换成:code

CATALINA_OPTS='-XX:PermSize=728m -XX:MaxPermSize=728m -Xms1024m -Xmx1024m -DNode=DLOG4J  
-DProductMode=false  -Dfile.encoding=utf-8 
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n'
相关文章
相关标签/搜索