当前位置: > Linux集群 > Hadoop >

hadoop2.4.1完全分布式安装

时间:2014-12-30 23:03来源:linux.it.net.cn 作者:IT

本文(亲测实录)主要列出在安装hadoop 2.4.1过程中各个文件配置情况,其他步骤请参考网络其他资源进行操作

1、JDK安装和SSH互信(略过)

2、各节点IP和hostname如下(各节点需配置)
[hadoop@master ~]$ cat /etc/hosts

127.0.0.1       localhost
100.12.56.221   slave-1
100.12.56.222   slave-2
100.12.56.223   slave-3
100.12.56.224   slave-4
100.12.56.227   slave-5
100.12.56.228   master

3、各节点操作使用hadoop用户进行,hadoop安装目录在/home/hadoop/hadoop-2.4.1下

4、JAVA环境变量配置如下
[hadoop@master hadoop-2.4.1]$ cat /etc/profile(各节点需配置)
export JAVA_HOME=/usr/java/jdk1.7.0_51
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=.:$JAVA_HOME/bin:$PATH

export PATH=/home/hadoop/hadoop-2.4.1/bin:/home/hadoop/hadoop-2.4.1/bin:$PATH
#该环境变量的配置,让shell能够查找到hadoop的类路径

5、master创建下这几个目录(这几个目录不知道是否必须创建,本例实验时创建了目录,实验成功)
mkdir -p /home/hadoop/tmp
mkdir -p /home/hadoop/dfs/name
mkdir -p /home/hadoop/dfs/data

6、编辑hadoop-env.sh(master节点)
vi /home/hadoop/hadoop-2.4.1/etc/hadoop/hadoop-env.sh
#添加如下内容
export JAVA_HOME=/usr/java/jdk1.7.0_51

7、编辑yarn-env.sh(master节点)
vi /home/hadoop/hadoop-2.4.1/etc/hadoop/yarn-env.sh
#添加如下内容
export JAVA_HOME=/usr/java/jdk1.7.0_51

8、编辑slaves(master节点)
vi /home/hadoop/hadoop-2.4.1/etc/hadoop/slaves
#添加如下内容
slave-1
slave-2
slave-3
slave-4
slave-5

9、编辑core-site.xml(master节点)
vi /home/hadoop/hadoop-2.4.1/etc/hadoop/core-site.xml
#添加如下内容
<configuration>
  <property>
    <name>fs.defaultFS</name>
    <value>hdfs://master:8020</value>
  </property>

  <property>
    <name>io.file.buffer.size</name>
    <value>131072</value>
  </property>

  <property>
    <name>hadoop.tmp.dir</name>
    <value>file:/home/hadoop/tmp</value>
    <description>Abase for other temporary   directories.</description>
  </property>

  <property>
    <name>hadoop.proxyuser.hadoop.hosts</name>
    <value>*</value>
  </property>

  <property>
    <name>hadoop.proxyuser.hadoop.groups</name>
    <value>*</value>
  </property>
</configuration>


10、编辑hdfs-site.xml(master节点)
vi /home/hadoop/hadoop-2.4.1/etc/hadoop/hdfs-site.xml
<configuration>
  <property>
    <name>dfs.namenode.secondary.http-address</name>
    <value>master:9001</value>
  </property>

  <property>
    <name>dfs.namenode.name.dir</name>
    <value>file:/home/hadoop/dfs/name</value>
  </property>

  <property>
    <name>dfs.datanode.data.dir</name>
    <value>file:/home/hadoop/dfs/data</value>
  </property>

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

  <property>
    <name>dfs.webhdfs.enabled</name>
    <value>true</value>
  </property>

</configuration>

11、编辑mapred-site.xml(master节点)
vi /home/hadoop/hadoop-2.4.1/etc/hadoop/mapred-site.xml
<configuration>
  <property>
    <name>mapreduce.framework.name</name>
    <value>yarn</value>
  </property>

  <property>
    <name>mapreduce.jobhistory.address</name>
    <value>master:10020</value>
  </property>

  <property>
    <name>mapreduce.jobhistory.webapp.address</name>
    <value>master:19888</value>
  </property>
</configuration>

12、编辑yarn-site.xml(master节点)
vi /home/hadoop/hadoop-2.4.1/etc/hadoop/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>
  <property>
    <name>yarn.resourcemanager.address</name>
    <value>master:8032</value>
  </property>
  <property>
    <name>yarn.resourcemanager.scheduler.address</name>
    <value>master:8030</value>
  </property>
  <property>
    <name>yarn.resourcemanager.resource-tracker.address</name>
    <value>master:8031</value>
  </property>
  <property>
    <name>yarn.resourcemanager.admin.address</name>
    <value>master:8033</value>
  </property>
  <property>
    <name>yarn.resourcemanager.webapp.address</name>
    <value>master:8088</value>
  </property>
</configuration>

13、拷贝软件到其他节点(master节点)
scp -r /home/hadoop/hadoop-2.4.1 slave-1:/home/hadoop/
scp -r /home/hadoop/hadoop-2.4.1 slave-2:/home/hadoop/
scp -r /home/hadoop/hadoop-2.4.1 slave-3:/home/hadoop/
scp -r /home/hadoop/hadoop-2.4.1 slave-4:/home/hadoop/
scp -r /home/hadoop/hadoop-2.4.1 slave-5:/home/hadoop/

14、格式化hdfs文件系统(master节点)
hdfs namenode –format

15、启动yarn
/home/hadoop/hadoop-2.4.1/sbin/start-yarn.sh(master节点)
16、jps
master节点:
[hadoop@master sbin]$ jps
8783 NameNode
8981 SecondaryNameNode
9759 Jps
9132 ResourceManager

slave节点:
[hadoop@slave-5 ~]$ jps
6911 DataNode
7035 NodeManager
7281 Jps

17、网页上访问
http://master:8088/

(责任编辑:IT)
------分隔线----------------------------