Java远程性能分析
2018-12-28 本文已影响25人
阿呆少爷
JMX
启动命令如下。
java -Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.rmi.port=9091 \
-Dcom.sun.management.jmxremote=true \
-Dcom.sun.management.jmxremote.port=9091 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.local.only=false \
-Djava.rmi.server.hostname=10.10.10.10 \
-jar xxx.jar

JMX没法使用VisualGC。

jstatd
首先配置好policy。
$ cat jstatd.all.policy
grant codebase "file:${java.home}/../lib/tools.jar"
{ permission java.security.AllPermission; };
接着在服务器端先启动jstatd。
jstatd -J-Djava.security.policy=jstatd.all.policy \
-J-Djava.rmi.server.hostname=10.10.10.10 \
-J-Djava.rmi.server.logCalls=true
在jvisualvm里面添加好远程主机,就能看到主机上所有的Java进程。

jstatd看不到CPU的使用情况。

jprofiler
在远程主机下载好 jprofiler,解压开。启动进程的时候,需要指定libjprofilerti.so的路径。
java -agentpath:./jprofiler10.1.4/bin/linux-x64/libjprofilerti.so=port=8849 \
-jar xxx.jar
jprofiler最强大,什么都能看到。

