DataStax Help Center

Using JMX Clients with Apache Cassandra

Background

Apache Cassandra exposes many metrics and commands over JMX. Both nodetool and OpsCenter use JMX to get metrics from cassandra and invoke commands. However, some commands are not exposed via OpsCenter or nodetool, so the use of a general-purpose JMX client is necessary.  Here are some recommended JMX clients.

jconsole

jconsole is a graphical JMX client that is shipped with every JDK.  Since it is easy to use and readily available, it may seem like the natural choice. However, it may be difficult to use with a remote server since it requires a graphical interface and because JMX requires a large range of ports to be open in your firewall in order to connect remotely.  On the other hand, if you are monitoring a development server on your desktop, it may be the easiest choice. More details on using jconsole with Cassandra are covered in the documentation: http://www.datastax.com/docs/1.1/operations/monitoring#monitoring-using-jconsole.

MX4J

MX4J provides a web-based JMX interface that can be accessed remotely from a web browser and only requires one HTTP port open in your firewall.  Cassandra has built-in support for MX4J, but you must download it separately and put the JAR file in your classpath.  Instructions for installing and using MX4J on Cassandra available here: http://wiki.apache.org/cassandra/Operations#Monitoring_with_MX4J.

Once you have configured MX4J as directed, access the web interface, and you will see a list of available MBeans.  Select the desired bean and you will see a list of attributes and operations. From here you can view the read-only attributes, set writeable attributes, and invoke operations.

Note that allowing unrestricted access to JMX via MX4J may be a security risk. We recommend using a firewall to limit access to trusted IP addresses.

jmxsh

jmxsh provides a command-line interface to JMX.  It allows scripting in the TCL language, but you don't need to know TCL to use it.  You only need to learn a few simple commands to use it, and it also provides a menu-driven interface to browse the available MBeans, operations, and attributes.  Download the latest jxmsh from here: http://code.google.com/p/jmxsh/downloads/list, and review the documentation here: http://code.google.com/p/jmxsh/wiki/Summary.

To connect jmxsh to cassandra, type the following command (assuming you are running on the node you want to connect to and using the default JMX port):

java -jar jmxsh-R5.jar -h localhost -p 7199

Once connected, you can press enter at the prompt to enter the menu-driven MBean browser. It will allow you to select the desired MBean, attribute, or operation by pressing the number associated with the entry.  You can also enter commands you wish to run directly.

For example, to take a heap dump, type the following command:

jmx_invoke -m com.sun.management:type=HotSpotDiagnostic dumpHeap /path/to/heapdump.hprof false

To bulk load some SSTables (see http://www.datastax.com/dev/blog/bulk-loading for more details), enter the following command:

jmx_invoke -m org.apache.cassandra.db:type=StorageService bulkLoad /path/to/SSTables

 

Was this article helpful?
2 out of 2 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk