不同hadoop集群之间迁移hive数据

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ggz631047367/article/details/50754005
#!/bin/bash
#set -x

DB=$1
#获取hive表定义
ret=$(hive -e 'use ${DB};show tables;'|grep -v _es|grep -v _hb|grep -v importinfo)

for tem in $ret;
do
    hive -e "use ${DB};show create table $tem" >> /tmp/secha.sh
    echo -e ';\c' >> /tmp/secha.sh
done


#迁移hive的表数据
ret=$(hive -e 'use ${DB};show tables;'|grep -v _es|grep -v _hb|grep -v importinfo)

for tem in $ret;
do
    hadoop distcp hdfs://master:9000/user/hive/warehouse/${DB}.db/$tem hdfs://192.168.0.21:8020/user/hive/warehouse/${DB}.db/$tem
done
展开阅读全文

没有更多推荐了,返回首页