6

In Cassandra the official documentation (https://wiki.apache.org/cassandra/GettingStarted) it states, to start the service use

'bin/cassandra -f'

Then use

'bin/cqlsh'

to access. But to use cqlsh in this way I always have to go to the bin folder. What is the procedure to make it work such that I can type 'cqlsh' from anywhere in the console to access (not have to be in the bin folder of Cassandra setup) ?

(just like we access python directly from anywhere by just typing python3 in console )

Aaron
  • 55,518
  • 11
  • 116
  • 132
  • 1
    Which Linux version do you use and how did you install Cassandra? – jny Apr 29 '15 at 13:52
  • Linux 3.13.0-24-generic x86_64 and Installed cassandra following the steps in https://wiki.apache.org/cassandra/GettingStarted –  Apr 30 '15 at 03:56
  • I'm pretty sure jny was inquiring as to which *flavor* of Linux you are running (Ubuntu, CentOS, etc...). The kernel version really doesn't affect the install process. – Aaron Apr 30 '15 at 13:41
  • sorry my bad, its ubuntu 14.04 –  May 04 '15 at 05:07

2 Answers2

3

To get this work work, you have to add your Cassandra bin directory to your $PATH.

From a terminal prompt, check the contents of your $PATH.

$ echo $PATH

On my Ubuntu VM, this is what I see:

/usr/local/apache-maven/apache-maven-3.1.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.7.0_45/bin

Since you mention Python3, I'll check the location of that on my system as well:

$ which python3
/usr/bin/python3

As you can see, Python3 is in my /usr/bin directory, and /usr/bin is in my $PATH, which is why simply typing python3 works for me (and you as well).

There are a few ways to get your Cassandra bin directory into your $PATH. There is some debate about which is the "correct" way to do accomplish this. So in lieu of telling you how I would do it, I will provide a link to a question on AskUbuntu that details something like 3 ways to add a directory into your $PATH: How to add a directory to my path?

Community
  • 1
  • 1
Aaron
  • 55,518
  • 11
  • 116
  • 132
0

Use cassandra -f in your root folder and then you should be able to use cqlsh anywhere you have cassandra installed

Sid
  • 2,683
  • 18
  • 22
  • yes did that (that step was mentioned in the above link) but then has to be inside bin folder to execute cqlsh. –  Apr 30 '15 at 03:57
  • 1
    @EshanM.Herath I got the impression from your question that you did cassandra -f in the bin folder not your root folder. Are you saying you already tried running cassandra -f in root? – Sid Apr 30 '15 at 04:46