hive 参数
hive 参数, 变量
- hive当中的参数,变量,都是以命名空间开头的

- 通过 ${}方式进行引用,其中system,env 下的变量必须以前缀开头
hive参数
- hive 参数设置方式
- 1 修改配置文件 ${HIVE_HOME}/conf/hive-site.xml
- 2 启动 hive cli 时,通过 --hiveconf key=vlaue的方式进行设置
例如:hive --hiveconf hive.cli.print.header=true - 3 进入 hive后, 通过set 命令设置
set hive.cli.print.header=true;

这是设置显示表头的
hive set命令
在hive CLI控制台可以通过set对hive中的参数进行查询、设置
- set设置:
set hive.cli.print.header=true; - set查看
set hive.cli.print.header - hive参数初始化配置
当前用户家目录下的.hiverc文件
如: ~/.hiverc
如果没有,可直接创建该文件,将需要设置的参数写到该文件中,hive启动运行时,会加载改文件中的配置。 - hive历史操作命令集 在当前用户的家目录下存在 ll -a
~/.hivehistory

在hive启动时中设置变量
hive -d abc=1
在调用时 ${abc}
select * from psn where id=${abc}
hive 动态分区
- 开启支持动态分区
set hive.exec.dynamic.partition=true;
默认:true
set hive.exec.dynamic.partition.mode=nostrict;
默认:strict(至少有一个分区列是静态分区)
相关参数
set hive.exec.max.dynamic.partitions.pernode;
每一个执行mr节点上,允许创建的动态分区的最大数量(100)
set hive.exec.max.dynamic.partitions;
所有执行mr节点上,允许创建的所有动态分区的最大数量(1000)
set hive.exec.max.created.files;
所有的mr job允许创建的文件的最大数量(100000)
测试数据
1,小明, lol-book-movie,beijing:dongchengqu-shanghai:pudong
2,小红, lol-movie,beijing:dongchengqu-shanghai:pudong
3,小刚, book-movie,beijing:dongchengqu-shanghai:pudong
先设置hive
set hive.exec.dynamic.partition=true;
默认:true
set hive.exec.dynamic.partition.mode=nostrict;
默认:strict(至少有一个分区列是静态分区)
然后读取测试数据
create table psn21
(
id int,
name string,
age int,
gender string,
likes array<string>,
address map<string,string>
)
row format delimited
fields terminated by ','
collection items terminated by '-'
map keys terminated by ':';
load data local inpath '/opt/dytest' insert psn21;
创建动态分区
create table psn22
(
id int,
name string,
likes array<string>,
address map<string,string>
)
partitioned by (age int, gender string)
row format delimited
fields terminated by ','
collection items terminated by '-'
map keys terminated by ':';
from psn21
insert into psn22 partition(age, gender)
select id, name,likes,address,age, gender;
创建会生成mr计算
Hive分桶
分桶: 控制多个文件的
分区:控制多级目录的
- 分桶表是对列值取哈希值的方式,将不同数

本文详细介绍了Hive的各种参数设置,包括Hive CLI的参数、动态分区、分桶、Lateral View、视图、索引以及运行方式。讨论了如何通过set命令调整配置,以及Hive的优化技巧,如并行计算、严格模式、Join优化和小文件合并。同时,文章涵盖了Hive的权限管理和不同运行模式,如本地模式和集群模式,并解释了SQL标准授权模式的使用和限制。
最低0.47元/天 解锁文章
2858

被折叠的 条评论
为什么被折叠?



