This article only applies to hostspot virtual machines
Step 1: Write a test policy file named test. Policy and specify that you can access tools. Jar. The content is as follows:
Grant codebase "file: $ {java. Home}/../lib/tools. Jar "{
Permission java. Security. allpermission;
};
Step 2: compile a test program testjvisualvm. Java:
Import Java. util. hashmap; import Java. util. map;/***** test the jvisualvm monitoring function **/public class testjvisualvm {public static void main (string [] ARGs) throws interruptedexception {// simulate the resource-consuming part for (INT I = 0; I <100; I ++) {Map <string, string> map = new hashmap <string, string> (); map. put ("" + I, "" + I); thread t = new thread () {public void run () {try {thread. sleep (200*1000);} catch (interruptedexception e) {e. printstacktrace () ;}}; T. start (); // sleep 1sthread. sleep (1000 );}}}
Step 3: compile:
Javac-encoding utf8 testjvisualvm. Java
Step 4: run:
Java-djava. Security. Policy = test. Policy -djava.net. preferipv4stack = true
-DCOM. Sun. Management. jmxremote. Port = 10990-DCOM. Sun. Management. jmxremote. SSL = false-DCOM. Sun. Management. jmxremote. Authenticate = false testjvisualvm
Step 5: Configure jvisualvm
Add the remote host and then the remote JMX port. The port must be the same as the one specified in-DCOM. Sun. Management. jmxremote. Port = 10990 in the startup file.
Click OK and double-click it. If it is displayed, the configuration is normal:
If an error occurs:
Check the port. If 0: 10990 is displayed
Check parameter: -djava.net. preferipv4stack = true
[Ssergsw @ JAZX5FVM-121-119 Dubbo-antifraud] $ netstat-an | grep 10990
TCP 0 0: 10990: * listen
If you see the following listener, you should be able to access it normally:
[Ssergsw @ JAZX5FVM-121-119 Dubbo-antifraud] $ netstat-an | grep 10990
TCP 0 0 0.0.0.0: 10990 0.0.0.0: * listen