How do you enable JMX in Websphere?

2019-01-07 04:23发布

I would like to use JConsole to monitor my Websphere application, but I am not sure how to enable JMX.

12条回答
Evening l夕情丶
2楼-- · 2019-01-07 05:08

You can find the correct port to connect to on the WebSphere Application Server under Communications -> Ports. The port associated with BOOTSTRAP_ADDRESS allows you to connect.

查看更多
戒情不戒烟
3楼-- · 2019-01-07 05:08

from http://malliktalksjava.in/2010/07/26/enable-jmx-remote-port-in-websphere/

  1. Login to Admin console of the web sphere any profile(server), short cut will be available in start menu programs.

    • Deploy the PerfServletApp.ear application if not deployed already.
    • Check if PerfServletApp.ear is deployed:
      • Exapnd Applications +> Application Types +> WebSphere Enterpise Applications
      • If not, click New Application.
    • Browse from WebSphere directory -> AppServer -> InstallableApps.
    • (FOLLOW THE STEPS.)
  2. Enable the PMI Data and set all the statistics enabled.

    • In left pane (bottom), go to Monitoring and Tuning +> Performance Monitoring Infrastructure(PMI)
    • In Configuration tab, enable the PMI.
    • In this Configuration tab, and the Runtime tab, set All statistics. Then Save changes.
  3. Set JVM argument

    • In Severs +> Server Types +> WebSphere Application Servers, then -> [server-name] +> Process definition -> Java Virtual Machine
    • Set the generic jvm argument to include

      -Djavax.management.builder.initial= -Dcom.sun.management.jmxremote

    in shows the servers list. click on the server you want.

    • In the right pane -> Server Infrastructure -> Java and Process Management click on Process definition, again in Additional Properties of Configuration tab click on Java Virtual Machine. put the -Djavax.management.builder.initial= -Dcom.sun.management.jmxremote in Generic Jvm Argument field and save changes.
  4. To enable the JMX remote port open the following properties file and add the code that follows. In [WebSphere-directory]\AppServer\java\jre\lib\management\management.properties, add:

    com.sun.management.jmxremote.port=9001
    com.sun.management.jmxremote.ssl=false
    com.sun.management.jmxremote.authenticate=false
    
  5. Save the master data, stop the server, and start the server to load the changes.

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-01-07 05:14

I couldn't get this to work. All I got was

The connection to username@service:jmx:iiop//localhost:2809/jndi/JMXConnector did not succeed. Would you like to try again?

I did however get it working by doing the following:

  1. Add "-Djavax.management.builder.initial= -Dcom.sun.management.jmxremote" to the Generic JVM Argument.
  2. Add these lines to WebSphere/AppServer/java/jre/lib/management/management.properties
com.sun.management.jmxremote.port=9999
com.sun.management.jmxremote.authenticate=false
com.sun.management.jmxremote.ssl=false

But none of the usefull mbeans show up..?

查看更多
够拽才男人
5楼-- · 2019-01-07 05:17

Following information is for Websphere 6.1 on Windows.

First of all, the magic URL to connect to the MBean server is:

service:jmx:iiop://<host>:<port>/jndi/JMXConnector

If you have a default Websphere installation, the JNDI port number will likely be 2809, 2810, ... depending on how many servers there are installed on one system and the specific one you want to connect to. To be sure, when starting Websphere, check the logs, as it will dump a line like

0000000a RMIConnectorC A   ADMC0026I: The RMI Connector is available at port 2810

If you don't get this line, open the Websphere admin console and go to

Application servers > server1 > Administration Services > JMX connectors

to see if you need to add or change the config.

Second important bit of information is that the following JAR is always needed when doing JMX with the server:

com.ibm.ws.admin.client_6.1.0.jar

You can find this JAR in the the runtimes directory of Websphere. Whatever you do, whether programmatically accessing MBeans on Websphere, or using JConsole, and so on, use the magic URL and always include this JAR.

For the remainder of this answer, assume that Websphere is installed in D:\prog\was61.

To run JConsole, type in the following:

D:\prog\was61\java\bin>jconsole -J-Djava.class.path=d:\prog\was61\java\lib\tools.jar;D:\prog\was61\runtimes\com.ibm.ws.admin.client_6.1.0.jar

Then go to the "Advanced" tab and type in the magic JMX URL. Press connect and you should see the MBeans appear.

Using a Sun JDK is an entirely different matter. You need one extra JAR that is in the lib of the IBM JDK but not Sun's (ibmorb.jar), and maybe the following command may work for you:

C:\Program Files\Java\jdk1.5.0_11\bin>jconsole -J-Djava.class.path="c:\Program Files\Java\jdk1.5.0_11\lib\jconsole.jar";"c:\Program Files\Java\jdk1.5.0_11\lib\tools.jar";D:\prog\was61\runtimes\com.ibm.ws.admin.client_6.1.0.jar;D:\prog\was61\java\jre\lib\ibmorb.jar

I say maybe, because it didn't work for me. I got a nice jndiUnavailCommErr error message, since it expected something on port 2809 while my Websphere installation is listening on 2810, although I correctly specified port 2810 in the JMX URL. But, if you adapt the paths to point to your Sun JDK, it might work for you. It's the closest I ever got to connecting to Websphere using Sun's JDK.

Final note: I tried a solution based on RMI, there is also a SOAP connector available but haven't tried it.

As always with J2EE, Websphere and stuff: good luck, you'll need it.

查看更多
贪生不怕死
6楼-- · 2019-01-07 05:17

It is simple. Just start Websphere with the following JMX parameters:

-Djavax.management.builder.initial= 
-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.port=1099

Then start JConsole or VisualVM and connect to localhost:1099

Since i am not allowed to post a proof screenshot i post the information from the visualvm "overview tab".

PID: 12568
Host: localhost
Main class: <unknown>
Arguments: <none>
JVM: IBM J9 VM (2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223-20100808 (JIT enabled)
J9VM - 20100629_60535_lHdSMr
JIT - 20100623_16197_r8
GC - 20100211_AA)
Java: version 1.5.0, vendor IBM Corporation
Java Home: C:\Program Files\IBM\SDP\runtimes\base_v61\java\jre
JVM Flags: <none>
Heap dump on OOME: disabled
查看更多
Melony?
7楼-- · 2019-01-07 05:17

I found that in order to connect to WAS 6.1 using the Sun JDK JConsole, in addition to the com.ibm.ws.admin.client_6.1.0.jar JAR file, I had to also include the following 3 JARs on the boot class path when starting JConsole:-

ibmorbapi.jar
ibmorb.jar
ibmcfw.jar

These can be found in the java\jre\lib directory of websphere.

For example on windows, if you copy all the four JARs listed above to a directory of your choice (i've copied them to C:\packages\was61-jmx in the example below), you can use a batch file like the following to start JConsole:-

set JAVA_HOME=C:\Progra~1\Java\jdk1.5.0_20
set WAS6.1_JARS=C:\packages\was61-jmx

set BOOTJARS=%WAS6.1_JARS%\ibmorbapi.jar
set BOOTJARS=%BOOTJARS%;%WAS6.1_JARS%\ibmorb.jar
set BOOTJARS=%BOOTJARS%;%WAS6.1_JARS%\ibmcfw.jar

set CLASSPATH=%WAS6.1_JARS%\com.ibm.ws.admin.client_6.1.0.jar
set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\tools.jar
set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\jconsole.jar


%JAVA_HOME%\bin\jconsole  -J-Xbootclasspath/p:%BOOTJARS% -J-Djava.class.path=%CLASSPATH%

This worked for me for jdk 1.5 and 1.6 versions of the Sun Jconsole.

查看更多
登录 后发表回答