Search code examples
springauthenticationcassandrareplicationscalability

system_auth replication in Cassandra


I'm trying to configure authentication on Cassandra. It seems like because of replication strategy that is used for system_auth, it can't replicate user credentials to all the nodes in cluster, so I end up getting Incorrect credentials on one node, and getting successful connection on another.

This is related question. The guy there says you have to make sure credentials are always on all nodes.

How to do it? The option that is offered there says you have to alter keyspace to put replication factor equal to amount of nodes in cluster, then run repair on each node. That's whole tons of work to be done if you want your cassandra to be dynamically scalable. If I add 1 node today, 1 node another day, alter keyspace replication and then keep restarting nodes manually that will end up some kind of chaos.

Hour of googling actually leaded to slightly mentioned EverywhereStrategy, but I don't see anywhere in docs it mentioned as available. How do people configure APIs to work with Cassandra authentication then, if you can't be sure that your user actually present on node, that you're specifying as contact point?

Obviously, talking about true scale, when you can change the size of cluster without doing restarts of each node.


Solution

  • When you enable authentication in Cassandra, then Yes you have increase the system_auth keyspace replication_factor to N(total number of nodes) and run a complete repair, but you don't need to restart the nodes after you add a new Node.

    If repair is consuming more time then you optimize your repair like repair only the system_auth keyspace

    nodetool repair system_auth
    

    (or)

    nodetool repair -pr system_auth
    

    As per Cassandra a complete repair should be done regularly. For more details on repair see the below links:

    http://www.datastax.com/dev/blog/repair-in-cassandra

    https://www.pythian.com/blog/effective-anti-entropy-repair-cassandra/

    http://docs.datastax.com/en/archived/cassandra/2.2/cassandra/tools/toolsRepair.html

    Answering your questions:

    Question: How do people configure APIs to work with Cassandra authentication then, if you can't be sure that your user actually present on node, that you're specifying as contact point?

    Answer: I'm using Cassandra 2.2 and Astyanax thrift API from my Spring project, using which I am able to handle the Cassandra authentication effectively. Specify what version of Cassandra you are using and what driver you are using to connect CQL driver or Astyanax thrift API?

    Question: Obviously, talking about true scale, when you can change the size of cluster without doing restarts of each node.

    Answer: Yes you can scale your Cassandra cluster without restarting nodes, please check the datastax documentation for Cassandra 2.2 version: http://docs.datastax.com/en/archived/cassandra/2.2/cassandra/operations/opsAddNodeToCluster.html

    Check the datastax docs for the version you are using.