如下所示:
#!/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 NOruVzNudyT EXISTS dept_part(
deptnruVzNudyo 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批量命令执行脚本的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持我们。