注:所有的运行只需要在hadoop1的master节点即可。系统会自动登录到其他两台去启动相应的节点。
在初次运行Hadoop的时候需要初始化Hadoop文件系统,命令如下:
$cd /home/hduser/hadoop/bin
$./hdfs namenode -format
如果执行成功,你会在日志中(倒数几行)找到如下成功的提示信息:
common.Storage: Storage directory /home/hduser/hadoop/tmp/hadoop-hduser/dfs/namehas been successfully formatted.
运行命令如下:
$cd home/hduser/hadoop/sbin/
$./start-dfs.sh
$./start-yarn.sh
启动完之后可分别用jps命令查看各个机子的进程是否正常,如下:
hduser@hadoop1:~/hadoop$jps
1777 ResourceManager
1464 NameNode
1618 SecondaryNameNode
hduser@hadoop2:~$ jps
1264 DataNode
1344 NodeManager
hduser@hadoop3:~$ jps
1289 NodeManager
1209 DataNode
还可以通过bin/hdfs dfsadmin -report查看dfs是否正常,相应如下:
hduser@hadoop1:~/hadoop$ bin/hdfs dfsadmin -report
Configured Capacity:40668069888 (37.88 GB)
Present Capacity:34336370688 (31.98 GB)
DFS Remaining:34334142464 (31.98 GB)
DFS Used: 2228224(2.13 MB)
DFS Used%: 0.01%
Under replicatedblocks: 0
Blocks with corruptreplicas: 0
Missing blocks: 0
-------------------------------------------------
Datanodes available:2 (2 total, 0 dead)
Live datanodes:
Name:192.168.128.131:50010 (hadoop2)
Hostname: hadoop2
Decommission Status: Normal
Configured Capacity:20334034944 (18.94 GB)
DFS Used: 1114112(1.06 MB)
Non DFS Used:3165851648 (2.95 GB)
DFS Remaining:17167069184 (15.99 GB)
DFS Used%: 0.01%
DFS Remaining%:84.43%
Last contact: MonOct 28 19:12:16 PDT 2013
Name:192.168.128.132:50010 (hadoop3)
Hostname: hadoop3
Decommission Status: Normal
Configured Capacity:20334034944 (18.94 GB)
DFS Used: 1114112(1.06 MB)
Non DFS Used:3165847552 (2.95 GB)
DFS Remaining:17167073280 (15.99 GB)
DFS Used%: 0.01%
DFS Remaining%:84.43%
Last contact: MonOct 28 19:12:16 PDT 2013