hive数据迁移(数据+元数据)

6 篇文章 0 订阅
4 篇文章 0 订阅

参考:https://blog.csdn.net/Lzx116/article/details/126539520

hive数据迁移(数据+元数据)已解决

在这里插入图片描述
报错:FAILED: SemanticException [Error 10090]: A view cannot be used as target table for LOAD or INSERT
没有处理

## hive数据迁移,导出数据库以hello为例
## 旧集群
## 设置hive默认数据库
vim ~/.hiverc
写入:use hello;

## hdfs上创建导出目录
hdfs dfs -mkdir -p /tmp/hello_db_export

## 生成脚本,export.hql脚本位置根据具体情况修改位置,执行完毕会在指定位置生成脚本
hive -e "show tables;" | awk  '{printf "export table %s to |/tmp/hello_db_export/%s|;\n",$1,$1}' | sed "s/|/'/g" | grep -v tab_name > ~/export.hql

## 执行脚本
hive -f ~/export.hql

## 下载数据,根据实际修改
hdfs dfs -get /tmp/hello_db_export /home/hivedb
## 发送数据 export.hql hello_db_export 这里我使用的scp
scp -r export.hql root@ip:/home
scp -r hello_db_export root@ip:/home

## 新集群
## 数据上传至集群某个位置
hdfs dfs -put /home/hello_db_export /tmp/
## 脚本备份一个出来
cd /home
cp export.hql import.sql
## 授权
chmod 777 import.sql
## 修改关键字
sed -i 's/export /import /g' import.sql
sed -i 's/ to / from /g' import.sql
## 修改需要执行的库,以community为例
方案一:
vim import.sql   
最上面一行加上 use community;
方案二:
在脚本表名变为 库名.表名
## 可能需要切换用户,根据实际情况
su hive
hive -f import.sql
完成,dbever验证
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值