user7866584
user7866584

Reputation: 65

How to distribute data across different nodes in cassandra cluster

I have setup a multinode cassandra cluster with two different nodes with all required configurations i.e cluster_name , endpoint_snitch , seeds , auto_bootstrap etc. I am using datacenter as dc1 for both nodes. I created keyspace using -

CREATE KEYSPACE dcTest WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'dc1' : 2 };

Now , when I start both nodes and try entering data in database , it creates replica on both nodes. i.e if I create 4 rows in table , it copies all 4 rows on another node also. I want this data to get distributed across nodes. i.e two on one node and two on another.

Is it achieved by configuring keyspace? Am I missing anything?

Nodetoll status -

 nodetool -p 7199 status cassandrareplication1
    Datacenter: dc1
    ===============
    Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address         Load       Tokens       Owns (effective)  Host ID                               Rack
UN  10.45.123.123  35.01 MB   256          50.3%             8c529955-c42a-4629-dfgh-0666a444acbb  rack1
UN  10.45.123.124  225.4 KB   256          49.7%             eddf1039-d803-4d61-dfse-1ce0ec3782a9  rack1

Upvotes: 1

Views: 884

Answers (2)

Payal
Payal

Reputation: 564

Having 2 Replication means you want 2 copies of your data into datacenter henceforth Cassnadra will put 1 full copy of data on each node to satisfy 2 RF. to achieve your goal you may want to have 1 RF and 2 nodes so Cassandra can distribute data among nodes. you can alter keyspace using

Alter KEYSPACE dcTest WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'dc1' : 1 };

Don't forget to run nodetool repair with -full option after that.

Upvotes: 1

Simon Fontana Oscarsson
Simon Fontana Oscarsson

Reputation: 2124

You should replication factor 1, not 2. This will mean all your data in this keyspace will be replicated once within this datacenter. With 2 as replication factor it will be replicated twice, 3 thrice and so on.

Upvotes: 1

Related Questions