Cassandra - Cannot achieve consistency level QUORUM

Viewed 21163

I'm running a single node at the moment. I'm trying to enable password authentication for Cassandra.

I'm following this guide: http://cassandra.apache.org/doc/latest/operating/security.html#password-authentication

I'll note that I didn't alter system_auth's replication as it's a single node cluster.

I edited cassandra.yaml to use authenticator: PasswordAuthenticator.

I then restarted cassandra and tried the command cqlsh -u cassandra -p cassandra, but that gives me the error:

Connection error: ('Unable to connect to any servers',
{'127.0.0.1': AuthenticationFailed(u'Failed to authenticate to 127.0.0.1: 
code=0100 [Bad credentials] message="org.apache.cassandra.exceptions.
UnavailableException: Cannot achieve consistency level QUORUM"',)})

I've tried running nodetool repair but it says: Replication factor is 1. No repair is needed for keyspace 'system_auth'

How do I solve this?

7 Answers

Follow the below steps:

  1. Set the authenticator in /etc/cassandra/cassandra.yaml file to AllowAllAuthenticator
  2. Restart the cassandra sudo service cassandra restart
  3. run the following commands cqlsh ALTER KEYSPACE system_auth WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
  4. Now change the authenticator again back to PasswordAuthenticator
  5. Restart the cassandra sudo service cassandra restart
  6. Now you will be able to login using the following command cqlsh -u cassandra -p cassandra

The issue is happening since a system_auth was set to {'class': 'NetworkTopologyStrategy', 'DC1': '1', 'DC2': '1'} previously, even though it was a single node cluster.

In the Cassandra.yaml file, switch the authentication back to authenticator: AllowAllAuthentication and make sure authorizer: AllowAllAuthorizer is set as well. This will allow you to use cqlsh again. It will no longer be checking for authentication before connecting. Once in cqlsh follow the other answers to lower the required replication to a lower level.

In case you are using docker-desktop do the following:

  • Use CLI of the docker image: enter image description here

  • cd etc/cassandra

  • vim cassandra.yml - to edit the file

  • Change authenticator to AllowAllAuthenticator

  • Restart the container and do following steps:

  • docker-compose up -d image_name

  • Refer below highlighted commands:

enter image description here

  • Now swith back the authenticator to PasswordAuthenticator in cassandra.yaml
  • Restart conatiner and now use below step to login to cqlsh: enter image description here

What fixed it for me was go into the cqlsh shell, use the keyspace you're having issue's with, and run the command CONSISTENCY QUORUM

Related