Cassandra Replication Ratio More Than Number of Nodes


I am using the java driver for datastax for Apache Cassandra (v. 2.1.9), and I am wondering what should happen when I set replication_factor to more than the number of nodes. I read somewhere that Cassandra allows this operation, but should fail when I try to save some data (of course, it depends on the level of write consistency, but I mean the ALL case).
The problem is that everything works, no exception is raised, even if I try to save the data. Why? Maybe the pieces of information that I read were old for older versions of Cassandra? One more question, isn't it true what happens when I add another node to the cluster?

+4
source share
3 answers

Cassandra has the concept of “custom consistency,” which in part means that you can control the setting of the level of consistency for read / write operations.

You can read a little more in the documents explaining the levels of consistency and how to install them in the cqlsh shell .

To learn more, I suggest experimenting with cqlsh on a single-node Cassandra. For example, we can create a key space with a replication factor of 2 and load some data into it:

cqlsh> create keyspace test with replication = {'class': 'SimpleStrategy', 'replication_factor':2};
cqlsh> create table test.keys (key int primary key, val int);
cqlsh> insert into test.keys (key, val) values (1, 1);
cqlsh> select * from test.keys;

 key | val
-----+-----
   1 |   1 

, - , 1 node . , :

cqlsh> CONSISTENCY ALL;
Consistency level set to ALL.
cqlsh> insert into test.keys (key, val) values (2, 2);
Traceback (most recent call last):
  File "resources/cassandra/bin/cqlsh.py", line 1324, in perform_simple_statement
    result = future.result()
  File "resources/cassandra/bin/../lib/cassandra-driver.zip/cassandra-driver/cassandra/cluster.py", line 3133, in result
    raise self._final_exception
Unavailable: code=1000 [Unavailable exception] message="Cannot achieve consistency level ALL" info={'required_replicas': 2, 'alive_replicas': 1, 'consistency': 'ALL'}

cqlsh> select * from test.keys;
Traceback (most recent call last):
  File "resources/cassandra/bin/cqlsh.py", line 1324, in perform_simple_statement
    result = future.result()
  File "resources/cassandra/bin/../lib/cassandra-driver.zip/cassandra-driver/cassandra/cluster.py", line 3133, in result
    raise self._final_exception
Unavailable: code=1000 [Unavailable exception] message="Cannot achieve consistency level ALL" info={'required_replicas': 2, 'alive_replicas': 1, 'consistency': 'ALL'}

, , 2- node . , , .

cqlsh, Java, , .

+4

, , , Cassandra , .

, 5 , 5. , 1 node , , - Cassandra.

, , , .

+1

, .

- vnode. node, vnodes ( ), node. .

0

All Articles