cassandranodesreplication-factor

Warnings : Your replication factor 3 for keyspace books is higher than the number of nodes 1


When I tried:

CREATE KEYSPACE IF NOT EXISTS books WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 3 };

I got:

Warnings :
Your replication factor 3 for keyspace books is higher than the number of nodes 1

I have installed Cassandra on my local Ubuntu 22.04 machine and don't remember if I specified how many nodes it should have if it was ever possible doing that. I am just wondering to know is it possible to have multi nodes on a local machine? How should I check the number of Cassandra nodes and how can I change them?


Solution

  • A "node" in Cassandra is an individual machine instance. If you're deploying in the cloud or on Kubernetes, increasing the number of nodes is a trivial thing. However, if you're just testing on your own machine, and you've installed Cassandra, then you have one node.

    How should I check the number of Cassandra nodes?

    You can check this by querying the local node's system.peers table. That table holds data on each of the other nodes in the cluster.

    SELECT * FROM system.peers;
    

    So, if you get two rows back, then you have a three node cluster. If nothing comes back, then you have a one node cluster.

    is it possible to have multi nodes on a local machine?

    Yes. It's not easy, though. Cassandra makes exclusive use of a few ports on a machine instance, so you'd need multiple Cassandra directories, and each would need its own offsets of ports 7000, 7001, 7199, and 9042.

    The easier way, is to use MiniKube to run multiple, small Cassandra nodes inside a Kubernetes cluster. I've build a repo to help folks with doing this on Windows: https://github.com/aploetz/cassandra_minikube

    There's also a companion YouTube video for it: https://www.youtube.com/watch?v=eMKXiItZ0Q4