Amazon Elastic MapReduce
Developer Guide (API Version 2009-03-31)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Launch a Hive Cluster

This section covers the basics of creating a cluster using Hive in Amazon Elastic MapReduce (Amazon EMR). You'll step through how to create a cluster using Hive with either the Amazon EMR console, the CLI, or the Query API. Before you create your cluster you'll need to create objects and permissions; for more information see Prepare Input Data (Optional).

For advanced information on Hive configuration options, see Analyze Data with Hive.

A cluster using Hive enables you to create a data analysis application using a SQL-like language. The example that follows is based on the Amazon EMR sample: Contextual Advertising using Apache Hive and Amazon EMR with High Performance Computing instances. This sample describes how to correlate customer click data to specific advertisements.

In this example, the Hive script is located in an Amazon S3 bucket at s3n://elasticmapreduce/samples/hive-ads/libs/model-build. All of the data processing instructions are located in the Hive script. The script requires additional libraries that are located in an Amazon S3 bucket at s3n://elasticmapreduce/samples/hive-ads/libs. The input data is located in the Amazon S3 bucket s3n://elasticmapreduce/samples/hive-ads/tables. The output is saved to an Amazon S3 bucket you created as part of Prepare an Output Location (Optional).

Amazon EMR Console

This example describes how to use the Amazon EMR console to create a cluster using Hive.

To create a cluster using Hive

  1. Sign in to the AWS Management Console and open the Amazon Elastic MapReduce console at https://console.aws.amazon.com/elasticmapreduce/.

  2. Click Create New Job Flow.

    Amazon EMR console
  3. In the DEFINE JOB FLOW page, do the following:

    1. Enter a name in the Job Flow Name field.

      We recommended you use a descriptive name. It does not need to be unique.

    2. Select which version of Hadoop to run on your cluster in Hadoop Version. You can choose to run the Amazon distribution of Hadoop or one of two MapR distributions. For more information about MapR distributions for Hadoop, see Using the MapR Distribution for Hadoop.

    3. Select Run your own application.

    4. Select Hive in the drop-down list.

    5. Click Continue.

    New Hive Cluster
  4. In SPECIFY PARAMETERS page, specify whether you want to run the Hive job from a script or interactively from the master node. If you are running Hive from a script, enter values in the boxes using the following table as a guide. Click Continue.

    FieldAction
    Script Location* Specify the URI where your script resides in Amazon S3. The value must be in the form BucketName/path/ScriptName.
    Input LocationOptionally, specify the URI where your input files reside in Amazon S3. The value must be in the form BucketName/path/. If specified, this will be passed to the Hive script as a parameter named INPUT.
    Output LocationOptionally, specify the URI where you want the output stored in Amazon S3. The value must be in the form BucketName/path. If specified, this will be passed to the Hive script as a parameter named OUTPUT.
    Extra Args Optionally, enter a list of arguments (space-separated strings) to pass to Hive.

    * Required parameter

    Specify Hive Parameters
  5. In the CONFIGURE EC2 INSTANCES page, select the type and number of instances, using the following table as a guide, and then click Continue.

    Note

    Twenty is the default maximum number of nodes per AWS account. For example, if you have two clusters running, the total number of nodes running for both clusters must be 20 or less. If you need more than 20 nodes, you must submit a request to increase your Amazon EC2 instance limit. For more information, go to the Request to Increase Amazon EC2 Instance Limit Form.

    FieldAction
    Instance CountSpecify the number of nodes to use in the Hadoop cluster. There is always one master node in each cluster. You can specify the number of core and tasks nodes.
    Instance TypeSpecify the Amazon EC2 instance types to use as master, core, and task nodes. Valid types are m1.small (default), m1.large, m1.xlarge, c1.medium, c1.xlarge, m2.xlarge, m2.2xlarge, m2.4xlarge, cc1.4xlarge, hi1.4xlarge, hs1.8xlarge, and cg1.4xlarge. The cc2.8xlarge instance type is only supported in the US East (Northern Virginia), US West (Oregon), and EU (Ireland) regions. The cc1.4xlarge and hs1.8xlarge instance types are only supported in the US East (Northern Virginia) region. The hi1.4xlarge instance type is only supported in the US East (Northern Virginia) and EU (Ireland) regions.
    Request Spot InstancesSpecify whether to run master, core, or task nodes on Spot Instances. For more information, see Lower Costs with Spot Instances (Optional)

    * Required parameter

    Configure EC2 Instances
  6. In the ADVANCED OPTIONS page, set additional configuration options, using the following table as a guide, and then click Continue.

    FieldAction
    Amazon EC2 Key PairOptionally, specify a key pair that you created previously. For more information, see Create an Amazon EC2 Key Pair and PEM File. If you do not enter a value in this field, you cannot SSH into the master node.
    Amazon VPC Subnet Id

    Optionally, specify a VPC subnet identifier to launch the cluster in an Amazon VPC. Set this only if you need to launch the cluster into a specific VPC subnet, otherwise you can leave this set to the default: No preference. For more information about how Amazon VPC integrates with Amazon EMR, see Select a Amazon VPC Subnet for the Cluster (Optional).

    Amazon S3 Log PathOptionally, specify a path in Amazon S3 to store the Amazon EMR log files. The value must be in the form BucketName/path. If you do not supply a location, Amazon EMR does not log any files.
    Enable debuggingSelect Yes to store Amazon Elastic MapReduce-generated log files. You must enable debugging at this level if you want to store the log files generated by Amazon EMR.

    If you select Yes, you must supply an Amazon S3 bucket name where Amazon Elastic MapReduce can upload your log files.

    For more information, see Troubleshoot a Cluster.

    Important

    You can enable debugging for a cluster only when you initially create the cluster.

    Keep AliveSelect Yes to cause the cluster to continue running when all processing is completed.
    Termination ProtectionSelect Yes to ensure the cluster is not shut down due to accident or error. For more information, see Protect a Cluster from Termination.
    Visible To All IAM UsersSelect Yes to make the cluster visible and accessible to all IAM users on the AWS account. For more information, see Configure IAM User Permissions.

    Advanced Options
  7. In the bootstrap ACTIONS page, select Proceed with no bootstrap Actions, and then click Continue.

    For more information about bootstrap actions, see Create Bootstrap Actions to Install Additional Software (Optional).

    bootstrap Actions
  8. In the REVIEW page, review the information, edit as necessary to correct any of the values, and then click Create Job Flow when the information is correct.

    After you click Create Job Flow your request is processed; when it succeeds, a message appears.

    Amazon EMR console
  9. Click Close.

    The Amazon EMR console shows the new cluster starting. Starting a new cluster may take several minutes, depending on the number and type of EC2 instances Amazon EMR is launching and configuring. Click the Refresh button for the latest view of the cluster's progress.

    Amazon EMR console

CLI

This example describes how to use the CLI to create a cluster using Hive.

To create a cluster using Hive

  • In the directory where you installed the Amazon EMR CLI, run the following from the command line. For more information, see the Command Line Interface Reference for Amazon EMR.

    • Linux, UNIX, and Mac OS X users:

      ./elastic-mapreduce --create --name "Test Hive" --hive-script \
      s3n://elasticmapreduce/samples/hive-ads/libs/model-build.q \
      --args "-d", "LIBS=s3n://elasticmapreduce/samples/hive-ads/libs",\
      "-d", "INPUT=s3n://elasticmapreduce/samples/hive-ads/tables", \
      "-d", "OUTPUT=s3n://myawsbucket/hive-ads/output/"
    • Windows users:

      ruby elastic-mapreduce --create --name "Test Hive" --hive-script s3n://elasticmapreduce/samples/hive-ads/libs/model-build.q --args "-d", "LIBS=s3n://elasticmapreduce/samples/hive-ads/libs","-d", "INPUT=s3n://elasticmapreduce/samples/hive-ads/tables",  "-d", "OUTPUT=s3n://myawsbucket/hive-ads/output/"

The output looks similar to the following.

Created cluster JobFlowID

By default, this command launches a cluster to run on a two-node cluster using an Amazon EC2 m1.small instance. Later, when your steps are running correctly on a small set of sample data, you can launch clusters to run on multiple nodes. You can specify the number of nodes and the type of instance to run with the --num-instances and --instance-type parameters, respectively.

API

This section describes the Amazon EMR API Query request parameters you need to create a cluster using Hive. For an explanation of the parameters unique to RunJobFlow, go to RunJobFlow in the Amazon Elastic MapReduce (Amazon EMR) API Reference. The response includes a <JobFlowID>, which you use in other Amazon EMR operations, such as when describing or terminating a cluster. For this reason, it is important to store cluster IDs.

The Args argument contains location information for your input data, output data, and LIBS, as shown in the following example.

"Name": "Hive cluster",
"HadoopJarStep": 
{
"Jar":"s3://us-west-1.elasticmapreduce/libs/script-runner/script-runner.jar",
"Args":[
    "s3://us-west-1.elasticmapreduce/libs/hive/hive-script",
    "--base-path",
    "s3://us-west-1.elasticmapreduce/libs/hive/",
    "--run-hive-script",
    "--args",
    "-f",
    "s3n://elasticmapreduce/samples/hive-ads/libs/model-build.q",
    "-d LIBS=s3n://elasticmapreduce/samples/hive-ads/libs"
      ]
}

Note

All paths are prefixed with their location. The prefix “s3://” refers to the s3n file system. If you use HDFS, prepend the path with hdfs:///. Make sure to use three slashes (///), as in hdfs:///home/hadoop/sampleInput2/.