Atlas 2.1.0 实践(3)—— Atlas集成HIve

Atlas集成Hive

在安装好Atlas以后,如果想要使用起来,还要让Atlas与其他组件建立联系。

其中最常用的就是Hive。

通过Atlas的架构,只要配置好Hive Hook ,那么每次Hive做任何操作就会写入Kafka从而被atlas接收。

并在Atlas中已图的形式展示出来。

Hive Model

都会记录Hive哪些操作信息呢?Altas对Hive Model进行了定义。

包含以下内容:

1、实体类型:

hive_db

类型: Asset

属性:qualifiedName, name, description, owner, clusterName, location, parameters, ownerName

hive_table

类型:DataSet

属性:qualifiedName, name, description, owner, db, createTime, lastAccessTime, comment, retention, sd, partitionKeys, columns, aliases, parameters, viewOriginalText, viewExpandedText, tableType, temporary

hive_column

​ 类型:DataSet

​ 属性:qualifiedName, name, description, owner, type, comment, table

hive_storagedesc

​ 类型:Referenceable

​ 属性: qualifiedName, table, location, inputFormat, outputFormat, compressed, numBuckets, serdeInfo, bucketCols, sortCols, parameters, storedAsSubDirectories

hive_process

​ 类型:Process

​ 属性:qualifiedName, name, description, owner, inputs, outputs, startTime, endTime, userName, operationType, queryText, queryPlan, queryId, clusterName

hive_column_lineage

​ 类型:Process

​ 属性:qualifiedName, name, description, owner, inputs, outputs, query, depenendencyType, expression

2、枚举类型:

​ hive_principal_type 值:USER, ROLE, GROUP

3、构造类型

hive_order 属性: col, order

hive_serde 属性: name, serializationLib, parameters

HIve实体的结构:

hive_db.qualifiedName:     <dbName>@<clusterName>
hive_table.qualifiedName:  <dbName>.<tableName>@<clusterName>
hive_column.qualifiedName: <dbName>.<tableName>.<columnName>@<clusterName>
hive_process.queryString:  trimmed query string in lower case

配置Hive hook

hive hook会监听hive的 create/update/delete 操作,下面是配置步骤:

1、修改hive-env.sh(指定包地址)

export HIVE_AUX_JARS_PATH=/opt/apps/apache-atlas-2.1.0/hook/hive

2、修改hive-site.xml(配置完需要重启hive)

<property>
    <name>hive.exec.post.hooks</name>
    <value>org.apache.atlas.hive.hook.HiveHook</value>
</property>
1234

注意,这里其实是执行后的监控,可以有执行前,执行中的监控。

3、同步配置
拷贝atlas配置文件atlas-application.properties到hive配置目录
添加配置:

atlas.hook.hive.synchronous=false
atlas.hook.hive.numRetries=3
atlas.hook.hive.queueSize=10000
atlas.cluster.name=primary
atlas.rest.address=http://doit33:21000

将Hive元数据导入Atlas

bin/import-hive.sh

Using Hive configuration directory [/opt/module/hive/conf]

Log file for import is /opt/module/atlas/logs/import-hive.log

log4j:WARN No such property [maxFileSize] in org.apache.log4j.PatternLayout.

log4j:WARN No such property [maxBackupIndex] in org.apache.log4j.PatternLayout.

输入用户名:admin;输入密码:admin

Enter username for atlas :- admin

Enter password for atlas :-

Hive Meta Data import was successful!!!

踩坑全记录

一、找不到类 org.apache.atlas.hive.hook.hivehook

hive第三方jar包没加进去

小技巧 使用hive-shell 看一下jar包加进去没有 set这将打印由用户或配置单元覆盖的配置变量列表。

以加入elsaticsearch-hadoop-2.1.2.jar为例,讲述在Hive中加入第三方jar的几种方式。

1,在hive shell中加入

hive> add jar /home/hadoop/elasticsearch-hadoop-hive-2.1.2.jar;

连接方式 是否有效
Hive Shell 不需要重启Hive服务就有效
Hive Server 无效

2,Jar放入${HIVE_HOME}/auxlib目录

在${HIVE_HOME}中创建文件夹auxlib,然后将自定义jar文件放入该文件夹中。
此方法添加不需要重启Hive。而且比较便捷。

连接方式 是否有效
Hive Shell 不需要重启Hive服务就有效
Hive Server 重启Hive服务才生效

3,HIVE.AUX.JARS.PATH和hive.aux.jars.path

hive-env.sh中的HIVE.AUX.JARS.PATH和hive-site.xml的hive.aux.jars.path配置对服务器无效,仅对当前hive shell有效,不同的hive shell相互不影响,每个hive shell都需要配置,可以配置成文件夹形式。
HIVE.AUX.JARS.PATH和hive.aux.jars.path仅支持本地文件。可配置成文件,也可配置为文件夹。

连接方式 是否有效
Hive Shell 重启Hive服务才生效
Hive Server 重启Hive服务才生效
二、HIVE报错 Failing because I am unlikely to write too

HIVE.AUX.JARS.PATH配置不对

hive-env.sh脚本中有一段

# Folder containing extra libraries required for hive compilation/execution can be controlled by:
if [ "${HIVE_AUX_JARS_PATH}" != "" ]; then
  export HIVE_AUX_JARS_PATH=${HIVE_AUX_JARS_PATH}
elif [ -d "/usr/hdp/current/hive-webhcat/share/hcatalog" ]; then
  export HIVE_AUX_JARS_PATH=/usr/hdp/current/hive-webhcat/share/hcatalog
fi

如果给HIVE_AUX_JARS_PATH设值,则/usr/hdp/current/hive-webhcat/share/hcatalog就会被忽略掉。

hive只能读取一个HIVE_AUX_JARS_PATH

在一个地方集中放置我们的共享jar包,然后在/usr/hdp/current/hive-webhcat/share/hcatalog下面建立一相应的软连接就可以

sudo -u hive ln -s /usr/lib/share-lib/elasticsearch-hadoop-2.1.0.Beta4.jar /usr/hdp/current/hive-webhcat/share/hcatalog/elasticsearch-hadoop-2.1.0.Beta4.jar

了解大数据实时计算 感受数据流动之美 欢迎关注 实时流式计算

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章