標籤:hadoop 分布式 mapreduce
官網上的教程版本不符,還過於簡單(很多必要的步驟沒提到),
所以自行網上找教程.
在這裡整理一下:
假設java_home已經配置完成,ssh也可連通
1.修改設定檔
以下檔案均在 %HADOOP_HOME%/conf/ 下
core-site.xml: Hadoop Core的配置項,例如HDFS和MapReduce常用的I/O設定等。
hdfs-site.xml: Hadoop 守護進程的配置項,包括namenode,輔助namenode和datanode等。
mapred-site.xml: MapReduce 守護進程的配置項,包括jobtracker和tasktracker。
預先建立好檔案目錄:
~/hadoop$ mkdir tmp
~/hadoop$ mkdir hdfs
~/hadoop$ mkdir hdfs/name
~/hadoop$ mkdir hdfs/data
配置內容:
core-site.xml
<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!-- Put site-specific property overrides in this file. --><configuration> <property> <name>fs.default.name</name> <value>hdfs://localhost:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/usr/hadoop/hadoop-1.2.1/tmp</value> </property></configuration>
hdfs-site.xml
<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!-- Put site-specific property overrides in this file. --><configuration> <property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>dfs.name.dir</name> <value>/usr/hadoop/hadoop-1.2.1/hdfs/name</value> </property> <property> <name>dfs.data.dir</name> <value>/usr/hadoop/hadoop-1.2.1/hdfs/data</value> </property></configuration>
mapred-site.xml
<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!-- Put site-specific property overrides in this file. --><configuration> <property> <name>mapred.job.tracker</name> <value>localhost:9001</value> </property></configuration>
2.格式化
[[email protected] hadoop-1.2.1]# bin/hadoop namenode -format
3.開啟
[[email protected] hadoop-1.2.1]# bin/start-all.sh
測試:
jps
使用web瀏覽器查看:
http://localhost:50030/ - Hadoop 管理介面
http://localhost:50060/ - Hadoop Task Tracker 狀態
http://localhost:50070/ - Hadoop DFS 狀態
4.執行map-reduce樣本
建立hdfs上的input
[[email protected] hadoop-1.2.1]# bin/hadoop dfs -mkdir input
配置拷上去
[[email protected] hadoop-1.2.1]# hadoop dfs -copyFromLocal conf/* input
執行java檔案
[[email protected] hadoop-1.2.1]# hadoop jar hadoop-examples-1.2.1.jar wordcount input output
完成:
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
偽分布式hadoop環境搭建