Tomcat 不會因 SNMP 選項而停止

Tomcat 不會因 SNMP 選項而停止

我們有一個使用 SNMP 的監控應用程序,我在我的 tomcat 伺服器中啟用了 SNMP,並在bin/setenv.sh檔案中使用了以下選項。

#
# SNMP for Tomcat
#
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.snmp.interface=10.101.21.31"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.snmp.port=1651"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.snmp.acl=false"

tomcat啟動時沒有任何問題,一切都很乾淨。但是當我停止 tomcat 時,我收到此錯誤。

[tomcat@webserver1 bin]$ ./catalina.sh stop
JAVA_OPTS: %JAVA_OPTS%
Using CATALINA_BASE:   /opt/tomcat7.1
Using CATALINA_HOME:   /opt/tomcat7.1
Using CATALINA_TMPDIR: /opt/tomcat7.1/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/tomcat7.1/bin/bootstrap.jar:/opt/tomcat7.1/bin/tomcat-juli.jar
Error: Failed to start SNMP adaptor with address: /10.101.21.31:1651 (Address already in use)

無論如何,我可以乾淨地阻止tomcat而不是殺死它?

答案1

您應該使用CATALINA_OPTS而不是JAVA_OPTS.該catalina.sh腳本很好地記錄了差異:

#   CATALINA_OPTS   (Optional) Java runtime options used when the "start",
#                   "run" or "debug" command is executed.
#                   Include here and not in JAVA_OPTS all options, that should
#                   only be used by Tomcat itself, not by the stop process,
#                   the version command etc.
#                   Examples are heap size, GC logging, JMX ports etc.

JAVA_OPTS設定為 的事實%JAVA_OPTS%也表明您有問題(可能是由 win32 管理員編寫的腳本)。

相關內容