分布式安装请参考:
http://acooly.iteye.com/blog/1179828
单机安装中,使用一台机器,即做namenode和JobTracker也是datanode和TaskTracker,当然也是SecondaryNameNode。
主要配置文件core-site.xml,hdfs-site.xml,mapred-site.xml,masters完全同分布树安装配置,如果分布式安装配置方案中hdfs-site.xml的副本数量定义大于1,则修改为1.
代码如下:
property
namedfs.replication/name
value1/value
/property
主要不同在于slaves的配置,分布式安装中是多个其他机器作为datanode,单机模式本机是datanode,所以修改slaves配置文件为本机的域名。如:本机机器名为hadoop11,则:
[hadoop@hadoop11 ~]$ cat hadoop/conf/slaves
hadoop11
完成配置后,启动:
代码如下:
$ start-all.sh
$ jps
15556 Jps
15111 JobTracker
15258 TaskTracker
15014 SecondaryNameNode
14861 DataNode
14712 NameNode
运行DEMO
$ echo word1 word2 word2 word3 word3 word3 words
$ cat words
word1 word2 word2 word3 word3 word3
$ hadoop dfsadmin -safemode leave
$ hadoop fs -copyFromLocal words /single/input/words
$ hadoop fs -cat /single/input/words
12/02/17 19:47:44 INFO security.Groups: Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping; cacheTimeout=300000
word1 word2 word2 word3 word3 word3
$ hadoop jar hadoop-0.21.0/hadoop-mapred-examples-0.21.0.jar wordcount /single/input /single/output
......
$ hadoop fs -ls /single/output
......
-rw-r--r-- 1 hadoop supergroup 0 2012-02-17 19:50 /single/output/_SUCCESS
-rw-r--r-- 1 hadoop supergroup 24 2012-02-17 19:50 /single/output/part-r-00000
$ hadoop fs -cat /single/output/part-r-00000
......
word1 1
word2 2
word3 3
猜你喜欢