hadoop环境搭建与測试

搭建參看:
查看集群状态:
[root@master bin]# hdfs dfsadmin -report
Configured Capacity: 36729053184 (34.21 GB)
Present Capacity: 13322559491 (12.41 GB)
DFS Remaining: 13322240000 (12.41 GB)
DFS Used: 319491 (312.00 KB)
DFS Used%: 0.00%
Under replicated blocks: 0
Blocks with corrupt replicas: 0
Missing blocks: 0 -------------------------------------------------
Datanodes available: 2 (2 total, 0 dead) Live datanodes:
Name: 192.168.137.103:50010 (slave2)
Hostname: slave2
Decommission Status : Normal
Configured Capacity: 18364526592 (17.10 GB)
DFS Used: 45056 (44 KB)
Non DFS Used: 11702558720 (10.90 GB)
DFS Remaining: 6661922816 (6.20 GB)
DFS Used%: 0.00%
DFS Remaining%: 36.28%
Last contact: Thu Nov 06 21:26:34 CST 2014 Name: 192.168.137.102:50010 (slave1)
Hostname: slave1
Decommission Status : Normal
Configured Capacity: 18364526592 (17.10 GB)
DFS Used: 274435 (268.00 KB)
Non DFS Used: 11703934973 (10.90 GB)
DFS Remaining: 6660317184 (6.20 GB)
DFS Used%: 0.00%
DFS Remaining%: 36.27%
Last contact: Thu Nov 06 21:26:31 CST 2014
查看文件块组成:
[root@master bin]# hdfs fsck / -files -blocks
Status: HEALTHY
Total size: 219351 B
Total dirs: 11
Total files: 12
Total symlinks: 0
Total blocks (validated): 10 (avg. block size 21935 B)
Minimally replicated blocks: 10 (100.0 %)
Over-replicated blocks: 0 (0.0 %)
Under-replicated blocks: 0 (0.0 %)
Mis-replicated blocks: 0 (0.0 %)
Default replication factor: 1
Average block replication: 1.0
Corrupt blocks: 0
Missing replicas: 0 (0.0 %)
Number of data-nodes: 2
Number of racks: 1
FSCK ended at Thu Nov 06 21:27:34 CST 2014 in 29 milliseconds The filesystem under path '/' is HEALTHY
[root@master bin]#
[hadoop@master hadoop2.2]$
查看各节点状态:
查看ResourceManager上cluster执行状态:

在环境搭建的过程中,假设出现不论什么问题。都要去查看日志
日志路径是:/home/hadoop/hadoop2.2/logs

在配置完毕HADOOP_HOME之后,而且使之生效,那么接下来就进行測试,启动hadoop
首先在/文件夹下创建input文件
[root@master /]# vim input。在该文件里输入例如以下内容:I am a very good person! I love you America !
将之上传到hdfs上:[root@master /]# hadoop fs -put /input /input
在hadoop的bin文件夹下运行:[root@master bin]# ./yarn jar ../share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar wordcount /input /output
这样运行完成之后能够看到:output文件夹下有两个文件
[root@master ~]# hadoop fs -ls /output
Found 2 items
-rw-r--r-- 1 root supergroup 0 2014-11-06 21:21 /output/_SUCCESS
-rw-r--r-- 1 root supergroup 64 2014-11-06 21:21 /output/part-r-00000
接着能够查看Wordcount的统计结果:
[root@master bin]# hadoop fs -cat /output/part-r-00000
! 1
America 1
I 2
a 1
am 1
good 1
love 1
person! 1
very 1
you 1
[root@master bin]#
上一篇:typedef 及其与struct的结合使用


下一篇:【知识整理】这可能是最好的RxJava 2.x 教程(完结版)