How to get the replication factor of C* cluster?
Asked Answered
B

6

23

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?

Bicker answered 18/1, 2016 at 16:33 Comment(0)
S
40

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.

Spook answered 18/1, 2016 at 16:43 Comment(3)
@will- Thanks, It worked. Can you tell what is the default value of the replication factor?Bicker
There is no default value for this setting. When you create a keyspace you have to specify the replication factor.Spook
In Cassandra 2.1, the data is in a different schema/table: select * from system.schema_keyspaces;Benniebenning
M
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);

Monarda answered 18/1, 2016 at 20:0 Comment(1)
This is more updated answer than the accepted one. Thx.Marcello
C
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'}
Castellany answered 12/6, 2018 at 6:0 Comment(0)
B
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

Branny answered 11/8, 2018 at 11:56 Comment(0)
P
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

Plump answered 8/2, 2019 at 9:37 Comment(0)
F
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}
Fitful answered 25/5, 2021 at 11:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.