官網上的教程版本不符,還過於簡單(很多必要的步驟沒提到),
所以自行網上找教程.
在這裏整理一下:
假設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>
<?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>
<?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.格式化
[root@localhost hadoop-1.2.1]# bin/hadoop namenode -format
3.開啓
[root@localhost 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
[root@localhost hadoop-1.2.1]# bin/hadoop dfs -mkdir input
配置拷上去
[root@localhost hadoop-1.2.1]# hadoop dfs -copyFromLocal conf/* input
執行java文件
[root@localhost hadoop-1.2.1]# hadoop jar hadoop-examples-1.2.1.jar wordcount input output
完成: