jmx doesnt seem to be working with activeMQ

2019-07-29 05:20发布

I'm trying to use JMX with activeMQ for monitoring so far I've been using this and this as a reference but so far I'm unable to connect to jmx remotely and also I don't see any mention of jmx url in activemq logs. I'm wondering if there is another way to make sure jmx is working? is it supposed to be indicated in activemq logs? PS I'm using jdk1.7 and activeMQ 5.14.2.

Thanks in advance!

EDIT

I set useJmx="true" in my activemq.xml file:

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="primary" useJmx="true" dataDirectory="${activemq.data}">

I tried two steps:

FIRST

I tried changing management context from createConnector="false" to :

<managementContext>
   <managementContext createConnector="true" connectorPort="1099"/>
</managementContext>

FOR FIRST TIME THE PORT IS OPEN AND ACTIVEMQ RUNS FINE AND JMX URL GETS REPORTED IN LOGS ALTHOUGH I CAN NOT CONNECT IT TO IT REMOTLEY BUT IM ASSUMING ITS WORKING

SECOND

I reverted back the changes I made for managmentContext and I tried setting:

ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_BASE}/jmx.password -Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_BASE}/jmx.access"

in bin/activemq script and I set a username in conf/jmx.access file as:

admin readwrite

And also have set a password in conf/jmx.password:

admin activemq

NOW ACTIVEMQ IS NOT RUNNINT AT ALL BUT IT WILL RUN IF I SET AUTHENTICATE=FALSE AND DELETE JMX.ACCESS AND JMX.PASSWORD CONFIGURATION IN BIN/ACTIVEMQ FILE BUT I NEED USER NAME AND PASSWORD FOR SECURITY REASONS I found this post which has the exact same issue as mine. any ideas?

标签: activemq jmx
2条回答
\"骚年 ilove
2楼-- · 2019-07-29 05:23

Password authentication for remote monitoring is enabled by default. To disable it, set the following system property when you start the JVM: -Dcom.sun.management.jmxremote.authenticate=false like you done in second test but you need to add system property -Dcom.sun.management.jmxremote

Try to add these jvm param to env file and update host ip

-Djava.net.preferIPv4Stack=true -Djava.rmi.server.hostname=X.X.X.X

UPDATE

SO, to resume, i think that the FIRST step you tried is the best, for making it working these are the steps :

  1. revert all jmx env file changes, like this :

        # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.port=1099 "
        # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_CONF}/jmx.password"
        # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_CONF}/jmx.access"
        # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false"
        ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote"
    
  2. <broker useJmx="true" ...

<managementContext>
  <managementContext createConnector="true"  connectorPort="1099" />
</managementContext>

verify that in AMQ logs you have

INFO | JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi | org.apache.activemq.broker.jmx.ManagementContext | JMX connector

NOTE : Assuming that 10.10.10.16 is the IP of AMQ host.

  1. try to connect with jconsole from another machine than AMQ host with url "service:jmx:rmi:///jndi/rmi://10.10.10.16:1099/jmxrmi" without user/pwd.

  2. if you cannot connect, try like this :

    <managementContext>
      <managementContext createConnector="true"  connectorPort="1099"  connectorHost="10.10.10.16" />
    </managementContext>
    

verify that in AMQ logs you have

INFO | JMX consoles can connect to service:jmx:rmi:///jndi/rmi://10.10.10.16:1099/jmxrmi | org.apache.activemq.broker.jmx.ManagementContext | JMX connector

  1. retry to connect, step 4

  2. at this step normally you can connect with jconsole.

  3. if you want to add security and authorizations, use this :
<managementContext>
  <managementContext  createConnector="true"  connectorPort="1099"  connectorHost="10.10.10.16" >
      <property xmlns="http://www.springframework.org/schema/beans" name="environment">
          <map xmlns="http://www.springframework.org/schema/beans">
              <entry xmlns="http://www.springframework.org/schema/beans" key="jmx.remote.x.password.file"
                     value="${activemq.conf}/jmx.password"/>
              <entry xmlns="http://www.springframework.org/schema/beans" key="jmx.remote.x.access.file"
                     value="${activemq.conf}/jmx.access"/>
          </map>
      </property>
  </managementContext>
</managementContext>

Please try these steps and let me know in which one you fails to connect and provide error message from jconsole.

查看更多
聊天终结者
3楼-- · 2019-07-29 05:35

A couple troubleshooting steps:

  1. Start jconsole or visualvm on the same system and connect using the "pid" attach method. Browse the MBeans and confirm org.apache.activemq beans are present

  2. Run netstat -na and confirm ports 1099 (and 44444) are in LISTEN

  3. Look at logs and confirm you do not have any "java.net.BindException: Address already in use.." messages that indicate a port conflict with an already running Java process.

Edit bin/env to configure JMX (this disables requiring SSL, sets the port to 1099 and disables requiring username and password.

ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.port=1099 "
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false "
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote "
# ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_CONF}/jmx.password"`
# ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_CONF}/jmx.access"
查看更多
登录 后发表回答