使用 Apache Hadoop、Apache Spark、Apache Kafka 及其他组件在 HDInsight 中设置群集Set up clusters in HDInsight with Apache Hadoop, Apache Spark, Apache Kafka, and more

了解如何在 HDInsight 中设置和配置 Apache Hadoop、Apache Spark、Apache Kafka、交互式查询、Apache HBase、机器学习服务或 Apache Storm。Learn how to set up and configure Apache Hadoop, Apache Spark, Apache Kafka, Interactive Query, Apache HBase, ML Services, or Apache Storm in HDInsight. 另外,了解如何自定义群集,并将它们加入域以提高安全性。Also, learn how to customize clusters and add security by joining them to a domain.

Hadoop 群集由用于对任务进行分布式处理的多个虚拟机(节点)组成。A Hadoop cluster consists of several virtual machines (nodes) that are used for distributed processing of tasks. Azure HDInsight 对各个节点的安装和配置的实现细节进行处理,因此你只需提供常规配置信息。Azure HDInsight handles implementation details of installation and configuration of individual nodes, so you only have to provide general configuration information.


HDInsight 群集计费在创建群集之后便会开始,删除群集后才会停止。HDInsight cluster billing starts once a cluster is created and stops when the cluster is deleted. HDInsight 群集按分钟收费,因此不再需要使用群集时,应将其删除。Billing is pro-rated per minute, so you should always delete your cluster when it is no longer in use. 了解如何删除群集Learn how to delete a cluster.

如果将多个群集一起使用,则需创建一个虚拟网络;如果使用的是 Spark 群集,则还需使用 Hive Warehouse Connector。If you're using multiple clusters together, you'll want to create a virtual network, and if you're using a Spark cluster you'll also want to use the Hive Warehouse Connector. 有关详细信息,请参阅为 Azure HDInsight 规划虚拟网络将 Apache Spark 和 Apache Hive 与 Hive Warehouse Connector 集成For more information, see Plan a virtual network for Azure HDInsight and Integrate Apache Spark and Apache Hive with the Hive Warehouse Connector.

群集设置方法Cluster setup methods

下表显示了可用于设置 HDInsight 群集的不同方法。The following table shows the different methods you can use to set up an HDInsight cluster.

群集创建方法Clusters created with Web 浏览器Web browser 命令行Command line REST APIREST API SDKSDK
Azure 门户Azure portal      
Azure 数据工厂Azure Data Factory
Azure CLIAzure CLI      
Azure PowerShellAzure PowerShell      
Azure Resource Manager 模板Azure Resource Manager templates      

本文介绍如何在 Azure 门户中进行设置,通过该门户创建 HDInsight 群集。This article walks you through setup in the Azure portal, where you can create an HDInsight cluster .


hdinsight 创建选项 - 自定义快速创建

项目详细信息Project details

可以借助 Azure Resource Manager 以组(称为 Azure 资源组)的形式处理应用程序中的资源。Azure Resource Manager helps you work with the resources in your application as a group, referred to as an Azure resource group. 可以通过单个协调的操作来部署、更新、监视或删除应用程序的所有资源。You can deploy, update, monitor, or delete all the resources for your application in a single coordinated operation.

群集详细信息Cluster details

群集名称Cluster name

HDInsight 群集名称具有以下限制:HDInsight cluster names have the following restrictions:

  • 允许的字符:a-z、0-9、A-ZAllowed characters: a-z, 0-9, A-Z
  • 最大长度:59Max length: 59
  • 保留的名称:appsReserved names: apps
  • 群集命名作用域适用于所有订阅中的所有 Azure。The cluster naming scope is for all Azure, across all subscriptions. 因此该名称必须全球唯一。So the cluster name must be unique worldwide.
  • 前六个字符在虚拟网络中必须唯一First six characters must be unique within a virtual network


不需要显式指定群集位置:群集与默认存储在相同的位置。You don't need to specify the cluster location explicitly: The cluster is in the same location as the default storage. 若要获取受支持区域的列表,请选择 HDInsight 定价中的“区域”下拉列表。For a list of supported regions, select the Region drop-down list on HDInsight pricing.

群集类型Cluster type

Azure HDInsight 目前提供以下群集类型,每种类型都具有一组用于提供特定功能的组件。Azure HDInsight currently provides the following cluster types, each with a set of components to provide certain functionalities.


HDInsight 群集以多种类型提供,每种类型适用于单个工作负荷或技术。HDInsight clusters are available in various types, each for a single workload or technology. 不支持在一个群集上创建合并了多个类型(如 Storm 和 HBase)的群集。There is no supported method to create a cluster that combines multiple types, such as Storm and HBase on one cluster. 如果解决方案需要分布在多种 HDInsight 群集类型上的技术,可以使用 Azure 虚拟网络 连接所需的群集类型。If your solution requires technologies that are spread across multiple HDInsight cluster types, an Azure virtual network can connect the required cluster types.

群集类型Cluster type 功能Functionality
HadoopHadoop Batch 查询和存储数据的分析Batch query and analysis of stored data
HBaseHBase 大量无架构 NoSQL 数据的处理Processing for large amounts of schemaless, NoSQL data
交互式查询Interactive Query 更快的交互式 Hive 查询的内存中缓存In-memory caching for interactive and faster Hive queries
KafkaKafka 分布式流式处理平台,可用于构建实时流数据管道和应用程序A distributed streaming platform that can be used to build real-time streaming data pipelines and applications
SparkSpark 内存中处理、交互式查询、微批流处理In-memory processing, interactive queries, micro-batch stream processing
StormStorm 实时事件处理Real-time event processing


选择此群集的 HDInsight 版本。Choose the version of HDInsight for this cluster. 有关详细信息,请参阅支持的 HDInsight 版本For more information, see Supported HDInsight versions.

群集凭据Cluster credentials

使用 HDInsight 群集时,可以在群集创建期间配置两个用户帐户:With HDInsight clusters, you can configure two user accounts during cluster creation:

  • 群集登录用户名:默认的用户名为 admin。它使用 Azure 门户上的基本配置。Cluster login username: The default username is admin. It uses the basic configuration on the Azure portal. 有时称为“群集用户”或“HTTP 用户”。Sometimes it's called "Cluster user," or "HTTP user."
  • 安全外壳 (SSH) 用户名:用来通过 SSH 连接到群集。Secure Shell (SSH) username: Used to connect to the cluster through SSH. 有关详细信息,请参阅 将 SSH 与 HDInsight 配合使用For more information, see Use SSH with HDInsight.

HTTP 用户名具有以下限制:The HTTP username has the following restrictions:

  • 允许的特殊字符:_@Allowed special characters: _ and @
  • 不允许的字符:#;."',/:`!*?$(){}[]<>|&--=+%~^空格Characters not allowed: #;."',/:`!*?$(){}[]<>|&--=+%~^space
  • 最大长度:20 个Max length: 20

SSH 用户名具有以下限制:The SSH username has the following restrictions:

  • 允许的特殊字符:_@Allowed special characters:_ and @
  • 不允许的字符:#;."',/:`!*?$(){}[]<>|&--=+%~^空格Characters not allowed: #;."',/:`!*?$(){}[]<>|&--=+%~^space
  • 最大长度:64Max length: 64
  • 保留的名称:hadoop、users、oozie、hive、mapred、ambari-qa、zookeeper、tez、hdfs、sqoop、yarn、hcat、ams、hbase、storm、administrator、admin、user、user1、test、user2、test1、user3、admin1、1、123、a、actuser、adm、admin2、aspnet、backup、console、david、guest、john、owner、root、server、sql、support、support_388945a0、sys、test2、test3、user4、user5、sparkReserved names: hadoop, users, oozie, hive, mapred, ambari-qa, zookeeper, tez, hdfs, sqoop, yarn, hcat, ams, hbase, storm, administrator, admin, user, user1, test, user2, test1, user3, admin1, 1, 123, a, actuser, adm, admin2, aspnet, backup, console, david, guest, john, owner, root, server, sql, support, support_388945a0, sys, test2, test3, user4, user5, spark


群集存储设置:符合 HDFS 标准的终结点

Hadoop 的本地安装对群集上的存储使用 Hadoop 分布式文件系统 (HDFS),而在云中,需使用已连接到群集的存储终结点。Although an on-premises installation of Hadoop uses the Hadoop Distributed File System (HDFS) for storage on the cluster, in the cloud you use storage endpoints connected to cluster. 使用云存储空间意味着可以安全删除用于计算的 HDInsight 群集,同时仍可保留数据。Using cloud storage means you can safely delete the HDInsight clusters used for computation while still retaining your data.

HDInsight 群集可以使用以下存储选项:HDInsight clusters can use the following storage options:

  • Azure Data Lake Storage Gen2Azure Data Lake Storage Gen2
  • Azure 存储常规用途 v2Azure storage General Purpose v2
  • Azure 存储常规用途 v1Azure storage General Purpose v1
  • Azure 存储块 Blob(仅支持作为辅助存储器Azure storage Block blob (only supported as secondary storage)


不支持在 HDInsight 群集之外的其他位置使用其他存储帐户。Using an additional storage account in a different location from the HDInsight cluster is not supported.

在配置期间,对于默认存储终结点,需要指定 Azure 存储帐户的 Blob 容器或 Data Lake Storage。During configuration, for the default storage endpoint you specify a blob container of an Azure Storage account or Data Lake Storage. 默认存储包含应用程序日志和系统日志。The default storage contains application and system logs. 可以选择指定群集可访问的其他链接的 Azure 存储帐户和 Data Lake Storage 帐户。Optionally, you can specify additional linked Azure Storage accounts and Data Lake Storage accounts that the cluster can access. HDInsight 群集和相关的存储帐户必须在同一个 Azure 位置。The HDInsight cluster and the dependent storage accounts must be in the same Azure location.


需要安全传输的功能强制通过安全连接来实施针对帐户的所有请求。The feature that requires secure transfer enforces all requests to your account through a secure connection. 仅 HDInsight 群集 3.6 或更高版本支持此功能。Only HDInsight cluster version 3.6 or newer supports this feature. 有关详细信息,请参阅在 Azure HDInsight 中使用安全传输存储帐户创建 Apache Hadoop 群集For more information, see Create Apache Hadoop cluster with secure transfer storage accounts in Azure HDInsight.


在创建群集后启用安全存储传输可能会导致使用存储帐户时出错,因此不建议这样做。Enabling secure storage transfer after creating a cluster can result in errors using your storage account and is not recommended. 最好使用已启用安全传输的存储帐户创建新群集。It is better to create a new cluster using a storage account with secure transfer already enabled.


Azure HDInsight 不会将 Azure 存储中存储的数据从一个区域自动传输、移动或复制到另一区域。Azure HDInsight does not automatically transfer, move or copy your data stored in Azure Storage from one region to another.

元存储设置Metastore settings

你可以创建可选的 Hive 或 Apache Oozie 元存储。You can create optional Hive or Apache Oozie metastores. 但是,并非所有群集类型都支持元存储,Azure Synapse Analytics 与元存储不兼容。However, not all cluster types support metastores, and Azure Synapse Analytics isn't compatible with metastores.

有关详细信息,请参阅在 Azure HDInsight 中使用外部元数据存储For more information, see Use external metadata stores in Azure HDInsight.


创建自定义元存储时,请不要在数据库名称中使用破折号、连字符或空格。When you create a custom metastore, don't use dashes, hyphens, or spaces in the database name. 否则可能导致群集创建过程失败。This can cause the cluster creation process to fail.

适用于 Hive 的 SQL 数据库SQL database for Hive

如果希望在删除 HDInsight 群集后保留 Hive 表,请使用自定义元存储。If you want to retain your Hive tables after you delete an HDInsight cluster, use a custom metastore. 这样,便可以将该元存储附加到另一个 HDInsight 群集。You can then attach the metastore to another HDInsight cluster.

为一个 HDInsight 群集版本创建的 HDInsight 元存储不能在不同的 HDInsight 群集版本之间共享。An HDInsight metastore that is created for one HDInsight cluster version cannot be shared across different HDInsight cluster versions. 有关 HDInsight 版本的列表,请参阅支持的 HDInsight 版本For a list of HDInsight versions, see Supported HDInsight versions.


默认元存储提供具有基本层 5 DTU 限制(不可升级)的 Azure SQL 数据库!The default metastore provides an Azure SQL Database with a basic tier 5 DTU limit (not upgradeable)! 适用于基本测试目的。Suitable for basic testing purposes. 对于大型或生产工作负载,我们建议迁移到外部元存储。For large or production workloads, we recommend migrating to an external metastore.

适用于 Oozie 的 SQL 数据库SQL database for Oozie

在使用 Oozie 时若要提高性能,请使用自定义元存储。To increase performance when using Oozie, use a custom metastore. 删除群集后,元存储也可提供对 Oozie 作业数据的访问权限。A metastore can also provide access to Oozie job data after you delete your cluster.

适用于 Ambari 的 SQL 数据库SQL database for Ambari

Ambari 用于监视 HDInsight 群集,进行配置更改,以及存储群集管理信息和作业历史记录。Ambari is used to monitor HDInsight clusters, make configuration changes, and store cluster management information as well as job history. 使用自定义 Ambari DB 功能,可以在由你管理的外部数据库中部署新群集和设置 Ambari。The custom Ambari DB feature allows you to deploy a new cluster and setup Ambari in an external database that you manage. 有关详细信息,请参阅自定义 Ambari DBFor more information, see Custom Ambari DB.


无法重用自定义 Oozie 元存储。You cannot reuse a custom Oozie metastore. 若要使用自定义 Oozie 元存储,必须在创建 HDInsight 群集时提供一个空的 Azure SQL 数据库。To use a custom Oozie metastore, you must provide an empty Azure SQL Database when creating the HDInsight cluster.

安全性 + 网络Security + networking

hdinsight 创建选项 选择企业安全数据包

企业安全数据包Enterprise security package

对于 Hadoop、Spark、HBase、Kafka 和 Interactive Query 群集类型,可选择启用“企业安全性套餐”。For Hadoop, Spark, HBase, Kafka, and Interactive Query cluster types, you can choose to enable the Enterprise Security Package. 启用此套餐,可通过使用 Apache Ranger 并与 Azure Active Directory 集成来实现更安全的群集设置。This package provides option to have a more secure cluster setup by using Apache Ranger and integrating with Azure Active Directory. 有关详细信息,请参阅 Azure HDInsight 中的企业安全性概述For more information, see Overview of enterprise security in Azure HDInsight.

企业安全数据包允许将 HDInsight 与 Active Directory 和 Apache Ranger 集成。The Enterprise security package allows you to integrate HDInsight with Active Directory and Apache Ranger. 可使用企业安全数据包创建多个用户。Multiple users can be created using the Enterprise security package.

有关如何创建已加入域的 HDInsight 群集的详细信息,请参阅创建已加入域的 HDInsight 沙盒环境For more information on creating domain-joined HDInsight cluster, see Create domain-joined HDInsight sandbox environment.


有关详细信息,请参阅传输层安全性For more information, see Transport Layer Security

虚拟网络Virtual network

如果解决方案需要分布在多种 HDInsight 群集类型上的技术,可以使用 Azure 虚拟网络 连接所需的群集类型。If your solution requires technologies that are spread across multiple HDInsight cluster types, an Azure virtual network can connect the required cluster types. 此配置允许群集以及部署到群集的任何代码直接相互通信。This configuration allows the clusters, and any code you deploy to them, to directly communicate with each other.

有关在 HDInsight 中使用 Azure 虚拟网络的详细信息,请参阅规划 HDInsight 的虚拟网络For more information on using an Azure virtual network with HDInsight, see Plan a virtual network for HDInsight.

有关在一个 Azure 虚拟网络中使用两种群集类型的示例,请参阅将 Apache Spark 结构化流式处理与 Apache Kafka 配合使用For an example of using two cluster types within an Azure virtual network, see Use Apache Spark Structured Streaming with Apache Kafka. 有关在 HDInsight 中使用虚拟网络的详细信息(包括虚拟网络的特定配置要求),请参阅规划 HDInsight 的虚拟网络For more information about using HDInsight with a virtual network, including specific configuration requirements for the virtual network, see Plan a virtual network for HDInsight.

磁盘加密设置Disk encryption setting

有关详细信息,请参阅客户管理的密钥磁盘加密For more information, see Customer-managed key disk encryption.

Kafka REST 代理Kafka REST proxy

此设置仅适用于群集类型 Kafka。This setting is only available for cluster type Kafka. 有关详细信息,请参阅使用 REST 代理For more information, see Using a REST proxy.


有关详细信息,请参阅 Azure HDInsight 中的托管标识For more information, see Managed identities in Azure HDInsight.

配置 + 定价Configuration + pricing

HDInsight 选择节点大小

只要群集存在,就会产生节点使用费。You're billed for node usage for as long as the cluster exists. 创建群集后便开始计费,删除群集后停止计费。Billing starts when a cluster is created and stops when the cluster is deleted. 无法取消分配群集或暂停群集。Clusters can’t be de-allocated or put on hold.

节点配置Node configuration

每个群集类型有自身的节点数目、节点术语和默认的 VM 大小。Each cluster type has its own number of nodes, terminology for nodes, and default VM size. 下表中的括号内列出了每个节点类型的节点数目。In the following table, the number of nodes for each node type is in parentheses.

类型Type NodesNodes 图示Diagram
HadoopHadoop 头节点 (2)、工作器节点 (1+)Head node (2), Worker node (1+) HDInsight Hadoop 群集节点
HBaseHBase 头服务器 (2),区域服务器 (1+),主控/ZooKeeper 节点 (3)Head server (2), region server (1+), master/ZooKeeper node (3) HDInsight HBase 群集类型设置
StormStorm Nimbus 节点 (2),监督程序服务器 (1+),ZooKeeper 节点 (3)Nimbus node (2), supervisor server (1+), ZooKeeper node (3) HDInsight storm 群集类型设置
SparkSpark 头节点 (2),工作器节点 (1+),ZooKeeper 节点 (3)(对于 A1 ZooKeeper VM 大小免费)Head node (2), Worker node (1+), ZooKeeper node (3) (free for A1 ZooKeeper VM size) HDInsight spark 群集类型设置

有关详细信息,请参阅“HDInsight 中的 Hadoop 组件和版本是什么?”中的群集的默认节点配置和虚拟机大小For more information, see Default node configuration and virtual machine sizes for clusters in "What are the Hadoop components and versions in HDInsight?"

HDInsight 群集的成本取决于节点数和节点的虚拟机大小。The cost of HDInsight clusters is determined by the number of nodes and the virtual machines sizes for the nodes.

不同群集类型具有不同的节点类型、节点数和节点大小:Different cluster types have different node types, numbers of nodes, and node sizes:

  • Hadoop 群集类型的默认配置:Hadoop cluster type default:
    • 两个头节点Two head nodes
    • 四个工作器节点Four Worker nodes
  • Storm 群集类型的默认配置:Storm cluster type default:
    • 两个 Nimbus 节点Two Nimbus nodes
    • 三个 ZooKeeper 节点Three ZooKeeper nodes
    • 四个监督器节点Four supervisor nodes

如果你只是想要试用 HDInsight,我们建议你使用一个工作器节点。If you are just trying out HDInsight, we recommend you use one Worker node. 有关 HDInsight 定价的详细信息,请参阅 HDInsight 定价For more information about HDInsight pricing, see HDInsight pricing.


群集大小限制因 Azure 订阅而异。The cluster size limit varies among Azure subscriptions. 可联系 Azure 支持部门以提高限制。Contact Azure Support to increase the limit.

使用 Azure 门户配置群集时,可通过“配置 + 定价”边栏选项卡查看节点大小。在门户中,还可以查看不同节点大小的相关费用。When you use the Azure portal to configure the cluster, the node size is available through the Configuration + pricing tab. In the portal, you can also see the cost associated with the different node sizes.

虚拟机大小Virtual machine sizes

部署群集时,请根据要部署的解决方案选择计算资源。When you deploy clusters, choose compute resources based on the solution you plan to deploy. 以下 VM 用于 HDInsight 群集:The following VMs are used for HDInsight clusters:

使用不同的 SDK 或使用 Azure PowerShell 创建群集时,若要确定应该使用哪个值来指定 VM 大小,请参阅用于 HDInsight 群集的 VM 大小To find out what value you should use to specify a VM size while creating a cluster using the different SDKs or while using Azure PowerShell, see VM sizes to use for HDInsight clusters. 请使用此链接本章的“大小”列中的值。From this linked article, use the value in the Size column of the tables.


如果需要在群集中使用 32 个以上的辅助角色节点,则必须选择至少具有 8 个核心和 14 GB RAM 的头节点大小。If you need more than 32 worker nodes in a cluster, you must select a head node size with at least 8 cores and 14 GB of RAM.

有关详细信息,请参阅虚拟机的大小For more information, see Sizes for virtual machines. 有关不同大小的定价信息,请参阅 HDInsight 定价For information about pricing of the various sizes, see HDInsight pricing.

脚本操作Script actions

可以在创建期间通过使用脚本安装其他组件或自定义群集配置。You can install additional components or customize cluster configuration by using scripts during creation. 此类脚本可通过 脚本操作调用,脚本操作是一种配置选项,可通过 Azure 门户、HDInsight Windows PowerShell cmdlet 或 HDInsight .NET SDK 使用。Such scripts are invoked via Script Action, which is a configuration option that can be used from the Azure portal, HDInsight Windows PowerShell cmdlets, or the HDInsight .NET SDK. 有关详细信息,请参阅使用脚本操作自定义 HDInsight 群集For more information, see Customize HDInsight cluster using Script Action.

某些本机 Java 组件(例如 Apache Mahout 和 Cascading)可以在群集上作为 Java 存档 (JAR) 文件运行。Some native Java components, like Apache Mahout and Cascading, can be run on the cluster as Java Archive (JAR) files. 可以使用 Hadoop 作业提交机制将这些 JAR 文件分发到 Azure 存储,然后提交到 HDInsight 群集。These JAR files can be distributed to Azure Storage and submitted to HDInsight clusters with Hadoop job submission mechanisms. 有关详细信息,请参阅以编程方式提交 Apache Hadoop 作业For more information, see Submit Apache Hadoop jobs programmatically.


如果在将 JAR 文件部署到 HDInsight 群集或调用 HDInsight 群集上的 JAR 文件时遇到问题,请联系 Azure 支持If you have issues deploying JAR files to HDInsight clusters, or calling JAR files on HDInsight clusters, contact Azure Support.

HDInsight 不支持级联,因此不符合 Azure 技术支持的条件。Cascading is not supported by HDInsight and is not eligible for Azure Support. 有关支持的组件的列表,请参阅 HDInsight 提供的群集版本有哪些新功能?For lists of supported components, see What's new in the cluster versions provided by HDInsight.

在创建过程中,有时需要配置以下配置文件:Sometimes, you want to configure the following configuration files during the creation process:

  • clusterIdentity.xmlclusterIdentity.xml
  • core-site.xmlcore-site.xml
  • gateway.xmlgateway.xml
  • hbase-env.xmlhbase-env.xml
  • hbase-site.xmlhbase-site.xml
  • hdfs-site.xmlhdfs-site.xml
  • hive-env.xmlhive-env.xml
  • hive-site.xmlhive-site.xml
  • mapred-sitemapred-site
  • oozie-site.xmloozie-site.xml
  • oozie-env.xmloozie-env.xml
  • storm-site.xmlstorm-site.xml
  • tez-site.xmltez-site.xml
  • webhcat-site.xmlwebhcat-site.xml
  • yarn-site.xmlyarn-site.xml

有关详细信息,请参阅 使用 Bootstrap 自定义 HDInsight 群集 For more information, see Customize HDInsight clusters using Bootstrap.

后续步骤Next steps