NoHostAvailable error in cqlsh console

jAvA picture jAvA · Jan 26, 2017 · Viewed 13.3k times · Source

I was able to get rid of this error later but i am not sure what i did is correct. 1 )

CREATE KEYSPACE myKeySpace WITH replication = 
  {'class': 'NetworkTopologyStrategy', 'dc1': '1', 'dc2': '2'}
  AND durable_writes = true;

Execute create table and select table after this. This throws "NoHostAvailable:" error in the console.

2 ) If I change the create statement to the below one, the select query works.

CREATE KEYSPACE myKeySpace WITH replication = 
  {'class': 'NetworkTopologyStrategy', 'datacenter1': '1', 'dc2': '2'}
  AND durable_writes = true; 

If I have a default datacenter1, it works. I'm not able to understand why it is only working when I give datacenter1. Please help.

Answer

Aaron picture Aaron · Jan 26, 2017

Which data centers do you see when you execute a nodetool status?

The data centers that you specify as the replication factor (RF) for your keyspace must be predefined in either your cassandra-rackdc.properties or cassandra-topology.properties files (depending the Snitch you configured).