How to run Cassandra (cqlsh) from anywhere

In Kassandra, the official documentation ( https://wiki.apache.org/cassandra/GettingStarted ) states that to start using the service

'bin/cassandra -f' 

Then use

 'bin/cqlsh' 

for access. But to use cqlsh in this way, I always need to go to the bin folder. What is the procedure for its operation, so that I can type "cqlsh" from anywhere in the console for access (should not be in the bin folder of the Cassandra installation)?

(just as we access python directly from anywhere, just by typing python3 in the console)

+6
source share
2 answers

To get this working, you need to add your Cassandra bin to your $PATH .

At the terminal command line, check the contents of $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 will also check the location of this on my system:

 $ which python3 /usr/bin/python3 

As you can see, Python3 is in my /usr/bin , and /usr/bin is in my $PATH , so just typing in python3 works for me (and you too).

There are several ways to get the Cassandra bin in $PATH . There is some discussion about which β€œright” way to do this. So instead of telling you how I will do this, I will provide a link to a question about AskUbuntu that describes something like 3 ways to add a directory to your $PATH : How do I add a directory to my path?

+2
source

Use cassandra -f in your root folder, and then you can use cqlsh anywhere cassandra is installed

0
source

Source: https://habr.com/ru/post/986223/


All Articles