Reputation: 190
I am having some difficulty in connecting to a Centos 7.x server hosted DataStax Cassandra 6.8.
I am able to successfully connect locally inside the Centos Shell and the nodetool status shows the cluster Up and Normal.
Things I tried in cassandra.yaml file -
as mentioned above - OS - CentOS 7 DSE Version - 6.8 Install method RPM
Python program -
#cluster = Cluster()
cluster = Cluster(['192.168.1.223'])
# To establish connection and begin executing queries, need a session
session = cluster.connect()
row = session.execute("select release_version from system.local;").one()
if row:
print(row[0])
else:
print("An error occurred.")
Exception thrown from python ->
NoHostAvailable: ('Unable to connect to any servers', {'192.168.1.223:9042': ConnectionRefusedError(10061, "Tried connecting to [('192.168.1.223', 9042)]. Last error: No connection could be made because the target machine actively refused it")})
Both my PC and my server are on the same network and I am able to ping from each other.
Any help is highly appreciated.
Thanks
Upvotes: 2
Views: 335
Reputation: 16353
The same question was asked on https://community.datastax.com/questions/12174/ so I'm re-posting my answer here.
This error indicates that you are connecting to a node which is not listening for CQL connections on IP 192.168.1.223
and CQL port 9042
:
No connection could be made because the target machine actively refused it
The 2 most likely causes are:
You indicated already that you are not able to start DSE. You 'll need to review the logs located in /var/log/cassandra
by default for clues as to why it's not running.
The other possible issue is that you haven't configured native_transport_address
(rpc_address
in open-source Cassandra). You need to set this to an IP address that is accessible to clients (your app) otherwise, it will default to localhost
(127.0.0.1
).
In cassandra.yaml
, configure the node with:
listen_address: private_ip
native_transport_address: public_ip
If you are just testing it on a local network, set both properties to the server's IP address. Cheers!
[EDIT] I just saw your conversation with @Alex Ott. I'm posting my response here because it won't fit in a comment.
This startup error means that the node couldn't talk to any seed nodes so it won't be able to join the cluster:
ERROR [DSE main thread] 2021-08-25 06:40:11,413 CassandraDaemon.java:932 - \
Exception encountered during startup
java.lang.RuntimeException: Unable to gossip with any peers
If you only have 1 node in the cluster, configure the seeds
list in cassandra.yaml
with the server's own IP address:
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "192.168.1.223"
Upvotes: 2