问题
I installed Cassandra on OSX. When trying to run cqlsh from /bin/, I get the following error:
> Connection error: ('Unable to connect to any servers', {'127.0.0.1':
> ConnectionShutdown('Connection <AsyncoreConnection(4522252560)
> 127.0.0.1:9160 (closed)> is already closed',)})
I had difficulty installing Cassandra, and had used brew install cassandra, installed DSE from datastax, and downloaded a binary from Apache.
回答1:
I think the issue was the result of having a previous installation that wasn't properly uninstalled. My user .cassandra
directory had some default configs, that must have been for a different version, and prevented cqlsh from starting.
rm -Rf ~/.cassandra
After that, I could run cqlsh properly.
$ bin/cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 | Native protocol v3]
Use HELP for help.
cqlsh>
回答2:
Running cassandra
helped me to troubleshot the problem:
> cassandra
Cassandra 3.0 and later require Java 8u40 or later.
and:
> java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-3)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
After installing Java 8 it worked.
回答3:
Cassandra-2.1 uses 9042 as cqlsh port.Connect on this it is default port.If you want to connect on 9160 port then change it by setting environment variable CQLSH_PORT and CQLSH_HOST but for setting this you have to change rpc_port from default 9160 to any other port.
回答4:
Well, I faced same issue and this is what i did on Mac.
$cd /usr/local/Cellar/cassandra/3.10_1/bin/
Or wherever your cassandra is installed.
$cassandra
this initializes all configuration in your local system to start cassandra.
$./cqlsh
This lets you enter cql query mode.
回答5:
I faced this issue when I was trying to connect to Cassandra 2.0.1 version using cqlsh 5.0.1 [cqlsh 4.1.1 | Cassandra 2.0.11.83 | CQL spec 3.1.1 | ] [cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 ]
This is just one of the reasons for the error "Connection error: ('Unable to connect to any servers',".
When I used the cqlsh client compatible with Cassandra 2.0.1, I was able to connect to the cluster.
Hope this helps to find the root cause.
回答6:
I resolved this in DSE-5.0 by editing below file:
vi ~/.cassandra/cqlshrc
And editing below configs to current IP address (192.168.1.6) of the machine I am running. In my case it's my MacBook.
[connection]
hostname = 192.168.1.6
port = 9042
; factory = cqlshlib.kerberos_ssl.kerberos_ssl_transport_factory
; [kerberos]
; hostname = 192.168.1.6
; service = cassandra
; optional
; principal = bill/cassandra-admin@foo.example.com
I hope it will help someone.
Thanks,
Chandan
回答7:
Just add/modify the following into the cassandra.yaml:
rpc_address: 127.0.0.1
seeds: "127.0.0.1"
listen_address: 127.0.0.1
Note that, the values in all these fields must be same. That means, if you are pointing to a static IP, then the same IP should be used. And if you are just pointing the localhost, then localhost must be used in all fields.
回答8:
I got myself into a mess so here was my scenario if anyone else runs into it:
- I followed this tutorial http://www.datastax.com/2012/01/working-with-apache-cassandra-on-mac-os-x (which is somewhat outdated).
- I got everything installed and working - all good. Then I decided to download Datastax Enterprise tools to try them out
- Ran into errors during the install but the install went through. Again following the tutorial above, tried running the ./datastax-agent program and it failed. Decided to just bag it so ran their uninstaller in their installation folder.
- Tried to go back to original cassandra folder (what I had working in step 2) and run "sudo ./cassandra" then I started getting JMX error (message "Unable to bind JMX, is Cassandra already running?") which led me to this link about changing the port which i did (not really fixing the issue but working around it) run two cassandra versions in the same machine.
- Got the server service running underneath a new port but when trying to connect with the client "sudo ./cqlsh" would not work (would get "Error=none" or destination not found).
- Did the remove step @Peter mentioned above and tried again and still did not work.
- Decided to go back and see what was holding onto the original port cassandra was using which I changed in step 4 Who is listening on a given TCP port on Mac OS X?
- Determined that JAVA.app was hanging onto it so killed it within Activity Monitor.
- Reran the remove command @Peter mentioned above again and decided to download the stable release (v2.0.13) instead of the dev release and walk through the tutorial from step 1 again.
- Exited and re-opened terminal. Ran "sudo ./cassandra" - worked perfect running under standard ports. Open another terminal window and ran "sudo ./cqlsh" and this also worked correctly.
I believe between Java hanging onto the default port 9042 (maybe from the DataStax install errors), version/host/port settings within ~/.cassandra/cqlshrc and using the dev version of cassandra these were all causing me fits.
回答9:
I was having trouble connecting Cassandra from the terminal
[
![](https://i0.wp.com/i.stack.imgur.com/GfU96.png)
and then I tried to connect using /usr/local/Cellar/
[
![](https://i0.wp.com/i.stack.imgur.com/cID4n.png)
and then invoke cassandra. Then opened a new terminal and typed cqlsh the Cassandra started.
Hope this may also applicable one to resolve Cassandra issue.
回答10:
install java jdk and Set JAVA_HOME in Environment Variables or set JAVA_HOME = java path in command prompt.
after
run cassandra.bat
it will show the logs if you get any error
回答11:
You need to start Cassandra form the install_location's bin directory. For example, this command will start Cassandra in the foreground:
$ ./cassandra -f
Then open another terminal tab (command + t) and run cqlsh
$ ./cqlsh
回答12:
Ensure that DEFAULT_HOST = '127.0.0.1' in script cqlsh.py is pointing to the node IP where you have done your cassandra installation. In my case I had installed cassandra on 10.160.1.5, edited above file and it started working.
回答13:
Running cqlsh
gets this error for me but running bin/cqlsh
from the cassandra directory works.
回答14:
I was having the same problem with Cassandra configured with SSL.
cqlsh --ssl
Solves connects correctly.
来源:https://stackoverflow.com/questions/27004773/cassandra-cqlsh-unable-to-connect-to-any-servers-127-0-0-19160-closed-is-a