For those that installed Cassandra from the tar package found at Cassandra website, here is a very basic script to start it at boot time and stop it later if needed.
Create cassandra boot script in /etc/init.d and make it executable.
sudo nano /etc/init.d/cassandra
#!/bin/sh
#
# chkconfig: - 80 45
# description: Starts and stops Cassandra
# update deamon path to point to the cassandra executable
DEAMON=/opt/cassandra/bin/cassandra
start() {
echo -n "Starting Cassandra... "
$DEAMON -p /var/run/cassandra.pid
echo "OK"
return 0
}
stop() {
echo -n "Stopping Cassandra... "
kill $(cat /var/run/cassandra.pid)
echo "OK"
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
sudo chmod +x /etc/init.d/cassandra
For Ubuntu, add it to the startup by executing
sudo update-rc.d cassandra defaults
That’s it! Next time you bootup, it will be automatically and you can stop it by:
sudo /etc/init.d/cassandra stop
本文提供了一个基本的Cassandra启动脚本,用于在Ubuntu系统上实现Cassandra服务的开机自启与手动控制。
4139

被折叠的 条评论
为什么被折叠?



