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.
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With