Use the local JConsole to monitor remote JVM (the most authoritative summary)
Problem background
Stage 1Two types of configuration are found. Do you need to enter a password. JAVA_OPTS = "$ JAVA_OPTS-Dcom. sun. management. jmxremote. port = 60001 "JAVA_OPTS =" $ JAVA_OPTS-Dcom. sun. management. jmxremote. authenticate = false "JAVA_OPTS =" $ JAVA_OPTS-Dcom. sun. management. jmxremote. ssl = false "authenticate is false. When the jconsole is connected to a remote jvm, you do not need to enter the user name and password. Otherwise, you must configure the password file and password. You can specify the location of the password file JAVA_OPTS = "$ JAVA_OPTS-Dcom. sun. management. jmxremote. pwd. file =/root/soft/jdk7/jre/lib/management/jmxremote. password "I put these configurations in catalish. sh.Stage 2The above configuration encountered a problem. If it was the first time that the system started normally, but when shutdown, the system prompts that the port number is occupied. The problem is that when Tomcat is disabled, the jmxremote port number in Catalish is also executed.Solution: In the catalish. sh file, determine whether it is a start command. If it is a start command, set the variable. Otherwise, it is not set.Related scripts: JAVA_OPTS = "$ JAVA_OPTS-Xms256m-Xmx1024m-XX: PermSize = 128 M-XX: MaxPermSize = 256 m" 101If ["$1" = "start"];Then102 echo "set console"; 103 # JAVA_OPTS = "$ JAVA_OPTS-Xms256m-Xmx1024m-XX: PermSize = 128 M-XX: maxPermSize = 256 m "104 JAVA_OPTS =" $ JAVA_OPTS-Dcom. sun. management. jmxremote-Dcom. sun. management. jmxremote. port = 60001-Djava. rmi. server. hostname = 42.96.84.84 "; 105 JAVA_OPTS =" $ JAVA_OPTS-Dcom. sun. management. jmxremote. authenticate = false "; 106 Java _ opts =" $ JAVA_OPTS-Dcom. sun. management. jmxremote. ssl = false "; 107 # JAVA_OPTS =" $ JAVA_OPTS-Dcom. sun. management. jmxremote. pwd. file =/root/soft/jdk7/jre/lib/management/jmxremote. password "108 else109 echo" no startup "; 110 fi; 111
Stage 3After the above settings, the connection may fail. You need to configure "java. rmi. server. hostname" as the ip address of the machine, for example, "42.96.84.84 ". Restart Tomcat, connect to the remote JVM on the local Jconsole, and enter "42.96.84.84: 60001 ".Stage 4Log on and use the password for several hours, Nima. Note Question 1. -Dcom. sun. management. jmxremote. authenticate = true 2. -Dcom. sun. management. jmxremote. pwd. file specifies the correct password file 3. username and password (refer to jmxremote. password File) monitorRole can only read, controlRole can read and write security reasons in the configuration error, because the password is saved in: jmxremote in plaintext. password, so this file can only be read by the owner, not by others. Note that the owner has the rw permission in 600. 4. Users and permissions exist in jmxremote. access. Please note that most of the information on the Internet does not mention the true role of this document. I tried this file for a few hours before I realized that it was so powerful. Similar to SVN configuration, user name-permission, user name-password, and two configuration files. Fansunion readonly admin readwrite \ create javax. management. monitor. *, javax. management. timer. * \ unregisterJmxremote. passwordContent: fansunion 12345 admin 12345
References