如何在JVM上激活JMX以使用jconsole进行访问?
当前回答
步骤1:使用以下参数运行应用程序。
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
上述参数将应用程序绑定到端口9999。
步骤2:在命令提示符或终端中执行命令jconsole来启动jconsole。
选择“远程进程:”并输入url为{IP_Address}:9999,然后单击连接按钮连接到远程应用程序。
您可以参考此链接以获得完整的应用程序。
其他回答
我使用的是WAS ND 7.0
我的JVM需要在JConsole中监视以下所有参数
-Djavax.management.builder.initial=
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8855
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
使用以下命令行参数运行java应用程序:
-Dcom.sun.management.jmxremote.port=8855
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
使用-Dcom.sun.management.jmxremote非常重要。如果不想在JMX主机上设置数字证书,则使用Ssl =false参数。
如果在IP地址为192.168.0.1的机器上启动应用程序,则打开jconsole,在Remote Process字段中输入192.168.0.1:8855,然后单击Connect。
使用远程进程选项运行本地进程JCONSOLE
为了在本地运行,这对我来说是可行的
我在vm args -中添加了这个
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=6001
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=localhost
-Dcom.sun.management.jmxremote.rmi.port=6001
我通过Intellij终端打开JConsole 它给我显示了本地所有的PID值 所以我选择了远程进程,并使用主机- localhost:6001登录 用户名和密码为空 然后点击连接
确保端口6001上没有其他进程正在运行。您也可以使用其他端口。
以下选项适合我:
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.rmi.port=9010
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname={host name}
并且记得在服务器上打开9010端口
sudo ufw allow 9010/udp
sudo ufw allow 9010/tcp
sudo ufw reload
首先,您需要检查java进程是否已经使用JMX参数运行。这样做:
ps -ef | grep java
检查您需要监视的java进程。如果你能看到jmx rmi参数Djmx.rmi.registry。Port =xxxx,然后在Java visualvm中使用这里提到的端口在JMX连接下远程连接它。
如果它没有通过jmx rmi端口运行,那么你需要使用以下提到的参数运行你的java进程:
-Djmx.rmi.registry.port=1234 -Djmx.rmi.port=1235 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
注意:端口号基于您的选择。
现在您可以将此端口用于jmx连接。这里是1234端口。
推荐文章
- 在流中使用Java 8 foreach循环移动到下一项
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 用Java计算两个日期之间的天数
- 如何配置slf4j-simple
- 在Jar文件中运行类
- 带参数的可运行?
- 我如何得到一个字符串的前n个字符而不检查大小或出界?
- 我可以在Java中设置enum起始值吗?
- Java中的回调函数
- c#和Java中的泛型有什么不同?和模板在c++ ?
- 在Java中,流相对于循环的优势是什么?
- Jersey在未找到InjectionManagerFactory时停止工作
- 在Java流是peek真的只是调试?
- Recyclerview不调用onCreateViewHolder
- 将JSON字符串转换为HashMap