20

I cant find it in cassandra.yaml, maybe nodetool can get me the configured replication factor of my cluster?

What is the default value of the replication factor?

6 Answers6

35

A cluster doesn't have a replication factor, however your keyspaces does.

If you want to look at the replication factor of a given keyspace, simply execute SELECT * FROM system_schema.keyspaces; and it will print all replication information you need.

mcmcc
  • 822
  • 6
  • 12
Will
  • 2,057
  • 1
  • 22
  • 34
  • @will- Thanks, It worked. Can you tell what is the default value of the replication factor? –  Jan 19 '16 at 09:28
  • 4
    There is no default value for this setting. When you create a keyspace you have to specify the replication factor. – Will Jan 19 '16 at 09:43
  • 3
    In Cassandra 2.1, the data is in a different schema/table: `select * from system.schema_keyspaces;` – Domenic D. Jan 29 '19 at 02:59
17

Consider using DESCRIBE SCHEMA - it's likely that using system.schema_keyspaces will fail to work in a future version (such as 3.0+, where schema is moved to system_schema);

Jeff Jirsa
  • 4,391
  • 11
  • 24
5

In the versions 3.0 + Cassandra you can get the RF details from the system_schema keyspace in the system_schema.keyspaces replication column.

cassandra@cqlsh:system_schema> SELECT * FROM system_schema.keyspaces;

 keyspace_name      | durable_writes | replication
--------------------+----------------+-------------------------------------------------------------------------------------
        system_auth |           True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '1'}
      system_schema |           True |                             {'class': 'org.apache.cassandra.locator.LocalStrategy'}
 system_distributed |           True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '3'}
            company |           True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '2'}
             system |           True |                             {'class': 'org.apache.cassandra.locator.LocalStrategy'}
             jerry  |           True |                   {'class': 'org.apache.cassandra.locator.NetworkTopologyStrategy'}
      system_traces |           True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '2'}
Jerry
  • 7,863
  • 2
  • 26
  • 35
1

Replication factor is defined at Keysapce level.

In order to view the Replication Factor for a particular keyspace use the following query in cqlsh:

desc KEYSPACE Keyspace_Name;

You will get the output in which you can see the replication factor for the mentioned keyspace: enter image description here

Yug Singh
  • 3,112
  • 5
  • 27
  • 52
1

For Cassandra 3.11 Version and above:

  • Go to Path on Cassandra node: cd /usr/local/cassandra/apache-cassandra-3.11.0/bin
  • Type command: ./cqlsh (your Cassandra node IP)
  • Then Type: SELECT * FROM system_schema.keyspaces;

Output: You will get the replication factors of all the respective keyspaces in Cassandra

Elletlar
  • 3,136
  • 7
  • 32
  • 38
Abhinay Gupta
  • 191
  • 2
  • 4
1

If you don't want to use cqlsh and just want to print the info from the terminal, use the nodetool and command called describe cluster, like this:

[user@user ~]$ nodetool describecluster

It will print very useful and brief info, including the info about keyspaces like this:

Keyspaces:
    system_schema -> Replication class: LocalStrategy {}
    system -> Replication class: LocalStrategy {}
    system_distributed -> Replication class: SimpleStrategy {replication_factor=3}
    system_traces -> Replication class: SimpleStrategy {replication_factor=2}
    system_auth -> Replication class: NetworkTopologyStrategy {dc1=3}

If you're looking for one particular keyspace replication info, just use the following command (in this example, we'll ask about system_auth keyspace info):

[user@user ~]$ nodetool describecluster | grep system_auth

..and it will print the info like this:

system_auth -> Replication class: NetworkTopologyStrategy {dc1=3}
Dharman
  • 30,962
  • 25
  • 85
  • 135
Ivan Sivak
  • 7,178
  • 3
  • 36
  • 42