Configuring Hadoop2.6.0 in Eclipse

Source: Internet
Author: User

1. Download and configure the plugin

Place the downloaded Hadoop-eclipse-plugin-2.6.0.jar in the eclipse's Dropins directory and restart Eclipse.

2. Configure the Hadoop installation directory

    • Windows->preference, Hadoop map/reduce, Hadoop installation directory

3. Configure Map/reduce View

    • Window->open Perspective, other->map/reduce click "OK"
    • Windows→show view→other->map/reduce locations-> Click "OK"
    • The console will have one more tab page for "Map/reduce Locations"

On the "Map/reduce Locations" tab, click the icon < elephant +> or right click on the blank, select "New Hadoop location ...", and the dialog box "new Hadoop locations ..." pops up, Configure the following: Change HA1 to your own Hadoop user

Note: The MR master and DFS master configurations must be consistent with the configuration files such as Mapred-site.xml and Core-site.xml

Open Project Explorer to view the HDFs file system.

4. New Map/reduce Task

File->new->project->map/reduce Project->next

Write the WordCount class: Remember to get the service up first

[Java]View Plaincopy
  1. Import java.io.IOException;
  2. Import java.util.*;
  3. Import Org.apache.hadoop.fs.Path;
  4. Import org.apache.hadoop.conf.*;
  5. Import org.apache.hadoop.io.*;
  6. Import org.apache.hadoop.mapred.*;
  7. Import org.apache.hadoop.util.*;
  8. Public class WordCount {
  9. Public static class Map extends Mapreducebase implements Mapper<longwritable, text, text, intwritable > {
  10. Private final static intwritable one = new intwritable (1);
  11. Private text word = new text ();
  12. Public void Map (longwritable key, Text value, Outputcollector<text, intwritable> output, Reporter Reporter) throws IOException {
  13. String line = value.tostring ();
  14. StringTokenizer tokenizer = new StringTokenizer (line);
  15. While (Tokenizer.hasmoretokens ()) {
  16. Word.set (Tokenizer.nexttoken ());
  17. Output.collect (Word, one);
  18. }
  19. }
  20. }
  21. Public static class Reduce extends Mapreducebase implements Reducer<text, Intwritable, Text, intwritable> {
  22. Public void Reduce (Text key, iterator<intwritable> values, Outputcollector<text, intwritable> output, Reporter Reporter) throws IOException {
  23. int sum = 0;
  24. While (Values.hasnext ()) {
  25. Sum + = Values.next (). get ();
  26. }
  27. Output.collect (Key, new intwritable (sum));
  28. }
  29. }
  30. Public static void Main (string[] args) throws Exception {
  31. jobconf conf = new jobconf (WordCount.   Class);
  32. Conf.setjobname ("WordCount");
  33. Conf.setoutputkeyclass (Text.   Class);
  34. Conf.setoutputvalueclass (intwritable.   Class);
  35. Conf.setmapperclass (Map.   Class);
  36. Conf.setreducerclass (Reduce.   Class);
  37. Conf.setinputformat (Textinputformat.   Class);
  38. Conf.setoutputformat (Textoutputformat.   Class);
  39. Fileinputformat.setinputpaths (conf, new Path (args[0]));
  40. Fileoutputformat.setoutputpath (conf, new Path (args[1]));
  41. Jobclient.runjob (conf);
  42. }
  43. }

5. Configure run-time parameters: Right-click-->run as-->run confiugrations

User/ha1/input/hadoop is the file you upload in the HDFs folder (which you create yourself) and put in the files you want to process. OUPUT4 Output Results

Run the program on a Hadoop cluster: Right--->runas-->run on Hadoop, and the final output will be displayed in the appropriate folder in HDFs. At this point, Ubuntu hadoop-2.6.0 Eclipse plugin configuration is complete.

Special Note: The Execute Mr Console does not have log details when configured as above.

Solution, copy the Hadoop-2.6.0/etc/haoop/log4j.properties file to the Eclipse project (for example, copy it to the/home/hadoop/workspace/wordcount path < Confusion: Copying to this path in the Linux file system is not valid, but copying from the Eclipse view is valid. and the corresponding generated log4j.properties file >) in the above path.

http://blog.csdn.net/zythy/article/details/17397153

Configuring Hadoop2.6.0 in Eclipse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.