Cassandra - 无法达到一致性等级QUORUM

时间:2017-07-03 11:02:27

标签: cassandra

我现在正在运行一个节点。我正在尝试为Cassandra启用密码身份验证。

我正在关注本指南:http://cassandra.apache.org/doc/latest/operating/security.html#password-authentication

我会注意到我没有改变system_auth的复制,因为它是一个单节点集群。

我修改了cassandra.yaml以使用authenticator: PasswordAuthenticator

然后我重新启动了cassandra并尝试了cqlsh -u cassandra -p cassandra命令,但这给了我错误:

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"',)})

我已尝试投放nodetool repair,但它说:Replication factor is 1. No repair is needed for keyspace 'system_auth'

我该如何解决这个问题?

7 个答案:

答案 0 :(得分:8)

我设法解决了这个问题。

我必须先运行ALTER KEYSPACE system_auth WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };,因为之前设置为{'class': 'NetworkTopologyStrategy', 'DC1': '1', 'DC2': '1'},即使它是单节点群集。

这就是为什么它无法达到QUORUM。

答案 1 :(得分:5)

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

用户'cassandra'默认情况下始终在system_auth中使用QUORUM。尝试创建一个不同的用户(作为超级用户),你的问题应该消失。

原因是您不能在单个节点cluser上使用QUORUM,请参阅Igors Anwser。

答案 2 :(得分:2)

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

答案 3 :(得分:2)

请遵循以下步骤:

  1. 将/etc/cassandra/cassandra.yaml文件中的身份验证器设置为 AllowAllAuthenticator
  2. 重新启动cassandra sudo服务cassandra重新启动
  3. 运行以下命令 cqlsh ALTER KEYSPACE system_auth有复制= {'class':'SimpleStrategy','replication_factor':1};
  4. 现在将身份验证器再次更改为 PasswordAuthenticator
  5. 重新启动cassandra sudo服务cassandra重新启动
  6. 现在您将可以使用以下命令登录 cqlsh -u cassandra -p cassandra

由于将 system_auth 先前设置为{'class':'NetworkTopologyStrategy','DC1':'1','DC2':'1'},所以发生了该问题是一个单节点群集。

答案 4 :(得分:1)

Cassandra.yaml文件中,将身份验证切换回authenticator: AllowAllAuthentication,并确保authorizer: AllowAllAuthorizer 也被设置。这将允许您再次使用cqlsh。连接前将不再检查身份验证。进入cqlsh后,请按照其他答案将所需的复制降低到较低的级别。

答案 5 :(得分:0)

对我来说,解决此问题的方法是进入cqlsh shell,使用遇到问题的键空间,然后运行命令CONSISTENCY QUORUM

答案 6 :(得分:0)

如果您使用的是 docker-desktop,请执行以下操作:

  • 使用 docker 镜像的 CLI: enter image description here

  • cd etc/cassandra

  • vim cassandra.yml - 编辑文件

  • 将身份验证器更改为 AllowAllAuthenticator

  • 重启容器并执行以下步骤:

  • docker-compose up -d image_name

  • 参考下面突出显示的命令:

enter image description here

  • 现在将身份验证器切换回 cassandra.yaml 中的 PasswordAuthenticator
  • 重启conatiner,现在使用以下步骤登录cqlsh: enter image description here