The script is stored in Amazon S3 at s3 region

The script is stored in amazon s3 at s3 region

This preview shows page 24 - 26 out of 395 pages.

The script is stored in Amazon S3 at s3:// region .elasticmapreduce.samples/cloudfront/ code/Hive_CloudFront.q where region is your region. The sample Hive script does the following: Creates a Hive table schema named cloudfront_logs . For more information about Hive tables, see the Hive Tutorial on the Hive wiki. Uses the built-in regular expression serializer/deserializer (RegEx SerDe) to parse the input data and apply the table schema. For more information, see SerDe on the Hive wiki. Runs a HiveQL query against the cloudfront_logs table and writes the query results to the Amazon S3 output location that you specify. 18
Image of page 24
Amazon EMR Management Guide Submit the Hive Script as a Step The contents of the Hive_CloudFront.q script are shown below. The ${INPUT} and ${OUTPUT} variables are replaced by the Amazon S3 locations that you specify when you submit the script as a step. When you reference data in Amazon S3 as this script does, Amazon EMR uses the EMR File System (EMRFS) to read input data and write output data. -- Summary: This sample shows you how to analyze CloudFront logs stored in S3 using Hive -- Create table using sample data in S3. Note: you can replace this S3 path with your own. CREATE EXTERNAL TABLE IF NOT EXISTS cloudfront_logs ( DateObject Date, Time STRING, Location STRING, Bytes INT, RequestIP STRING, Method STRING, Host STRING, Uri STRING, Status INT, Referrer STRING, OS String, Browser String, BrowserVersion String ) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe' WITH SERDEPROPERTIES ( "input.regex" = "^(?!#)([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s +([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+[^\(]+[\(]([^\;]+).*\%20([^\/]+)[\/](.*)$" ) LOCATION '${INPUT}/cloudfront/data'; -- Total requests per operating system for a given time frame INSERT OVERWRITE DIRECTORY '${OUTPUT}/os_requests/' SELECT os, COUNT(*) count FROM cloudfront_logs WHERE dateobject BETWEEN '2014-07-05' AND '2014-08-05' GROUP BY os; Submit the Hive Script as a Step Use the Add Step option to submit your Hive script to the cluster using the console. The Hive script and sample data have been uploaded to Amazon S3, and you specify the output location as the folder you created earlier in Create an Amazon S3 Bucket (p. 12) . To run the Hive script by submitting it as a step 1. Open the Amazon EMR console at . 2. In Cluster List , select the name of your cluster. Make sure the cluster is in a Waiting state. 3. Choose Steps , and then choose Add step . 4. Configure the step according to the following guidelines: • For Step type , choose Hive program . • For Name , you can leave the default or type a new name. If you have many steps in a cluster, the name helps you keep track of them. • For Script S3 location , type s3:// region .elasticmapreduce.samples/cloudfront/ code/Hive_CloudFront.q . Replace region with your region identifier. For example, s3://us- west-2.elasticmapreduce.samples/cloudfront/code/Hive_CloudFront.q if you are working in the Oregon region. For a list of regions and corresponding Region identifiers, see AWS Regions and Endpoints for Amazon EMR in the AWS General Reference .
Image of page 25
Image of page 26

You've reached the end of your free preview.

Want to read all 395 pages?

  • Spring '12
  • LauraParker
  • Amazon Web Services, Amazon Elastic Compute Cloud

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors