hive-shell批量命令执行脚本的实现方法
程序员文章站
2022-03-20 15:37:15
如下所示:
#!/usr/bin/bash
hadoop_home="/opt/module/cdh-5.3.6-ha/hadoop-2.5.0-cdh5.3....
如下所示:
#!/usr/bin/bash hadoop_home="/opt/module/cdh-5.3.6-ha/hadoop-2.5.0-cdh5.3.6" hive_home='/opt/module/cdh-5.3.6-ha/hive-0.13.1-cdh5.3.6' ####### execute hive ###### sql=$(cat <<!eof use db_01; drop table dept_nopart; create table if not exists dept_part( deptno int, dname string, loc string ) partitioned by (day string) row format delimited fields terminated by '\t'; !eof) ############ execute begin ########### echo $sql cd $hive_home bin/hive -e "$sql" cd $hadoop_home bin/hdfs dfs -mkdir -p /hive/warehouse/db_01.db/dept_part/day=20150913 ; bin/hdfs dfs -put /opt/data/dept.txt /hive/warehouse/db_01.db/dept_part/day=20150913 ; cd $hive_home bin/hive -e "use db_01;msck repair table dept_part;" exitcode=$? if [ $exitcode -ne 0 ];then echo "[error] hive execute failed!" exit $exitcode fi
以上这篇hive-shell批量命令执行脚本的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
下一篇: python基础学习20----线程