分享

请问如何在不同集群之间 迁移hive数据

Hentai 发表于 2016-9-30 10:44:24 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 3 24854

已有(3)人评论

跳转到指定楼层
langke93 发表于 2016-9-30 13:34:00

可以根据自己的修改,切记做好备份
[mw_shl_code=bash,true]#!/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[/mw_shl_code]

回复

使用道具 举报

Hentai 发表于 2016-9-30 15:02:30
langke93 发表于 2016-9-30 13:34
可以根据自己的修改,切记做好备份
[mw_shl_code=bash,true]#!/bin/bash
#set -x

thanks  这是写的一个脚本里面的吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条