Setup Cassandra in Linux

This post is mainly used as a personal memo, but you may find something useful if you are a beginner.

  • Install Java
  • Make sure $JAVA_HOME is properly set.

  • Download and install Cassandra
  • Cassandra can be downloaded from

    To install, simply unzip it:
    tar -zxvf apache-cassandra-2.0.9-bin.tar.gz

  • Configuring Cassandra
  • The configuration make differ a bit in different Cassandra versions. Taking 2.0.9 as a example.

    In conf/cassandra.yaml, search for the following key words, and change the directory if necessary:
    1. data_file_directories
    2. commitlog_directory
    3. saved_caches_directory

    In, change log4j.appender.R.File to your preferred log file location.

  • Starting Cassandra
  • To start Cassandra, run /bin/cassandra -f. You can run it in different modes. By default it is running in background mode. -f option indicates running in foreground mode. If running in background mode, it is suggested to use /bin/cassandra -p pid_file. pid_file is the file name where the Cassandra background process PID will be written to, so later to kill the process, you can simply run kill `cat pid_file`.

  • Other tweaks
  • In conf/, it will try detect your system free memory. If you don’t have permission to run the “free” command, change the command for setting “system_memory_in_mb” to the following:

    system_memory_in_kb=`cat /proc/meminfo | grep MemFree | awk ‘/:/ {print $2;exit}’`

Leave a Reply

Your email address will not be published. Required fields are marked *