4.启动hadoop:
这里用简单的命令进行启动,
A.格式化文件系统:
#bin/hadoop namenode –format
B.启动hadoop
#bin/start-all.sh
C.利用hadoop自带的例子测试hadoop是否启动成功
#bin/hadoop fs -mkdir input ###在文件系统中创建input文件夹 #bin/hadoopfs -put README.txt input ###把本地readme.txt上传到input中 #bin/hadoop fs –lsr ###查看本件系统所有文件 存在文件并且大小不为0则hadoop文件系统搭建成功。 #bin/hadoopjar hadoop-0.20.2-examples.jar wordcount input/README.txt output ###将输出结果输出到output中 #bin/hadoop jar hadoop-0.20.2-examples.jar wordcount input/1.txt output
11/12/02 17:47:14 INFOinput.FileInputFormat: Total input paths to process : 1
11/12/02 17:47:14 INFO mapred.JobClient:Running job: job_201112021743_0001
11/12/02 17:47:15 INFOmapred.JobClient: map 0% reduce 0%
11/12/02 17:47:22 INFOmapred.JobClient: map 100% reduce 0%
11/12/02 17:47:34 INFOmapred.JobClient: map 100% reduce 100%
11/12/02 17:47:36 INFO mapred.JobClient:Job complete: job_201112021743_0001
11/12/02 17:47:36 INFO mapred.JobClient:Counters: 17
11/12/02 17:47:36 INFOmapred.JobClient: Job Counters
11/12/02 17:47:36 INFOmapred.JobClient: Launched reducetasks=1
11/12/02 17:47:36 INFOmapred.JobClient: Launched maptasks=1
11/12/02 17:47:36 INFOmapred.JobClient: Data-local maptasks=1
11/12/02 17:47:36 INFOmapred.JobClient: FileSystemCounters
11/12/02 17:47:36 INFOmapred.JobClient: FILE_BYTES_READ=32523
11/12/02 17:47:36 INFOmapred.JobClient: HDFS_BYTES_READ=44253
11/12/02 17:47:36 INFOmapred.JobClient: FILE_BYTES_WRITTEN=65078
11/12/02 17:47:36 INFOmapred.JobClient: HDFS_BYTES_WRITTEN=23148
11/12/02 17:47:36 INFOmapred.JobClient: Map-Reduce Framework
11/12/02 17:47:36 INFOmapred.JobClient: Reduce inputgroups=2367
11/12/02 17:47:36 INFOmapred.JobClient: Combine outputrecords=2367
11/12/02 17:47:36 INFOmapred.JobClient: Map inputrecords=734
11/12/02 17:47:36 INFOmapred.JobClient: Reduce shufflebytes=32523
11/12/02 17:47:36 INFOmapred.JobClient: Reduce outputrecords=2367
11/12/02 17:47:36 INFO mapred.JobClient: Spilled Records=4734
11/12/02 17:47:36 INFOmapred.JobClient: Map outputbytes=73334
11/12/02 17:47:36 INFOmapred.JobClient: Combine inputrecords=7508
11/12/02 17:47:36 INFOmapred.JobClient: Map outputrecords=7508
11/12/02 17:47:36 INFOmapred.JobClient: Reduce inputrecords=2367
也可以通过本地浏览器进行查看状态:50070和50030端口(注意配置本地C:\Windows\System32\drivers\etc\hosts文件)