Hive的Security配置
为了更好地使用好Hive,我将《Programming Hive》的Security章节取出来,翻译了一下。
Hive还是支持相当多的权限管理功能,满足一般数据仓库的使用。
Hive由一个默认的设置来配置新建文件的默认权限。
- <property>
- <name>hive.files.umask.value</name>
- <value>0002</value>
- <description>The dfs.umask value for the hive created folders</description>
- </property>
<property>
<name>hive.files.umask.value</name>
<value>0002</value>
<description>The dfs.umask value for the hive created folders</description>
</property>
当hive.metastore.authorization.storage.checks属性被设置成true时,
Hive将会阻止没有权限的用户进行表删除操作。
不过这个配置的默认值是false,应该设置成true
- <property>
- <name>hive.metastore.authorization.storage.checks</name>
- <value>true</value>
- <description>Should the metastore do authorization checks against
- the underlying storage for operations like drop-partition (disallow
- the drop-partition if the user in question doesn't have permissions
- to delete the corresponding directory on the storage).</description>
- </property>
<property>
<name>hive.metastore.authorization.storage.checks</name>
<value>true</value>
<description>Should the metastore do authorization checks against
the underlying storage for operations like drop-partition (disallow
the drop-partition if the user in question doesn't have permissions
to delete the corresponding directory on the storage).</description>
</property>
同时,Hive会尽可能地将hive.metastore.execute.setugi设置成true。
开启Hive的身份认证功能,默认是false
- <property>
- <name>hive.security.authorization.enabled</name>
- <value>true</value>
- <description>Enable or disable the hive client authorization</description>
- </property>
<property>
<name>hive.security.authorization.enabled</name>
<value>true</value>
<description>Enable or disable the hive client authorization</description>
</property>
另外还有一个是表格创建者用于的权限配置项:
- <property>
- <name>hive.security.authorization.createtable.owner.grants</name>
- <value>ALL</value>
- <description>The privileges automatically granted to the owner whenever
- a table gets created.An example like "select,drop" will grant select
- and drop privilege to the owner of the table</description>
- </property>
<property>
<name>hive.security.authorization.createtable.owner.grants</name>
<value>ALL</value>
<description>The privileges automatically granted to the owner whenever
a table gets created.An example like "select,drop" will grant select
and drop privilege to the owner of the table</description>
</property>
这个配置默认是NULL,我们建议将其设置成ALL,让用户能够访问自己创建的表。
试验,在命令行环境开启用户认证
- hive> set hive.security.authorization.enabled=true;
- hive> CREATE TABLE authorization_test (key int, value string);
- Authorization failed:No privilege 'Create' found for outputs { database:default}.
- Use show grant to get more details.
hive> set hive.security.authorization.enabled=true;
hive> CREATE TABLE authorization_test (key int, value string);
Authorization failed:No privilege 'Create' found for outputs { database:default}.
Use show grant to get more details.
我们可以看到,建表需要权限了。
权限可以授予给不同的主题,如用户(USER),组(GROUP),角色(ROLES)
现在我们通过授权方式,将权限授予给当前用户:
- hive> set system:user.name;
- system:user.name=edward
- hive> GRANT CREATE ON DATABASE default TO USER edward;
- hive> CREATE TABLE authorization_test (key INT, value STRING);
hive> set system:user.name;
system:user.name=edward
hive> GRANT CREATE ON DATABASE default TO USER edward;
hive> CREATE TABLE authorization_test (key INT, value STRING);
这样就可以创建表了。
我们可以通过SHOW GRANT命令确认我们拥有的权限:
- hive> SHOW GRANT USER edward ON DATABASE default;
- database default
- principalName edward
- principalType USER
- privilege Create
- grantTime Mon Mar 19 09:18:10 EDT 2012
- grantor edward
hive> SHOW GRANT USER edward ON DATABASE default;
database default
principalName edward
principalType USER
privilege Create
grantTime Mon Mar 19 09:18:10 EDT 2012
grantor edward
当Hive里面用于N多用户和N多张表的时候,管理员给每个用户授权每张表会让他崩溃的。
所以,这个时候就可以进行组(GROUP)授权。
Hive里的用户组的定义等价于POSIX里面的用户组。
- hive> CREATE TABLE authorization_test_group(a int,b int);
- hive> SELECT * FROM authorization_test_group;
- Authorization failed:No privilege 'Select' found for inputs
- { database:default, table:authorization_test_group, columnName:a}.
- Use show grant to get more details.
- hive> GRANT SELECT on table authorization_test_group to group edward;
- hive> SELECT * FROM authorization_test_group;
- OK
- Time taken: 0.119 seconds
hive> CREATE TABLE authorization_test_group(a int,b int);
hive> SELECT * FROM authorization_test_group;
Authorization failed:No privilege 'Select' found for inputs
{ database:default, table:authorization_test_group, columnName:a}.
Use show grant to get more details.
hive> GRANT SELECT on table authorization_test_group to group edward;
hive> SELECT * FROM authorization_test_group;
OK
Time taken: 0.119 seconds
当给用户组授权变得不够灵活的时候,角色(ROLES)就派上用途了。
用户可以被放在某个角色之中,然后角色可以被授权。
角色不同于用户组,是由Hadoop控制的,它是由Hive内部进行管理的。
- hive> CREATE TABLE authentication_test_role (a int , b int);
- hive> SELECT * FROM authentication_test_role;
- Authorization failed:No privilege 'Select' found for inputs
- { database:default, table:authentication_test_role, columnName:a}.
- Use show grant to get more details.
- hive> CREATE ROLE users_who_can_select_authentication_test_role;
- hive> GRANT ROLE users_who_can_select_authentication_test_role TO USER edward;
- hive> GRANT SELECT ON TABLE authentication_test_role
- > TO ROLE users_who_can_select_authentication_test_role;
- hive> SELECT * FROM authentication_test_role;
- OK
- Time taken: 0.103 seconds
hive> CREATE TABLE authentication_test_role (a int , b int);
hive> SELECT * FROM authentication_test_role;
Authorization failed:No privilege 'Select' found for inputs
{ database:default, table:authentication_test_role, columnName:a}.
Use show grant to get more details.
hive> CREATE ROLE users_who_can_select_authentication_test_role;
hive> GRANT ROLE users_who_can_select_authentication_test_role TO USER edward;
hive> GRANT SELECT ON TABLE authentication_test_role
> TO ROLE users_who_can_select_authentication_test_role;
hive> SELECT * FROM authentication_test_role;
OK
Time taken: 0.103 seconds
介绍一下常用的授权关键字:
| ALTER | 更改表结构,创建分区 |
| CREATE | 创建表 |
| DROP | 删除表,或分区 |
| INDEX | 创建和删除索引 |
| LOCK | 锁定表,保证并发 |
| SELECT | 查询表权限 |
| SHOW_DATABASE | 查看数据库权限 |
| UPDATE |
为表加载本地数据的权限 |
分区表级别的授权
默认情况下,分区表的授权将会跟随表的授权
当然,也可以给每一个分区建立一个授权机制,
只需要设置表的属性PARTITION_LEVEL_PRIVILEGE设置成TRUE:
- hive> ALTER TABLE authorization_part
- > SET TBLPROPERTIES ("PARTITION_LEVEL_PRIVILEGE"="TRUE");
- Authorization failed:No privilege 'Alter' found for inputs
- {database:default, table:authorization_part}.
- Use show grant to get more details.
hive> ALTER TABLE authorization_part
> SET TBLPROPERTIES ("PARTITION_LEVEL_PRIVILEGE"="TRUE");
Authorization failed:No privilege 'Alter' found for inputs
{database:default, table:authorization_part}.
Use show grant to get more details.
自动授权
属性hive.security.authorization.createtable.owner.grants决定了
建表者对表拥有的权限,一版情况下,有select和drop
- <property>
- <name>hive.security.authorization.createtable.owner.grants</name>
- <value>select,drop</value>
- </property>
<property>
<name>hive.security.authorization.createtable.owner.grants</name>
<value>select,drop</value>
</property>
类似的,特定的用户可以被在表创建的时候自动授予其权限。
- <property>
- <name>hive.security.authorization.createtable.user.grants</name>
- <value>admin1,edward:select;user1:create</value>
- </property>
<property>
<name>hive.security.authorization.createtable.user.grants</name>
<value>admin1,edward:select;user1:create</value>
</property>
当表建立的时候,管理员admin1和用户edward授予读所有表的权限。
而user1只能创建表。
同样的配置也可以作用于组授权和角色授权
hive.security.authorization.createtable.group.grants
hive.security.authorization.createtable.role.grants
转自 http://dacoolbaby.iteye.com/blog/1829545
Hive的Security配置的更多相关文章
- 【转】hive简介安装 配置常见问题和例子
原文来自: http://blog.csdn.net/zhumin726/article/details/8027802 1 HIVE概述 Hive是基于Hadoop的一个数据仓库工具,可以将结构化 ...
- hadoop2.2.0 + hbase 0.94 + hive 0.12 配置记录
一开始用hadoop2.2.0 + hbase 0.96 + hive 0.12 ,基本全部都配好了.只有在hive中查询hbase的表出错.以直报如下错误: java.io.IOException: ...
- Hive的安装配置
Hive的安装配置 Hive的安装配置 安装前准备 下载Hive版本1.2.1: 1.[root@iZ28gvqe4biZ ~]# wget http://mirror.bit.edu.cn/apac ...
- Hive安装与配置详解
既然是详解,那么我们就不能只知道怎么安装hive了,下面从hive的基本说起,如果你了解了,那么请直接移步安装与配置 hive是什么 hive安装和配置 hive的测试 hive 这里简单说明一下,好 ...
- spring boot 之 spring security 配置
Spring Security简介 之前项目都是用shiro,但是时过境迁,spring security变得越来越流行.spring security的前身是Acegi, acegi 我也玩过,那都 ...
- [hive] hive 安装、配置
一.hive安装 1.官网下载 1.2.2版本 http://apache.fayea.com/hive/hive-1.2.2/ 2. 解压,此处目录为 /opt/hadoop/hive-1.2.2 ...
- Hive安装与配置--- 基于MySQL元数据
hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供简单的sql查询功能,可以将sql语句转换为MapReduce任务进行运行. 其优点是学习成本低,可以通过 ...
- 【Hive一】Hive安装及配置
Hive安装及配置 下载hive安装包 此处以hive-0.13.1-cdh5.3.6版本的为例,包名为:hive-0.13.1-cdh5.3.6.tar.gz 解压Hive到安装目录 $ tar - ...
- CentOS6安装各种大数据软件 第八章:Hive安装和配置
相关文章链接 CentOS6安装各种大数据软件 第一章:各个软件版本介绍 CentOS6安装各种大数据软件 第二章:Linux各个软件启动命令 CentOS6安装各种大数据软件 第三章:Linux基础 ...
随机推荐
- 【转】VB中应用DDE
动态数据交换(dde)是windows应用程序间通讯的基本方法之一,在动态数据交换的过程中,提供数据和服务的应用程序称为服务器,请求数据或服务的应用程序则称为客户. dde交谈是由客户程序启动的.如果 ...
- Burpsuite之Http Basic认证爆破
有的时候经常遇到401.今天正好朋友问怎么爆破,也顺便记录一下 怕忘记了 referer:http://www.2cto.com/Article/201303/194449.html 看到Burpsu ...
- sencha touch之store
store相当于数据库的表,是模型实例的集合.(是不是可以看成结构体数组) 可以对模型实例进行新建.更新.读取.删除.排序和过滤等操作. 创建store 由于store是表,必须要有模型或者定义字段, ...
- poj 2398 (叉积+二分)
http://poj.org/problem?id=2398 Toy Storage Time Limit: 1000MS Memory Limit: 65536K Total Submissio ...
- Linux 下常用解压命令(转载)
Linux下常用文件解压(包括rpm.deb包) Linux下怎么解后缀名是gzip的文件?1.以.a为扩展名的文件:#tar xv file.a2.以.z为扩展名的文件:#uncompress fi ...
- [资源] Getting started with Tensorflow
Learning Website / Blog: Official Tutorial: https://www.tensorflow.org/tutorial Learn Tensorflow: ht ...
- 问题: unrecognized selector sent to class 0x10affab20
今天遇到了一个问题, 害我足足找了半个小时 问题: 明明可以跳进 方法 的实现里面, 但是程序运行的时候, 就是报错: 发送一个未识别消息, 而且程序直接跳出, 停止执行 原因: 项目的编译文件列表里 ...
- list map vector set 常用函数列表
#include <stdio.h> #include <iostream>//cin,cout #include <sstream>//ss transfer. ...
- mongoDB 类型参考表
$type操作符是基于BSON类型来检索集合中匹配的数据类型,并返回结果. MongoDB 中可以使用的类型如下表所示: 参考资料:http://www.runoob.com/mongodb/mong ...
- Python学习笔记12—类
典型的类和调用方法: #!/usr/bin/env Python # coding=utf-8 __metaclass__ = type #新式类 class Person: #创建类 def __i ...