Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

out of Memory Error in Hadoop

Tags:

java

hadoop

I tried installing Hadoop following this http://hadoop.apache.org/common/docs/stable/single_node_setup.html document. When I tried executing this

bin/hadoop jar hadoop-examples-*.jar grep input output 'dfs[a-z.]+'  

I am getting the following Exception

java.lang.OutOfMemoryError: Java heap space 

Please suggest a solution so that i can try out the example. The entire Exception is listed below. I am new to Hadoop I might have done something dumb . Any suggestion will be highly appreciated.

anuj@anuj-VPCEA13EN:~/hadoop$ bin/hadoop jar hadoop-examples-*.jar grep input output 'dfs[a-z.]+' 11/12/11 17:38:22 INFO util.NativeCodeLoader: Loaded the native-hadoop library 11/12/11 17:38:22 INFO mapred.FileInputFormat: Total input paths to process : 7 11/12/11 17:38:22 INFO mapred.JobClient: Running job: job_local_0001 11/12/11 17:38:22 INFO util.ProcessTree: setsid exited with exit code 0 11/12/11 17:38:22 INFO mapred.Task:  Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@e49dcd 11/12/11 17:38:22 INFO mapred.MapTask: numReduceTasks: 1 11/12/11 17:38:22 INFO mapred.MapTask: io.sort.mb = 100 11/12/11 17:38:22 WARN mapred.LocalJobRunner: job_local_0001 java.lang.OutOfMemoryError: Java heap space     at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.<init>(MapTask.java:949)     at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:428)     at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)     at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:212) 11/12/11 17:38:23 INFO mapred.JobClient:  map 0% reduce 0% 11/12/11 17:38:23 INFO mapred.JobClient: Job complete: job_local_0001 11/12/11 17:38:23 INFO mapred.JobClient: Counters: 0 11/12/11 17:38:23 INFO mapred.JobClient: Job Failed: NA java.io.IOException: Job failed!     at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1257)     at org.apache.hadoop.examples.Grep.run(Grep.java:69)     at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)     at org.apache.hadoop.examples.Grep.main(Grep.java:93)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)     at java.lang.reflect.Method.invoke(Method.java:597)     at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:68)     at org.apache.hadoop.util.ProgramDriver.driver(ProgramDriver.java:139)     at org.apache.hadoop.examples.ExampleDriver.main(ExampleDriver.java:64)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)     at java.lang.reflect.Method.invoke(Method.java:597)     at org.apache.hadoop.util.RunJar.main(RunJar.java:156) 
like image 953
Anuj Avatar asked Dec 11 '11 12:12

Anuj


People also ask

How do I resolve out of memory error in hive?

Increase the maximum memory allocation for the JVM If your process attempts to use more than the maximum value, Hive kills the process and throws the OutOfMemoryError exception. To resolve this issue, increase the -Xmx value in the Hive shell script (in MB), and then run your Hive query again.

How do you handle out of memory error?

1) An easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options "-Xmx512M", this will immediately solve your OutOfMemoryError.

What is out of memory error?

OutOfMemoryError exception. Usually, this error is thrown when there is insufficient space to allocate an object in the Java heap. In this case, The garbage collector cannot make space available to accommodate a new object, and the heap cannot be expanded further.


2 Answers

For anyone using RPM or DEB packages, the documentation and common advice is misleading. These packages install hadoop configuration files into /etc/hadoop. These will take priority over other settings.

The /etc/hadoop/hadoop-env.sh sets the maximum java heap memory for Hadoop, by Default it is:

   export HADOOP_CLIENT_OPTS="-Xmx128m $HADOOP_CLIENT_OPTS"

This Xmx setting is too low, simply change it to this and rerun

   export HADOOP_CLIENT_OPTS="-Xmx2048m $HADOOP_CLIENT_OPTS"
like image 96
Zach Garner Avatar answered Oct 01 '22 11:10

Zach Garner


You can assign more memory by editing the conf/mapred-site.xml file and adding the property:

  <property>     <name>mapred.child.java.opts</name>     <value>-Xmx1024m</value>   </property> 

This will start the hadoop JVMs with more heap space.

like image 43
Tudor Avatar answered Oct 01 '22 12:10

Tudor