Installing Cassandra in your local machine for experimental or development purposes is as easy as downloading and unzipping the tarball (the .tar
compressed file). For development purposes, Cassandra does not have any extreme requirements. Any modern computer with 1 GB of RAM and a dual core processor is good to test the water. Anything higher than that is great. All the examples in this chapter are done on a laptop with 4 GB of RAM, a dual core processor, and the Ubuntu 13.04 operating system. Cassandra is supported on all major platforms; after all, it's Java. Here are the steps to install Cassandra locally:
# Check if you have Java ~$ java -version java version "1.7.0_21" Java(TM) SE Runtime Environment (build 1.7.0_21-b11) Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
If you do not have Java, you may want to follow the installation details for your machine from the Oracle Java website (http://www.oracle.com/technetwork/java/javase/downloads/index.html).
Uncompress this file to a suitable directory.
# Download Cassandra $ wget http://archive.apache.org/dist/cassandra/1.1.11/apache-cassandra-1.1.11-bin.tar.gz # Untar to /home/nishant/apps/ $ tar xvzf apache-cassandra-1.1.11-bin.tar.gz -C /home/nishant/apps/
The unzipped file location is /home/nishant/apps/apache-cassandra-1.1.11
. Let's call this location CASSANDRA_HOME
. Wherever we refer to CASSANDRA_HOME
in this book, always assume it to be the location where Cassandra is installed.
$CASSANDRA_HOME/conf/cassandra.yaml
.cluster_name: 'nishant_sandbox'
data_file_directories: - /home/nishant/apps/data/cassandra/data
commitlog_directory: /home/nishant/apps/data/cassandra/commitlog
saved_caches_directory: /home/nishant/apps/data/cassandra/saved_caches
$CASSANDRA_HOME/conf/log4j-server.properties
:log4j.appender.R.File=/tmp/cassandra.log
With this, you are ready to start Cassandra. Fire up your shell, and type in $CASSANDRA_HOME/bin/cassandra -f
. In this command, -f
stands for foreground. You can keep viewing the logs and Ctrl + C to shut the server down. If you want to run it in the background, do not use the -f
option. The server is ready when you see Bootstrap/Replace/Move completed! Now serving reads
in the startup log as shown:
$ /home/nishant/apps/apache-cassandra-1.1.11/bin/cassandra -f xss = -ea -javaagent:/home/nishant/apps/apache-cassandra-1.1.11/bin/../lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms1024M -Xmx1024M -Xmn200M -XX:+HeapDumpOnOutOfMemoryError -Xss180k INFO 20:16:02,297 Logging initialized [-- snip --] INFO 20:16:08,386 Node localhost/127.0.0.1 state jump to normal INFO 20:16:08,394 Bootstrap/Replace/Move completed! Now serving reads.
3.145.70.38