当卡桑德拉不知道默认用户时,如何重置'cassandra'卡桑德拉超级用户?



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

我检查了类似的问题,如如何重置丢失的Cassandra admin用户的密码?我有Datastax Cassandra 2.0.8的三个节点集群,我正在尝试实现身份验证。我已经安排好了卡桑德拉。在所有节点中添加Yaml并重新启动它们。问题是我仍然不能登录到cqlsh.

我也尝试重置密码为cassandra用户在cqlsh(我已经禁用了认证):

update system_auth.credentials set salted_hash='$2a$10$vbfmLdkQdUz3Rmw.fF7Ygu6GuphqHndpJKTvElqAciUJ4SZ3pwquu' where username='cassandra';

日志中有创建cassandra超级用户的Info。我已经检查了keyspace 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)

但是,当我尝试:

./cqlsh -u cassandra -p cassandra

我得到异常,该用户不存在,但我没有权限创建一个

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

我不确定,但是您上面使用的散列很有可能随着每个版本的变化而变化,并且可能是特定于特定版本的Cassandra。考虑到这一点,您可以(理论上)在VM中安装相同的版本,然后查询该机器的system_auth.credentials以获取cassandra用户的salted_hash。如果不是因为你上面链接的问题,我从来没有想过要尝试。

否则,下一个选项工作。

  1. 停止Cassandra集群。
  2. 在每个节点上,将cd降至data目录,并执行:

    $ mv system_auth system_auth_20140814

  3. 重启每个节点

只要验证器仍然设置(在Cassandra .yaml中)使用PasswordAuthenticator, Cassandra将使用默认的Cassandra超级用户重建system_auth键空间,您可以使用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>

指出:

  • 你必须重新添加所有的用户,并重新申请所有的权限。
  • 而不是重命名(mv) system_auth目录,你也可以直接删除它(rm)。
  • 您必须将适当的复制设置重新应用到system_auth键空间。缺省情况下,system_auth的复制因子只有1。

最新更新