JMX is a great tool to monitor a Java application like Alfresco, but it can be tricky to configure, especially if you are not on the same internal network as your server and you have to pass through a firewall. Usually, this is what happens when you deploy your application in the cloud : you have only a SSH connection to admin your server. In that case, SSH tunneling is a good solution to access the JMX server.
You can connect to your Alfresco JMX server from 2 different URL's:
- service:jmx:rmi:///jndi/rmi://localhost:50500/jmxrmi : this is the standard Java JMX URL
- service:jmx:rmi:///jndi/rmi://localhost:50500/alfresco/jmxrmi : this is the JMX Alfresco URL
- set a static port for the second (server) RMI connection
- set the hostname for the second (server) RMI connection
- creates a tunnel for the first (registry) connection
- creates a tunnel for the second (server) connection
- We need to add the property
monitor.rmi.services.port=50510
to alfresco-global.properties, in order to set the static port for the RMI server connection - We need to modify alfresco.sh to set the hostname by adding
-Djava.rmi.server.hostname=jmxhost
to the JAVA_OPTS.
- We need to add
127.0.0.1 jmxhost
to /etc/hosts - Then we can create the 2 ssh tunnels for the RMI registry and server connections:
ssh -f user@theserver.com -L 2000:localhost:50500 -N
ssh -f user@theserver.com -L jmxhost:50510:localhost:50510 -N
com.sun.management.jmxremote.rmi.port
. As the next Alfresco 4.2 will support Java 1.7, it will become an option.