Hadoop MapReduce Demo

Versions: Hadoop 3.1.1  Java10 Set the following environment variables: JAVA_HOME  HADOOP_HOME For Windows Download Hadoop 3.1.1 binaries fo...


Versions:
  • Hadoop 3.1.1 
  • Java10
Set the following environment variables:
  • JAVA_HOME 
  • HADOOP_HOME

For Windows

Download Hadoop 3.1.1 binaries for windows at https://github.com/s911415/apache-hadoop-3.1.0-winutils. Extract in HADOOP_HOME\bin and make sure to override the existing files.

For Ubuntu

$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ chmod 0600 ~/.ssh/authorized_keys

The following instruction will install Hadoop as Pseudo-Distributed Operation

1.) Create the following folders:
HADOOP_HOME/tmp
HADOOP_HOME/tmp/dfs/data
HADOOP_HOME/tmp/dfs/name

2.) Set the following properties: core-site.xml and hdfs-site.xml
<property>
fs.defaultFS
hdfs://localhost:9001
</property>
<property>
</property>
core-site.xml
<property>
hadoop.tmp.dir
HADOOP_HOME/tmp
</property>
<property>
</property>
hdfs-site.xml
<property>
dfs.namenode.name.dir
file:///HADOOP_HOME/tmp/dfs/name
</property>
<property>
dfs.datanode.data.dir
file:///HADOOP_HOME/tmp/dfs/data
</property>

<property>
dfs.permissions
false
</property>
<property>
</property>
3.) Run hadoop namenode -format Don't forget the file:/// prefix in hdfs-site.xml for windows. Otherwise, the format will fail.

4.) Run HADOOP_HOME/sbin/start-dfs.xml.

5.) If all goes well, you can check the log for the web port in the console. In my case it's http://localhost:9870.


6.) You can now upload any file in the #4 URL.



Now let's try to create a project that will test our Hadoop setup. Or download an already existing one. For example this project: https://www.guru99.com/create-your-first-Hadoop-program.html. It has a nice explanation with it, so let's try. I've repackaged it into a pom project and uploaded at Github at https://github.com/czetsuya/Hadoop-MapReduce.
  1. Clone the repository. 
  2. Open the hdfs url from the #5 above, and create an input and output folder.
  3. In input folder, upload the file SalesJan2009 from the project's root folder. 
  4. Run Hadoop jar Hadoop-mapreduce-0.0.1-SNAPSHOT.jar /input /output. 
  5. Check the output from the URL and download the resulting file.

To run Hadoop as standalone, download and unpack it as is. Go to our projects folder, build using maven, then run the Hadoop command below:
>$HADOOP_HOME/bin/hadoop jar target/hadoop-mapreduce-0.0.1-SNAPSHOT.jar input output

input - is a directory that should contain the csv file
output - is a directory that will be created after launch. The output file will be save here.

The common cause of problems: 

  • Un-properly configured core-site or hdfs-site related to data and name node?
  • File / folder permission

References

  • https://www.guru99.com/create-your-first-hadoop-program.html
  • https://github.com/czetsuya/Hadoop-MapReduce
  • https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/SingleCluster.html#Standalone_Operation

COMMENTS

mas template
Name

amazon,1,angular,8,bigdata,2,business,1,course-spring,27,courses,6,database,4,docker,3,java,50,kafka,1,keycloak,4,microservices,5,mysql,1,neworking,1,nosql,2,php,1,pinned,2,react,3,server management,7,shared drive,1,spring,7,synology,1,troubleshooting,2,web,1,wordpress,1,
ltr
item
toztech: Hadoop MapReduce Demo
Hadoop MapReduce Demo
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlpooU5DZShnyj9xSuKvykLp4co1Ia8Pid92bWBwbkyp2JtY5Ou2dlc13cJpZf5-1OETzb5xGKLEhiVOTynXdD79YhDunA1mGT7HVXsFu26EyzvWhmiLy1n1ZAl4_dqiobxsr20YEFhik/s400/1_1gx5I6RbBoJieKjT-mzRzA.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlpooU5DZShnyj9xSuKvykLp4co1Ia8Pid92bWBwbkyp2JtY5Ou2dlc13cJpZf5-1OETzb5xGKLEhiVOTynXdD79YhDunA1mGT7HVXsFu26EyzvWhmiLy1n1ZAl4_dqiobxsr20YEFhik/s72-c/1_1gx5I6RbBoJieKjT-mzRzA.png
toztech
https://toztech.blogspot.com/2018/08/hadoop-mapreduce-demo.html
https://toztech.blogspot.com/
https://toztech.blogspot.com/
https://toztech.blogspot.com/2018/08/hadoop-mapreduce-demo.html
true
2554149350007112447
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content