Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoHostAvailable error in cqlsh console

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.

like image 734
jAvA Avatar asked Jan 26 '17 17:01

jAvA


2 Answers

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).

like image 94
Aaron Avatar answered Nov 03 '22 00:11

Aaron


I encountered the same issue when I am trying to access the table that is created in keyspace with a replication strategy as NetworkTopologyStrategy.

The reason I found later is due to replicas unavailability because I am using it in local.

If I change the keyspace replication strategy to SimpleStrategy and replication_factor to 1, the error is gone.

Hope this helps.

like image 32
prince2020 Avatar answered Nov 03 '22 01:11

prince2020