`

Connecting VisualVM with a remote JBoss AS 7 / EAP6 JVM process

阅读更多

http://blog.akquinet.de/2012/11/01/connecting-visualvm-with-a-remote-jboss-as-7-eap6-jvm-process/

VisualVM is a useful tool for monitoring and simple profiling of JVM processes. It integrates various command line tools of the JDK such as jstat, jinfo, jstack into a graphical UI. The tool is part of the JDK since 1.6.0_07.

VisualVM start screen

VisualVM discover local and remote JVM processes. There are two different way to connect a remote host and JVM processes:

  1. jstatd connection
  2. jmx connection

To auto discover remote processes it is necessary to start a jstat daemon with the appropriate security policy for native permissions. But this is out of scope in this post. We will cover and explain how to create a JMX connection to an EAP6 instance or respectively a JBoss AS7 instance with VisualVM. This has also the benefit, that we can use more capabilities of VisualVM and we get more information for profiling.

 

Connecting a remote EAP6 / AS7 JVM process

Connecting VisualVM to a remote EAP6 / AS7 JVM process is quit easy. The application server supports the JMX Remote API for remote management and monitoring (JSR 160). Therefor, JBoss implements a JSR 160 compliant JMXConnector instead of an RMI interface to establish a connection to a JMX MBeanServer form a remote client. There is no need for any additional JVM options. The JMXConnector uses under the hood JBoss Remoting for the transport and by default the native management endpoint of the AS7 if the server is running in the standalone mode. To access the management endpoints a management user in the realm ManagementRealm is required. If no user exists, you can use the add-user script from the EAP6 / AS7 distribution. You can create a user as follows:

$JBOSS_HOME/bin/add-user.sh username password

If you are running your server or multiple server instances in the domain mode the JMXConnector uses the remoting connector. To establish a connection over the remoting connector a user in the realm ApplicationRealm is required. You can create a user for the ApplicationRealm with the option -a as follows:

$JBOSS_HOME/bin/add-user.sh -a username password

The configuration is located in the JMX subsystem. You can use the command line interface (CLI) of the application server to see a full description of all possible configurations:

 

$JBOSS_HOME/bin/jboss-cli.sh

[disconnected /] connect --controller

...

[standalone@hostname:9999 /] /subsystem=jmx :read-resource-description(recursive=true)

 

Note that the management interface must be accessible in both modes from a remote client. You can bind the management interfaces at server startup by setting this system property:

Standalone Mode

$JBOSS_HOME/bin/standalone.sh –Djboss.bind.address.management=

Domain Mode

$JBOSS_HOME/bin/domain.sh –Djboss.bind.address.management=

 

Starting VisualVM with the necessary libraries to connect JMX over JBoss Remoting

As already mentioned before, the JMX MBeanServer is accessible using JBoss Remoting through the management connection. Therefore, it is necessary to add the following libaries from the modules directoriy of the EAP6 / AS7 distribution to the classpath of VisualVM:

  • org/jboss/remoting3/remoting-jmx
  • org/jboss/remoting3
  • org/jboss/logging
  • org/jboss/xnio
  • org/jboss/xnio/nio
  • org/jboss/sasl
  • org/jboss/marshalling
  • org/jboss/marshalling/river

To start VisualVM, you can also use the attached script and copy it into the bin directory of the EAP6 / AS7 distribution.

$JBOSS_HOME/bin/visualvm.sh

Configure VisualVM for a remote connection

The next step is to add a Remote Host as shown in the following screenshots of VisualVM.

 


 After that you need to configure a JMX connection as shown in the screenshot below. We need to use a JMX Service URL to identify the JSR-160 compliant JMXConnectorServer of the AS7 to establish a connection from VisualVM with the form service:jmx:PROTOCOL://IP:PORT.




 

The service URL begins always with service:jmx: followed by the protocol, host and port. The protocol is JBoss specific and named remoting-jmx. If you are running the server in the standalone mode the default port of the native management interface is 9999. The default port of the remoting connector in the domain mode is 4447 plus port offset, if configured.

For authentication the credentials of the management user in standalone mode or the credentials of the application user in domain mode are required.

After a successful connection via JMX, you should see the following screen.

 

  • 大小: 12.4 KB
  • 大小: 19.3 KB
  • 大小: 22.8 KB
  • 大小: 23.1 KB
  • 大小: 20.4 KB
  • 大小: 26.6 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics