我已经用自制软件安装了cassandra,我正在尝试创建一个超级用户管理员帐户。当我输入sudo cqlsh -u cassandra -p cassandra
时,我收到此错误:
Python Cassandra driver not installed, or not on PYTHONPATH.
You might try "pip install cassandra-driver".
Python: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Module load path: ['/usr/local/Cellar/cassandra/2.1.2/bin', '/Library/Python/2.7/site-packages/cql-1.4.0-py2.7.egg', '/Library/Python/2.7/site-packages/thrift-0.9.2-py2.7-macosx-10.10-intel.egg', '/Library/Python/2.7/site-packages/ccm-2.0.2-py2.7.egg', '/Library/Python/2.7/site-packages/tailer-0.3-py2.7.egg', '/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/psutil-2.2.0-py2.7-macosx-10.10-intel.egg', '/Library/Python/2.7/site-packages/pip-6.0.6-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']
Error: No module named cassandra
当我没有sudo时,我被允许使用默认登录进入cqlsh。问题是,当我输入CREATE USER admn WITH PASSWORD 'pw' SUPERUSER;
时,会返回此信息:
code=2100 [Unauthorized] message="Only superusers are allowed to perform CREATE USER queries"
当我看到这个时,我就像,没有任何疑问,进入我的cassandra.yaml文件,该文件位于/usr/local/etc/cassandra
并更改了authenticator: AllowAllAuthenticator
到authenticator: PasswordAuthenticator
。我保存文件回到cqlsh并再次尝试。结果相同。有人可以告诉我如何设置新用户吗?
答案 0 :(得分:3)
你走在正确的轨道上。默认的超级用户帐户是用户名&cassandra'密码&cassandra'并且您正在适当地配置身份验证器。
缺少的是更改cassandra.yaml文件后,需要重新启动cassandra才能使Authenticator更改生效。请注意,您还应将授权程序更改为“CassandraAuthorizer'。
如果您有多节点群集,则应在所有节点上进行此更改,并且还应增加system_auth键空间上的复制因子,以便在拥有数据的节点关闭后允许auth继续工作。 / p>
答案 1 :(得分:2)
在将csssh的cssandra节点连接为cqlsh -u cassandra -p cassandra之后,我遇到了创建新用户的问题。
// authenticator:AllowAllAuthenticator
// authorizer:AllowAllAuthorizer
重新启动cassandra节点
从cqlsh连接cassandra / cassandra凭据
4.看了一个system.log(tail -f system.log),你会看到以下消息。
INFO [NonPeriodicTasks:1] 2015-04-23 11:02:03,973 PasswordAuthenticator.java:215 - PasswordAuthenticator创建了默认用户' cassandra'
INFO [NonPeriodicTasks:1] 2015-04-23 11:02:03,987 Auth.java:277 - 创建默认超级用户' cassandra'
答案 2 :(得分:2)
注意:适用于Cassandra 2.2及更高版本
"支持CREATE USER以实现向后兼容性。 Cassandra 2.2及更高版本的身份验证和授权基于ROLES,并且应该使用CREATE ROLE。"
看看:Creating a new user using ROLE
回答你的问题,这对我有用:
在Cassandra的配置文件中, cassandra.yaml 修改以下行:
评论此行:
authenticator:AllowAllAuthenticator
并替换为:
身份验证者: PasswordAuthenticator
评论此行:
authorizer:AllowAllAuthorizer
并替换为:
授权人: CassandraAuthorizer
之后,您可以创建自己的超级用户:
使用密码' your_password '创建用户 your_user_name 超级用户; 强>