Hadoop单机非分布式模式 配置
环境:ubuntu 8.04.4
hadoop-1.0.2
参考网址:
http://www.cnblogs.com/guoyuanwei/archive/2011/10/17/2215749.html
http://www.ibm.com/developerworks/cn/opensource/os-cn-hadoop1/index.html
一、介绍 Hadoop(官网,了解下即可)
http://hadoop.apache.org/
二、下载Hadoop,我下的是hadoop-1.0.2.tar.gz
http://www.apache.org/dyn/closer.cgi/hadoop/common/
推荐用renren的源:
http://labs.renren.com/apache-mirror/hadoop/common/
三、解压
tar -xf hadoop-1.0.2.tar.gz
四、拷贝到 /usr/local/ 路径下
sudo mv hadoop-1.0.2/ /usr/local/
五、修改hadoop的java环境变量的路径
sudo gedit /usr/local/hadoop-1.0.2/conf/hadoop-env.sh
加入:
export JAVA_HOME=/usr/lib/java/jdk1.7.0_03
单机非分布式模式 完成!
六、测试
参考:http://www.ibm.com/developerworks/cn/opensource/os-cn-hadoop1/index.html
执行以下命令:
cd /usr/local/hadoop-1.0.2
mkdir test-in
cd test-in/
#在 test-in 目录下创建两个文本文件, WordCount 程序将统计其中各个单词出现次数
echo "hello world bye world" >file1.txt //自动新建文件,并写入字符串
echo "hello hadoop goodbye hadoop" >file2.txt
cd ..
bin/hadoop jar hadoop-examples-1.0.2.jar wordcount test-in/ test-out
#执行完毕,下面查看执行结果:
cd test-out/
cat part-r-00000
结果如下:
bye 1
goodbye 1
hadoop 2
hello 2
world 2