0

I installed Docker and run the first Cassandra node and used Cqlsh to run some commands and it works fine. I installed python driver and then when i run the command below i get the following error. I saw many stack questions and not much people were able to answer. Please give your ideas. I have been longing for a while to use cassandra but could never come up with a good solution for this problem. Thanks

>>> from cassandra.cluster import Cluster
>>> cluster=Cluster()
>>> keyspace='north'
>>> session=Cluster(['192.168.1.xx']).connect()

Error

cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'192.168.1.xx': ConnectionRefusedError(111, "Tried connecting to [('192.168.1.xx', 9042)]. Last error: Connection refused")})

When i tried to replace the Ip address with the cassandra node which i created, 'node1' in my case it gives me this error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cassandra/cluster.py", line 826, in cassandra.cluster.Cluster.__init__
  File "/usr/lib/python3.5/socket.py", line 732, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -5] No address associated with hostname
KSp
  • 1,199
  • 1
  • 11
  • 29

2 Answers2

1

I actually solved this by giving the container Ip address which was inside the docker. I was quite confused which address i should give. But then after running this command.

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id. 

I was not aware that i need to specify the container id which had the cluster node. So i was always giving the ip address of the machine.

KSp
  • 1,199
  • 1
  • 11
  • 29
0

The IP address you have provided is not valid: 192.168.1.xx.

You need provide the IP address (or valid hostname) of at least one node in your cluster.

Justin Cameron
  • 611
  • 4
  • 8
  • Hey justin thanks for your answer, Yes right after i posted this question in few seconds i found the answer, So its almost the same as you said. – KSp Nov 14 '18 at 16:47