How to run Cassandra (cqlsh) from anywhere

≯℡__Kan透↙ 提交于 2020-01-03 08:50:14

问题


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 )


回答1:


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?




回答2:


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



来源:https://stackoverflow.com/questions/29944484/how-to-run-cassandra-cqlsh-from-anywhere

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!