Tested on Tomcat, theoretically tried on any Java process, and any program that implements the JMX specification.
Modify the $catalina_home/bin/catalina.sh file and add the following JVM parameters
-DCOM.SUN.MANAGEMENT.JMXREMOTE.PORT=18100//Specify JMX connection ports
-dcom.sun.management.jmxremote.authenticate=false//this configuration is insecure. Any remote user who knows (or guesses) your JMX port number and host name would be able to monitor and control your Java AP Plication and platform. While it may was acceptable for development, it was not recommended for production systems. This parameter is enabled by default
-dcom.sun.management.jmxremote.pwd.file=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/management/ Jmxremote.password
-dcom.sun.management.jmxremote.ssl=false//default is True, need to specify
-dcom.sun.management.jmxremote.pwd.file the file path specified by this parameter, the default is under $jre_home/lib/management, The default is to have only one jmxremote.password.template file, copy this file into Jmxremote.password, modify the last 2 lines to specify the username password, such as: Monitorrole 123456 (Use this pair of username and password when connecting with Jconsole) of course, JVM parameters
-dcom.sun.management.jmxremote.authenticate=false, you can connect without a password
Enable JMX There are a number of other JVM parameters that can be configured, configured to use password connections and secure connections using SSL, and so on, not one to try, see http://docs.oracle.com/javase/6/docs/technotes/guides/ Management/agent.html.
The process also needs to modify the machine's hosts,
# vi/etc/hosts
127.0.0.1 (modified to machine IP) localhost localhost.localdomain localhost
Modify the Machine host name file (not modified, but to match with hosts):/etc/sysconfig/network
Note: After you add these JVM parameters to the catalina.sh file, you will be prompted to use the Jmxremote port when you run shutdown.sh. The reason is that running the shutdown.sh script starts a JVM and attempts to bind the Jmxremote port, causing the problem. See https://issues.apache.org/bugzilla/show_bug.cgi?id=36976. There is no way to solve it, the direct kill process (should be able to be resolved through configuration).