4

我想在 tomcat7-maven-plugin 上启用 JMX。如何将 CATALINA_OPTS 传递给插件配置?

4

3 回答 3

0

两种可能的解决方案(未测试):

于 2013-01-04T18:17:47.713 回答
0

如果你想启用 jmxremote.authenticate 然后使用它。

在 setenv.sh

 -Dcom.sun.management.jmxremote.port=7091 \
 -Dcom.sun.management.jmxremote.ssl=false \
 -Dcom.sun.management.jmxremote.authenticate=true \
 -Djava.rmi.server.hostname=127.0.0.1 \
 -Dcom.sun.management.jmxremote.password.file=/usr/tomcat/conf/jmxremote.password \
 -Dcom.sun.management.jmxremote.access.file=/usr/tomcat/conf/jmxremote.access"

vi jmxremote.access 文件

monitor   readonly
admin     readwrite \
              create javax.management.monitor.*,javax.management.timer.* \
              unregister

vi jmxremote.password 文件

monitor pass1
admin pass2

更改权限

sudo chown tomcat7:tomcat7 /usr/tomcat/conf/jmxremote.*
sudo chmod 0600 /usr/tomcat/conf/jmxremote.*

控制我们需要添加 jmx listener
/usr/tomcat/conf/server.xml 文件的端口,如下所示:

<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"
  rmiRegistryPortPlatform="7091" rmiServerPortPlatform="7091" />

在 tomcat lib:/usr/tomcat/lib/ 中添加 jmx jar 文件。

The jar we are looking for is called catalina-jmx-remote.jar.

重启 tomcat 然后尝试使用 jconsole 或 jvisualvm 连接

参考:
1. https://blog.markshead.com/1129/connecting-visual-vm-to-tomcat-7/
2.https://geekflare.com/enable-jmx-tomcat-to-monitor-administer/#:~:text=JMX%20(Java%20Management%20Extension)%20is,Classes%2C%20and%20configure%20various %20MBean。
于 2020-08-11T08:18:19.547 回答
0

在我的 .profile 中添加了以下行

   export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9000 -Xmx1024m -XX:MaxPermSize=256m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
于 2015-08-11T12:36:46.437 回答