如何重置Cassandra超级用户,当Cassandra不知道'cassandra'默认用户?

Lad*_*odi 2 authentication cassandra

如何在不更改源代码的情况下重置默认的Cassandra凭据?

我检查过类似的问题,例如如何重置丢失的Cassandra管理员用户的密码?.我有三个Datastax Cassandra 2.0.8节点集群,我正在尝试实现身份验证.我在所有节点中设置了cassandra.yaml并重新启动它们.问题是我仍然无法登录到cqlsh.

我还尝试在cqlsh中为cassandra用户重置密码(我已禁用身份验证):

update system_auth.credentials set salted_hash='$2a$10$vbfmLdkQdUz3Rmw.fF7Ygu6GuphqHndpJKTvElqAciUJ4SZ3pwquu' where username='cassandra';
Run Code Online (Sandbox Code Playgroud)

在日志中有关于创建cassandra超级用户的信息.我检查了密钥空间system_auth,它包括凭据,权限和用户.凭证列系列确实包含用户cassandra:

cqlsh> use system_auth;
cqlsh:system_auth> select * from credentials;

 username  | options | salted_hash
-----------+---------+----------------------------------------------------------                                ----
 cassandra |    null | $2a$10$vbfmLdkQdUz3Rmw.fF7Ygu6GuphqHndpJKTvElqAciUJ4SZ3pw                                quu

(1 rows)
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试时:

./cqlsh -u cassandra -p cassandra
Run Code Online (Sandbox Code Playgroud)

我得到例外,该用户不存在,但我没有权限创建一个.

cql.cassandra.ttypes.AuthenticationException: AuthenticationException(why="User cassandra doesn't exist - create it with CREATE USER query first")
Run Code Online (Sandbox Code Playgroud)

Aar*_*ron 6

我不确定,但上面使用的哈希很可能随每个版本而变化,并且可能特定于Cassandra的特定版本.考虑到这一点,你可以(在理论上)在VM中安装相同的版本,然后查询该机器的system_auth.credentialscassandra用户salted_hash.如果不是你上面提到的问题,我从来没有想过尝试过.

否则,下一个选项起作用.

  1. 停止你的Cassandra集群.
  2. 在每个节点上,cd直到您的data目录,然后执行:

    $ mv system_auth system_auth_20140814

  3. 重启每个节点.

只要验证器仍然设置(在你的cassandra.yaml中)使用PasswordAuthenticator,Cassandra将system_auth使用默认的Cassandra超级用户重建密钥空间,你可以使用它cqlsh来重新进入.

$ ./cqlsh -u cassandra -p cassandra
Connected to MyCluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.1.0-rc5-SNAPSHOT | CQL spec 3.2.0 | Native protocol v3]
Use HELP for help.
cqlsh>
Run Code Online (Sandbox Code Playgroud)

笔记:

  • 您必须重新添加所有用户,然后重新应用所有权限.
  • 您也可以删除它(),而不是重命名(mv)system_auth目录rm.
  • 您必须将适当的复制设置重新应用于system_auth密钥空间.默认情况下,system_auth复制因子仅为1.

  • 在尝试了您的答案并设置了更高的复制因子后,它开始起作用。 (2认同)
  • @Scooletz我已禁用身份验证,启动节点和更新复制因子,如下所示:CREATE KEYSPACE system_auth WITH REPLICATION = {'class':'SimpleStrategy','replication_factor':3}; 然后我再次启用验证并使用上面的解决方案.但是,在清理system_auth后,我没有遇到启动节点的任何问题.您是否在节点启动期间看到了有助于logg的任何内容?应该有关于cassandra超级用户创建的信息.你在所有节点上清理了system_auth吗? (2认同)