VisualVM/JConsole连接到远程服务器

简介

一般操作都不直接在服务器上进行,通过VisualVM连接到远程服务器上可以更方便得进行jvm跟踪调优。

配置JMX连接

在这里插入图片描述

启动程序

java \
-Djava.rmi.server.hostname=127.0.0.1 \
-Dcom.sun.management.jmxremote.port=8877 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
Hello

查看端口占用

[hello@test hello]$ jps -lm
9263 Hello
[hello@test hello]$ netstat -anp | grep 9263
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::10027                :::*                    LISTEN      9263/java           
tcp6       0      0 :::8877                 :::*                    LISTEN      9263/java           
tcp6       0      0 :::20928                :::*                    LISTEN      9263/java     

这个步骤可以看到,不仅占用了8877端口,还随机多占用了两个端口。这点许多资料没讲,干脆把防火墙给关了,实际上把端口打通即可。

建立隧道连接

在这里插入图片描述

开开心心连上去

在这里插入图片描述
在这里插入图片描述

JConsole连接

和VisualVM连接是一样的
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章