Hadoop Interview Questions

Q.What is BIG Data? Ans: Big Data is nothing but an assortment of such a huge and complex data that it becomes very tedious to capture, store, process, retrieve and analyze it with the help of on-hand database management tools or traditional data processing techniques. Q.What is Hadoop framework? Ans: Hadoop is an open source framework which is written in java by apache software foundation. This framework is used to write software application which requires to process vast amount of data (It could handle multi tera bytes of data). It works in-parallel on large clusters which could have 1000 of computers (Nodes) on the clusters. It also process data very reliably and fault-tolerant manner. See the below image how does it looks. Q.On What concept the Hadoop framework works? Ans: It works on MapReduce, and it is devised by the Google. Q.What is MapReduce? Ans: Map reduces is an algorithm or concept to process Huge amount of data in a faster way. As per its name you can divide it Map and Reduce.

  • The main MapReduce job usually splits the input data-set into independent chunks. (Big data sets in the multiple small datasets)
  • Reduce Task: And the above output will be the input for the reduce tasks, produces the final result. Your business logic would be written in the Mapped Task and Reduced Task. Typically both the input and the output of the job are stored in a file-system (Not database). The framework takes care of scheduling tasks, monitoring them and re-executes the failed tasks.

Q.What is compute and Storage nodes? Ans: Compute Node: This is the computer or machine where your actual business logic will be executed. Storage Node: This is the computer or machine where your file system resides to store the processing data. In most of the cases compute node and storage node would be the same machine. Q.How does master slave architecture in the Hadoop? Ans: the MapReduce framework consists of a single master Job Tracker and multiple slaves, each cluster-node will have one Task Tracker. The master is responsible for scheduling the jobs' component tasks on the slaves, monitoring them and re-executing the failed tasks. The slaves execute the tasks as directed by the master. Q.How does a Hadoop application look like or their basic components? Ans: Minimally a Hadoop application would have following components.

  • Input location of data
  • Output location of processed data.
  • A map task.
  • A reduced task.
  • Job configuration

The Hadoop job client then submits the job (jar/executable etc.) and configuration to the Job Tracker which then assumes the responsibility of distributing the software/configuration to the slaves, scheduling tasks and monitoring them, providing status and diagnostic information to the job-client. Q.Explain how input and output data format of the Hadoop framework? Ans: The MapReduce framework operates exclusively on pairs, that is, the framework views the input to the job as a set of pairs and produces a set of pairs as the output of the job, conceivably of different types. See the flow mentioned below (input) -> map -> -> combine/sorting -> -> reduce -> (output) Q.What are the restriction to the key and value class? Ans: The key and value classes have to be serialized by the framework. To make them serializable Hadoop provides a Writable interface. As you know from the java itself that the key of the Map should be comparable, hence the key has to implement one more interface Writable Comparable. Q.Explain the Word Count implementation via Hadoop framework?  Ans: We will count the words in all the input file flow as below

  • Input

Assume there are two files each having a sentence Hello World Hello World (In file 1) Hello World Hello World (In file 2)

  • Mapper: There would be each mapper for the a file For the given sample input the first map output:

< Hello, 1>

  • World, 1>
  • Hello, 1>
  • World, 1>
  • Hello, 1>
  • World, 1>
  • Hello, 1>
  • World, 1>
  • Combiner/Sorting (This is done for each individual map) So output looks like this

The output of the first map: < Hello, 2> < World, 2> The output of the second map: < Hello, 2> < World, 2>

  • Reducer:
  • Output

It sums up the above output and generates the output as below

  • Hello, 4>
  • World, 4>

Final output would look like Hello 4 times World 4 times Q.Which interface needs to be implemented to create Mapper and Reducer for the Hadoop? Ans: org.apache.hadoop.mapreduce.Mapper org.apache.hadoop.mapreduce.Reducer Q.What Mapper does? Ans: Maps are the individual tasks that transform input records into intermediate records. The transformed intermediate records do not need to be of the same type as the input records. A given input pair may map to zero or many output pairs. Q.What is the Input Split in map reduce software? Ans: An Input Split is a logical representation of a unit (A chunk) of input work for a map task; e.g., a filename and a byte range within that file to process or a row set in a text file. Q.What is the Input Format? Ans: The Input Format is responsible for enumerate (itemize) the Input Split, and producing a Record Reader which will turn those logical work units into actual physical input records. Q.Where do you specify the Mapper Implementation? Ans: Generally mapper implementation is specified in the Job itself. Q.How Mapper is instantiated in a running job? Ans: The Mapper itself is instantiated in the running job, and will be passed a Map Context object which it can use to configure itself Q.Which are the methods in the Mapper interface? Ans: the Mapper contains the run () method, which call its own setup () method only once, it also call a map () method for each input and finally calls it cleanup () method. All above methods you can override in your code. Q.What happens if you don’t override the Mapper methods and keep them as it is? Ans: If you do not override any methods (leaving even map as-is), it will act as the identity function, emitting each input record as a separate output. Q.What is the use of Context object? Ans: The Context object allows the mapper to interact with the rest of the Hadoop system. It Includes configuration data for the job, as well as interfaces which allow it to emit output. Q.How can you add the arbitrary key-value pairs in your mapper? Ans: You can set arbitrary (key, value) pairs of configuration data in your Job, e.g. with Job.getConfiguration ().set ("myKey", "myVal"), and then retrieve this data in your mapper with context.getConfiguration ().get ("myKey"). This kind of functionality is typically done in the Mapper's setup () method. Q.How does Mapper’s run () method works? Ans: The Mapper. Run () method then calls map (KeyInType, ValInType, Context) for each key/value pair in the Input Split for that task Q.Which object can be used to get the progress of a particular job? Ans: Context Q.What is next step after Mapper or MapTask? Ans: The output of the Mapper is sorted and Partitions will be created for the output. Number of partition depends on the number of reducer. Q.How can we control particular key should go in a specific reducer? Ans: Users can control which keys (and hence records) go to which Reducer by implementing a custom Partitioner. Q.What is the use of Combiner? Ans: It is an optional component or class, and can be specify via Job.setCombinerClass (Class Name), to perform local aggregation of the intermediate outputs, which helps to cut down the amount of data transferred from the Mapper to the Reducer. Q.How many maps are there in a particular Job? Ans: the number of maps is usually driven by the total size of the inputs, that is, the total number of blocks of the input files. Generally it is around 10-100 maps per-node. Task setup takes awhile, so it is best if the maps take at least a minute to execute. Suppose, if you expect 10TB of input data and have a block size of 128MB, you'll end up with 82,000 maps, to control the number of block you can use the mapreduce.job.maps parameter (which only provides a hint to the framework). Ultimately, the number of tasks is controlled by the number of splits returned by the InputFormat.getSplits () method (which you can override). Q.What is the Reducer used for? Ans: Reducer reduces a set of intermediate values which share a key to a (usually smaller) set of values. The number of reduces for the job is set by the user via Job.setNumReduceTasks (int). Q.Explain the core methods of the Reducer? Ans: The API of Reducer is very similar to that of Mapper, there's a run() method that receives a Context containing the job's configuration as well as interfacing methods that return data from the reducer itself back to the framework. The run() method calls setup() once, reduce() once for each key associated with the reduce task, and cleanup() once at the end. Each of these methods can access the job's configuration data by using Context.getConfiguration (). As in Mapper, any or all of these methods can be overridden with custom implementations. If none of these methods are overridden, the default reducer operation is the identity function; values are passed through without further processing. The heart of Reducer is it’s reduce () method. This is called once per key; the second argument is an Iterable which returns all the values associated with that key. Q.What are the primary phases of the Reducer? Ans: Shuffle, Sort and Reduce Q.Explain the shuffle? Ans: Input to the Reducer is the sorted output of the mappers. In this phase the framework fetches the relevant partition of the output of all the mappers, via HTTP. Q.Explain the Reducer’s Sort phase? Ans: The framework groups Reducer inputs by keys (since different mappers may have output the same key) in this stage. The shuffle and sort phases occur simultaneously; while map-outputs are being fetched they are merged (It is similar to merge-sort). Q.Explain the Reducer’s reduce phase? Ans: In this phase the reduce (MapOutKeyType, Iterable, Context) method is called for each pair in the grouped inputs. The output of the reduce task is typically written to the File System via Context. write (ReduceOutKeyType, ReduceOutValType). Applications can use the Context to report progress, set application-level status messages and update Counters, or just indicate that they are alive. The output of the Reducer is not sorted. Q.How many Reducers should be configured? Ans: The right number of reduces seems to be 0.95 or 1.75 multiplied by ( * mapreduce.tasktracker.reduce.tasks.maximum). With 0.95 all of the reduces can launch immediately and start transferring map outputs as the maps finish. With 1.75 the faster nodes will finish their first round of reduces and launch a second wave of reduces doing a much better job of load balancing. Increasing the number of reduces increases the framework overhead, but increases load balancing and lowers the cost of failures. Q.It can be possible that a Job has 0 reducers? Ans: It is legal to set the number of reduce-tasks to zero if no reduction is desired. Q.What happens if number of reducers are 0? Ans: In this case the outputs of the map-tasks go directly to the FileSystem, into the output path set by setOutputPath (Path). The framework does not sort the map-outputs before writing them out to the FileSystem. Q.How many instances of Job Tracker can run on a Hadoop Cluster? Ans: Only one Q.What is the Job Tracker and what it performs in a Hadoop Cluster? Ans: Job Tracker is a daemon service which submits and tracks the MapReduce tasks to the Hadoop cluster. It runs its own JVM process. And usually it run on a separate machine and each slave node is configured with job tracker node location. The Job Tracker is single point of failure for the Hadoop MapReduce service. If it goes down, all running jobs are halted. Job Tracker in Hadoop performs following actions Client applications submit jobs to the Job tracker. The Job Tracker talks to the Name Node to determine the location of the data The Job Tracker locates Task Tracker nodes with available slots at or near the data TheJob Tracker submits the work to the chosen Task Tracker nodes. The Task Tracker nodes are monitored. If they do not submit heartbeat signals often enough, they are deemed to have failed and the work is scheduled on a different Task Tracker. A Task Tracker will notify the Job Tracker when a task fails. The Job Tracker decides what to do then: it may resubmit the job elsewhere, it may mark that specific record as something to avoid, and it may even blacklist the Task Tracker as unreliable. When the work is completed, the Job Tracker updates its status. Client applications can poll the Job Tracker for information. Q.How a task is scheduled by a Job Tracker? Ans: The Task Trackers send out heartbeat messages to the Job Tracker, usually every few minutes, to reassure the Job Tracker that it is still alive. These messages also inform the Job Tracker of the number of available slots, so the Job Tracker can stay up to date with where in the cluster work can be delegated. When the Job Tracker tries to find somewhere to schedule a task within the MapReduce operations, it first looks for an empty slot on the same server that hosts the Data Node containing the data, and if not, it looks for an empty slot on a machine in the same rack. Q.How many instances of Task tracker run on a Hadoop cluster? Ans: There is one Daemon Task tracker process for each slave node in the Hadoop cluster. Q.What are the two main parts of the Hadoop framework? Ans: Hadoop consists of two main parts

  • Hadoop distributed file system, a distributed file system with high throughput,
  • Hadoop MapReduce, a software framework for processing large data sets.

Q.Explain the use of Task Tracker in the Hadoop cluster? Ans: A Task tracker is a slave node in the cluster which that accepts the tasks from Job Tracker like Map, Reduce or shuffle operation. Task tracker also runs in its own JVM Process. Every Task Tracker is configured with a set of slots; these indicate the number of tasks that it can accept. The Task Tracker starts a separate JVM processes to do the actual work (called as Task Instance) this is to ensure that process failure does not take down the task tracker. The Task tracker monitors these task instances, capturing the output and exit codes. When the Task instances finish, successfully or not, the task tracker notifies the Job Tracker. The Task Trackers also send out heartbeat messages to the Job Tracker, usually every few minutes, to reassure the Job Tracker that it is still alive. These messages also inform the Job Tracker of the number of available slots, so the Job Tracker can stay up to date with where in the cluster work can be delegated. Q.What do you mean by Task Instance? Ans: Task instances are the actual MapReduce jobs which run on each slave node. The Task Tracker starts a separate JVM processes to do the actual work (called as Task Instance) this is to ensure that process failure does not take down the entire task tracker. Each Task Instance runs on its own JVM process. There can be multiple processes of task instance running on a slave node. This is based on the number of slots configured on task tracker. By default a new task instance JVM process is spawned for a task. Q.How many daemon processes run on a Hadoop cluster? Ans: Hadoop is comprised of five separate daemons. Each of these daemons runs in its own JVM. Following 3 Daemons run on Master Nodes.NameNode - This daemon stores and maintains the metadata for HDFS. Secondary Name Node - Performs housekeeping functions for the Name Node. Job Tracker - Manages MapReduce jobs, distributes individual tasks to machines running the Task Tracker. Following 2 Daemons run on each Slave nodes Data Node – Stores actual HDFS data blocks. Task Tracker – It is Responsible for instantiating and monitoring individual Map and Reduce tasks. Q.How many maximum JVM can run on a slave node? Ans: One or Multiple instances of Task Instance can run on each slave node. Each task instance is run as a separate JVM process. The number of Task instances can be controlled by configuration. Typically a high end machine is configured to run more task instances. Q.What is NAS? Ans: It is one kind of file system where data can reside on one centralized machine and all the cluster member will read write data from that shared database, which would not be as efficient as HDFS. Q.How HDFA differs with NFS? Ans: Following are differences between HDFS and NAS

  1. In HDFS Data Blocks are distributed across local drives of all machines in a cluster. Whereas in NAS data is stored on dedicated hardware.
  2. HDFS is designed to work with MapReduce System, since computation is moved to data. NAS is not suitable for MapReduce since data is stored separately from the computations
  3. HDFS runs on a cluster of machines and provides redundancy using replication protocol. Whereas NAS is provided by a single machine therefore does not provide data redundancy.

Q.How does a Name Node handle the failure of the data nodes? Ans: HDFS has master/slave architecture. An HDFS cluster consists of a single Name Node, a master server that manages the file system namespace and regulates access to files by clients. In addition, there are a number of DataNodes, usually one per node in the cluster, which manage storage attached to the nodes that they run on. The Name Node and Data Node are pieces of software designed to run on commodity machines. Name Node periodically receives a Heartbeat and a Block report from each of the DataNodes in the cluster. Receipt of a Heartbeat implies that the Data Node is functioning properly. A Block report contains a list of all blocks on a Data Node. When Name Node notices that it has not received a heartbeat message from a data node after a certain amount of time, the data node is marked as dead. Since blocks will be under replicated the system begins replicating the blocks that were stored on the dead Data Node. The Name Node orchestrates the replication of data blocks from one Data Node to another. The replication data transfer happens directly between Data Node and the data never passes through the Name Node. Q.Can Reducer talk with each other? Ans: No, Reducer runs in isolation. Q.Where the Mapper’s Intermediate data will be stored? Ans: The mapper output (intermediate data) is stored on the Local file system (NOT HDFS) of each individual mapper nodes. This is typically a temporary directory location which can be setup in config by the Hadoop administrator. The intermediate data is cleaned up after the Hadoop Job completes. Q.What is the use of Combiners in the Hadoop framework? Ans: Combiners are used to increase the efficiency of a MapReduce program. They are used to aggregate intermediate map output locally on individual mapper outputs. Combiners can help you reduce the amount of data that needs to be transferred across to the reducers. You can use your reducer code as a combiner if the operation performed is commutative and associative. The execution of combiner is not guaranteed; Hadoop may or may not execute a combiner. Also, if required it may execute it more than 1 times. Therefore your MapReduce jobs should not depend on the combiners’ execution. Q.What is the Hadoop MapReduce API contract for a key and value Class? Ans: ◦The Key must implement the org.apache.hadoop.io.WritableComparable interface. ◦The value must implement the org.apache.hadoop.io.Writable interface. Q.What is Identity Mapper and Identity Reducer in MapReduce? Ans: ◦ org.apache.hadoop.mapred.lib.IdentityMapper: Implements the identity function, mapping inputs directly to outputs. If MapReduce programmer does not set the Mapper Class using JobConf.setMapperClass then IdentityMapper.class is used as a default value. ◦org.apache.hadoop.mapred.lib.IdentityReducer: Performs no reduction, writing all input values directly to the output. If MapReduce programmer does not set the Reducer Class using JobConf.setReducerClass then IdentityReducer.class is used as a default value. Q.What is the meaning of speculative execution in Hadoop? Why is it important? Ans: Speculative execution is a way of coping with individual Machine performance. In large clusters where hundreds or thousands of machines are involved there may be machines which are not performing as fast as others. This may result in delays in a full job due to only one machine not performing well. To avoid this, speculative execution in Hadoop can run multiple copies of same map or reduce task on different slave nodes. The results from first node to finish are used Q.When the reducers are started in a MapReduce job? Ans: In a MapReduce job reducers do not start executing the reduce method until the all Map jobs have completed. Reducers start copying intermediate key-value pairs from the mappers as soon as they are available. The programmer defined reduce method is called only after all the mappers have finished. If reducers do not start before all mappers finish then why does the progress on MapReduce job shows something like Map (50%) Reduce (10%)? Why reducer’s progress percentage is displayed when mapper is not finished yet? Reducers start copying intermediate key-value pairs from the mappers as soon as they are available. The progress calculation also takes in account the processing of data transfer which is done by reduce process, therefore the reduce progress starts showing up as soon as any intermediate key-value pair for a mapper is available to be transferred to reducer. Though the reducer progress is updated still the programmer defined reduce method is called only after all the mappers have finished. Q.What is HDFS? How it is different from traditional file systems? Ans: HDFS, the Hadoop Distributed File System, is responsible for storing huge data on the cluster. This is a distributed file system designed to run on commodity hardware. It has many similarities with existing distributed file systems. However, the differences from other distributed file systems are significant. ◦HDFS is highly fault-tolerant and is designed to be deployed on low-cost hardware. ◦HDFS provides high throughput access to application data and is suitable for applications that have large data sets. ◦HDFS is designed to support very large files. Applications that are compatible with HDFS are those that deal with large data sets. These applications write their data only once but they read it one or more times and require these reads to be satisfied at streaming speeds. HDFS supports write-once-read-many semantics on files. Q.What is HDFS Block size? How is it different from traditional file system block size? Ans: In HDFS data is split into blocks and distributed across multiple nodes in the cluster. Each block is typically 64Mb or 128Mb in size. Each block is replicated multiple times. Default is to replicate each block three times. Replicas are stored on different nodes. HDFS utilizes the local file system to store each HDFS block as a separate file. HDFS Block size cannot be compared with the traditional file system block size. Q.What is a Name Node? How many instances of Name Node run on a Hadoop Cluster? Ans: The Name Node is the centerpiece of an HDFS file system. It keeps the directory tree of all files in the file system, and tracks where across the cluster the file data is kept. It does not store the data of these files itself. There is only One Name Node process run on any Hadoop cluster. Name Node runs on its own JVM process. In a typical production cluster its run on a separate machine. The Name Node is a Single Point of Failure for the HDFS Cluster. When the Name Node goes down, the file system goes offline. Client applications talk to the Name Node whenever they wish to locate a file, or when they want to add/copy/move/delete a file. The Name Node responds the successful requests by returning a list of relevant Data Node servers where the data lives. Q.What is a Data Node? How many instances of Data Node run on a Hadoop Cluster? Ans: A Data Node stores data in the Hadoop File System HDFS. There is only One Data Node process run on any Hadoop slave node. Data Node runs on its own JVM process. On startup, a Data Node connects to the Name Node. Data Node instances can talk to each other, this is mostly during replicating data. Q.How the Client communicates with HDFS? Ans: The Client communication to HDFS happens to be using Hadoop HDFS API. Client applications talk to the Name Node whenever they wish to locate a file, or when they want to add/copy/move/delete a file on HDFS. The Name Node responds the successful requests by returning a list of relevant Data Node servers where the data lives. Client applications can talk directly to a Data Node, once the Name Node has provided the location of the data. Q.How the HDFS Blocks are replicated? Ans: HDFS is designed to reliably store very large files across machines in a large cluster. It stores each file as a sequence of blocks; all blocks in a file except the last block are the same size. The blocks of a file are replicated for fault tolerance. The block size and replication factor are configurable per file. An application can specify the number of replicas of a file. The replication factor can be specified at file creation time and can be changed later. Files in HDFS are writing-once and have strictly one writer at any time. The Name Node makes all decisions regarding replication of blocks. HDFS uses rack-aware replica placement policy. In default configurations there are total 3 copies of a data block on HDFS, 2 copies are stored on DataNodes on same rack and 3rd copy on a different rack. Hadoop Interview Questions                 Hadoop Interview Question and Answers Hyperion MapReduce Interview Questions Q.What is MapReduce? Ans: It is a framework or a programming model that is used for processing large data sets over clusters of computers using distributed programming. Q.What are ‘maps’ and ‘reduces’? Ans:Maps‘ and ‘Reduces‘ are two phases of solving a query in HDFS. ‘Map’ is responsible to read data from input location, and based on the input type, it will generate a key value pair, that is, an intermediate output in local machine. ’Reducer’ is responsible to process the intermediate output received from the mapper and generate the final output. Q.What are the four basic parameters of a mapper? Ans: The four basic parameters of a mapper are LongWritable, text, text and IntWritable. The first two represent input parameters and the second two represent intermediate output parameters. Q.What are the four basic parameters of a reducer? Ans: The four basic parameters of a reducer are text, IntWritable, text, IntWritable. The first two represent intermediate output parameters and the second two represent final output parameters. Q.What do the master class and the output class do? Ans: Master is defined to update the Master or the job tracker and the output class is defined to write data onto the output location. Q.What is the input type/format in MapReduce by default? Ans: By default the type input type in MapReduce is ‘text’. Q.Is it mandatory to set input and output type/format in MapReduce? Ans: No, it is not mandatory to set the input and output type/format in MapReduce. By default, the cluster takes the input and the output type as ‘text’. Q.What does the text input format do? Ans: In text input format, each line will create a line object, that is an hexa-decimal number. Key is considered as a line object and value is considered as a whole line text. This is how the data gets processed by a mapper. The mapper will receive the ‘key’ as a ‘LongWritable‘ parameter and value as a ‘text‘ parameter. Q.What does job conf class do? Ans: MapReduce needs to logically separate different jobs running on the same cluster. ‘Job conf class‘  helps to do job level settings such as declaring a job in real environment.  It is recommended that Job name should be descriptive and represent the type of job that is being executed. Q.What does conf.setMapper Class do? Ans: Conf.setMapper class sets the mapper class and all the stuff related to map job such as reading a data and generating a key-value pair out of the mapper. Q.What do sorting and shuffling do? Ans: Sorting and shuffling are responsible for creating a unique key and a list of values. Making similar keys at one location is known as Sorting. And the process by which the intermediate output of the mapper is sorted and sent across to the reducers is known as Shuffling. Q.What does a split do? Ans: Before transferring the data from hard disk location to map method, there is a phase or method called  the ‘Split Method‘. Split method pulls a block of data from HDFS to the framework. The Split class does not write anything, but reads data from the block and pass it to the mapper. Be default, Split is taken care by the framework. Split method is equal to the block size and is used to divide block into bunch of splits. Q.How can we change the split size if our commodity hardware has less storage space? Ans: If our commodity hardware has less storage space, we can change the split size by writing the ‘custom splitter‘. There is a feature of customization in Hadoop which can be called from the main method. Q.What does a MapReduce partitioner do? Ans: A MapReduce partitioner makes sure that all the value of a single key goes to the same reducer, thus allows evenly distribution of the map output over the reducers. It redirects the mapper output to the reducer by determining which reducer is responsible for a particular key. Q.How is Hadoop different from other data processing tools? Ans: In Hadoop, based upon your requirements, you can increase or decrease the number of mappers without bothering about the volume of data to be processed. this is the beauty of parallel processing in contrast to the other data processing tools available. Q.Can we rename the output file? Ans: Yes we can rename the output file by implementing multiple format output class. Q.Why we cannot do aggregation (addition) in a mapper? Why we require reducer for that? Ans: We cannot do aggregation (addition) in a mapper because, sorting is not done in a mapper. Sorting happens only on the reducer side. Mapper method initialization depends upon each input split. While doing aggregation, we will lose the value of the previous instance. For each row, a new mapper will get initialized. For each row, input split again gets divided into mapper,  thus we do not have a track of the previous row value. Q.What is Streaming? Ans: Streaming is a feature with Hadoop framework that allows us to do programming using MapReduce in any programming language which can accept standard input and can produce standard output. It could be Perl, Python, Ruby and not necessarily be Java. However, customization in MapReduce can only be done using Java and not any other programming language. Q.What is a Combiner? Ans: A ‘Combiner’ is a mini reducer that performs the local reduce task. It receives the input from the mapper on a particular node and sends the output to the reducer. Combiners help in enhancing the efficiency of MapReduce by reducing the quantum of data that is required to be sent to the reducers. Q.What is the difference between an HDFS Block and Input Split? Ans: HDFS Block is the physical division of the data and Input Split is the logical division of the data. Q.What happens in a textinputformat? Ans: In textinputformat, each line in the text file is a record. Key is the byte offset of the line and value is the content of the line. For instance, Key: longWritable, value: text. Q.What do you know about keyvaluetextinputformat? Ans: In keyvaluetextinputformat, each line in the text file is a ‘record‘. The first separator character divides each line. Everything before the separator is the key and everything after the separator is the value. For instance, Key: text, value: text. Q.What do you know about Sequencefileinputformat? Ans: Sequencefileinputformat is an input format for reading in sequence files. Key and value are user defined. It is a specific compressed binary file format which is optimized for passing the data between the output of one MapReduce job to the input of some other MapReduce job. Q.What do you know about Nlineoutputformat? Ans: Nlineoutputformat splits ‘n’ lines of input as one split. Hadoop Hive Interview Questions and Answers Q.What is a Hive Metastore? Ans: Hive Metastore is a central repository that stores metadata in external database. Q.Are multiline comments supported in Hive? Ans: No Q.What is ObjectInspector functionality? Ans: ObjectInspector is used to analyze the structure of individual columns and the internal structure of the row objects. ObjectInspector in Hive provides access to complex objects which can be stored in multiple formats. Q.Explain about the different types of join in Hive. Ans: HiveQL has 4 different types of joins – JOIN­ Similar to Outer Join in SQL FULL OUTER JOIN – Combines the records of both the left and right outer tables that fulfil the join condition. LEFT OUTER JOIN­ All the rows from the left table are returned even if there are no matches in the right table. RIGHT OUTER JOIN­All the rows from the right table are returned even if there are no matches in the left table. Q.How can you configure remote metastore mode in Hive? Ans: To configure metastore in Hive, hive­site.xml file has to be configured with the below property – hive.metastore.uris thrift: //node1 (or IP Address):9083 IP address and port of the metastore host Q.Explain about the SMB Join in Hive. Ans: In SMB join in Hive, each mapper reads a bucket from the first table and the corresponding bucket from the second table and then a merge sort join is performed. Sort Merge Bucket (SMB) join in hive is mainly used as there is no limit on file or partition or table join. SMB join can best be used when the tables are large. In SMB join the columns are bucketed and sorted using the join columns. All tables should have the same number of buckets in SMB join. Q.Is it possible to change the default location of Managed Tables in Hive, if so how? Ans: Yes, we can change the default location of Managed tables using the LOCATION keyword while creating the managed table. The user has to specify the storage path of the managed table as the value to the LOCATION keyword. Q.How data transfer happens from HDFS to Hive? Ans: If data is already present in HDFS then the user need not LOAD DATA that moves the files to the /user/hive/warehouse/. So the user just has to define the table using the keyword external that creates the table definition in the hive metastore. Create external table table_name ( id int, myfields string ) location '/my/location/in/hdfs'; Q.How can you connect an application, if you run Hive as a server? Ans: When running Hive as a server, the application can be connected in one of the 3 ways­ ODBC Driver­This supports the ODBC protocol JDBC Driver­ This supports the JDBC protocol Thrift Client­ This client can be used to make calls to all hive commands using different programming language like PHP, Python, Java, C++ and Ruby. Q.What does the overwrite keyword denote in Hive load statement? Ans: Overwrite keyword in Hive load statement deletes the contents of the target table and replaces them with the files referred by the file path i.e. the files that are referred by the file path will be added to the table when using the overwrite keyword. Q.What is SerDe in Hive? How can you write your own custom SerDe? Ans: SerDe is a Serializer DeSerializer. Hive uses SerDe to read and write data from tables. Generally, users prefer to write a Deserializer instead of a SerDe as they want to read their own data format rather than writing to it. If the SerDe supports DDL i.e. basically SerDe with parameterized columns and different column types, the users can implement a Protocol based DynamicSerDe rather than writing the SerDe from scratch. Q.In case of embedded Hive, can the same metastore be used by multiple users? Ans: We cannot use metastore in sharing mode. It is suggested to use standalone real database like PostGreSQL and MySQL. Hadoop Pig Interview Questions and Answers Q.What do you mean by a bag in Pig? Ans: Collection of tuples is referred as a bag in Apache Pig Q.Does Pig support multi­line commands? Ans: Yes Q.What are different modes of execution in Apache Pig? Ans: Apache Pig runs in 2 modes­ one is the “Pig (Local Mode) Command Mode” and the other is the “Hadoop MapReduce (Java) Command Mode”. Local Mode requires access to only a single machine where all files are installed and executed on a local host whereas MapReduce requires accessing the Hadoop cluster. Q.Explain the need for MapReduce while programming in Apache Pig. Ans: Apache Pig programs are written in a query language known as Pig Latin that is similar to the SQL query language. To execute the query, there is need for an execution engine. The Pig engine converts the queries into MapReduce jobs and thus MapReduce acts as the execution engine and is needed to run the programs. Q.Explain about co­group in Pig. Ans: COGROUP operator in Pig is used to work with multiple tuples. COGROUP operator is applied on statements that contain or involve two or more relations. The COGROUP operator can be applied on up to 127 relations at a time. When using the COGROUP operator on two tables at once­Pig first groups both the tables and after that joins the two tables on the grouped columns. Q.Explain about the BloomMapFile. Ans: BloomMapFile is a class that extends the MapFile class. It is used n HBase table format to provide quick membership test for the keys using dynamic bloom filters. Q.Differentiate between Hadoop MapReduce and Pig Ans: Pig provides higher level of abstraction whereas MapReduce provides low level of abstraction. MapReduce requires the developers to write more lines of code when compared to Apache Pig. Pig coding approach is comparatively slower than the fully tuned MapReduce coding approach. Q.What is the usage of foreach operation in Pig scripts? Ans: FOREACH operation in Apache Pig is used to apply transformation to each element in the data bag so that respective action is performed to generate new data items. Syntax­ FOREACH data_bagname GENERATE exp1, exp2 Q.Explain about the different complex data types in Pig. Ans: Apache Pig supports 3 complex data types­ Maps­ These are key, value stores joined together using #. Tuples­ Just similar to the row in a table where different items are separated by a comma. Tuples can have multiple attributes. Bags­ Unordered collection of tuples. Bag allows multiple duplicate tuples. Q.What does Flatten do in Pig? Ans: Sometimes there is data in a tuple or bag and if we want to remove the level of nesting from that data then Flatten modifier in Pig can be used. Flatten un­nests bags and tuples. For tuples, the Flatten operator will substitute the fields of a tuple in place of a tuple whereas un­nesting bags is a little complex because it requires creating new tuples. Hadoop Zookeeper Interview Questions and Answers Q.Can Apache Kafka be used without Zookeeper? Ans: It is not possible to use Apache Kafka without Zookeeper because if the Zookeeper is down Kafka cannot serve client request. Q.Name a few companies that use Zookeeper. Ans: Yahoo, Solr, Helprace, Neo4j, Rackspace Q.What is the role of Zookeeper in HBase architecture? Ans: In HBase architecture, ZooKeeper is the monitoring server that provides different services like –tracking server failure and network partitions, maintaining the configuration information, establishing communication between the clients and region servers, usability of ephemeral nodes to identify the available servers in the cluster. Q.Explain about ZooKeeper in Kafka Ans: Apache Kafka uses ZooKeeper to be a highly distributed and scalable system. Zookeeper is used by Kafka to store various configurations and use them across the hadoop cluster in a distributed manner. To achieve distributed­ness, configurations are distributed and replicated throughout the leader and follower nodes in the ZooKeeper ensemble. We cannot directly connect to Kafka by bye­ passing ZooKeeper because if the ZooKeeper is down it will not be able to serve the client request. Q.Explain how Zookeeper works ZooKeeper is referred to as the King of Coordination and distributed applications use ZooKeeper to store and facilitate important configuration information updates. ZooKeeper works by coordinating the processes of distributed applications. ZooKeeper is a robust replicated synchronization service with eventual consistency. A set of nodes is known as an ensemble and persisted data is distributed between multiple nodes. 3 or more independent servers collectively form a ZooKeeper cluster and elect a master. One client connects to any of the specific server and migrates if a particular node fails. The ensemble of ZooKeeper nodes is alive till the majority of nods are working. The master node in ZooKeeper is dynamically selected by the consensus within the ensemble so if the master node fails then the role of master node will migrate to another node which is selected dynamically. Writes are linear and reads are concurrent in ZooKeeper. Q.List some examples of Zookeeper use cases. Ans: Found by Elastic uses Zookeeper comprehensively for resource allocation, leader election, high priority notifications and discovery. The entire service of Found built up of various systems that read and write to Zookeeper. Apache Kafka that depends on ZooKeeper is used by LinkedIn Storm that relies on ZooKeeper is used by popular companies like Groupon and Twitter. Q.How to use Apache Zookeeper command line interface? Ans: ZooKeeper has a command line client support for interactive use. The command line interface of ZooKeeper is similar to the file and shell system of UNIX. Data in ZooKeeper is stored in a hierarchy of Znodes where each znode can contain data just similar to a file. Each znode can also have children just like directories in the UNIX file system. Zookeeper­client command is used to launch the command line client. If the initial prompt is hidden by the log messages after entering the command, users can just hit ENTER to view the prompt. Q.What are the different types of Znodes? Ans: There are 2 types of Znodes namely­ Ephemeral and Sequential Znodes. The Znodes that get destroyed as soon as the client that created it disconnects are referred to as Ephemeral Znodes. Sequential Znode is the one in which sequential number is chosen by the ZooKeeper ensemble and is pre­fixed when the client assigns name to the znode. Q.What are watches? Ans: Client disconnection might be troublesome problem especially when we need to keep a track on the state of Znodes at regular intervals. ZooKeeper has an event system referred to as watch which can be set on Znode to trigger an event whenever it is removed, altered or any new children are created below it. Q.What problems can be addressed by using Zookeeper? Ans: In the development of distributed systems, creating own protocols for coordinating the hadoop cluster results in failure and frustration for the developers. The architecture of a distributed system can be prone to deadlocks, inconsistency and race conditions. This leads to various difficulties in making the hadoop cluster fast, reliable and scalable. To address all such problems, Apache ZooKeeper can be used as a coordination service to write correct distributed applications without having to reinvent the wheel from the beginning. Hadoop Flume Interview Questions and Answers Q.Explain about the core components of Flume. Ans: The core components of Flume are – Event- The single log entry or unit of data that is transported. Source- This is the component through which data enters Flume workflows. Sink-It is responsible for transporting data to the desired destination. Channel- it is the duct between the Sink and Source. Agent- Any JVM that runs Flume. Client- The component that transmits event to the source that operates with the agent. Q.Does Flume provide 100% reliability to the data flow? Ans: Yes, Apache Flume provides end to end reliability because of its transactional approach in data flow. Q.How can Flume be used with HBase? Ans: Apache Flume can be used with HBase using one of the two HBase sinks –

  • HBaseSink (org.apache.flume.sink.hbase.HBaseSink) supports secure HBase clusters and also the novel HBase IPC that was introduced in the version HBase 0.96.
  • AsyncHBaseSink (org.apache.flume.sink.hbase.AsyncHBaseSink) has better performance than HBase sink as it can easily make non-blocking calls to HBase.

Working of the HBaseSink – In HBaseSink, a Flume Event is converted into HBase Increments or Puts. Serializer implements the HBaseEventSerializer which is then instantiated when the sink starts. For every event, sink calls the initialize method in the serializer which then translates the Flume Event into HBase increments and puts to be sent to HBase cluster. Working of the AsyncHBaseSink- AsyncHBaseSink implements the AsyncHBaseEventSerializer. The initialize method is called only once by the sink when it starts. Sink invokes the setEvent method and then makes calls to the getIncrements and getActions methods just similar to HBase sink. When the sink stops, the cleanUp method is called by the serializer. Q.Explain about the different channel types in Flume. Which channel type is faster? Ans: The 3 different built in channel types available in Flume are- MEMORY Channel – Events are read from the source into memory and passed to the sink. JDBC Channel – JDBC Channel stores the events in an embedded Derby database. FILE Channel –File Channel writes the contents to a file on the file system after reading the event from a source. The file is deleted only  after the contents are successfully delivered to the sink. MEMORY Channel is the fastest channel among the three however has the risk of data loss. The channel that you choose completely depends on the nature of the big data application and the value of each event. Q.Which is the reliable channel in Flume to ensure that there is no data loss? Ans: FILE Channel is the most reliable channel among the 3 channels JDBC, FILE and MEMORY. Q.Explain about the replication and multiplexing selectors in Flume. Ans: Channel Selectors are used to handle multiple channels. Based on the Flume header value, an event can be written just to a single channel or to multiple channels. If a channel selector is not specified to the source then by default it is the Replicating selector. Using the replicating selector, the same event is written to all the channels in the source’s channels list. Multiplexing channel selector is used when the application has to send different events to different channels. Q.How multi-hop agent can be setup in Flume? Ans: Avro RPC Bridge mechanism is used to setup Multi-hop agent in Apache Flume. Q.Does Apache Flume provide support for third party plug-ins? Ans: Most of the data analysts use Apache Flume has plug-in based architecture as it can load data from external sources and transfer it to external destinations. Q.Is it possible to leverage real time analysis on the big data collected by Flume directly? If yes, then explain how. Ans: Data from Flume can be extracted, transformed and loaded in real-time into Apache Solr servers usingMorphlineSolrSink Q.Differentiate between FileSink and FileRollSink Ans: The major difference between HDFS FileSink and FileRollSink is that HDFS File Sink writes the events into the Hadoop Distributed File System (HDFS) whereas File Roll Sink stores the events into the local file system. Hadoop Sqoop Interview Questions and Answers Q.Explain about some important Sqoop commands other than import and export. Ans: Create Job (--create) Here we are creating a job with the name my job, which can import the table data from RDBMS table to HDFS. The following command is used to create a job that is importing data from the employee table in the db database to the HDFS file. $ Sqoop job --create myjob \ --import \ --connect jdbc:mysql://localhost/db \ --username root \ --table employee --m 1 Verify Job (--list) ‘--list’ argument is used to verify the saved jobs. The following command is used to verify the list of saved Sqoop jobs. $ Sqoop job --list Inspect Job (--show) ‘--show’ argument is used to inspect or verify particular jobs and their details. The following command and sample output is used to verify a job called myjob. $ Sqoop job --show myjob Execute Job (--exec) ‘--exec’ option is used to execute a saved job. The following command is used to execute a saved job called myjob. $ Sqoop job --exec myjob Q.How Sqoop can be used in a Java program? Ans: The Sqoop jar in classpath should be included in the java code. After this the method Sqoop.runTool () method must be invoked. The necessary parameters should be created to Sqoop programmatically just like for command line. Q.What is the process to perform an incremental data load in Sqoop? Ans: The process to perform incremental data load in Sqoop is to synchronize the modified or updated data (often referred as delta data) from RDBMS to Hadoop. The delta data can be facilitated through the incremental load command in Sqoop. Incremental load can be performed by using Sqoop import command or by loading the data into hive without overwriting it. The different attributes that need to be specified during incremental load in Sqoop are- 1)Mode (incremental) –The mode defines how Sqoop will determine what the new rows are. The mode can have value as Append or Last Modified. 2)Col (Check-column) –This attribute specifies the column that should be examined to find out the rows to be imported. 3)Value (last-value) –This denotes the maximum value of the check column from the previous import operation. Q.Is it possible to do an incremental import using Sqoop? Ans: Yes, Sqoop supports two types of incremental imports- 1)Append 2)Last Modified To insert only rows Append should be used in import command and for inserting the rows and also updating Last-Modified should be used in the import command. Q.What is the standard location or path for Hadoop Sqoop scripts? /usr/bin/Hadoop Sqoop Q.How can you check all the tables present in a single database using Sqoop? Ans: The command to check the list of all tables present in a single database using Sqoop is as follows- Sqoop list-tables –connect jdbc: mysql: //localhost/user; Q.How are large objects handled in Sqoop? Ans: Sqoop provides the capability to store large sized data into a single field based on the type of data. Sqoop supports the ability to store- 1)CLOB ‘s – Character Large Objects 2)BLOB’s –Binary Large Objects Large objects in Sqoop are handled by importing the large objects into a file referred as “LobFile” i.e. Large Object File. The LobFile has the ability to store records of huge size, thus each record in the LobFile is a large object. Q.Can free form SQL queries be used with Sqoop import command? If yes, then how can they be used? Ans: Sqoop allows us to use free form SQL queries with the import command. The import command should be used with the –e and – query options to execute free form SQL queries. When using the –e and –query options with the import command the –target dir value must be specified. Q.Differentiate between Sqoop and distCP. Ans: DistCP utility can be used to transfer data between clusters whereas Sqoop can be used to transfer data only between Hadoop and RDBMS. Q.What are the limitations of importing RDBMS tables into Hcatalog directly? Ans: There is an option to import RDBMS tables into Hcatalog directly by making use of –hcatalog –database option with the –hcatalog –table but the limitation to it is that there are several arguments like –as-avrofile , -direct, -as-sequencefile, -target-dir , -export-dir are not supported. Hadoop HBase Interview Questions and Answers Q.When should you use HBase and what are the key components of HBase? Ans: HBase should be used when the big data application has – 1)A variable schema 2)When data is stored in the form of collections 3)If the application demands key based access to data while retrieving. Key components of HBase are – Region- This component contains memory data store and Hfile. Region Server-This monitors the Region. HBase Master-It is responsible for monitoring the region server. Zookeeper- It takes care of the coordination between the HBase Master component and the client. Catalog Tables-The two important catalog tables are ROOT and META.ROOT table tracks where the META table is and META table stores all the regions in the system. Q.What are the different operational commands in HBase at record level and table level? Ans: Record Level Operational Commands in HBase are –put, get, increment, scan and delete. Table Level Operational Commands in HBase are-describe, list, drop, disable and scan. Q.What is Row Key? Ans: Every row in an HBase table has a unique identifier known as RowKey. It is used for grouping cells logically and it ensures that all cells that have the same RowKeys are co-located on the same server. RowKey is internally regarded as a byte array. Q.Explain the difference between RDBMS data model and HBase data model. Ans: RDBMS is a schema based database whereas HBase is schema less data model. RDBMS does not have support for in-built partitioning whereas in HBase there is automated partitioning. RDBMS stores normalized data whereas HBase stores de-normalized data. Q.Explain about the different catalog tables in HBase? Ans: The two important catalog tables in HBase, are ROOT and META. ROOT table tracks where the META table is and META table stores all the regions in the system. Q.What is column families? What happens if you alter the block size of ColumnFamily on an already populated database? Ans: The logical deviation of data is represented through a key known as column Family. Column families consist of the basic unit of physical storage on which compression features can be applied. In an already populated database, when the block size of column family is altered, the old data will remain within the old block size whereas the new data that comes in will take the new block size. When compaction takes place, the old data will take the new block size so that the existing data is read correctly. Q.Explain the difference between HBase and Hive. Ans: HBase and Hive both are completely different hadoop based technologies-Hive is a data warehouse infrastructure on top of Hadoop whereas HBase is a NoSQL key value store that runs on top of Hadoop. Hive helps SQL savvy people to run MapReduce jobs whereas HBase supports 4 primary operations-put, get, scan and delete. HBase is ideal for real time querying of big data where Hive is an ideal choice for analytical querying of data collected over period of time. Q.Explain the process of row deletion in HBase. Ans: On issuing a delete command in HBase through the HBase client, data is not actually deleted from the cells but rather the cells are made invisible by setting a tombstone marker. The deleted cells are removed at regular intervals during compaction. Q.What are the different types of tombstone markers in HBase for deletion? Ans: There are 3 different types of tombstone markers in HBase for deletion- 1)Family Delete Marker- This markers marks all columns for a column family. 2)Version Delete Marker-This marker marks a single version of a column. 3)Column Delete Marker-This markers marks all the versions of a column. Q.Explain about HLog and WAL in HBase. Ans: All edits in the HStore are stored in the HLog. Every region server has one HLog. HLog contains entries for edits of all regions performed by a particular Region Server.WAL abbreviates to Write Ahead Log (WAL) in which all the HLog edits are written immediately.WAL edits remain in the memory till the flush period in case of deferred log flush. contact for more on Hadoop Online Training hadoop interview questions