shell调用sqoop

Mysql 数据导入Hive

自动创建hive表 

#!/bin/bash
source /etc/profile
num=0
list="table1 table2 table3"
for i in $list; do
   echo "$sum"
   echo "$i"
   echo "sqoop开始批量导入......"
   sqoop import --connect jdbc:mysql://localhost:3306/test --username root --password 123456 --table person --hive-table db.$i --delete-target-dir  --hive-overwrite --hive-import &
   num=$(expr $num + 1)
   if [$sum -gt 4 ]; then
      {
         echo "等待批量任务完成"
         wait
         echo "开始下一批导入"
         num = 0
      }
   fi
done
echo "等待最后一批任务完成"
wait
echo "全部导入完成"

 

你可能感兴趣的:(sqoop)