简体   繁体   中英

Cassandra - Cannot achieve consistency level QUORUM

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?

I managed to solve the problem.

I had to run ALTER KEYSPACE system_auth WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; as it was set to {'class': 'NetworkTopologyStrategy', 'DC1': '1', 'DC2': '1'} previously, even though it was a single node cluster.

This is why it couldn't achieve a QUORUM.

http://docs.datastax.com/en/datastax_enterprise/4.8/datastax_enterprise/sec/secConfiguringInternalAuthentication.html

The user 'cassandra' always uses QUORUM in system_auth per default. Try creating a different user (as superuser) and your problem should be gone.

The reason is that you cannot have QUORUM on a single node cluser, see Igors Anwser.

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.

在 1 节点(或 2 节点)配置中 QUORUM 是不可能的,并且不需要修复(因为它用于修复节点之间的数据不一致)

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.

对我来说修复它的是进入 cqlsh shell,使用您遇到问题的键空间,然后运行命令CONSISTENCY QUORUM

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

  • Use CLI of the docker image: 在此处输入图片说明

  • 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:

在此处输入图片说明

  • Now swith back the authenticator to PasswordAuthenticator in cassandra.yaml
  • Restart conatiner and now use below step to login to cqlsh: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM