How to enable JMXRemote authentication and connect with JConsole

This tutorial will summarize how to setup a jmxremote access, so that a remote jconsole can be authenticated and connect.

We will be interested in 2 files, located in:
JAVA_HOME\jre\lib\management
  1. jmxremote.access
  2. jmxremote.password.template, rename to jmxremote.password
What needs to be done with these files:
  1. Add an admin role in jmxremote.access, so at the end you should see:
  2. monitorRole   readonly
    admin readonly
    controlRole readwrite \
    create javax.management.monitor.*,javax.management.timer.* \
    unregister
  3. Then we need to add the role and password in jmxremote.password
  4. monitorRole     secret
    controlRole secret
    admin secret
Then we need to restrict the owner's right to read-only, right clicking on the file and clicking read-only won't do. Need to execute the lines below:

cacls jmxremote.password /P :R
cacls jmxremote.access /P :R

Then for example I'm interested to monitor JBoss with JConsole. And I have added JBoss in eclipse's server view. I need to add the following in Program Arguments:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9001
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=true
-Dcom.sun.management.jmxremote.ssl=false

Assumming I want to use port 9001.

Refer to the image below:

Finally run jconsole in command prompt, select org.jboss.xxx and enter our admin and password which is admin / secret.

0 nhận xét:

Đăng nhận xét