天天看點

Apache Atlas2.1.0 內建Hive中繼資料管理

Atlas裡的相關概念

  • Type

    中繼資料類型定義,這裡可以是表,列,視圖,物化視圖等,還可以細分hive表(hive_table),hbase表(hbase_table)等,甚至可以是一個資料操作行為,比如定時同步從一張表同步到另外一張表這個也可以描述為一個中繼資料類型,atlas自帶了很多類型,但是可以通過調用api自定義類型

  • Classification

    分類,通俗點就是給中繼資料打标簽,分類是可以傳遞的,比如user_view這個視圖是基于user這個表生成的,那麼如果user打上了HR這個标簽,user_view也會自動打上HR的标簽,這樣的好處就是便于資料的追蹤

  • GLOSSARY

    詞彙表,GLOSSARY包含兩個概念,Category(類别)和Term(術語),Category表示一組Term的集合,術語為中繼資料提供了别名,以便使用者更好的了解資料,舉個例子,有個pig的表,裡面有個豬腎的字段,但很多人更習慣叫做豬腰子,那麼就可以給豬腎這個字段加一個Term,不僅更好了解,也更容易搜尋到

  • Entity

    實體,表示具體的中繼資料,Atlas管理的對象就是各種Type的Entity

  • Lineage

    資料血緣,表示資料之間的傳遞關系,通過Lineage我們可以清晰的知道資料的從何而來又流向何處,中間經過了哪些操作

內建 hive 3.1.2 版本

官方doc:

http://atlas.apache.org/2.1.0/index.html#/HookHive

  • 配置 Hive Hook

    Atlas Hive hook registers with Hive to listen for create/update/delete operations and updates the metadata in Atlas, via Kafka notifications, for the changes in Hive. Follow the instructions below to setup Atlas hook in Hive

    在叢集的hive hive-site.xml 中添加 hive.exec.post.hooks 參數 ,每個hive任務執行後 均會執行該鈎子 預設空

    采集以下hive操作:

    • create database
    • create table/view, create table as select
    • load, import, export
    • DMLs (insert)
    • alter database
    • alter table (skewed table information, stored as, protection is not supported)
    • alter view
<property>
    <name>hive.exec.post.hooks</name>
      <value>org.apache.atlas.hive.hook.HiveHook</value>
  </property>
           
  • hive-env.sh 修改
# hive-env.sh 中添加 
export HIVE_AUX_JARS_PATH=<atlas package>/hook/hive
           
  • atlas-application.properties 添加
#移動 atlas-application.properties 
/data/software/apache-atlas-sources-2.1.0/distro/target/apache-atlas-2.1.0-bin/apache-atlas-2.1.0/conf/
下的 atlas-application.properties 放置在 hive /conf/目錄下
           
  • 導入hive 中繼資料
# 執行目前目錄下的 import-hive.sh
/data/software/apache-atlas-sources-2.1.0/distro/target/apache-atlas-2.1.0-hive-hook/apache-atlas-hive-hook-2.1.0/hook-bin
           
  • atlas 頁面 hive 中繼資料展示
Apache Atlas2.1.0 內建Hive中繼資料管理
  • hive 表血緣關系展示

    在hive 用戶端 執行以下hive作業,

insert overwrite  table project_statistics
select
	p.city_code,
	a.name as city_name,
	sum(b.real_amt) as real_amt,
	sum(b.real_number) as real_number
from project p 
left join area a on p.city_code = a.code 
join salary_batch b on p.id = b.id 
group by p.city_code,a.name;
           
Apache Atlas2.1.0 內建Hive中繼資料管理

以上圖示, project area salary_batch 三張表 經過 hive op操作 最終形成 project_statistics 表

  • hive表 字段血緣關系管理
Apache Atlas2.1.0 內建Hive中繼資料管理

繼續閱讀