In this post i’ll show you how to make Cassandra as CentOS service, so that you can run cassandra with commands like start, stop, restart or status.
The other advantage is you can make cassandra to run in startup. Lets start now.
First make a file called cassandra using below command
This command opens up nano editor, now you are ready to make some scripts.
First make some constants
As you see first define CASS_HOME as cassandra path you have extracted the cassandra, secondly you must define the bin of the cassandra using cassandra home.
Next two is where you want to log the logs which is displayed on console and path to save the pid.
Now lets write start script.
This Scripts checks if PID exist then it displays cassandra is already running else it starts the cassandra and saves pid in a file
Lets see stop scripts
This scripts check if cassandra is already stopped else it kills the pid which is stored in pid file
Lets see Status Script
This checks if pid exist then it shows its running else stopped.
The full Script is
Now you paste this cassandra
file under /etc/init.d
Add cassandra service to chkconfig, command is
Now you can start or stop or check status using below command
If you want to start cassandra on startup the use below command
To remove from startup use below command