> Linux集群 > Hadoop >

Hadoop 2.0 安装向导 (0.23.x)

Hadoop 2.0 安装向导 (0.23.x)

最新版本的HADOOP2.0与老版本相比有不同的目录结构。

本文将介绍一种简单安装Hadoop2.0到你的电脑上的方法(Hadoop 0.23 安装)。

这有许多可以执行的方式,现在介绍以下:

如果想安装老版本的hadoop此处不再介绍。

首先一个可用的linux操作系统,此处介绍使用ubuntu

创建一个名为hadoop的用户并做以下操作:

1、  配置SSH

2、  安装JDK

3、  安装Hadoop

更新 repository
#sudo apt-get update 

下载SSH

#sudo apt-get install openssh-serveropenssh-client
#ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
#cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys 

#sudo chmod go-w $HOME $HOME/.ssh
#sudo chmod 600 $HOME/.ssh/authorized_keys
#sudo chown `whoami` $HOME/.ssh/authorized_keys 

测试SSH

#ssh localhost
OK
#exit

安装jdk

#sudo mkdir /usr/java
#cd /usr/java
#sudo wgethttp://download.oracle.com/otn-pub/java/jdk/6u31-b04/jdk-6u31-linux-i586.bin

#sudo chmod o+w jdk-6u31-linux-i586.bin
#sudo chmod +x jdk-6u31-linux-i586.bin
#sudo ./jdk-6u31-linux-i586.bin 

下载并解压hadoop2.0.x并解压到一个文件夹中,此处叫此文件夹为HADOOP_PREFIX

设置环境变量

exportHADOOP_PREFIX="/home/hadoop/software/hadoop-2.0.0-alpha"
export PATH=$PATH:$HADOOP_PREFIX/bin
export PATH=$PATH:$HADOOP_PREFIX/sbin 

exportHADOOP_MAPRED_HOME=${HADOOP_PREFIX}
export HADOOP_COMMON_HOME=${HADOOP_PREFIX}
export HADOOP_HDFS_HOME=${HADOOP_PREFIX}
export YARN_HOME=${HADOOP_PREFIX}

重启一次电脑使env / path 变量生效

Hadoop 2.x 版本中 /etc/hadoop 是默认的配置文件夹

需要在/etc/hadoop目录中修改/创建以下属性文件

编辑 core-site.xml

<configuration>

<property>
<name>fs.default.name</name>
<value>hdfs://localhost:8020</value>
<description>The name of the default file system. Either the
literal string "local" or a host:port for NDFS.
</description>
<final>true</final>
</property>
</configuration>

编辑hdfs-site.xml

<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/hadoop/workspace/hadoop_space/hadoop23/dfs/name</value>
<description>Determines where on the local filesystem the DFS name node
should store the name table. If this is a comma-delimited list
of directories then the name table is replicated in all of the
directories, for redundancy. </description>
<final>true</final>
</property> 

<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/hadoop/workspace/hadoop_space/hadoop23/dfs/data</value>
<description>Determines where on the local filesystem an DFS data node
should store its blocks. If this is a comma-delimited
list of directories, then data will be stored in all named
directories, typically on different devices.
Directories that do not exist are ignored.
</description>
<final>true</final>
</property> 

<property>
<name>dfs.replication</name>
<value>1</value>
</property> 

<property>
<name>dfs.permissions</name>
<value>false</value>
</property> 

</configuration>

路径

file:/home/hadoop/workspace/hadoop_space/hadoop23/dfs/name

file:/home/hadoop/workspace/hadoop_space/hadoop23/dfs/data

是计算机中的一些文件夹,用于存放数据和编辑文件的

路径必须用一个详细的URI描述。

 /etc/hadoop 使用以下内容创建一个文件mapred-site.xml

<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property> 

<property>
<name>mapred.system.dir</name>
<value>file:/home/hadoop/workspace/hadoop_space/hadoop23/mapred/system</value>
<final>true</final>
</property> 

<property>
<name>mapred.local.dir</name>
<value>file:/home/hadoop/workspace/hadoop_space/hadoop23/mapred/local</value>
<final>true</final>
</property> 

</configuration>

路径

file:/home/hadoop/workspace/hadoop_space/hadoop23/mapred/system

file:/home/hadoop/workspace/hadoop_space/hadoop23/mapred/local

为计算机中用于存放数据的文件夹

路径必须用一个详细的URI描述。

编辑yarn-site.xml

<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce.shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property> 

</configuration>

 /etc/hadoop 目录中

创建hadoop-env.sh 并添加:

export JAVA_HOME=/usr/java/jdk1.6.0_31

将以上JAVA_HOME 改为本机jdk安装地址

保存并准备格式化

格式化 namenode

# hdfs namenode –format

 

开始守护进程

# hadoop-daemon.sh start namenode

# hadoop-daemon.sh start datanode

可以同时启动:

# start-dfs.sh

开始 Yarn 守护进程

# yarn-daemon.sh start resourcemanager

# yarn-daemon.sh start nodemanager

或同时启动:

# start-yarn.sh

检查守护进程是否启动

# jps


2539 NameNode
2744 NodeManager
3075 Jps
3030 DataNode
2691 ResourceManager

浏览UI

打开 localhost:8088 查看资源管理页面

OK

搞定手工!

(责任编辑:IT)