7

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.

Aaron
  • 55,518
  • 11
  • 116
  • 132
jAvA
  • 557
  • 1
  • 8
  • 22

5 Answers5

15

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

Aaron
  • 55,518
  • 11
  • 116
  • 132
  • 2
    i didn't specify any datacenter when i create it, so it could have used the default. Thanks for the help , i am able to figure out what i need to do now :) – jAvA Jan 26 '17 at 19:13
  • This issue is with latest cassandra builds and older create scripts – ininprsr Aug 14 '18 at 11:53
6

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.

Yaser Darzi
  • 1,480
  • 12
  • 24
prince2020
  • 61
  • 1
  • 2
1

At first step, you may try:

'class':'SimpleStrategy'

to review your code, exclude strategy class!

After that you work on strategy class, if you did not find any error.

0

You can only specify the datacenter which are present/configured in you cassandra cluster.

Run nodetool status, which gives you the cluster details like datacenter names, rack names etc.

Used the datacenter names from here while creating keyspaces with NetworkTopologyStrategy class replication.

0

You should first check the defined datacenter name in the property file "cassandra-rackdc.properties"(latest version of Cassandra using this property file) or "cassandra-topology.properties" based on the defined datacenter name you have to use that datacenter name while create a keyspace. of you can check the nodetool status before creating keyspace where you can see the default datacenter name.

LetsNoSQL
  • 1,478
  • 1
  • 11
  • 23