0
点赞
收藏
分享

微信扫一扫

CDH集群之间迁移hive数据脚本

waaagh 2023-04-09 阅读 88

#!/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://hadoop-cdh-pro-001:8020/user/hive/warehouse/${DB}.db/$tem hdfs://hadoop-cdh-pro-010:8020/user/hive/warehouse/${DB}.db/$tem
done

举报

相关推荐

0 条评论