CentOS 7 Firewall

In CentOS 7, use the following commands to add a service to a public zone.

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --permanent --zone=public --add-port=2812/tcp
firewall-cmd --reload

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 http://cassandra.apache.org/download/:
    wget http://mirror.ox.ac.uk/sites/rsync.apache.org/cassandra/2.0.9/apache-cassandra-2.0.9-bin.tar.gz

    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 log4j-server.properties, 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/cassandra-env.sh, 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}’`