Pre-Installation Setup
Before installing Cassandra in Linux environment, we require to set up Linux using ssh (Secure Shell). Follow the steps given below for setting up Linux environment.
Setting the Path
Set the path of Cassandra path in “/.bashrc” as shown below.
1 | @linux ~]$ gedit ~/.bashrc |
1 2 3 | export CASSANDRA_HOME = ~/cassandra export PATH = $PATH:$CASSANDRA_HOME/bin |
Download Cassandra
Unzip Cassandra using the command zxvf as shown below.
1 | $ tar zxvf apache-cassandra-<version>-bin.tar.gz. |
Create a new directory named cassandra and move the contents of the downloaded file to it as shown below.
1 2 3 | $ mkdir Cassandra $ mv apache-cassandra-<version>/* cassandra. |
Configure Cassandra
Open the cassandra.yaml: file, which will be available in the bin directory of Cassandra.
1 | $ gedit cassandra.yaml |
Note: If you have installed Cassandra from a deb or rpm package, the configuration files will be located in /etc/cassandra directory of Cassandra.
The above command opens the cassandra.yaml file. Verify the following configurations. By default, these values will be set to the specified directories.
- data_file_directories “/var/lib/cassandra/data”
- commitlog_directory “/var/lib/cassandra/commitlog”
- saved_caches_directory “/var/lib/cassandra/saved_caches”
Make sure these directories exist and can be written to, as shown below.
Create Directories
As super-user, create the two directories /var/lib/cassandra and /var./log/cassandra into which Cassandra writes its data.
1 2 3 | [root@linux cassandra]# mkdir /var/lib/cassandra [root@linux cassandra]# mkdir /var/log/cassandra |
Give Permissions to Folders
Give read-write permissions to the newly created folders as shown below.
1 2 3 | [root@linux /]# chmod 777 /var/lib/cassandra [root@linux /]# chmod 777 /var/log/cassandra |
Start Cassandra
To start Cassandra, open the terminal window, navigate to Cassandra home directory/home, where you unpacked Cassandra, and run the following command to start your Cassandra server.
1 2 3 | $ cd $CASSANDRA_HOME $./bin/cassandra -f |
Using the –f option tells Cassandra to stay in the foreground instead of running as a background process. If everything goes fine, you can see the Cassandra server starting.