标签:style blog http color io os ar java for
1.core-site.xml
在<configuration></configuration>中插入
<property> <name>fs.default.name</name> <value>hdfs://localhost:9000</value> </property> <property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/home/你自己的用户名/tmp</value> </property>
2.mapred-site.xml
在<configuration></configuration>中插入
<property> <name>mapred.job.tracker</name> <value>localhost:9001</value> </property>
3.首次运行hadoop必须进行格式化Hadoop文件系统。
进入安装了Hadoop的文件路径下,然后在命令行输入
bin/hadoop namenode -format
4.启动Hadoop,在命令行里面输入
bin/start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
bash start-dfs.sh (需要配置export JAVA_HOME)
bash start-yarn.sh
jps
http://localhost:50070 (dfshealth)
http://localhost:8088 (Cluster Metrics)
5.运行wordcount示例
1).创建文件
/home/guan/myword.txt
2).创建hadoop目录
./bin/hadoop fs -mkdir /input
3).上传文件
./bin/hadoop fs -put -f /home/guan/myword.txt /input
4).执行
./bin/hadoop jar./share/hadoop/mapreduce/sources/hadoop-mapreduce-examples-2.4.1-sources.jarorg.apache.hadoop.examples.WordCount /input /output
5).查看结果
./bin/hadoop fs -cat /output/part-r-00000
标签:style blog http color io os ar java for
原文地址:http://www.cnblogs.com/yuyutianxia/p/4020308.html