Hive跨集群遷移

2021-09-28 21:37:29 字數 1622 閱讀 1014

hive跨集群遷移資料工作是會出現的事情, 其中涉及到資料遷移, metastore遷移, hive版本公升級等。

1. 遷移hdfs資料至新集群

hadoop distcp -skipcrccheck -update hdfs: hdfs:

-skipcrccheck 因本次遷移涉及低版本遷移高版本, 如果hadoop版本則不需要

-update 增量更新, 通過名稱和大小比較,源與目標不同則更新

***.***.***.***這個位置最好使用ip位址,盡量不要使用主機名或集群名稱,否則需要配置hosts檔案解析

2. 源集群metastore資料備份匯出(mysql匯出)

mysqldump -u root -p』密碼』--skip-lock-tables -h ***.***.***.*** hive > mysql_hive.sql

mysqldump -uroot -p --database hive > mysql_hive_data.sql (我的環境操作)

3. 新的集群匯入metastore資料(mysql匯入)

mysql -u root -proot --default-character-set=utf8 hvie < mysql_hive.sql

mysql -uroot -p < mysql_data.sql(我的環境操作)

4. 公升級hive內容庫(如果hive版本需要公升級操作,同版本不需要操作)

mysql -uroot -proot risk -h***.***.***.*** < mysqlupgrade-0.13.0-to-0.14.0.mysql.sql

mysql -uroot -proot risk -h***.***.***.*** < mysqlupgrade-0.14.0-to-1.1.0.mysql.sql

版本要依據版本序列公升序公升級,不可跨越版本,如當前是hive0.12打算公升級到0.14,需要先公升級到0.13再公升級到0.14

5. 修改 metastore 內容庫的集群資訊(重要)

因為誇集群,hdfs訪問的名字可能變化了,所以需要修改下hive庫中的表dbs和sds內容,除非你的集群名字或者ha的名字跟之前的一致這個就不用修改了

登入mysql資料庫,檢視:

mysql> use hive;

update dbs  set db_location_uri = replace(db_location_uri,'hdfs://源1','hdfs://目標') ;

update sds set location = replace(location ,'hdfs://ns2','hdfs://adhoc') ;

如果操作,我這裡需要將hdfs://hacluster修改為hdfs://hacluster_new,我為了操作簡單,新集群ha起了同樣的名字hdfs://hacluster

6. 拷貝hive安裝包, 拷貝core-site.xml 與 hdfs-site.xml至 conf中, 後續則正常啟動即可。(一般不用操作)

參考:hive 跨集群遷移

不同hadoop集群之間遷移hive資料 

hive 資料遷移,利用hive提供的export/import工具實現批量同步

hadoop 集群 跨 版本資料遷移 hadoop1遷移到hadoop2上

遷移hive,不同集群。

step1 設定預設需要匯出的hive資料庫為defaultdatabase 在原集群中的任意節點上,新建 hiverc 檔案,加入如下內容 vi hiverc use defaultdatabase defaultdatabase可修改為需要遷移的其它名稱 step2 建立資料臨時目錄 hdfs ...

集群間 Hive 資料 遷移 問題

1 從hive中匯出資料至本地目錄 insert overwrite local directory export tmp select from test1 where create time 2013 11 25 列資料之間預設以 a隔開。2 將本地資料上傳另乙個集群的hdfs usr loca...

hive集群間資料遷移,export import

theexportandimportcommands were added in hive 0.8.0 see hive 1918 replication extensions to theexportandimportcommands were added in hive 1.2.0 see hi...