首先,将测试数据上载到hadoop的hdfs上。
进入hadoop目录后输入命令:
bin/start-all.sh(启动hadoop的守护进程)
输入jps看进程是否启动,启动完成后输入命令:
bin/hadoop fs -put input02 input //将hadoop目录下的input02文件夹上载到文件系统hdfs上
输入命令:
bin/hadoop fs -ls//查看文件系统上的文件 也可以用bin/hadoop fs -ls input 查看文件是否上载成功
文件上载成功后,打开eclipse Maxtemperature代码 -->右击-->Run as-->Run Configurations 打开界面如下:
点击Arguments配置参数:
hdfs://localhost:9000/user/tgrqap6qhvnoh4d/administrator/input/ncdc/sample.txt
hdfs://localhost:9000/user/tgrqap6qhvnoh4d/administrator/output/
这里的路径要对应你文件系统的路径一个输入 一个输出
点击run(当然,你要提前配置好MapReduce locations)
Console:
12/12/01 15:20:37 INFO jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=
12/12/01 15:20:38 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
12/12/01 15:20:38 WARN mapred.JobClient: No job jar file set. User classes may not be found. See JobConf(Class) or JobConf#setJar(String).
12/12/01 15:20:38 INFO mapred.FileInputFormat: Total input paths to process : 1
12/12/01 15:20:39 INFO mapred.JobClient: Running job: job_local_0001
12/12/01 15:20:39 INFO mapred.FileInputFormat: Total input paths to process : 1
12/12/01 15:20:39 INFO mapred.MapTask: numReduceTasks: 1
12/12/01 15:20:39 INFO mapred.MapTask: io.sort.mb = 100
12/12/01 15:20:40 INFO mapred.MapTask: data buffer = 79691776/99614720
12/12/01 15:20:40 INFO mapred.MapTask: record buffer = 262144/327680
12/12/01 15:20:40 INFO mapred.MapTask: Starting flush of map output
12/12/01 15:20:40 INFO mapred.JobClient: map 0% reduce 0%
12/12/01 15:20:40 INFO mapred.MapTask: Finished spill 0
12/12/01 15:20:40 INFO mapred.TaskRunner: Task:attempt_local_0001_m_000000_0 is done. And is in the process of commiting
12/12/01 15:20:40 INFO mapred.LocalJobRunner: hdfs://localhost:9000/user/tgrqap6qhvnoh4d/administrator/input/ncdc/sample.txt:0+529
12/12/01 15:20:40 INFO mapred.TaskRunner: Task 'attempt_local_0001_m_000000_0' done.
12/12/01 15:20:40 INFO mapred.LocalJobRunner:
12/12/01 15:20:40 INFO mapred.Merger: Merging 1 sorted segments
12/12/01 15:20:40 INFO mapred.Merger: Down to the last merge-pass, with 1 segments left of total size: 57 bytes
12/12/01 15:20:40 INFO mapred.LocalJobRunner:
12/12/01 15:20:41 INFO mapred.TaskRunner: Task:attempt_local_0001_r_000000_0 is done. And is in the process of commiting
12/12/01 15:20:41 INFO mapred.LocalJobRunner:
12/12/01 15:20:41 INFO mapred.TaskRunner: Task attempt_local_0001_r_000000_0 is allowed to commit now
12/12/01 15:20:41 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_r_000000_0' to hdfs://localhost:9000/user/tgrqap6qhvnoh4d/administrator/output
12/12/01 15:20:41 INFO mapred.LocalJobRunner: reduce > reduce
12/12/01 15:20:41 INFO mapred.TaskRunner: Task 'attempt_local_0001_r_000000_0' done.
12/12/01 15:20:41 INFO mapred.JobClient: map 100% reduce 100%
12/12/01 15:20:41 INFO mapred.JobClient: Job complete: job_local_0001
12/12/01 15:20:41 INFO mapred.JobClient: Counters: 15
12/12/01 15:20:41 INFO mapred.JobClient: FileSystemCounters
12/12/01 15:20:41 INFO mapred.JobClient: FILE_BYTES_READ=33453
12/12/01 15:20:41 INFO mapred.JobClient: HDFS_BYTES_READ=1058
12/12/01 15:20:41 INFO mapred.JobClient: FILE_BYTES_WRITTEN=67938
12/12/01 15:20:41 INFO mapred.JobClient: HDFS_BYTES_WRITTEN=17
12/12/01 15:20:41 INFO mapred.JobClient: Map-Reduce Framework
12/12/01 15:20:41 INFO mapred.JobClient: Reduce input groups=2
12/12/01 15:20:41 INFO mapred.JobClient: Combine output records=0
12/12/01 15:20:41 INFO mapred.JobClient: Map input records=5
12/12/01 15:20:41 INFO mapred.JobClient: Reduce shuffle bytes=0
12/12/01 15:20:41 INFO mapred.JobClient: Reduce output records=2
12/12/01 15:20:41 INFO mapred.JobClient: Spilled Records=10
12/12/01 15:20:41 INFO mapred.JobClient: Map output bytes=45
12/12/01 15:20:41 INFO mapred.JobClient: Map input bytes=529
12/12/01 15:20:41 INFO mapred.JobClient: Combine input records=0
12/12/01 15:20:41 INFO mapred.JobClient: Map output records=5
12/12/01 15:20:41 INFO mapred.JobClient: Reduce input records=5
输入命令:bin/hadoop fs -ls
$ bin/hadoop fs -cat output/*
1949 111
1950 22
走到这里就成功了,当然我们也可以通过jar直接在终端上执行只需要打好包就行了