Gabriel Cain

Using SSH Proxying with Jconsole to remote Cassandra instances

This guide leans heavily on the work of http://simplygenius.com/2010/08/jconsole-via-socks-ssh-tunnel.html — what I’ve done is collect his work into something a little more manageable for our environment.

Prerequisites

This guide assumes a few things are set up:

  1. That you’ve got ssh keys pushed around to do passwordless logins between your machine and your intermediate client machine
  2. That you’ve got cassandra up and running remotely
  3. That cassandra is listening on 8080 for it’s JMX service port

The Meat

This hunk of bash script is the meat of making this work.  Put the following in your .bashrc.  Make sure to edit proxy_host= to match your environment.

function jc {
    # set this to the host you'll proxy through.
    proxy_host="remoteuser@remotehost -p 22"    host=$1

    jmxport=8080
    proxy_port=${2:-8123}

    if [ "x$host" = "x" ]; then
        echo "Usage: jc <remote server> [proxy port]"
        return 1
    fi 

    # start up a background ssh tunnel on the desired port
    ssh -N -f -D$proxy_port $proxy_host 

    # if the tunnel failed to come up, fail gracefully.
    if [ $? -ne 0 ]; then
        echo "Ssh tunnel failed"
        return 1
    fi

    ssh_pid=`ps awwwx | grep "[s]sh -N -f -D$proxy_port" \
        | awk '{print $1}'`     echo "ssh pid = $ssh_pid"     # Fire up jconsole to your remote host     jconsole -J-DsocksProxyHost=localhost -J-DsocksProxyPort=$proxy_port \         service:jmx:rmi:///jndi/rmi://${host}:${jmxport}/jmxrmi     # tear down the tunnel     kill $ssh_pid }

Then, either close your shell, or source your .bashrc.  Then you should be able simply to call your function like so:

    host$ jc cassandra-host01

Jconsole will pop up, and log you in.

-Gabriel

Originally available at http://gabrielcain.com/blog/

Building Cassandra-Cacti-M6 on Centos 5.5

 

Turns out this is hard to do.    I’m writing this here for my benefit, and everyone else’s, too.  I’ve got a client using Cassandra, and of course you monitor that stuff.  So I figure that using the cassandra-cacti-m6 stuff is a good plan.  That’s cool, it works with Cacti.  Cacti’s pretty snazzy.   My customer is using Centos 5.5 on the monitoring box.  Turns out there are a lot of hoops to jump through for that to work.  So here’s what I did.

  1. Install jpackage-utils
  2. Install the jpackage.repo into /etc/yum.repos.d, and enable the rhel5 targets
  3. Install JDK6 Update 3 (because of the following step)
  4. Install java-1.6.0-sun-compat from ftp://jpackage.hmdc.harvard.edu/JPackage/5.0/generic/RPMS.non-free/

Then I go to install ANT, but I discover something — trying to install ant.noarch complains about “Missing Dependency: /usr/bin/rebuild-security-providers is needed by package”.  This sucks.  So I do some googling, and figure out that someone solved this issue on Centos 5.x.  I do what they did (documented at http://plone.lucidsolutions.co.nz/linux/centos/jpackage-jpackage-utils-compatibility-for-centos-5.x ).  This works great.  The package is built, I install it out of the local build dir.

Then I install ant.noarch and ant-nodeps.noarch.  These do the trick.

The I build cassandra-cacti-m6 as documented in its source tree.  Woo.

It took me a while to dig up and get all this working, but for you, I hope it’s fast and easy.  Enjoy!

-Gabriel

 

Syndicate content
Website by Digital Loom