天天看點

HBase實戰 | Hive資料導入雲HBase

網絡環境

  1. 專線:使用者需要把hbase叢集的VPC相關網絡資訊配置到專線裡面,可直通hbase環境
  2. 公有雲虛拟機VPC環境:選擇和hbase通VPC
  3. 其他:需要開hbase公網
  4. 注意:預設導入hbase資料,依賴的hbase-common、hbase-client、hbase-server、hbase-protocol使用社群的包即可。如果是公網需要使用雲hbase釋出的相關包

方案一:hive關聯hbase表方式

  1. 适用場景:資料量不大4T以下(因為需要走hbase的api導入資料)
  2. 從hbase頁面擷取zk連接配接位址,并用下述方式啟動hive用戶端
    HBase實戰 | Hive資料導入雲HBase
  1. hbase表不存在的情況
  • 建立hive表hive_hbase_table映射hbase表base_table,會自動建立hbase表hbase_table,且會随着hive表删除而删除。這裡需要指定hive的schema到hbase schema的映射關系。關于類型可參考Hive/HBaseIntegration
HBase實戰 | Hive資料導入雲HBase
  • 建立一張原始的hive表,準備一些資料
HBase實戰 | Hive資料導入雲HBase
  • 把hive原表hive_data中資料,通過hive表hive_hbase_table導入到hbase的表hbase_table中
HBase實戰 | Hive資料導入雲HBase
  • 檢視hbase表hbase_table中是否有資料
HBase實戰 | Hive資料導入雲HBase
  1. hbase表存在的情況
  • 建立hive的外表關聯hbase表,注意hive schema到hbase schema的映射關系。删除外表不會删除對應hbase表
HBase實戰 | Hive資料導入雲HBase
  • 其他導入資料相關同2

方案二:hive表生成hfile,通過bulkload導入到hbase

  1. 适用場景:資料量大(4T以上)
  2. 把hive資料轉換為hfile
  • 啟動hive并添加相關hbase的jar包
HBase實戰 | Hive資料導入雲HBase
  • 建立一個outputformat為HiveHFileOutputFormat的hive表
  • 其中/tmp/hbase_table_hfile/cf_0是hfile儲存到hdfs的路徑,cf_0是hbase family的名字
HBase實戰 | Hive資料導入雲HBase
  •  把原始資料表的資料通過hbase_hfile_table表儲存為hfile
HBase實戰 | Hive資料導入雲HBase
  • 檢視對應hdfs路徑是否生成了hfile
HBase實戰 | Hive資料導入雲HBase
  1. 通過bulkload将資料導入到hbase表中
  • 使用阿裡雲hbase用戶端建立具有上面對應family的hbase表
HBase實戰 | Hive資料導入雲HBase
  • 下載下傳雲hbase用戶端,配置hbase-site.xml,并将hdfs-site.xml、core-site.xml拷貝到hbase/conf目錄
HBase實戰 | Hive資料導入雲HBase
  • 執行bulkload導入到hbase表中
  • HBase實戰 | Hive資料導入雲HBase
  • 在hbase表hbase_hfile_load_table檢視資料是否導入
HBase實戰 | Hive資料導入雲HBase

大家工作學習遇到HBase技術問題,把問題釋出到HBase技術社群論壇http://hbase.group,歡迎大家論壇上面提問留言讨論。想了解更多HBase技術關注HBase技術社群公衆号(微信号:hbasegroup),非常歡迎大家積極投稿。

HBase實戰 | Hive資料導入雲HBase

HBase技術交流社群 - 阿裡官方“HBase生态+Spark社群大群”點選加入:

https://dwz.cn/Fvqv066s
上一篇: CONCAT_WS
下一篇: CHR