Let's clear the air here...
You ABSOLUTELY can use NetworkTopologyStrategy
in a single-node configuration. I currently have five versions of Cassandra installed on my local, and they are all configured that way, and they work just fine.
Albeit, it is not as simple as just using SimpleStrategy
, so there are some steps that need to be taken:
Start by setting the GossipingPropertyFileSnitch
in the cassandra.yaml
:
endpoint_snitch: GossipingPropertyFileSnitch
That tells Cassandra to use the cassandra-rackdc.properties
file to name logical data centers and racks:
$ cat conf/cassandra-rackdc.properties | grep -v "#"
dc=dc1
rack=rack1
If you have a new cluster, you can change those. If you have an existing cluster, leaving them is the best idea. But you'll want to reference the dc
name, because you'll need that in your keyspace definition.
Now, if you define your keyspace like this:
CREATE KEYSPACE stackoverflow WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': '1'};
With this configuration, NetworkTopologyStrategy
can be used just fine.
Opinions will differ on this, but I do not recommend using SimpleStrategy
. It's a good idea to practice getting used to using NetworkTopologyStrategy
on your local. I say this, because I have seen the opposite happen: folks accidentally deploy a SimpleStrategy
keyspace into a MDHA cluster in production, and then wonder why their configured application consistency cannot be met.