Unable to establish connection, All host(s) tried for query failed - cassandra

i know this may be basic problem but as i am new to cassandra and did not find solution of it anywhere so When i am trying to make connection in DataStax Dev Center to cassandra server, it is giving me below exception.
Below is system configuration:
Operating System: Windows 10 pro(64- Bit)
apache-cassandra-3.11.2
Below is cassandra.yaml configuration:
start_native_transport: true
broadcast_rpc_address: 1.2.3.4
native_transport_port_ssl: 9142
listen_address: 192.168.2.22
rpc_address: 192.x.x.x
I have done these changes in cassandra.yaml file: start_rpc: true rpc_port: 9042
when running this command on cmd: nodetool -h localhost -p 9042 status
getting this error: Failed to connect to 'localhost:9042' - ConnectIOException: 'non-JRMP server at remote endpoint'.
Any help would be appreciated.

Seems like you have configured native-transport-port as :9142, but you are trying to connect to 9042 port with dev center. Please correct it and verify.

You have set rpc (rpc_port) to use the the same port as cql (native_transport_port). Are you sure you want to use rpc? This is the old deprecated interface and should not be used unless you need it for backwards compatibility.
If you actually do want to use rpc then it has to be another port than native_transport_port.

You should use jmx port (7199 default) for nodetool

I have found answer of this question and below are configurations which need to configure once you install Cassandra for first time:
broadcast_rpc_address: 192.168.2.22(ip address of system on which Cassandra is installed
rpc_address: 0.0.0.0

Related

Cassandra Cqlsh is not working

I've just started working with Cassandra (homebrew install), version 3.7 and cqlsh version 5.0.1. , OS X El Capitan
Cassandra starts up fine and the cluster is operational instantly.
Cqlsh is not working (on any of the nodes) and emits the following error:
Connection error: ('Unable to connect to any servers', {'127.0.0.1':
error(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error:
Connection refused")})
Edit cqlsh and change DEFAULT_HOST = IP and then run cqlsh.
I think the first step you should be doing is running netstat -ntpl. This should list down all the ports active on the system. Check for Local Address there you shall find a IP prepended with 9042.
Use this IP to connect ie cqlsh IP . If you do not find the 9042 port in the netstat output than check your cassandra.yaml file. Grep for native_transport_port see if it is 9042 or something different.
If different than connect on that port via cqlsh.
For future reference, if someone else gets it.
I'm running [cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4].
Add start_native_transport: true field in cassandra.yaml file, by default it doesn't enables it and so no rpc communication with client.
Now try connecting with cqlsh rpc_endpoint(rpc addr set in cassandra.yaml).

How to configure cassandra for remote connection

I am trying to configure Cassandra Datastax Community Edition for remote connection on windows,
Cassandra Server is installed on a Windows 7 PC, With the local CQLSH it connects perfectly to the local server.
But when i try to connect with CQLSH from another PC in the same Network, i get this error message:
Connection error: ('Unable to connect to any servers', {'MYHOST':
error(10061, "Tried connecting to [('HOST_IP', 9042)]. Last error: No
connection could be made because the target machine actively refused
it")})
So i am wondering how to configure correctly (what changes should i make on cassandra.yaml config file) the Cassandra server to allow remote connections.
Thank you in advance!
How about this:
Make these changes in the cassandra.yaml config file:
start_rpc: true
rpc_address: 0.0.0.0
broadcast_rpc_address: [node-ip]
listen_address: [node-ip]
seed_provider:
- class_name: ...
- seeds: "[node-ip]"
reference: https://gist.github.com/andykuszyk/7644f334586e8ce29eaf8b93ec6418c4
Remote access to Cassandra is via its thrift port for Cassandra 2.0. In Cassandra 2.0.x, the default cqlsh listen port is 9160 which is defined in cassandra.yaml by the rpc_port parameter. By default, Cassandra 2.0.x and earlier enables Thrift by configuring start_rpc to true in the cassandra.yaml file.
In Cassandra 2.1, the cqlsh utility uses the native protocol. In Cassandra 2.1, which uses the Datastax python driver, the default cqlsh listen port is 9042.
The cassandra node should be bound to the IP address of your server's network card - it shouldn't be 127.0.0.1 or localhost which is the loopback interface's IP, binding to this will prevent direct remote access. To configure the bound address, use the rpc_address parameter in cassandra.yaml. Setting this to 0.0.0.0 will listen on all network interfaces.
Have you checked that the remote machine can connect to the Cassandra node? Is there a firewall between the machines? You can try these steps to test this out:
1) Ensure you can connect to that IP from the server you are on:
$ ssh user#xxx.xxx.xx.xx
2) Check the node's status and also confirm it shows the same IP:
$nodetool status
3) Run the command to connect with the IP (only specify the port if you are not using the default):
$ cqlsh xxx.xxx.xx.xx
Alternate solution to Kat. Worked with Ubuntu 16.04
ssh into server server_user#**.**.**.**
Stop cassandra if running:
Check if running with ps aux | grep cassandra
If running, will output a large block of commands / flags, e.g.
ubuntu 14018 4.6 70.1 2335692 712080 pts/2 Sl+ 04:15 0:11 java -Xloggc:./../logs/gc.log ........
Note 14018 in the example is the process id
Stop with kill <process_id> (in this case 14018)
edit cassandra.yaml file to be the following
rpc_address: 0.0.0.0
broadcast_rpc_address: **.**.**.** <- your server's IP (cannot be set to 0.0.0.0)
Restart cassandra ./bin/cassandra -f (from within cassandra root)
Open another terminal on local machine & connect via cqlsh **.**.**.** (your server's IP) to test.
The ./bin/nodetool status address reported my localhost IP (127.0.0.1), but cqlsh remotely still worked despite that.

Cannot connect to datastax agent

I am unable to connect to any nodes through opscenter. In opscenter it says that agents need to be connected inorder for opscenter to work. I checked in datastax-agent/agent.log file and found below errors.
ERROR [clojure-agent-send-off-pool-0] 2016-01-27 09:30:54,545 Can't connect to Cassandra (All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.TransportException: [/127.0.0.1:9042] Cannot connect))), retrying soon.
I checked port 9042 and 7199 both are listening..
x.x.x.10:9042 :::* LISTEN 497 499005 28550/java
pls advise.. what needs to be checked for this. Thanks
Leave broadcast_rpc_address to rpc_address as it is to point to their respective ip address as below: and changing to 0.0.0.0 is not required.
10.154.3.10 - Cassandra.yaml
broadcast_rpc_address: 10.154.3.10
rpc_address: 10.154.3.10
10.154.3.10 - address.yaml
stomp_interface: 10.154.3.XX --> (Mention the IP of opscenter server)
hosts: ["10.154.3.10"]
Restart the datastax-agent, and in agent.log, no errors will be seen.
There are few basic settings in cassandra.yaml to tune network connection params.
listen_address : localhost
Address or interface to bind to and tell other Cassandra nodes to connect to. Specifying it to localhost will always do the Right Thing. Setting listen_address to 0.0.0.0 is always wrong
rpc_address : 0.0.0.0
That unlike listen_address, you can specify 0.0.0.0, but you must also set broadcast_rpc_address to a value other than 0.0.0.0
broadcast_rpc_address: localhost
This setting will be usefull probably for redirect conversation between nodes from broadcast_rpc_address to rpc_address (i.e. Machine has two network interfaces)
If all settings is correct for you environment try to connect with console client cqlsh and try to use nodetool for monitoring state of your nodes. After try to run OPC center

cassandra 1.2 nodetool getting 'Failed to connect' when trying to connect to remote node

I am running a 6 node cluster of cassandra 1.2 on an Amazon Web Service VPC with Oracle's 64-bit JVM version 1.7.0_10.
When I'm logged on to one of the nodes (ex. 10.0.12.200) I can run nodetool -h 10.0.12.200 status just fine.
However, if I try to use another ip address in the cluster (10.0.32.153) from that same terminal I get Failed to connect to '10.0.32.153:7199: Connection refused'.
On the 10.0.32.153 node I am trying to connect to I've made the following checks.
From 10.0.12.200 I can run telnet 10.0.32.153 7199 and I get a connection, so it doesn't appear to be a security group/firewall issue to port 7199.
On 10.0.32.153 if I run netstat -ant|grep 7199 I see
tcp 0 0 0.0.0.0:7199 0.0.0.0:* LISTEN
so cassandra does appear to be listening on the port
The cassandra-env.sh file on 10.0.32.153 has all of the JVM_OPTS for jmx active
-Dcom.sun.management.jmxremote.port=7199 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
The only shot in the dark I've seen while trying to solve this problem while searching the interwebs is to set the following:
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=10.0.32.153"
But when I do this I don't even get a response. It just hangs.
Any guidance would be greatly appreciated.
The issue did end up being a firewall/security group issue. While it is true that the jmx port 7199 is used, apparently other ports are used randomly for rmi. Cassandra port usage - how are the ports used?
So the solution is to open up the firewalls then configure the cassandra-env.sh to include
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<ip>

Cassandra nodetool connection timed out

Im trying to use nodetool to check the status of my cluster, but its unable to connect.
My cassandra.yaml is configured with listen_address and rpc_address set as the server IP (e.g. 10.10.10.266).
Im able to connect through cqlsh and cassandra-cli using the same IP, but when I connect to nodetool it doesnt work.
/bin$ nodetool -h 10.10.10.266 ring
Failed to connect to '10.10.10.266:7199': Connection has timed out
I dont think I have a firewall enabled on the server (Ubuntu). Im running this directly on the server in question, so I wouldnt have thought it would be a firewall issue anyway.
You probably need to uncomment the following parameter in cassandra-env.sh:
-Djava.rmi.server.hostname=<public name>
Replace with the address of the interface you want the jmx interface to listen on.
nodetool connects through JMX interface. By default it's listening on port 7199 (other tools use RPC interface listening on port 9160 by default). Check JMX settings in cassandra-env.sh file. Most likely JMX server is listening on wrong interface (or probably loopback interface).
Default JMX configuration section (cassandra ver. 1.1.5) contains link to troubleshooting guide:
# jmx: metrics and administration interface
#
# add this if you're having trouble connecting:
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
#
# see
# https://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole
# for more on configuring JMX through firewalls, etc. (Short version:
# get it working with no firewall first.)
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS"
It also worths to list all network interfaces using ifconfig and try telnet'ing port 7199 on all interfaces.
I was facing the same timeout issue. However I found that my cluster was not getting started properly because of token issue and I was getting "Host ID collision between active endpoint". Once i deleted data directory and restarted cluster then nodetool started working fine.
I also saw this same issue but it turned out to be some weirdness in my hosts file that was preventing JMX from binding to the interfaces.
Specifically, the host file had an entry for the external IP address with the hostname. Our servers had two interfaces, one external and one for an internal network. Removing that hosts entry did the trick.
As someone mentioned, it connects to the JMX port.
You can find the JMX port:
In /etc/cassandra/cassandra-env.sh. This won't work for ccm based local clusters OR
(my fav) by looking at the command-line of Cassandra node process running on the node.
My case was a cluster created locally using ccm so all my nodes were running on same host with different JMX port.
vagrant#triforce:~$ ps -eaf | grep cassandra | grepi -o " [^ ]*jmx.local.port[^ ]* "
-Dcassandra.jmx.local.port=7100
-Dcassandra.jmx.local.port=7300
-Dcassandra.jmx.local.port=7200
vagrant#triforce:~$
This is because I have 3 nodes running on the localhost.
vagrant#triforce:~$ nodetool -p 7100 ring
Datacenter: datacenter1
==========
Address Rack Status State Load Owns Token
3074457345618258602
127.0.0.1 rack1 Up Normal 64.65 MB 33.33% -9223372036854775808
127.0.0.2 rack1 Up Normal 65.26 MB 33.33% -3074457345618258603
127.0.0.3 rack1 Up Normal 65.92 MB 33.33% 3074457345618258602
vagrant#triforce:~$

Resources