13-天亮大数据系列教程之hive参数设置与应用,13-hive
13-天亮大数据系列教程之hive参数设置与应用,13-hive
目录
1、hive参数介绍
2、hive参数设置方法
3、hive参数应用
详情
1、hive参数介绍
2、hive参数设置方法
主要是4种,
通过配置文件设置
- 此种主要是设置系统配置文件,多是全局性质的。在安装完hive后基本不需要再改动。
主要是修改hive-site.xml或是hive-default.xml文件
- 此种主要是设置系统配置文件,多是全局性质的。在安装完hive后基本不需要再改动。
通过在进入hive cli时指定配置参数,如hive –hiveconf param=value来设定session级参数
- 如:hive –hiveconf hive.cli.print.current.db=true
- 如:hive –hiveconf hive.cli.print.current.db=true
通过在进入hive cli后,通过set来设定也是session级参数,此种最为常见
- 如之前提到的set hive.cli.print.current.db=true;
- 如之前提到的set hive.cli.print.current.db=true;
通过shell脚本调用hive -e来做参数设置和脚本执行,生产环境最多采用的方式
- 详细步骤:
- 创建一个shell文件,名为hive_shell.sh:touch hive_shell.sh
- 编辑文件,加入以下脚本:
- 详细步骤:
#!/bin/sh
db="tianliangedu"
table_name="student"
jar_path="/home/hive/tianliangedu_course/04_udf/TlHadoopCore-jar-with-dependencies.jar"
class_path="com.tianliangedu.hive.udaf.DIYCountUDAF"
hive -e "
use $db;
add jar $jar_path;
create temporary function selfcount as '$class_path';
select selfcount(1) from $table_name;
"
执行脚本
- sh hive_shell.sh
- 输出效果
3、hive参数应用
- 参数hive.execution.engine使用
#!/bin/sh
db="tianliangedu"
table_name="student"
jar_path="/home/hive/tianliangedu_course/04_udf/TlHadoopCore-jar-with-dependencies.jar"
class_path="com.tianliangedu.hive.udaf.DIYCountUDAF"
hive -e "
use $db;
set hive.execution.engine=mr;
add jar $jar_path;
create temporary function selfcount as '$class_path';
select selfcount(1) from $table_name;
"
- 参数mapred.job.name使用
#!/bin/sh
db="tianliangedu"
table_name="student"
jar_path="/home/hive/tianliangedu_course/04_udf/TlHadoopCore-jar-with-dependencies.jar"
class_path="com.tianliangedu.hive.udaf.DIYCountUDAF"
hive -e "
use $db;
set hive.execution.engine=mr;
set mapred.job.name='hive_shell_任务';
add jar $jar_path;
create temporary function selfcount as '$class_path';
select selfcount(1) from $table_name;
"
执行输出:
- 参数“合并小文件组合参数”使用
- 不加该参数时候的脚本
#!/bin/sh
db="tianliangedu"
table_name="student"
jar_path="/home/hive/tianliangedu_course/04_udf/TlHadoopCore-jar-with-dependencies.jar"
class_path="com.tianliangedu.hive.udaf.DIYCountUDAF"
hive -e "
use $db;
set hive.execution.engine=mr;
set mapred.job.name='自动合并小文件-未启用';
add jar $jar_path;
create temporary function selfcount as '$class_path';
select selfcount(1) from $table_name;
"
- 加入该参数脚本
#!/bin/sh
db="tianliangedu"
table_name="student"
jar_path="/home/hive/tianliangedu_course/04_udf/TlHadoopCore-jar-with-dependencies.jar"
class_path="com.tianliangedu.hive.udaf.DIYCountUDAF"
hive -e "
use $db;
set hive.execution.engine=mr;
set mapred.job.name='自动合并小文件-已启用';
set mapred.max.split.size=100000000
set mapred.min.split.size.per.node=100000000
set mapred.min.split.size.per.rack=100000000
set hive.input.format=org.apache.hadoop.hive.ql.io.CombineHiveInputFormat
add jar $jar_path;
create temporary function selfcount as '$class_path';
select selfcount(1) from $table_name;
"
执行结果:
天亮教育是一家从事Java、Hadoop大数据云计算、Python的教育培训、产品开发、咨询服务、人才优选为一体的综合型互联网科技公司。
公司由一批BAT等一线互联网IT精英人士创建,
以”快乐工作,认真生活,打造高端职业技能教育的一面旗帜”为愿景,
胸怀”让天下没有难找的工作”使命,
坚持”客户第一、诚信、激情、拥抱变化”的价值观,
全心全意为学员赋能提效,践行技术改变命运的初心。
欢迎关注天亮教育公众号,大数据技术资料与课程、招生就业动态、教育资讯动态、创业历程分享一站式分享,官方
评论暂时关闭