设置

安装说明

qianmoQqianmoQ· 更新于 2026-09-27· 阅读 26 分钟· 0 次阅读

登录后可跨设备保存划线和私人笔记登录

安装并运行 Apache Atlas

安装 Apache Atlas

在你希望安装 Apache Atlas 的目录下,执行以下命令:

tar -xzvf apache-atlas-{project.version}-server.tar.gz
cd apache-atlas-{project.version}

使用本地 Apache HBase 和 Apache Solr 运行 Apache Atlas

若要使用随 Atlas 启动/停止一起启停的本地 Apache HBase 和 Apache Solr 实例来运行 Apache Atlas,请执行以下命令:

export MANAGE_LOCAL_HBASE=true
export MANAGE_LOCAL_SOLR=true
bin/atlas_start.py

使用 Apache Atlas

  • 要验证 Apache Atlas 服务器是否已启动并正常运行,请按如下所示运行 curl 命令:
curl -u username:password http://localhost:21000/api/atlas/admin/version
    {"Description":"Metadata Management and Data Governance Platform over Hadoop","Version":"2.1.0","Name":"apache-atlas"}
  • 运行快速入门,加载示例模型和数据
bin/quick_start.py
Enter username for atlas :-
Enter password for atlas :-

停止 Apache Atlas 服务

要停止 Apache Atlas,请运行以下命令:

bin/atlas_stop.py

配置 Apache Atlas

默认情况下,Apache Atlas 使用的配置目录是 {package dir}/conf。若要覆盖该默认值,请将环境变量 ATLAS_CONF 设置为配置目录的路径。

运行 Apache Atlas 所需的环境变量可以在配置目录下的 atlas-env.sh 文件中设置。Apache Atlas 脚本在执行任何命令之前会先加载该文件。可以设置以下环境变量。

# The java implementation to use. If JAVA_HOME is not found we expect java and jar to be in path
#export JAVA_HOME=
any additional java opts you want to set. This will apply to both client and server operations
#export ATLAS_OPTS=
any additional java opts that you want to set for client only
#export ATLAS_CLIENT_OPTS=
java heap size we want to set for the client. Default is 1024MB
#export ATLAS_CLIENT_HEAP=
any additional opts you want to set for atlas service.
#export ATLAS_SERVER_OPTS=
java heap size we want to set for the atlas server. Default is 1024MB
#export ATLAS_SERVER_HEAP=
What is is considered as atlas home dir. Default is the base location of the installed software
#export ATLAS_HOME_DIR=
Where log files are stored. Defatult is logs directory under the base install location
#export ATLAS_LOG_DIR=
Where pid files are stored. Defatult is logs directory under the base install location
#export ATLAS_PID_DIR=
Where do you want to expand the war file. By Default it is in /server/webapp dir under the base install dir.
#export ATLAS_EXPANDED_WEBAPP_DIR=

支持大量元数据对象的设置

如果你计划存储大量的元数据对象,建议你使用针对 JVM 更佳 GC 性能调优过的值。

以下是常见的服务端选项:

export ATLAS_SERVER_OPTS="-server -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+PrintTenuringDistribution -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dumps/atlas_server.hprof -Xloggc:logs/gc-worker.log -verbose:gc -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=1m -XX:+PrintGCDetails -XX:+PrintHeapAtGC -XX:+PrintGCTimeStamps"

-XX:SoftRefLRUPolicyMSPerMB 选项被发现对于调节查询繁重、并发用户众多的工作负载的 GC 性能尤为有效。

针对 JDK 8,建议使用以下取值:

export ATLAS_SERVER_HEAP="-Xms15360m -Xmx15360m -XX:MaxNewSize=5120m -XX:MetaspaceSize=100M -XX:MaxMetaspaceSize=512m"

macOS 用户请注意 如果您使用的是 macOS,则需要配置 ATLAS_SERVER_OPTS(上文已作说明)。

在 {package dir}/conf/atlas-env.sh 中取消以下行的注释

export ATLAS_SERVER_OPTS=

并将其修改为如下所示

export ATLAS_SERVER_OPTS="-Djava.awt.headless=true -Djava.security.krb5.realm= -Djava.security.krb5.kdc="

将 Apache HBase 配置为图存储库的后端

Apache Atlas 默认使用 JanusGraph 作为图存储库,这也是目前唯一可用的图存储库实现。当前支持的 Apache HBase 版本为 1.1.x。有关在 Apache HBase 上配置 Apache Atlas 图持久化的详细信息,请参阅配置章节中的"图持久化引擎 - HBase"。

Apache Atlas 使用的 Apache HBase 表可以通过以下配置项进行设置:

atlas.graph.storage.hbase.table=atlas
atlas.audit.hbase.tablename=apache_atlas_entity_audit

配置 Apache Solr 作为图存储库的索引后端

默认情况下,Apache Atlas 使用 JanusGraph 作为图存储库,这也是目前唯一可用的图存储库实现。若要配置 JanusGraph 与 Apache Solr 配合使用,请按照以下说明操作

  • 以云模式(cloud mode)启动 Apache Solr。

SolrCloud 模式使用 ZooKeeper 服务作为高可用的集中式位置来进行集群管理。对于小型集群,使用现有的 ZooKeeper 仲裁组即可。对于较大规模的集群,你可能需要运行多个独立的 ZooKeeper 仲裁组,且至少包含 3 台服务器。更多信息请参阅 Apache Solr 文档 - https://cwiki.apache.org/confluence/display/solr/SolrCloud

  • 例如,要在某台机器上启动一个监听 8983 端口的 Apache Solr 节点,可以使用如下命令:
$SOLR_HOME/bin/solr start -c -z <zookeeper_host:port> -p 8983
  • 在 SOLR_BIN 目录(例如 $SOLR_HOME/bin)中运行以下命令,为 Apache Atlas 所使用的索引在 Apache Solr 中创建对应的 collection。如果 Apache Atlas 实例与 Apache Solr 实例位于两台不同的主机上,请先将 ATLAS_HOME/conf/solr 目录下的所需配置文件从 Apache Atlas 实例所在主机复制到 Apache Solr 实例所在主机。下述命令中的 SOLR_CONF 指的是 Apache Solr 配置文件在 Apache Solr 主机上被复制到的目录:
$SOLR_BIN/solr create -c vertex_index -d SOLR_CONF -shards #numShards -replicationFactor #replicationFactor
$SOLR_BIN/solr create -c edge_index -d SOLR_CONF -shards #numShards -replicationFactor #replicationFactor
$SOLR_BIN/solr create -c fulltext_index -d SOLR_CONF -shards #numShards -replicationFactor #replicationFactor

注意:如果未指定 numShards 和 replicationFactor,它们默认为 1,这对于在单节点实例上试用 Solr 与 ATLAS 来说已经足够。否则,请根据 Solr 集群中的主机数量以及 maxShardsPerNode 配置来指定 numShards。分片数量不能超过 SolrCloud 集群中 Solr 节点的总数。

副本数(replicationFactor)可根据所需的冗余度进行设置。

另请注意,如果设置了 SOLR_BIN 和 SOLR_CONF 环境变量,且搜索索引后端设置为 'solr5',那么在 Apache Atlas 服务器启动时,系统会自动调用 Apache Solr 来创建索引。

  • 修改 ATLAS 配置以指向所搭建的 Apache Solr 实例。请确保 ATLAS_HOME/conf/atlas-application.properties 中的以下配置项设置为下列值:
atlas.graph.index.search.backend=solr
atlas.graph.index.search.solr.mode=cloud
atlas.graph.index.search.solr.zookeeper-url=<the ZK quorum setup for solr as comma separated value> eg: 10.1.6.4:2181,10.1.6.5:2181
atlas.graph.index.search.solr.zookeeper-connect-timeout=<SolrCloud Zookeeper Connection Timeout>. Default value is 60000 ms
atlas.graph.index.search.solr.zookeeper-session-timeout=<SolrCloud Zookeeper Session Timeout>. Default value is 60000 ms

有关 JanusGraph Solr 配置的更多信息,请参阅 http://docs.janusgraph.org/0.2.0/solr.html

以云模式运行 Apache Solr 的先决条件

  • 内存 —— Apache Solr 既耗内存又耗 CPU。请确保运行 Apache Solr 的服务器具备足够的内存、CPU 和磁盘空间。Apache Solr 在 32GB 内存下运行良好。请尽量为 Apache Solr 进程分配更多内存。

  • 磁盘 —— 如果需要存储的实体数量很大,请确保 Apache Solr 存放索引数据的卷中至少有 500 GB 的可用空间。

  • SolrCloud 支持复制和分片。强烈建议使用 SolrCloud,并至少在不同服务器上运行两个 Apache Solr 节点且启用复制。如果使用 SolrCloud,则还需要安装并配置 ZooKeeper,包含 3 个或 5 个 ZooKeeper 节点。

  • 以 http 模式启动 Apache Solr —— 这是云模式 Solr 的替代设置方式。

    Solr Standalone(独立模式)用于单实例场景,其配置信息保存在文件系统上。它不需要 ZooKeeper,并能为中等规模的索引提供高性能。对于快速原型开发而言,它可以被视为一个不错的选择,同时也是适用于开发环境的有效配置。在某些情况下,它在 Atlas 的生产级部署中表现出比 Solr 云模式更好的性能。

  • 将 ATLAS 配置改为指向 Standalone Apache Solr 实例的设置。请确保以下配置项在 ATLAS_HOME/conf/atlas-application.properties 中设置为如下值。

atlas.graph.index.search.backend=solr
atlas.graph.index.search.solr.mode=http
atlas.graph.index.search.solr.http-urls=<a single or list of URLs for the Solr instances must be provided.> eg: localhost:2181,10.1.6.5:2181

注意:Solr 独立模式可以通过 embedded-hbase-solr profile 以嵌入方式运行。

将 Elasticsearch 配置为图库(Graph Repository)的索引后端(技术预览)

默认情况下,Apache Atlas 使用 JanusGraph 作为图库,这也是目前唯一可用的图库实现。若要配置 JanusGraph 与 Elasticsearch 配合使用,请遵循以下步骤:

  • 对于简单测试,可在 Elasticsearch 发行版的 bin 目录下使用 elasticsearch 命令启动单个 Elasticsearch 节点。
  • 修改 Apache Atlas 的配置,使其指向所搭建的 Elasticsearch 实例。请确保以下配置项在 ATLAS_HOME/conf/atlas-application.properties 中被设置为如下值:
atlas.graph.index.search.backend=elasticsearch
atlas.graph.index.search.hostname=<the hostname(s) of the Elasticsearch master nodes comma separated>
atlas.graph.index.search.elasticsearch.client-only=true

有关 JanusGraph 针对 elasticsearch 的配置的更多信息,请参阅 http://docs.janusgraph.org/0.2.0/elasticsearch.html

配置 Kafka 主题

Apache Atlas 使用 Apache Kafka 在运行时从其他组件采集元数据。这一点在架构一节中有更详细的说明。根据 Apache Kafka 的配置情况,有时可能需要在使用 Apache Atlas 之前显式地创建主题。为此,Apache Atlas 提供了脚本 =bin/atlas_kafka_setup.py=,可以在 Apache Atlas 服务器上运行。在某些环境中,钩子(hook)可能会在 Apache Atlas 服务器自身完成设置之前就开始被使用。在这种情况下,可以在安装了钩子的主机上运行类似的脚本 hook-bin/atlas_kafka_setup_hook.py 来创建主题。这两个脚本都使用 atlas-application.properties 中的配置来创建主题。有关这些细节,请参阅配置。

设置 Apache Atlas

Apache Atlas 有一些步骤用于设置其依赖项,其中一例就是在所选的存储后端中设置 JanusGraph 模式(schema)。在简单的单服务器设置中,当服务器首次访问这些依赖项时,这些内容会以默认配置自动完成设置。

不过,在某些场景下,我们可能希望将设置步骤作为一次性操作显式执行。例如,在使用高可用的多服务器场景中,最好先在其中一个服务器实例上运行设置步骤,然后再启动各项服务。

要一次性运行这些步骤,请在单个 Apache Atlas 服务器实例上执行命令 =bin/atlas_start.py -setup=。

不过,Apache Atlas 服务器确实会处理设置步骤的并行执行问题。此外,多次运行设置步骤是幂等的。因此,如果为了方便而选择在服务器启动过程中运行设置步骤,则应通过在 atlas-application.properties 文件中将配置项 atlas.server.run.setup.on.start 的值定义为 true 来启用它。

示例:调用 Apache Atlas REST API

以下是一些通过 curl 命令调用 Apache Atlas REST API 的示例。

  • 列出存储库中的类型
curl -u username:password http://localhost:21000/api/atlas/v2/types/typedefs/headers
    [ {"guid":"fa421be8-c21b-4cf8-a226-fdde559ad598","name":"Referenceable","category":"ENTITY"},
      {"guid":"7f3f5712-521d-450d-9bb2-ba996b6f2a4e","name":"Asset","category":"ENTITY"},
      {"guid":"84b02fa0-e2f4-4cc4-8b24-d2371cd00375","name":"DataSet","category":"ENTITY"},
      {"guid":"f93975d5-5a5c-41da-ad9d-eb7c4f91a093","name":"Process","category":"ENTITY"},
      {"guid":"79dcd1f9-f350-4f7b-b706-5bab416f8206","name":"Infrastructure","category":"ENTITY"}
    ]
  • 列出给定类型的实例
curl -u username:password http://localhost:21000/api/atlas/v2/search/basic?typeName=hive_db
    {
      "queryType":"BASIC",
      "searchParameters":{
        "typeName":"hive_db",
        "excludeDeletedEntities":false,
        "includeClassificationAttributes":false,
        "includeSubTypes":true,
        "includeSubClassifications":true,
        "limit":100,
        "offset":0
      },
      "entities":[
        {
          "typeName":"hive_db",
          "guid":"5d900c19-094d-4681-8a86-4eb1d6ffbe89",
          "status":"ACTIVE",
          "displayText":"default",
          "classificationNames":[],
          "attributes":{
            "owner":"public",
            "createTime":null,
            "qualifiedName":"default@cl1",
            "name":"default",
            "description":"Default Hive database"
          }
        },
        {
          "typeName":"hive_db",
          "guid":"3a0b14b0-ab85-4b65-89f2-e418f3f7f77c",
          "status":"ACTIVE",
          "displayText":"finance",
          "classificationNames":[],
          "attributes":{
            "owner":"hive",
            "createTime":null,
            "qualifiedName":"finance@cl1",
            "name":"finance",
            "description":null
          }
        }
      ]
    }
  • 搜索实体
curl -u username:password http://localhost:21000/api/atlas/v2/search/dsl?query=hive_db%20where%20name='default'
      {
        "queryType":"DSL",
        "queryText":"hive_db where name='default'",
        "entities":[
          {
            "typeName":"hive_db",
            "guid":"5d900c19-094d-4681-8a86-4eb1d6ffbe89",
            "status":"ACTIVE",
            "displayText":"default",
            "classificationNames":[],
            "attributes":{
              "owner":"public",
              "createTime":null,
              "qualifiedName":"default@cl1",
              "name":"default",
              "description":
              "Default Hive database"
            }
          }
        ]
      }

故障排查

安装配置问题

如果 Apache Atlas 服务的安装配置因任何原因失败,下次运行安装配置(无论是显式调用 atlas_start.py -setup,还是通过启用配置项 atlas.server.run.setup.on.start)时都会失败,并显示类似 A previous setup run may not have completed cleanly. 的消息。在这种情况下,您需要手动确保安装配置可以运行,并在尝试再次运行安装配置之前,删除 Zookeeper 中位于 /apache_atlas/setup_in_progress 的节点。

如果安装配置因 Apache HBase 表结构错误而失败,则可能需要修复 Apache HBase 表结构。如果尚未存储任何数据,也可以禁用并删除 Apache Atlas 使用的 Apache HBase 表,然后重新运行安装配置。

评论

登录后参与评论

正在加载评论…