Nov 132009
 

I’ve deployed Cassandra to my development environment, running on 4 servers with replica 2. I picked the number 4 and 2 because it’s more like a real world thing, and it is the requirement from my friend. I can test fail-over etc later on.

I’ve also composed some scripts to do service stuffs – the script I composed can start/stop/restart Cassandra gracefully, it can also tell status of the node and the cluster, it’s a simple Shell script, I will make it a service under Fedora, and a init.d script under Ubuntu (I’m running only these two platform now). Cassandra was upgrade from 0.4.1 to 0.4.2 days ago, and I used that as a chance to test my deployment stuffs, seems pretty good. I think I just need to be careful with 0.4.x => 0.5.x upgrade since it may break compatibility on configuration and command line.

I’ve converted my PowerBook to a dedicated client machine running Fedora … it’s a pretty old machine and seems Apple does not want to roll out new software (such as JDK 1.6) for it, so I did some survey around and picked Fedora (Ubuntu is not ppc friendly – the support is community based).

And finally I have Thrift/PHP up and running. At the very beginning I was thinking I should use Java as the client but later one found that I have no idea how to develop Java based web application, and since Thrift mentioned it supports all C/C++, Java, Perl, PHP, Ruby, Python pretty well, I should just pick my favorite language to do the test and then let real clients pick what theyย  want to use (where is my client, BTW? ๐Ÿ™ ).

And yes, I confirmed the schema (though Cassandra is schema-less thing), I’m going to test the schema with PHP client today. After that I will have to find a place to hold all my codes/configuration, etc, in a subversion, and based on what I found so far, github.com is the best candidate.

Will update here today or tomorrow.

  2 Responses to “Update on research”

  1. Any chance that you can post the scripts that “start/stop/restart Cassandra gracefully”

    I am trying to do the same thing … but having difficulty.

    Thanks in advance for any help you can provide.

  2. Here we go, it works with 0.6.4 at least, as I stopped playing with Cassandra after that. I cannot recall if I wrote the script all by myself or I actually changed an existing one from someone else, but anyway:

    #!/bin/sh
    #
    # cassandra     This shell script takes care of starting and stopping
    #               the Cassandra service.
    #
    # chkconfig: - 30 60
    # description: Cassandra is a highly scalable, eventually consistent,
    #              distributed, structured key-value store.
    # probe: true
    
    ### BEGIN INIT INFO
    # Provides: cassandra
    # Required-Start: network autofs syslog
    # Should-Start: network autofs syslog
    # Required-Stop: $autofs $network $syslog
    # Should-Stop: $autofs $network $syslog
    # Default-Start:  2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start up the Cassandra server sevice
    # Description: Cassandra is a highly scalable, eventually consistent,
    #              distributed, structured key-value store.
    ### END INIT INFO
    
    CASSANDRA_HOME=/net/f5/shared/nosql/cassandra/current
    HOSTNAME=$(hostname)
    DATA_DIR=/var/lib/cassandra
    
    export JVM_OPTS=" \
            -Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n \
            -Xms256M \
            -Xmx384M \
            -XX:SurvivorRatio=8 \
            -XX:TargetSurvivorRatio=90 \
            -XX:+AggressiveOpts \
            -XX:+UseParNewGC \
            -XX:+UseConcMarkSweepGC \
            -XX:CMSInitiatingOccupancyFraction=1 \
            -XX:+CMSParallelRemarkEnabled \
            -XX:+HeapDumpOnOutOfMemoryError \
            -Dcom.sun.management.jmxremote.port=8080 \
            -Dcom.sun.management.jmxremote.ssl=false \
            -Dcom.sun.management.jmxremote.authenticate=false"
    
    export CASSANDRA_CONF=/etc/cassandra
    export CASSANDRA_INCLUDE=/dev/null
    export CLASSPATH=$(find $CASSANDRA_HOME/lib -name \*.jar | tr "\n" ":")
    if [ -d $CASSANDRA_HOME/build/ ] ; then
        export CLASSPATH=$CLASSPATH$(find $CASSANDRA_HOME/build/ -name \*.jar | tr "\n" ":")
    fi
    
    PATIENCE=30
    start() {
        $CASSANDRA_HOME/bin/nodetool -h $HOSTNAME info >/dev/null 2>&1
        if [ $? -eq 0 ] ; then
            echo "There is already an instance running"
            return
        fi
    
        $CASSANDRA_HOME/bin/cassandra -p $DATA_DIR/cassandra.pid > $DATA_DIR/rc.log 2>&1
        if [ $? -ne 0 ] ; then
            echo "Unable to start Cassandra"
            return
        fi
    
        echo -n Waiting for Cassandra warm up .
        for RETRY in $(seq 1 $PATIENCE) ; do
            $CASSANDRA_HOME/bin/nodetool -h $HOSTNAME info >/dev/null 2>&1
            [ $? -eq 0 ] && break
            echo -n .
            sleep 1
        done
    
        echo
        $CASSANDRA_HOME/bin/nodetool -h $HOSTNAME info >/dev/null 2>&1
        if [ $? -eq 0 ] ; then
            echo "Cassandra started"
        else
            echo "Cassandra was not started"
        fi
    }
    
    stop() {
        $CASSANDRA_HOME/bin/nodetool -h $HOSTNAME info >/dev/null 2>&1
        if [ $? -ne 0 ] ; then
            echo "There is no instance running"
            return
        fi
    
        [ -f $DATA_DIR/cassandra.pid ] && kill $(cat $DATA_DIR/cassandra.pid) >/dev/null 2>&1
        rm -f $DATA_DIR/cassandra.pid
        lsof -P | grep TCP | grep :7000 | grep LISTEN | awk '{print $2}' | xargs -r kill
        echo -n Waiting for Cassandra terminate .
        for RETRY in $(seq 1 $PATIENCE) ; do
            $CASSANDRA_HOME/bin/nodetool -h $HOSTNAME info >/dev/null 2>&1
            [ $? -ne 0 ] && break
            echo -n .
            sleep 1
        done
        echo
    
        $CASSANDRA_HOME/bin/nodetool -h $HOSTNAME info >/dev/null 2>&1
        if [ $? -eq 0 ] ; then
           echo "Cannot stop Cassandra"
        else
           echo "Cassandra stopped"
        fi
    }
    
    status() {
        unset CASSANDRA_INCLUDE
        $CASSANDRA_HOME/bin/nodetool -h $HOSTNAME info >/dev/null 2>&1
        if [ $? -eq 0 ] ; then
            $CASSANDRA_HOME/bin/nodetool -h $HOSTNAME $1
        else
            echo "Cassandra is not running"
        fi
    }
    
    case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        restart)
            stop
            start
            ;;
        status)
            status info
            ;;
        ring)
            status ring
            ;;
        *)
            echo $"Usage: $(basename $0) {start|stop|restart|status|ring}"
            exit 2
    esac
    

Sorry, the comment form is closed at this time.