Cassandra NoHostAvailable: error in CQLSH
This is too late to answer. But I wanted to share my experience.
If you have a single node cluster and use NetworkTopologyStrategy, then it throws this error. Check your keyspace configuration.
Error during inserting data: NoHostAvailable:
My CQL command to update the replication
ALTER KEYSPACE my_keyspace WITH replication = {'class' : 'NetworkTopologyStrategy', 'DC1' : 1 ,'DC2' :2 };
was slightly different from the config files : conf/cassandra-rackdc.properties
# These properties are used with GossipingPropertyFileSnitch and will
# indicate the rack and dc for this node
dc=dc1
rack=rack1
resulting in a
cqlsh: my_keyspace> select * from world where message_id = 'hello_world';
NoHostAvailable:
the replication strategy is case sensitive and copy/paste from documentation may lead you to a mistake.
Fix : Changing the replication info so that it match the config files
ALTER KEYSPACE my_keyspace WITH replication = {'class' : 'NetworkTopologyStrategy', 'dc1' : 1 ,'dc2' :2 };
And execute on each node :
bin/nodetool repair --full my_keyspace
Got replication set on every node