cdh hive配置mysql,hive记录-cdh配置hive和sentry

1.cdh添加组件-sentry-选择主机-配置数据库

2.配置数据库

1)mysql -uroot -p

DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

3) grant all privileges on sentry.* to root@‘%‘ identified by ‘123‘ with grant option;

选择mysql数据库主机、用户名、密码、需要将mysql jdbc驱动拷贝到对应主机下的cm/share/cmf/lib和/opt/cloudera/parcels/CDH-5.10.2-1.cdh5.10.2.p0.5/lib/sentry/lib

测试连接-下一步-创建数据库表,开启sentry服务

3.hive配置下勾选sentry和hue配置勾选sentry

4.重启hive和hue

5.beeline登录进行授权角色

beeline -u "jdbc:hive2://hadoop03:10000/" -n hive -p hive -d org.apache.hive.jdbc.HiveDriver

1)创建角色并授权给组

执行下面的 sql 语句创建 role、group等:

create role admin_role;

GRANT ALL ON SERVER server1 TO ROLE admin_role;

GRANT ROLE admin_role TO GROUP admin;

GRANT ROLE admin_role TO GROUP hive;

create role test_role;

GRANT ALL ON DATABASE filtered TO ROLE test_role;

GRANT ROLE test_role TO GROUP test;

上面创建了两个角色:

admin_role,具有管理员权限,可以读写所有数据库,并授权给 admin 和 hive 组(对应操作系统上的组)

test_role,只能读写 filtered 数据库,并授权给 test 组。

因为系统上没有test用户和组,所以需要手动创建:

groupadd test

useradd test

测试admin_role角色

使用hive用户访问beeline:

$ beeline -u "jdbc:hive2://hadoop03:10000/" -n hive -p hive -d org.apache.hive.jdbc.HiveDriver

set system:user.name;

show roles;

SHOW GRANT ROLE test_role;

SHOW GRANT ROLE admin_role;

测试test_role角色

使用test用户访问beeline:

$ beeline -u "jdbc:hive2://hadoop03:10000/" -n test -p test -d org.apache.hive.jdbc.HiveDriver

set system:user.name;

原文:https://www.cnblogs.com/xinfang520/p/9329077.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值