赞
踩
通过${}方式进行引用,其中 system、env 下的变量必须以前缀开头。
1、修改配置文件 ${HIVE_HOME}/conf/hive-site.xml
2、启动 hive cli 时,通过--hiveconf key=value 的方式进行设置
例:hive --hiveconf hive.cli.print.header=true
3、进入 cli 之后,通过使用 set 命令设置
注意:2 和 3 两种方式设置的参数只在当前会话有效。
在 hive CLI 控制台可以通过 set 对 hive 中的参数进行查询、设置
set 设置:
set hive.cli.print.header=true;
set 查看
set hive.cli.print.header;查看该参数的值
set;查看 hive 的所有参数。
hive 历史操作命令集
~/.hivehistory
hive 参数初始化配置
当前用户家目录下的.hiverc 文件
如: ~/.hiverc
如果没有,可直接创建该文件,将需要设置的参数写到该文件中,hive 启动运行时,会加载改文件中的配置。
[root@node4 ~]#vim .hiverc set hive.cli.print.header=true; [root@node4 ~]#hive hive> |
开启支持动态分区
set hive.exec.dynamic.partition=true; |
默认:true
set hive.exec.dynamic.partition.mode=nostrict; |
默认:strict 严格模式
(比如订单表以秒为单位创建分区,将会导致特别多的分区,严格模式一般不允许,但是非严格模式允许)。
nostrict:非严格模式
案例演示:
创建原始数据表
create table person21( 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 '/root/data/person21.txt' into table person21;
create table person22( 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 person21 insert overwrite table person22 partition(age, gender) select id, name,likes, address,age, gender distribute by age, gender; |
或简写为:
from person21 insert overwrite table person22 partition(age, gender) select id, name,likes, address,age, gender; |
注意:分区字段一定要写到最后面,否则容易出错。
show partitions person22;#查询某表上的 分区
相关参数
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)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。