步骤:
在eclipse中运行
右键--》run as -->run configuration
在Programs argument中添加:/user/hadoop/output(此处随你自己修改)
代码:
/**
* Licensed to the Apache Software Foundation (ASF) under onepublic void configure(JobConf job) {
/*当个Map写的字节数 变量读能见名知意**/
numBytesToWrite = job.getLong("test.randomwrite.bytes_per_map",job.setOutputValueClass(BytesWritable.class);
/* 此处设置输入类型*/
job.setInputFormat(RandomInputFormat.class);job.setReducerClass(IdentityReducer.class);
/**设置输出类型 此处要修改的话 前面那个randomKey类型也需要修改 **/
job.setOutputFormat(SequenceFileOutputFormat.class);}
输出:
Running 10 maps.
Job started: Wed Apr 10 22:41:10 CST 2013
13/04/10 22:41:10 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
numMaps-------10
13/04/10 22:41:11 INFO mapred.JobClient: Running job: job_local_0001
13/04/10 22:41:11 INFO util.ProcessTree: setsid exited with exit code 0
13/04/10 22:41:11 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@28bd68
13/04/10 22:41:11 INFO mapred.MapTask: numReduceTasks: 0
13/04/10 22:41:12 INFO mapred.JobClient: map 0% reduce 0%
13/04/10 22:41:13 INFO mapred.Task: Task:attempt_local_0001_m_000000_0 is done. And is in the process of commiting
13/04/10 22:41:13 INFO mapred.LocalJobRunner:
13/04/10 22:41:13 INFO mapred.Task: Task attempt_local_0001_m_000000_0 is allowed to commit now
13/04/10 22:41:14 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_m_000000_0' to hdfs://localhost:49002/user/hadoop/output
13/04/10 22:41:14 INFO mapred.LocalJobRunner: done with 1987 records.
13/04/10 22:41:14 INFO mapred.Task: Task 'attempt_local_0001_m_000000_0' done.
13/04/10 22:41:14 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@209661
13/04/10 22:41:14 INFO mapred.MapTask: numReduceTasks: 0
13/04/10 22:41:15 INFO mapred.JobClient: map 100% reduce 0%
13/04/10 22:41:18 INFO mapred.Task: Task:attempt_local_0001_m_000001_0 is done. And is in the process of commiting
13/04/10 22:41:18 INFO mapred.LocalJobRunner:
13/04/10 22:41:18 INFO mapred.Task: Task attempt_local_0001_m_000001_0 is allowed to commit now
13/04/10 22:41:18 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_m_000001_0' to hdfs://localhost:49002/user/hadoop/output
13/04/10 22:41:19 INFO mapred.JobClient: map 50% reduce 0%
13/04/10 22:41:20 INFO mapred.LocalJobRunner: done with 2038 records.
13/04/10 22:41:20 INFO mapred.LocalJobRunner: done with 2038 records.
13/04/10 22:41:20 INFO mapred.Task: Task 'attempt_local_0001_m_000001_0' done.
13/04/10 22:41:20 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@1f2b5c
13/04/10 22:41:20 INFO mapred.MapTask: numReduceTasks: 0
13/04/10 22:41:21 INFO mapred.JobClient: map 100% reduce 0%
13/04/10 22:41:22 INFO mapred.Task: Task:attempt_local_0001_m_000002_0 is done. And is in the process of commiting
13/04/10 22:41:22 INFO mapred.LocalJobRunner:
13/04/10 22:41:22 INFO mapred.Task: Task attempt_local_0001_m_000002_0 is allowed to commit now
13/04/10 22:41:22 INFO mapred.JobClient: map 66% reduce 0%
13/04/10 22:41:22 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_m_000002_0' to hdfs://localhost:49002/user/hadoop/output
13/04/10 22:41:23 INFO mapred.LocalJobRunner: done with 1988 records.
13/04/10 22:41:23 INFO mapred.Task: Task 'attempt_local_0001_m_000002_0' done.
13/04/10 22:41:23 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@195804b
13/04/10 22:41:23 INFO mapred.MapTask: numReduceTasks: 0
13/04/10 22:41:24 INFO mapred.JobClient: map 100% reduce 0%
13/04/10 22:41:27 INFO mapred.Task: Task:attempt_local_0001_m_000003_0 is done. And is in the process of commiting
13/04/10 22:41:27 INFO mapred.LocalJobRunner:
13/04/10 22:41:27 INFO mapred.Task: Task attempt_local_0001_m_000003_0 is allowed to commit now
13/04/10 22:41:27 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_m_000003_0' to hdfs://localhost:49002/user/hadoop/output
13/04/10 22:41:28 INFO mapred.JobClient: map 75% reduce 0%
13/04/10 22:41:29 INFO mapred.LocalJobRunner: done with 2003 records.
13/04/10 22:41:29 INFO mapred.LocalJobRunner: done with 2003 records.
13/04/10 22:41:29 INFO mapred.Task: Task 'attempt_local_0001_m_000003_0' done.
13/04/10 22:41:29 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@9ee241
13/04/10 22:41:29 INFO mapred.MapTask: numReduceTasks: 0
13/04/10 22:41:30 INFO mapred.JobClient: map 100% reduce 0%
13/04/10 22:41:32 INFO mapred.Task: Task:attempt_local_0001_m_000004_0 is done. And is in the process of commiting
13/04/10 22:41:32 INFO mapred.LocalJobRunner:
13/04/10 22:41:32 INFO mapred.Task: Task attempt_local_0001_m_000004_0 is allowed to commit now
13/04/10 22:41:32 INFO mapred.JobClient: map 80% reduce 0%
13/04/10 22:41:32 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_m_000004_0' to hdfs://localhost:49002/user/hadoop/output
13/04/10 22:41:32 INFO mapred.LocalJobRunner: done with 1961 records.
13/04/10 22:41:32 INFO mapred.Task: Task 'attempt_local_0001_m_000004_0' done.
13/04/10 22:41:32 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@10ef227
13/04/10 22:41:32 INFO mapred.MapTask: numReduceTasks: 0
13/04/10 22:41:33 INFO mapred.JobClient: map 100% reduce 0%
13/04/10 22:41:34 INFO mapred.Task: Task:attempt_local_0001_m_000005_0 is done. And is in the process of commiting
13/04/10 22:41:34 INFO mapred.LocalJobRunner:
13/04/10 22:41:34 INFO mapred.Task: Task attempt_local_0001_m_000005_0 is allowed to commit now
13/04/10 22:41:35 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_m_000005_0' to hdfs://localhost:49002/user/hadoop/output
13/04/10 22:41:35 INFO mapred.JobClient: map 83% reduce 0%
13/04/10 22:41:35 INFO mapred.LocalJobRunner: done with 1984 records.
13/04/10 22:41:35 INFO mapred.Task: Task 'attempt_local_0001_m_000005_0' done.
13/04/10 22:41:35 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@1b647b9
13/04/10 22:41:35 INFO mapred.MapTask: numReduceTasks: 0
13/04/10 22:41:36 INFO mapred.JobClient: map 100% reduce 0%
13/04/10 22:41:38 INFO mapred.Task: Task:attempt_local_0001_m_000006_0 is done. And is in the process of commiting
13/04/10 22:41:38 INFO mapred.LocalJobRunner:
13/04/10 22:41:38 INFO mapred.Task: Task attempt_local_0001_m_000006_0 is allowed to commit now
13/04/10 22:41:38 INFO mapred.JobClient: map 85% reduce 0%
13/04/10 22:41:38 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_m_000006_0' to hdfs://localhost:49002/user/hadoop/output
13/04/10 22:41:38 INFO mapred.LocalJobRunner: done with 1980 records.
13/04/10 22:41:38 INFO mapred.Task: Task 'attempt_local_0001_m_000006_0' done.
13/04/10 22:41:38 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@730333
13/04/10 22:41:38 INFO mapred.MapTask: numReduceTasks: 0
13/04/10 22:41:39 INFO mapred.JobClient: map 100% reduce 0%
13/04/10 22:41:40 INFO mapred.Task: Task:attempt_local_0001_m_000007_0 is done. And is in the process of commiting
13/04/10 22:41:40 INFO mapred.LocalJobRunner:
13/04/10 22:41:40 INFO mapred.Task: Task attempt_local_0001_m_000007_0 is allowed to commit now
13/04/10 22:41:41 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_m_000007_0' to hdfs://localhost:49002/user/hadoop/output
13/04/10 22:41:41 INFO mapred.JobClient: map 87% reduce 0%
13/04/10 22:41:41 INFO mapred.LocalJobRunner: done with 1992 records.
13/04/10 22:41:41 INFO mapred.Task: Task 'attempt_local_0001_m_000007_0' done.
13/04/10 22:41:41 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@890800
13/04/10 22:41:41 INFO mapred.MapTask: numReduceTasks: 0
13/04/10 22:41:42 INFO mapred.JobClient: map 100% reduce 0%
13/04/10 22:41:45 INFO mapred.Task: Task:attempt_local_0001_m_000008_0 is done. And is in the process of commiting
13/04/10 22:41:45 INFO mapred.LocalJobRunner:
13/04/10 22:41:45 INFO mapred.Task: Task attempt_local_0001_m_000008_0 is allowed to commit now
13/04/10 22:41:46 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_m_000008_0' to hdfs://localhost:49002/user/hadoop/output
13/04/10 22:41:46 INFO mapred.JobClient: map 88% reduce 0%
13/04/10 22:41:47 INFO mapred.LocalJobRunner: done with 1999 records.
13/04/10 22:41:47 INFO mapred.LocalJobRunner: done with 1999 records.
13/04/10 22:41:47 INFO mapred.Task: Task 'attempt_local_0001_m_000008_0' done.
13/04/10 22:41:47 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@36f7a0
13/04/10 22:41:47 INFO mapred.MapTask: numReduceTasks: 0
13/04/10 22:41:48 INFO mapred.JobClient: map 100% reduce 0%
13/04/10 22:41:49 INFO mapred.Task: Task:attempt_local_0001_m_000009_0 is done. And is in the process of commiting
13/04/10 22:41:50 INFO mapred.LocalJobRunner:
13/04/10 22:41:50 INFO mapred.Task: Task attempt_local_0001_m_000009_0 is allowed to commit now
13/04/10 22:41:50 INFO mapred.FileOutputCommitter: Saved output of task 'attempt_local_0001_m_000009_0' to hdfs://localhost:49002/user/hadoop/output
13/04/10 22:41:50 INFO mapred.JobClient: map 89% reduce 0%
13/04/10 22:41:50 INFO mapred.LocalJobRunner: done with 2025 records.
13/04/10 22:41:50 INFO mapred.Task: Task 'attempt_local_0001_m_000009_0' done.
13/04/10 22:41:51 INFO mapred.JobClient: map 100% reduce 0%
13/04/10 22:41:51 INFO mapred.JobClient: Job complete: job_local_0001
13/04/10 22:41:51 INFO mapred.JobClient: Counters: 16
13/04/10 22:41:51 INFO mapred.JobClient: File Input Format Counters
13/04/10 22:41:51 INFO mapred.JobClient: Bytes Read=0
13/04/10 22:41:51 INFO mapred.JobClient: File Output Format Counters
13/04/10 22:41:51 INFO mapred.JobClient: Bytes Written=210459071
13/04/10 22:41:51 INFO mapred.JobClient: org.apache.hadoop.examples.RandomWriter$Counters
13/04/10 22:41:51 INFO mapred.JobClient: BYTES_WRITTEN=209767059
13/04/10 22:41:51 INFO mapred.JobClient: RECORDS_WRITTEN=19957
13/04/10 22:41:51 INFO mapred.JobClient: FileSystemCounters
13/04/10 22:41:51 INFO mapred.JobClient: FILE_BYTES_READ=2382785
13/04/10 22:41:51 INFO mapred.JobClient: FILE_BYTES_WRITTEN=2782330
13/04/10 22:41:51 INFO mapred.JobClient: HDFS_BYTES_WRITTEN=1157478956
13/04/10 22:41:51 INFO mapred.JobClient: Map-Reduce Framework
13/04/10 22:41:51 INFO mapred.JobClient: Map input records=10
13/04/10 22:41:51 INFO mapred.JobClient: Physical memory (bytes) snapshot=0
13/04/10 22:41:51 INFO mapred.JobClient: Spilled Records=0
13/04/10 22:41:51 INFO mapred.JobClient: CPU time spent (ms)=0
13/04/10 22:41:51 INFO mapred.JobClient: Total committed heap usage (bytes)=356450304
13/04/10 22:41:51 INFO mapred.JobClient: Virtual memory (bytes) snapshot=0
13/04/10 22:41:51 INFO mapred.JobClient: Map input bytes=0
13/04/10 22:41:51 INFO mapred.JobClient: Map output records=19957
13/04/10 22:41:51 INFO mapred.JobClient: SPLIT_RAW_BYTES=1080
Job ended: Wed Apr 10 22:41:51 CST 2013
The job took 41 seconds.