hive-shell批量命令执行脚本的实现方法
时间:2021-08-07 08:43:33|栏目:Shell|点击: 次
如下所示:
#!/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
栏 目:Shell
下一篇:linux shell命令快捷获得系统帮助(一)[man-pages定义规范]
本文地址:http://www.codeinn.net/misctech/164851.html