Cassandra2.0和OpsCenter4.0登录权限配置

一、Cassandra2.0访问密码设置

1. vi /etc/cassandra/conf/cassandra.yaml,修改:

 

authenticator: PasswordAuthenticator

 

2. 重启

 

/etc/init.d/cassandra restart

 这里要注意下Cassandra2.0默认没有system_auth表,需要做上面配置并重启Cassandra后才会生成System_auth表。

 

3. 修改system_auto的副本因子(必须做must)

 

cqlsh <your_host> -u cassandra -p cassandra

ALTER KEYSPACE system_auth WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 3};

 
4. 创建用户、修改cassandra用户密码

 

CREATE USER admin WITH PASSWORD 'xxxxx' SUPERUSER;
ALTER USER cassandra WITH PASSWORD 'xxxx' NOSUPERUSER ;

 

5. 查看用户

 

use system_auth;
select * from users;

 


6. 配置cqlsh免密码登录

 

vi ~/.cassandra/cqlshrc

[authentication]
username = admin
password = xxxx 

二、OpsCenter4.0 Web界面访问密码设置

 1. 创建用户(这里的用户只限于Opscenter。和Cassandra用户管理没关系)

# 创建用户heipark,角色为admin,密码敲入回车后设置
python /usr/share/opscenter/bin/set_passwd.py heipark admin

 

2. 重启opscenter

 

/etc/init.d/opscenterd restart

 

三、OpsCenter4.0集成带访问密码的Cassandra2.0

 
Cassandra2.0和OpsCenter4.0登录权限配置Cassandra2.0和OpsCenter4.0登录权限配置

 上面用户名、密码为Cassandra用户名、密码,而非Opscenter用户名、密码。

 

四、使用datastax java driver

cluster = Cluster.builder().withCredentials("username", "password").addContactPoints("host").build();

 

要使用CQL,一定要打开Cassandra 9042端口,它是CQL服务端口。

 

start_native_transport: true
native_transport_port: 9042

 

否则会出现这个错误:

 

2014-01-16 14:52:47,241 ERROR [com.chinacache.core.SixShot] - <com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /xxx.xx.xx.xx (com.datastax.driver.core.TransportException: [/xxx.xx.xx.xx] Cannot connect))

 

P.S. 更详细的对Table级别的权限认证参考这里:

http://www.datastax.com/documentation/cassandra/2.0/webhelp/index.html#cassandra/security/secure_config_native_authorize_t.html

 

参考:

http://www.datastax.com/documentation/cassandra/2.0/webhelp/index.html#cassandra/security/security_config_native_authenticate_t.html

http://www.datastax.com/documentation/opscenter/4.0/webhelp/index.html#opsc/configure/opscConfigureUserAccess_c.html

 

--end

你可能感兴趣的:(Access,cassandra,password,username,Opscenter,authorizer)