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 againstthe underlying storage for operations like drop-partition (disallowthe drop-partition if the user in question doesn't have permissionsto 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 whenevera table gets created.An example like "select,drop" will grant selectand 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_Zeppelin带有Kerberos认证的Hive解释器的配置
2.zeppelin连接Hive安装配置 zeppelin 版本0.8.2 ,hive版本:3.0.0 2.1.安装启动hive3 略 2.1.配置hiveserver2 如果需要配置zeppelin ...
- Hadoop集群搭建(八:Hive的安装配置)
实验 目的 要求 目的: (1)掌握数据仓库工具Hive的安装和配置: 要求: 完成Hive工具的安装和配置: Hive工具能够正常启动运行: Hive控制台命令能够正常使用: 能够正常操作数据库.表 ...
- hadoop安装hive及配置mysql_Hadoop系列之Hive(数据仓库)安装配置
Hadoop系列之Hive(数据仓库)安装配置 1.在NameNode安装 cd /root/soft tar zxvf apache-hive-0.13.1-bin.tar.gz mv apache ...
- Spring Security配置错误
我最近看到Mike Wienser的SpringOne2GX谈论了Application Security Pitfalls . 如果您在Servlet容器上使用Spring的堆栈,这将非常有用,值得 ...
- Hive安装与配置MySQL元数据库
一.MySQL的安装 1.1 更新获取最新软件源,并安装MySQL. sudo apt-get update sudo apt-get install mysql-server 1.2 启动和关闭My ...
- hive2.3.2+mysql5.7.21驱动包_2018-08-30期 Hive外部元数据库配置
一.说明 Hive默认情况下使用derby作为元数据库,derby元数据库只允许单连接,如果两个会话在相同目录去连接hive,会导致第二个连上的用户做相同操作报错,如下图: A用户连接到hive,并创 ...
- Hive安装和配置(利用SecureCRT)
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 Hive安装和配置 前提 一.开启Hadoop集群 1.配置hadoop 2.启动hadoop 3.验证启动 二.安装和配置hive ...
- Security配置
/*** Spring Security配置类*/ @Slf4j @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true) p ...
- Hive 安装与配置步骤
Hive 安装与配置步骤 一.下载版本 1.1下载hive 1.2 直接用 wget 下载 1.3 解压 二. 配置文件 2.1 修改hive-env.sh 2.2 修改hive-log4j.prop ...
最新文章
- __bridge 使用注意
- java编程器答疑z湖南岚鸿,吐血整理
- golang中的collection
- linux编译lua,Linux CentOS 编译LUA。。搞半天终于对了= =
- C语言实现简单的面向对象例子
- boost::noinit_adaptor用法实例
- Java ArrayList get()方法与示例
- kali linux wps 2019 删除_良心推荐!Linux系统下常用办公软件大盘点
- Python import容易犯的一个错误
- 简易效率的抽奖算法(转)
- Linux下exec函数族比如execve等函数的基本使用
- 为什么软件开发方法论让你觉得糟糕?
- 无限弹窗(bat代码 整人恶作剧)
- sql语句如何获得当前日期
- vue阿里云点播播放器
- 3Dmax玻璃材质参数应该怎样设置
- spss 描述性分析
- 基因组组装---基因组大小评估(genome survey)
- 深刻认识差模电压和共模电压
- Not a managed type
热门文章
- python爬取疫情信息html.xpath p标签_python xpath 如何过滤div中的script和style标签
- 怎么让修改的html持久化_一文让你明白Redis持久化
- 设计模式学习1:设计模式简述和设计模式原则
- Java学习总结:33(System类)
- Java学习总结:29
- Java项目:在线课程会员系统(java+Springboot+Maven+JSP+Spring+Mysql+layui)
- java servlet applet,详解Java Servlet与Applet比较
- 【Ant Design Pro 三】样式动态绑定 react样式绑定
- 利用Oracle GoldenGate记录源系统所有表的操作
- antd+dva笔记