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?
远程监控密码身份验证默认情况下启用。 要禁用它,设置下面的系统属性,当你启动JVM:-Dcom.sun.management.jmxremote.authenticate =假像你在第二个测试完成,但您需要添加系统属性-Dcom.sun.management.jmxremote
尝试添加这些JVM参数去env中的文件和更新主机IP
-Djava.net.preferIPv4Stack =真-Djava.rmi.server.hostname = XXXX
UPDATE
因此,要恢复,我认为你尝试的第一步是最好的,为使其工作的这些步骤如下:
恢复所有的JMX ENV文件的变化,这样的:
# 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"
<broker useJmx="true" ...
<managementContext> <managementContext createConnector="true" connectorPort="1099" /> </managementContext>
验证在AMQ记录你有
INFO | JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi | org.apache.activemq.broker.jmx.ManagementContext | JMX connector
注意:假设10.10.10.16
是AMQ主机的IP。
尝试用JConsole的另一台机器比AMQ主机与URL连接"service:jmx:rmi:///jndi/rmi://10.10.10.16:1099/jmxrmi"
而无需用户名/密码。
如果您无法连接,尝试这样的:
<managementContext> <managementContext createConnector="true" connectorPort="1099" connectorHost="10.10.10.16" /> </managementContext>
验证在AMQ记录你有
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
重试连接,第4步
在这一步,通常你可以用JConsole的连接。
- 如果你想添加的安全性和授权,使用:
<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>
请尝试以下步骤,让我知道在哪一个你无法连接,并从JConsole中提供错误信息。
一对夫妇的故障排除步骤:
开始在同一系统上的JConsole或VisualVM的,并使用“PID”连接方法进行连接。 浏览MBean和确认org.apache.activemq豆类存在
运行netstat -na并确认端口1099(44444和)在LISTEN
看日志,确认你没有任何“java.net.BindException:地址已在使用。”指示与一个已经运行的Java进程端口冲突的消息。
编辑斌/ env的配置JMX(这需要禁用SSL,设置端口1099和禁用需要用户名和密码。
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"