Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Big data, just an introduction to Hadoop and Scripting Languages


Published on

Just an introduction to Hadoop framework and scripting languages.

Published in: Technology

Big data, just an introduction to Hadoop and Scripting Languages

  1. 1. BigData - Introduction Walter Dal Mut – @walterdalmut - @corleycloud - @upcloo
  2. 2. Whoami• Walter Dal Mut • Corley S.r.l. • Startupper • Load and Stress tests • Corley S.r.l. • • • UpCloo Ltd. • Scalable CMS • • Electronic Engineer • • Polytechnic of Turin • Consultancy• Social • PHP • @walterdalmut - @corleycloud - @upcloo • AWS• Websites • Distributed Systems • – – • Scalable Systems Walter Dal Mut @walterdalmut @corleycloud @upcloo
  3. 3. Wait a moment… What is it?• Big data is a collection of data sets • So large and complex • Difficult to process: • using on-hand database management tools • traditional data processing• Big data challenges • Capture • Curation • Storage • Search • Sharing • Transfer • Analysis • Visualization
  4. 4. Common scenario• Data arriving at fast rates• Data are typically unstructured or partially structured • Log files • JSON/BSON structures• Data are stored without any kind of aggregation
  5. 5. What we are looking for?• Scalable Storage • In 2010 Facebook claimed that they had 21 PB of storage • 30PB in 2011 • 100PB in 2012 • 500PB in 2013• Massive Parallel Processing • In 2012 we can elaborate exabytes (10^18 bytes) of data in a reasonable amount of time • The Yahoo! Search Webmap is a Hadoop application that runs on a more than 10,000 core Linux cluster and produces data that is used in every Yahoo! Web search query.• Resonable Cost • The New York Times used 100 Amazon EC2 instances and a Hadoop application to process 4 TB of raw image TIFF data (stored in S3) into 11 million finished PDFs in the space of 24 hours at a computation cost of about $240 (not including bandwidth)
  6. 6. What is Apache Hadoop?• Apache Hadoop is an open-source software framework that supports data- intensive distributed applications. • It was derived from Google’s MapReduce and Google File System (GFS) papers • Hadoop implements a computational paradigm named: MapReduce• Hadoop architecture • Hadoop Kernel • MapReduce • Hadoop Distributed File System (HDFS)• Other project created in top of Hadoop • Hive, Pig • Hbase • ZooKeeper • Etc.
  7. 7. What is MapReduce? SLICE 0 SLICE 1 R0 SLICE 2 SLICE 3 Input SLICE 4 R1 Output SLICE 5 SLICE 6 R2 SLICE 7 MAP REDUCE
  8. 8. Word Count with Map Reduce
  9. 9. The Hadoop Ecosystem Data Mining Data Access Client Access Mahout Sqoop Hive, Pig Network Data Storage Data Processing Coordination HDFS, HBase MapReduce ZooKeeper JVM (Java Virtual Machine) Operating System (RedHat, Ubuntu, etc) Hardware
  10. 10. Getting Started with Apache Hadoop• Hadoop is a framework• We need to write down our software • A Map • A Reduce • Put all togheter• WordCount MapReduce with Hadoop •
  11. 11. (MAP) WordCount MapReduce withHadooppublic static class Map extends Mapper<LongWritable, Text, Text, IntWritable> { private final static IntWritable one = new IntWritable(1); private Text word = new Text(); public void map(LongWritable key, Text value, Context context) throwsIOException, InterruptedException { String line = value.toString(); StringTokenizer tokenizer = new StringTokenizer(line); while (tokenizer.hasMoreTokens()) { word.set(tokenizer.nextToken()); context.write(word, one); } }}
  12. 12. (RED) WordCount MapReduce withHadooppublic static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> { public void reduce(Text key, Iterable<IntWritable> values,Context context) throws IOException, InterruptedException { int sum = 0; for (IntWritable val : values) { sum += val.get(); } context.write(key, new IntWritable(sum)); }}
  13. 13. WordCount MapReduce with Hadooppublic static void main(String[] args) throws Exception { Configuration conf = new Configuration(); Job job = new Job(conf, "wordcount"); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); job.setMapperClass(Map.class); job.setReducerClass(Reduce.class); job.setInputFormatClass(TextInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); FileInputFormat.addInputPath(job, new Path(args[0])); FileOutputFormat.setOutputPath(job, new Path(args[1])); job.waitForCompletion(true);}
  14. 14. Scripting Languages on top of Hadoop
  15. 15. Apache HIVE – Data Warehouse• Hive is a data warehouse system for Hadoop • Facilitates easy data summarization • Ad-hoc queries • Analysis of large datasets stored in Hadoop compatible file systems• SQL-like language called HiveQL• Custom plug-in MapReduce if needed
  16. 16. Apache Hive Features• SELECTs and FILTERs • SELECT * FROM table_name; • SELECT * FROM table_name tn WHERE tn.weekday = 12;• GROUP BY • SELECT * FROM table_name GROUP BY weekday;• JOINs • SELECT a.* FROM a JOIN b ON ( =• More (multitable inserts, streaming)• Example: tarted-SimpleExampleUseCases
  17. 17. A real example with a CSV (tab-separated)CREATE TABLE u_data ( userid INT, movieid INT, rating INT, unixtime STRING)ROW FORMAT DELIMITEDFIELDS TERMINATED BY tSTORED AS TEXTFILE;LOAD DATA LOCAL INPATH ml-data/ OVERWRITE INTO TABLEu_data;SELECT COUNT(*) FROM u_data;
  18. 18. Apache PIG• It is a platform for analyzing large data sets that consists of a high- level language for expressing data analysis programs• Pigs infrastructure layer consists of a compiler that produces sequences of Map-Reduce programs • Ease of programming • Optimization opportunities • Auto-optimization of tasks, allowing the user to focus on semantics rather than efficiency. • Extensibility
  19. 19. Apache Pig – Log Flow analysis• A common scenario is collect logs and analyse it as post processing• We will cover Apache2 (web server) log analysis • Read AWS Elastic Map Reduce  Apache Pig example •• Apache Log: • - - [21/Jul/2009:13:14:17 -0700] "GET / HTTP/1.1" 200 35942 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.21022; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30618; OfficeLiveConnector.1.3; OfficeLivePatch.1.3; MSOffice 12)"
  20. 20. Log Analysis [Common Log Format(CLF)]• More information about CLF: •• Log interesting fields: • Remote Address (IP) • Remote Log Name • User • Time • Request • Status • Bytes • Refererer • Browser
  21. 21. Getting started with Apache Pig• First of all we need to load all logs from a HDFS compabile source (for example AWS S3)• Create a table starting from all log lines• Create the Map Reduce program in order to analyse and store results
  22. 22. Load logs from S3 and create a tableRAW_LOGS = LOAD ‘s3://bucket/path’ USING TextLoader as (line:chararray);LOGS_BASE = FOREACH RAW_LOGS GENERATE FLATTEN( EXTRACT(line, ^(S+) (S+) (S+) [([w:/]+s[+-]d{4})] "(.+?)" (S+) (S+)"([^"]*)" "([^"]*)") ) as ( remoteAddr: chararray, remoteLogname: chararray, user: chararray, time: chararray, request: chararray, status: int, bytes_string: chararray, referrer: chararray, browser: chararray );
  23. 23. LOGS_BASE is a TableRemote logNm User Time Request Status Bytes Refererer Browser72.14.194.1 - - 21/Jul/20 GET 200 2969 - FeedFetch 09:18:04: /gwidgets er- 54 -0700 /alexa.xml Google; HTTP/1.1 (+http://w ww.googl dfetcher.h tml)
  25. 25. Thanks for Listening• Any questions?