如何在不更改源代码的情况下重置默认Cassandra凭据?
我已经检查过类似的问题,比如How to reset a lost Cassandra admin user's password?。我有Datastax Cassandra 2.0.8的三节点集群,并且我正在尝试实现身份验证。我已经在所有节点上设置了cassandra.yaml并重启了它们。问题是我仍然不能登录到cqlsh。
我还尝试在cqlsh中重置cassandra用户的密码(为此我禁用了身份验证):
update system_auth.credentials set salted_hash='$2a$10$vbfmLdkQdUz3Rmw.fF7Ygu6GuphqHndpJKTvElqAciUJ4SZ3pwquu' where username='cassandra';在日志中有关于创建cassandra超级用户的信息。我已经检查了密钥空间system_auth,它包括凭证、权限和用户。并且credentials列系列包含用户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")发布于 2014-08-14 22:00:18
我不确定,但您上面使用的散列很可能在每个版本中都有所不同,并且可能特定于某个特定版本的Cassandra。考虑到这一点,您可以(理论上)在VM中安装相同的版本,然后在该机器的system_auth.credentials中查询cassandra用户的salted_hash。如果不是因为你上面链接的问题,我永远不会想到去尝试。
否则,下一个选项将工作。
cd到您的data目录,然后执行:$ mv system_auth system_auth_20140814
只要验证器(在您的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目录,您也可以直接将其删除,然后必须将适当的复制设置重新应用到您的system_auth密钥空间。默认情况下,system_auth的复制因子仅为1。https://stackoverflow.com/questions/25306785
复制相似问题