参考: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验证