刚刚接触Atlas的时候,像要做一个数据一致性和血缘关系,方便业务数据库字段变更,更新hive里面各个层级的表。然后就发现,删除hdfs路径后,atlas的hdfs_path没有随之删除。
找了很多资料,都没有找到解决办法,然后就从Atlas的SWAGGER 入手,找到解决办法,供各位参考。
官网的API地址:Atlas REST API (apache.org)
本地Atlas SWAGGER 进入方式:用户—>help—>API Decomentation
删除方式脚本:
#bin/bash
while read line
do(
str=$line
echo $str
ustr=`echo ${str//\//%2F}`
echo $ustr
rei=`curl -u admin:admin -X GET "http://atlashost:21000/api/atlas/v2/search/attribute?attrName=name&attrValuePrefix=${ustr}&limit=10&offset=0&typeName=hdfs_path" -H "accept: application/json"`
h=`echo ${rei} | jq '.entities'`
echo $h
a=`echo ${h//\[/\"}`
b=`echo ${a//\]/\"}`
line=`echo ${b:1:-1}| jq -r '.guid'`
curl -iv -u admin:admin -X DELETE http://atlashost:21000/api/atlas/v2/entity/guid/${line}
)
done < hdfs.txt
hdfs.txt 里面写删除的hdfs相对路径 例如:/user/hive/warehouse/test.db/a/2023-01-01/
可以试试。