使用 Amazon EMR 项目存储库检查依赖项 - Amazon EMR

使用 Amazon EMR 项目存储库检查依赖项

您可以使用 Amazon EMR 构件存储库构建针对特定 Amazon EMR 发行版(从 Amazon EMR 发布版 5.18.0 开始)附带的准确版本的库和依赖项的 Apache Hive 和 Apache Hadoop 任务代码。针对存储库中的 Amazon EMR 项目进行构建可确保针对其创建任务的库的版本是在集群上运行时提供的相同版本,从而帮助避免运行时类路径问题。目前,Amazon EMR 项目仅适用于 Maven 构建。

要访问项目存储库,请将存储库 URL 添加到 Maven 设置文件或特定项目的 pom.xml 配置文件。之后,您可以在项目配置中指定依赖项。对于依赖项版本,请为 Amazon EMR 5.x 发行版 上所需的发行版使用 Component Versions (组件版本) 下列出的版本。例如,组件版本 上提供了最新 Amazon EMR 发行版的组件版本。如果项目的构件未在 Component Versions (组件版本) 下列出,请指定为该发行版中的 Hive 和 Hadoop 列出的版本。例如,对于 Amazon EMR 发行版 5.18.0 中的 Hadoop 组件,版本为 2.8.4-amzn-1

项目存储库 URL 具有以下语法:

https://s3-endpoint/region-ID-emr-artifacts/emr-release-label/repos/maven/
  • s3-endpoint 是存储库区域的 Amazon Simple Storage Service(Amazon S3)终端节点,而 region-ID 是对应的区域。例如,s3.us-west-1.amazonaws.comus-west-1。有关更多信息,请参阅《Amazon Web Services 一般参考》中的 Amazon S3 endpoints。由于区域之间的项目不存在差异,因此,您可以为开发环境指定最方便的区域。

  • emr-release-label 是将运行代码的 Amazon EMR 集群的发行版标注。发行版标注的格式是 emr-x.x.x,例如 emr-5.36.1。一个 EMR 版本系列可能包含多个版本。例如,如果您使用的是 EMR 发行版 5.24.1,请在构件存储库 URL 中使用 5.24 系列中的第一个 EMR 发行版标注,即 emr-5.24.0

    https://s3-endpoint/region-ID-emr-artifacts/emr-5.24.0/repos/maven/
例 Maven pom.xml 的配置

以下 pom.xml 示例配置 Maven 项目以使用 us-west-1 中的项目存储库针对 emr-5.18.0 Apache Hadoop 和 Apache Hive 项目进行构建。由于快照版本在项目存储库中不可用,因此已在 pom.xml 中禁用快照。以下示例中的省略号 (...) 指示忽略其它配置参数。请勿将它们复制到 Maven 项目。

<project> ... <repositories> ... <repository> <id>emr-5.18.0-artifacts</id> <name>EMR 5.18.0 Releases Repository</name> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> <url>https://s3.us-west-1.amazonaws.com/us-west-1-emr-artifacts/emr-5.18.0/repos/maven/</url> </repository> ... </repositories> ... <dependencies> ... <dependency> <groupId>org.apache.hive</groupId> <artifactId>hive-exec</artifactId> <version>2.3.3-amzn-2</version> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-common</artifactId> <version>2.8.4-amzn-1</version> </dependency> ... </dependencies> </project>