View a markdown version of this page

Migrating Apache Hive to Amazon EMR - Amazon EMR Migration Guide

Migrating Apache Hive to Amazon EMR

Apache Hive is one of the popular applications used by Amazon EMR customers as a data warehouse. As with any migration, you have several considerations to make. This chapter covers key migration topics, updated through Amazon EMR 7.12.0, and incorporates the latest improvements in metastore management, execution engines, storage, high availability, and encryption.

Hive metastore

By default, Amazon EMR clusters are configured to use a local instance of MySQL as the Hive metastore. To use Amazon EMR most effectively, use a shared Hive metastore such as Amazon RDS, Amazon Aurora, or AWS Glue Data Catalog. If you require a persistent metastore, or a metastore shared by different clusters, services, applications, or AWS accounts, use AWS Glue Data Catalog as the metastore for Hive. For more information, see Configuring an external metastore for Hive.

Upgrading

Hive upgrades are coupled with Hive metastore updates. Back up and isolate the Hive metadata database from production instances, because Hive upgrades might change the Hive schema, which can cause compatibility issues in production. Perform upgrades using the upgradeSchema command in the Hive Schema Tool, which can also upgrade the schema from an older version to the current version.

Upgrading the Hive metastore across Amazon EMR major versions

When upgrading across Amazon EMR major versions, the Hive metastore schema must be updated to match the Hive version shipped with the target release. This applies to both Amazon EMR 5.x to 6.x and 6.x to 7.x.

Option 1: Using the Hive Schema Tool

Run upgradeSchema to migrate your metastore schema to the version required by Hive on the target release. Before running, back up your metastore database and validate the upgrade against a staging environment. The schema upgrade is not reversible.

/usr/lib/hive/bin/schematool -dbType mysql -upgradeSchemaFrom <source-version> -upgradeSchema
Note

Both Amazon EMR 6.x and Amazon EMR 7.x ship with Hive 3.1.3. If you are upgrading from Amazon EMR 6.x to 7.x and your metastore schema is already at the Hive 3.1.3 schema version, a schema upgrade might not be required. Validate metastore compatibility in a staging environment before migrating production workloads.

Option 2: Migrating to AWS Glue Data Catalog

Migrate the metastore to AWS Glue Data Catalog, which eliminates the need to manage metastore schema upgrades across Amazon EMR versions and provides a fully managed serverless catalog. AWS Glue Data Catalog is compatible with the Apache Hive metastore and can be used as a drop-in replacement. To configure Hive to use AWS Glue Data Catalog, set hive.metastore.client.factory.class to com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory in the hive-site classification when you create the cluster.

Additional considerations for Amazon EMR 7.x

  • Default filesystem change (Amazon EMR 7.10.0+) – Starting with Amazon EMR 7.10.0, S3A replaces EMRFS as the default Amazon S3 connector, so Hive operations no longer create _$folder$ marker objects in Amazon S3 and intermediate manifest files are stored differently. Review the EMRFS to S3A migration guide.

  • Java runtime – Amazon EMR 7.0 and higher use Amazon Corretto 17 (OpenJDK 17) by default, which might affect custom UDFs or Hive extensions compiled against older Java versions.

  • Amazon Linux 2023 – Amazon EMR 7.x clusters run on Amazon Linux 2023, which removed Python 2.7.

Hive execution engine

Apache Tez is the supported and default execution engine for Hive clusters on Amazon EMR. In most cases, Tez provides improved performance. If you are migrating from an older Hive version that used the MapReduce (MR) execution engine, certain jobs might require changes.

Hive 3.1.3 added support for Apache Spark as an execution engine. However, this setup is not supported on Amazon EMR without changes to the underlying Hive jars in Spark, and is not a supported configuration on Amazon EMR.

Tez container size

If you have large input files that cannot be split, or if the map portion of a job exceeds the default memory limits of a container, you require a larger Tez container size. On Amazon EMR, the default container setting is hive.tez.container.size, set to -1, which means the value of mapreduce.map.memory.mb is used for the memory limit. The default values of mapreduce.map.memory.mb depend on the instance type selected (see Task configuration). The Tez container size must be at least the same value as mapreduce.map.memory.mb.

If the Tez container runs out of memory, the following error appears:

Error: GC overhead limit exceeded

To increase memory, set hive.tez.container.size to a value greater than what the job requires (the required value is in the error message). In addition, increase the Tez Java heap size, which in general should be 80 percent of the Tez container size, using the setting hive.tez.java.opts.

Recent Tez release improvements

Amazon EMR has shipped several Tez-related improvements. The following sections describe these improvements by release.

Amazon EMR 7.4.0

  • Upgraded Hadoop to version 3.4.0, improving stability and performance for HDFS and YARN.

  • Enabled a short-circuit mechanism in the Tez DAG for simple SELECT queries with LIMIT, reducing unnecessary DAG stages and improving latency.

  • Allowed flattening of table subdirectories when using the Tez execution engine with the UNION clause, improving write performance and simplifying the output directory structure for UNION ALL queries.

Amazon EMR 7.5.0

  • Increased the maximum wait time for the Tez session to 10 seconds, reducing timeout failures under high cluster load or slow session initialization.

  • Tuned configuration parameters for improved performance in simple SELECT queries with LIMIT.

Amazon EMR 7.6.0

Added fast Amazon S3 partition discovery through the hive.exec.fast.s3.partition.discovery.enabled configuration property. When enabled, it significantly reduces partition discovery time for large tables on Amazon S3 using optimized directory listing.

"hive.exec.fast.s3.partition.discovery.enabled": "true"

Also in 7.6.0, Magic Committer in-memory tracking improvements reduced memory pressure during large write operations, improving reliability for high-throughput Hive jobs writing to Amazon S3.

HDFS vs Amazon S3 considerations

A key benefit of Amazon EMR is the separation of storage and compute, with Amazon S3 as the primary data store. This architecture saves costs compared to HDFS, because you scale storage and compute independently. Amazon S3 provides scalability, durability, availability, encryption, and lifecycle management.

Hadoop was designed with the expectation of atomic renames and consistency. Consider the following options if you require immediate list and read-after-write consistency.

Amazon S3 strong consistency

As of December 2020, Amazon S3 delivers strong read-after-write consistency for all GET, PUT, and LIST operations. This eliminates the eventual-consistency scenarios that previously required EMRFS Consistent View. EMRFS Consistent View was deprecated in June 2023 and is not available in Amazon EMR 7.x. No additional configuration is required.

For the EMRFS to S3A transition starting with Amazon EMR 7.10, see Data Migration.

Hive Tez merge files

When you use the EMRFS S3-Optimized Committer, which is the zero-rename committer, enabling Hive to merge small files automatically with hive.merge.tezfiles is not supported. When merge is enabled, Hive uses the default Hive commit logic even when the optimized committer is enabled, which bypasses the write-performance benefits of the committer.

If small file merging is required, perform INSERT OVERWRITE or ALTER CONCATENATE statements on transient HDFS-backed Amazon EMR clusters, and then copy the results to Amazon S3 using s3-dist-cp. Other approaches include a custom manifest file approach, or building a metadata store such as Apache Iceberg.

Hive blobstore optimization

Hive blobstore optimizations increase the performance of intermediate MapReduce jobs. However, for simple Hive queries against Amazon S3-backed tables, such as INSERT OVERWRITE or ALTER TABLE CONCATENATE, this setting can increase execution times and cause missing data.

Applying this setting to queries that are not multi-staged MapReduce jobs makes Hive use Amazon S3 as the scratch directory. This increases renames, because the job writes scratch data, copies it to another Amazon S3 temporary location, and finally copies it to the final Amazon S3 location. If you disable this setting, the scratch directory relocates to HDFS. Allocate enough space on the cluster.

By default, the distcp job at the end is limited to a maximum of 20 mappers. If it takes too long, such as when processing terabytes of data, set the maximum number of mappers.

set hive.exec.copyfile.maxnummaps=100;

EMRFS S3-Optimized Committer (zero-rename)

The EMRFS S3-Optimized Committer is available from Amazon EMR 6.5.0 and Amazon EMR 5.34.0 and later. It delivers up to 15x improvement in Hive write performance by eliminating the expensive rename operations that standard Hadoop output committers perform when writing to Amazon S3. Traditional committers write to a temporary location and rename on completion, which Amazon S3 implements as copy-then-delete, and this is slow for large datasets. The EMRFS S3-Optimized Committer writes directly to the final output location using a manifest-based approach for atomicity.

To enable the committer for Hive, provide the following configuration:

"hive.blobstore.use.blobstore.as.scratchdir": "false", "hive.exec.stagingdir": "/tmp/hive-staging"
Note

The EMRFS S3-Optimized Committer is enabled by default for new clusters running Amazon EMR 6.5.0 and later. For Amazon EMR 5.x clusters, configure it using the emrfs-site classification. Starting with Amazon EMR 7.10, EMR S3A replaces EMRFS as the default Amazon S3 connector.

For more information, see the blog posts Up to 15 times improvement in Hive write performance with the Amazon EMR Hive zero-rename feature and Accelerate Apache Hive read and write on Amazon EMR using enhanced S3A.

MSCK optimization

The hive.emr.optimize.msck.fs.check configuration property was introduced in Amazon EMR 6.5.0 and is enabled by default starting in Amazon EMR 6.8.0. It significantly improves partition repair performance on large tables that have many partitions on Amazon S3. The standard MSCK REPAIR TABLE command performs a full filesystem check that lists all directories under the table location, which is slow because of the volume of Amazon S3 LIST calls. This optimization uses a more efficient partition discovery mechanism that leverages Amazon S3 metadata and listing optimizations.

"hive.emr.optimize.msck.fs.check": "true"

For Amazon EMR 6.5.0 through 6.7.x, explicitly set this property. For Amazon EMR 6.8.0 and later, it is enabled by default.

Amazon S3 Express One Zone considerations

Starting in Amazon EMR 7.6.0, support was added for Amazon S3 Express One Zone with Hive INSERT OVERWRITE queries. Amazon S3 Express One Zone is a high-performance storage class that offers single-digit millisecond latency and higher throughput than standard Amazon S3. When you use it as the target for Hive INSERT OVERWRITE, consider the following:

  • Directory buckets use a different namespace and endpoint than standard buckets, so Hive configurations and output paths must use s3a://.

  • The EMRFS S3-Optimized Committer is compatible and recommended for optimal performance.

  • Amazon S3 Express One Zone is single-AZ, so for multi-AZ durability use standard Amazon S3 or Amazon S3 Standard-IA.

Job throughput and scheduling

By default, Amazon EMR uses the Hadoop CapacityScheduler to allocate resources. It allows large cluster sharing and provides capacity guarantees per organization, and it supports queues to grant capacity in a multitenant cluster. Configure it by modifying the capacity-scheduler classification at cluster creation.

In some cases, the FairScheduler might be more desirable for clusters where a job can consume unused resources. In FairScheduler, resources are shared between queues.

Configure FairScheduler

Use one of the following methods to configure FairScheduler.

Method 1 – Modify the yarn-config.json file.

[ { "Classification": "yarn-site", "Properties": { "yarn.resourcemanager.scheduler.class": "org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler" } } ]

Method 2 – Edit software settings in the AWS Management Console.

  1. Sign in to the AWS Management Console and open the Amazon EMR console.

  2. Choose Create cluster, Go to advanced options.

  3. Under Edit software settings, leave Enter configuration selected, and then enter the FairScheduler configuration.

  4. Choose Create cluster.

Maintaining a highly available Hive-based cluster

Hive clusters are often long running, because ad hoc queries can arrive at any time. There are several approaches to maintaining high availability.

Warm failover

A secondary, smaller cluster runs alongside the primary cluster. On failure, redirect clients to the new cluster manually or by updating an Amazon Route 53 entry. Configure the secondary cluster with few nodes, and use automatic scaling to grow it when it becomes the primary cluster.

Multi-cluster configuration

Because all data is on Amazon S3, clients do not need the same cluster. Configure multiple clusters with a load balancer or a job submission framework, shared across all clients or per team. Benefits include a limited blast radius, where a cluster failure affects only the queries on that cluster, and independent automatic scaling. The trade-off is multiple primary nodes and additional Amazon EC2 cost.

With pay-per-second billing, which has a one-minute minimum, you can activate only the cluster you need. You can also use an AWS Lambda function to start or take down a cluster without impacting others.

Transient design

Transient clusters mitigate the cost and operational requirements of a single long-running cluster. They are useful for predictable short-lived jobs, but they might not suit consumers who constantly query data.

Single-click high availability

Amazon EMR supports single-click high availability for clusters with multiple primary nodes, which provides automatic failover without the manual complexity of warm failover. It is available when you create a cluster with three primary nodes. The following services support automatic failover:

  • YARN ResourceManager uses ZooKeeper-based leader election, and the standby becomes active within seconds.

  • HDFS NameNode uses active-standby with shared edit logs in JournalNodes, coordinated through ZooKeeper.

  • Apache Spark provides history server and driver recovery.

  • Apache HBase provides automatic Master failover with a standby Master.

  • Apache Hive runs HiveServer2 instances configured for high availability using ZooKeeper-based service discovery, with clients connecting to a ZooKeeper ensemble for transparent failover.

To create a cluster with multiple primary nodes and single-click high availability, use the following command:

aws emr create-cluster \ --release-label emr-7.10.0 \ --instance-groups InstanceGroupType=MASTER,InstanceCount=3,InstanceType=m5.xlarge \ --applications Name=Hive Name=Spark Name=HBase \ --multi-master-enabled
Note

Clusters with multiple primary nodes require at least three primary nodes for ZooKeeper quorum. The cluster must use Amazon S3 as the primary storage backend, because HDFS data must be accessible from any primary node. Multiple primary nodes are supported on Amazon EMR 5.23.0 and later, with automatic failover fully supported on Amazon EMR 6.x and 7.x.

Frequently asked questions

How do I implement transactions and compactions on Amazon EMR?

Amazon EMR supports transactions and compactions through open table formats. Apache Iceberg is recommended for new workloads. It provides ACID transactions, row-level updates and deletes, and table maintenance that includes compaction, snapshot expiry, and orphan-file cleanup, and it has the broadest engine support across Amazon EMR, Amazon Athena, Amazon Redshift, and AWS Glue. Amazon S3 Tables further simplifies this by handling compaction and snapshot management automatically. Apache Hudi and Delta Lake remain supported and are appropriate when you migrate existing Hudi or Delta workloads. For format selection and configuration, see Incremental Data Processing.

How do I troubleshoot loading data from Amazon S3?

A common mistake is to use Amazon S3 like a typical file system. There are differences to consider when you move from HDFS to Amazon S3. For more information, see Cluster input and output errors during Amazon EMR operations.

Does Amazon EMR support Hive LLAP?

Amazon EMR release 6.0.0 and later supports the Live Long and Process (LLAP) functionality for Hive. LLAP uses persistent daemons with intelligent in-memory caching to improve query performance over the default Tez container execution mode. For more information, see Using Hive Live Long and Process (LLAP).

The LLAP daemons are managed and run as a YARN service. Because a YARN service is a long-running YARN application, some cluster resources are dedicated to LLAP. For more information, see LLAP and YARN Service API.

Magic Committer integration in Hive LLAP (Amazon EMR 7.6.0)

Starting in Amazon EMR 7.6.0, the Magic Committer integration for Hive LLAP was updated with a new configuration property to improve compatibility with Amazon S3 writes from LLAP daemons.

"hive.blobstore.output-committer.magic.disable.fs.cache.for.llap": "true"

This disables the filesystem cache for the Magic Committer when running with Hive LLAP. In LLAP mode, multiple daemons might write to Amazon S3 simultaneously using shared filesystem client instances, which can cause stale cache entries and incomplete writes. Disabling the cache ensures that each write uses a fresh client. This is recommended for all Amazon EMR 7.6.0 and later clusters running Hive LLAP that write to Amazon S3.

Table format selection for multi-tenant environments

When you implement multi-tenancy on Amazon EMR, selecting the right open table format is critical for data isolation, concurrent access, and operational simplicity. Apache Iceberg is the recommended format, and it provides the following capabilities:

  • Snapshot isolation.

  • Branch-based write isolation for write-audit-publish patterns.

  • Row-level access control through AWS Lake Formation on Amazon EMR 6.15.0 and later.

  • Concurrent writers with optimistic concurrency control.

  • Partition evolution without data rewrites.

  • Catalog-level governance through the AWS Glue Data Catalog.

Apache Hudi remains appropriate for high-frequency upsert workloads, near-real-time streaming CDC ingestion, or workloads already built on Hudi with established runbooks. Iceberg has strengthened its streaming and row-level update capabilities, such as Flink upserts on v2 tables and automatic compaction with Amazon S3 Tables, which narrows this gap. Evaluate both against your latency and upsert-frequency requirements.

For a detailed comparison of Iceberg, Hudi, and Delta Lake, including version compatibility and migration guidance, see Incremental Data Processing. For the Iceberg version in each Amazon EMR release, see Iceberg release history in the Amazon EMR Release Guide. For Hudi and Delta Lake version mappings, see Incremental Data Processing.

Encryption

Amazon EMR provides multiple encryption options for Hive workloads, including encryption at rest and in transit.

Parquet modular encryption in Hive

Parquet Modular Encryption (PME) enables column-level encryption of Parquet files written by Hive, so sensitive columns are encrypted independently while non-sensitive columns remain readable. This is useful for compliance where different users have access to different column subsets. It uses the Apache Parquet encryption specification and integrates with AWS KMS.

PME provides the following key features:

  • Column-level encryption, where different columns are encrypted with different keys.

  • Footer encryption, where the Parquet footer with schema and column statistics can be encrypted.

  • Key management through AWS KMS, where root keys reside in AWS KMS and column keys are wrapped under the root key, with access controlled through AWS KMS key policies and IAM.

  • Transparent read access, where readers with the appropriate AWS KMS key read encrypted columns without query changes.

To enable PME for Hive tables, configure the following in the hive-site classification:

"parquet.encryption.kms.client.class": "org.apache.parquet.crypto.keytools.mrcrypto.MREncryptionClient", "parquet.encryption.key.list": "keyA: <base64-encoded-key>, keyB: <base64-encoded-key>", "parquet.encryption.column.keys": "keyA: SSN, CreditCardNumber; keyB: Salary"
Note

PME requires that all Parquet readers, including Spark and Trino on the same cluster, be configured with compatible encryption settings and have access to the required AWS KMS keys. Ensure that the Amazon EMR instance profile has kms:GenerateDataKey and kms:Decrypt for the configured root keys.

In-transit encryption in HiveServer2 (HS2)

HiveServer2 supports in-transit encryption for client connections using TLS/SSL, which protects data between Hive clients, such as JDBC or ODBC applications, Beeline, and visualization tools, and the HS2 server on the Amazon EMR primary node. Amazon EMR provides two approaches.

Using Amazon EMR security configurations (recommended)

When you enable in-transit encryption in a security configuration, Amazon EMR automatically configures HS2 to use TLS with a managed certificate.

aws emr create-security-configuration \ --name "hive-encryption-config" \ --security-configuration '{ "EnableInTransitEncryption": true, "InTransitEncryptionConfiguration": { "TLSCertificateConfiguration": { "CertificateProviderType": "PEM", "S3Object": "s3://your-bucket/certs/my-cert.zip" } } }'

Manual TLS configuration for HS2

For more granular control, configure TLS using the hive-site classification, where you manage the keystore and truststore files.

"hive.server2.use.SSL": "true", "hive.server2.keystore.path": "/etc/pki/tls/keystore.jks", "hive.server2.keystore.password": "<keystore-password>", "hive.server2.truststore.path": "/etc/pki/tls/truststore.jks", "hive.server2.truststore.password": "<truststore-password>"

When HS2 TLS is enabled, Beeline clients must connect using ssl=true and provide the truststore.

beeline -u "jdbc:hive2://master-node:10000/default;ssl=true;sslTrustStore=/path/to/truststore.jks;trustStorePassword=<password>"
Note

In-transit encryption for HS2 adds a small TLS handshake overhead. For high-throughput JDBC or ODBC workloads, use connection pooling. In-transit encryption is strongly recommended for production and is required for most compliance frameworks, such as SOC 2, PCI DSS, and HIPAA.

Amazon EMR version coverage

This document covers Amazon EMR Hive features and release notes through Amazon EMR 7.12.0, released November 2025. The following table summarizes key Hive features by Amazon EMR release.

Amazon EMR Hive features by release
Amazon EMR version Key Hive feature Section reference
5.28.0+ Apache Hudi introduced Apache Hudi
5.34.0+ EMRFS S3-Optimized Committer EMRFS S3-Optimized Committer
6.0.0+ Hive LLAP support Hive LLAP (FAQ)
6.1.0+ Hudi and Trino integration Apache Hudi
6.5.0+ EMRFS S3-Optimized Committer; MSCK optimization Storage considerations (Amazon S3)
6.8.0+ MSCK optimization enabled by default Storage considerations (Amazon S3)
7.4.0 Tez DAG improvements; Hadoop 3.4.0 Execution engine (Tez)
7.5.0 Tez session wait time; performance tuning Execution engine (Tez)
7.6.0 Fast S3 partition discovery; S3 Express One Zone; LLAP Magic Committer Execution engine; Storage; LLAP
7.10.0 Coverage through this version All sections