在 Azure 数据工厂或 Synapse Analytics 中使用 Hadoop Streaming 活动转换数据

适用于: Azure 数据工厂 Azure Synapse Analytics

提示

试用 Microsoft Fabric 中的数据工厂,这是一种适用于企业的一站式分析解决方案。 Microsoft Fabric 涵盖从数据移动到数据科学、实时分析、商业智能和报告的所有内容。 了解如何免费开始新的试用

Azure 数据工厂或 Synapse Analytics 管道中的 HDInsight Streaming 活动会在自己的按需 HDInsight 群集上执行 Hadoop Streaming 程序。 本文基于数据转换活动一文,它概述了数据转换和受支持的转换活动。

要了解详细信息,请在阅读本文之前,先通读 Azure 数据工厂Synapse Analytics 的简介文章,并学习教程:转换数据

使用 UI 将 HDInsight 流式传输活动添加到管道

要将 HDInsight 流式处理活动用于管道,请完成以下步骤:

  1. 在管道“活动”窗格中搜索“流式处理”,然后将流式处理活动拖到管道画布上。

  2. 在画布上选择新的流式传输活动(如果尚未选择)。

  3. 选择“HDI 群集”选项卡以选择或创建新的链接到 HDInsight 群集的服务,该群集将用于执行流式传输活动。

    Shows the UI for a Streaming activity.

  4. 选择“文件”选项卡以指定流式处理作业的映射器和减速器名称,然后选择或创建到 Azure 存储帐户的新链接服务,该帐户将为作业提供映射器、减速器、输入和输出文件。 还可以配置高级详细信息,包括调试配置以及要传递给作业的实参和形参。

    Shows the UI for the File tab for a Streaming activity.

JSON 示例

{
    "name": "Streaming Activity",
    "description": "Description",
    "type": "HDInsightStreaming",
    "linkedServiceName": {
        "referenceName": "MyHDInsightLinkedService",
        "type": "LinkedServiceReference"
    },
    "typeProperties": {
        "mapper": "MyMapper.exe",
        "reducer": "MyReducer.exe",
        "combiner": "MyCombiner.exe",
        "fileLinkedService": {
            "referenceName": "MyAzureStorageLinkedService",
            "type": "LinkedServiceReference"
        },
        "filePaths": [
            "<containername>/example/apps/MyMapper.exe",
            "<containername>/example/apps/MyReducer.exe",
            "<containername>/example/apps/MyCombiner.exe"
        ],
        "input": "wasb://<containername>@<accountname>.blob.core.chinacloudapi.cn/example/input/MapperInput.txt",
        "output": "wasb://<containername>@<accountname>.blob.core.chinacloudapi.cn/example/output/ReducerOutput.txt",
        "commandEnvironment": [
            "CmdEnvVarName=CmdEnvVarValue"
        ],
        "getDebugInfo": "Failure",
        "arguments": [
            "SampleHadoopJobArgument1"
        ],
        "defines": {
            "param1": "param1Value"
        }
    }
}

语法详细信息

属性 描述 必需
name 活动名称
description 描述活动用途的文本
type 对于 Hadoop 流式处理活动,活动类型是 HDInsightStreaming
linkedServiceName 引用注册为链接服务的 HDInsight 群集。 若要了解此链接服务,请参阅计算链接服务一文。
mapper 指定映射器可执行文件的名称
reducer 指定化简器可执行文件的名称
combiner 指定合并器可执行文件的名称
fileLinkedService 对 Azure 存储链接服务的引用,该服务用于存储要执行的映射器、合并器和化简器程序。 此处仅支持 Azure Blob 存储ADLS Gen2 链接服务 。 如果未指定此链接服务,则使用 HDInsight 链接服务中定义的 Azure 存储链接服务。
filePath 提供由 fileLinkedService 引用的 Azure 存储中存储的映射器、合并器和化简器程序的路径数组。 此路径区分大小写。
input 指定映射器输入文件的 WASB 路径。
output 指定化简器输出文件的 WASB 路径。
getDebugInfo 指定何时将日志文件复制到 HDInsight 群集使用的(或者)scriptLinkedService 指定的 Azure 存储。 允许的值:None、Always 或 Failure。 默认值:无。
参数 指定 Hadoop 作业的参数数组。 参数以命令行参数的形式传递到每个任务。
定义 在 Hive 脚本中指定参数作为键/值对,以供引用。

参阅以下文章了解如何以其他方式转换数据: