vim cassandra.yaml
authenticator: PasswordAuthenticator
cassandra -f
cqlsh -u cassandra -p cassandra
CREATE ROLE busuanzi WITH SUPERUSER = true AND LOGIN = true AND PASSWORD = 'busuanzi.org';
exit
cqlsh -u busuanzi -p busuanzi.org
ALTER ROLE cassandra WITH SUPERUSER = false AND LOGIN = false;
之后可以根据新的用户名和密码登录Cassandra。
至于Cassandra远程连接相关配置请看下一节。
扩展内容:
1.如何在集群中更新密码验证配置(如果是单机版,忽略此步骤)
ALTER KEYSPACE system_auth WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': 3, 'DC2': 3};
2.如果遇到登录失败报错
cqlsh -u cassandra -p cassandra
Connection error: ('Unable to connect to any servers', {'127.0.0.1': AuthenticationFailed('Failed to authenticate to 127.0.0.1: Error from server: code=0100 [Bad credentials] message="Error during authentication of user cassandra : org.apache.cassandra.exceptions.UnavailableException: Cannot achieve consistency level QUORUM"',)})
单机版的更改成集群复制了,因为找不到节点,单机版登录会失败。需要将密码验证改回去,然后进入cqlsh
ALTER KEYSPACE system_auth WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
内容来源于网络,如有侵权,请联系作者删除!