背景:因為系統是個大資料平臺,會有很多不同的生產廠家在HIVE中建表,因此需要有個規范來約束廠家存放資料,
因有些廠家把資料存放到了公共目錄,現在需要遷移出指定的目錄,不知道有沒有啥方法;
以下為具體問題描述
1、廠家Y建了個表A
create table a(f1 int,f2 int,……) partition(xx,yy) location '/usr/hive/warehouse/a';
需要遷移A表的資料至 '/usr/hive/warehouse/廠家Y‘ ;
2、在直接更改location (alter table a set location '/usr/hive/warehouse/廠家Y/a‘ ) 發現hdfs的路徑并沒有變化;
在外網上查到一些方法:
1、新建一個表B,指定location到目標路徑 create table b like a location '/usr/hive/warehouse/廠家Y/B';
2、遷移A的資料至B,
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
因為表A或者其他表有大量的磁區,這樣設定,可以自動在表B上維護磁區
insert overwrite table B partition(xx,yy) select * from A;
3、drop 原來的表A drop table a;
4、更名表B為A, alter table b rename to a;
在步驟4之前,B的資料存放目錄還是在 '/usr/hive/warehouse/廠家Y/B' 下,但是執行4后,表A(原表B)資料存放目錄又變回了
'/usr/hive/warehouse/a' 下,結果失敗了;
請問大家有沒有啥好方法,謝謝了!
uj5u.com熱心網友回復:
啥情況啊,有沒有大牛幫忙解決下?uj5u.com熱心網友回復:
遇上同樣問題了,最后你們怎么解決的,有啥好點的辦法嗎uj5u.com熱心網友回復:
同求解決方案轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/113839.html
標籤:數據倉庫
下一篇:mysql中間件的一個問題
