Remote monitoring of jboss application java memory configuration (actual test)
Preface
This is because a Java memory overflow problem occurs when the last project is deployed on the client side for about a month. to constantly monitor the java memory, you need to remotely view the java memory on the server. The company simulated the deployment of remote monitoring of Linux project running.
1. Two visual monitoring tools that come with jdk1.6 are briefly introduced.
Jconsole: Java 6.x uses JMX to provide a series of APIS for monitoring and managing virtual machines. The JConsole released with the SDK uses these APIs to monitor virtual machines. JConsole can provide the memory, thread, class loading, MBean, and other information of the monitored virtual machine, so as to monitor the running status of the server in real time.
JVisualVM: a sub-project of Netbeans profile, which is automatically included in JDK6.0 update 7 (no specific parameters are required when java is started, and the monitoring tool is in bin/jvisualvm.exe) to monitor threads and memory, view the CPU time and memory objects of the method, GC objects, and reverse view the allocated stack (for example, which of the 100 String objects are allocated ).
2. If you are using Windows series computers to view the local memory, you can directly find the jdk installation path and double-click the visualization monitoring tool mentioned above.
3. If you want to monitor the remote java memory, you can configure it accordingly.
- Running Environment
Server: Redhat6.0 + JDK 1.6 + Jboss5.1
IP Address: 192.168.1.250
Client: Windows + JDK 1.6
2. You only need to modify run. sh in bin in jboss without configuring parameters with username and password (very simple. Add the text in red below the sentence.
JAVA_OPTS = "-Dprogram. name = $ PROGNAME $ JAVA_OPTS"
JAVA_OPTS = "$ JAVA_OPTS-Dcom. sun. management. jmxremote. port = 9999"
JAVA_OPTS = "$ JAVA_OPTS-Dcom. sun. management. jmxremote. authenticate = false"
JAVA_OPTS = "$ JAVA_OPTS-Dcom. sun. management. jmxremote. ssl = false"
JAVA_OPTS = "$ JAVA_OPTS-Djava. rmi. server. hostname = 192.168.1.250"
Note:
1. 9999 indicates the monitored port number, so that the specified port is not occupied;
2. You can use netstat-an to view the occupied ports;
3. Use lsof-I: portnum to view the specific application that uses the port;
4. If the Firewall service is enabled, ensure that the port can be accessed through the firewall;
5. 192.168.1.250 is the IP address of the current server;
3. Start the JBoss Server
./Run. sh-B 192.168.1.250 & the address bound to the Jboss server must be specified through the-B parameter;
Allow all users to connect to-B 0.0.0.0
4. connect to a remote VM
Start JConsole under the directory % JAVA_HOME % \ bin of the local machine,
In the "Remote Process:" dialog box, enter 192.168.1.250: 9999 and click "Connect", as shown in:
Additional: parameter configuration with username and password
1. Modify run. sh under bin in jboss. Add the text in red below the sentence
JAVA_OPTS = "-Dprogram. name = $ PROGNAME $ JAVA_OPTS"
JAVA_OPTS = "$ JAVA_OPTS-Dcom. sun. management. jmxremote. port = 9999"
JAVA_OPTS = "$ JAVA_OPTS-Dcom. sun. management. jmxremote. authenticate = true"
JAVA_OPTS = "$ JAVA_OPTS-Dcom. sun. management. jmxremote. ssl = false"
JAVA_OPTS = "$ JAVA_OPTS-Djava. rmi. server. hostname = 192.168.1.250"
JAVA_OPTS = "$ JAVA_OPTS-Dcom. sun. management. jmxremote. password. file =/usr/java/jdk1.6/jre/lib/management/jmxremote. password"
Note that jmxremote. password in $ JAVA_HOME/jre/lib/management/jmxremote. password is copied from the original jmxremote. password. template,
Remove the username before monitorRole QED # If you do not change the logon Username: monitorRole password: QED (you can change the username and password as needed, but if you do change the password
Is the permission to modify the corresponding name in jmxremote. access.
2. If this problem or error occurs during startup
The reason is that the permission of jmxremote. password is incorrect. Run chmod 600jmxremote. password in the file path.
Start the project as per 3.
4. For JVisualVM, add a Remote ip address to Remote in the tree structure, right-click the ip address, add the JMX link, and add the port number and user name and password to the link ,: