-
Notifications
You must be signed in to change notification settings - Fork 43
Preparing Standalone Cassandra on Local Machine
-
Download Cassandra from http://cassandra.apache.org/download/
-
Untar the package, put it in /opt/bin and setup other directories:
tar -zxvf apache-cassandra-1.2.1-bin.tar.gz
sudo mv apache-cassandra-1.2.1 /opt/cassandra
sudo mkdir -p /var/log/cassandra
sudo chown -R _USER_NAME_ /var/log/cassandra
sudo mkdir -p /var/lib/cassandra
sudo chown -R _USER_NAME_ /var/lib/cassandra
-
Add Cassandra binaries to path by adding the following line to ~/.profile
export PATH=$PATH:/opt/cassandra/bin
-
Run the following line to add the binaries to path without logging in again
source ~/.profile
-
Try to run it with:
`cassandra -f\´
If it does not work, try installing JDK version 7:
sudo apt-get install openjdk-7-jre-headless openjdk-7-jre-lib
sudo update-alternatives --config java
Pick the newest java available and try again:
cassandra -f
Create the file /etc/init.d/cassandra with the following content:
#!/bin/sh
# chkconfig: 2345 80 45
# description: Starts and stops Cassandra
# update deamon path to point to the cassandra executable
CASS_BIN=/opt/cassandra/bin/cassandra
CASS_PID=/var/run/cassandra.pid
start() {
if [ -f $CASS_PID ] && checkpid `cat $CASS_PID`; then
echo "Cassandra is already running."
exit 0
fi
echo -n "Starting Cassandra... "
$CASS_BIN -p $CASS_PID
echo "OK"
return 0
}
stop() {
if [ ! -f $CASS_PID ]; then
echo "Cassandra is already stopped."
exit 0
fi
echo -n "Stopping Cassandra... "
kill $(cat $CASS_PID)
echo "OK"
return 0
}
status_fn() {
if [ -f $CASS_PID ]; then
echo "Cassandra is running."
exit 0
else
echo "Cassandra is stopped."
exit 1
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status_fn
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
exit 1
esac
exit $?
Besides that, run the following line to make this file executable:
sudo chmod +x /etc/init.d/cassandra
For Ubuntu, make this to add cassandra to the initialization process:
sudo update-rc.d cassandra defaults
For other distributions:
chkconfig --add cassandra
chkconfig cassandra on
That's, restart your machine and test it!
The native transport protocol is how the ruby driver accesses Cassandra. To configure it, open /opt/cassandra/conf/cassandra.yaml and look for native_transport_protocol and set it to true
Restart Cassandra with:
/etc/init.d/cassandra restart
You're all set to play with Cassandra in development environment!