标题: How to setup VisualVM and jstatd to take heap dump and thread dump in linux [打印本页] 作者: 翔子 时间: 2014-11-19 09:24 标题: How to setup VisualVM and jstatd to take heap dump and thread dump in linux How to setup JVisualVM
jvisualvm comes installed with JDK and is available in bin directory. File name is jvisualvm.exe
How to setup jstatd in linux
In order to do remote profiling, jstatd must be running on remote host. jstatd setup needs to complete in 6 steps
Replace 192.169.31.224 with the IP address of the remote host
Replace "/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/lib/tools.jar" with the actual path of tools.jar
To find actual path of tools.jar, if you have multiple jvm installed in linux, run following commands
Check Java using following command
Enter to keep the current selection[+], or type selection number:
Here current JVM path is "/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java" so enter this path in jstatd.sh
Check the path to tools.jar. Here tools.jar is available at multiple locations
Use chmod 777 -R /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/lib
To find running jstatd use following commands:-
[root@App31224 ~]# which jstatd
/usr/bin/jstatd
[root@App31224 ~]# ls -lart /usr/bin/jstatd
lrwxrwxrwx 1 root root 24 Oct 16 2010 /usr/bin/jstatd -> /etc/alternatives/jstatd
[root@App31224 ~]# ll /etc/alternatives/jstatd
lrwxrwxrwx 1 root root 49 Oct 15 2010 /etc/alternatives/jstatd -> /usr/lib/jvm/java-1.6.0-openjdk.x86_64/bin/jstatd
use chmod a+x jstatd.sh to make it executable
Finally run ./jstatd.sh
How to setup jstatd in windows
Run the "jstatd" command in a command window:
C:\Program Files\Java\jdk1.7.0_45\bin>jstatd.exe
Could not create remote object
access denied ("java.util.PropertyPermission" "java.rmi.server.ignoreSubClasses"
"write")
java.security.AccessControlException: access denied ("java.util.PropertyPermissi
on" "java.rmi.server.ignoreSubClasses" "write")
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:372)
at java.security.AccessController.checkPermission(AccessController.java:
559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.System.setProperty(System.java:783)
at sun.tools.jstatd.Jstatd.main(Jstatd.java:139)
The "access denied" error is expected, because "jstatd" requires a security policy file specified with the "java.security.policy" system property, if there is no security manager running on my machine.
Create the security policy file, jstatd.all.policy, that grants permissions to run "jstatd" and other tools in the tools.jar:
grant codebase "file:C:/Program Files/Java/jdk1.7.0_45/lib/tools.jar" {
permission java.security.AllPermission;
};
Run "jstatd" with the security policy file, tools.policy specified to the "java.security.policy" system property: