1. 程式人生 > >超詳細的Hadoop2配置詳解

超詳細的Hadoop2配置詳解

site work .data pro class In art etc 刷新

1. 集群環境
Master 192.168.2.100
Slave1 192.168.2.101
Slave2 192.168.2.102

2. 下載安裝包
#Master
wget http://mirrors.shu.edu.cn/apache/hadoop/common/hadoop-2.8.4/hadoop-2.8.4.tar.gz
tar zxvf hadoop-2.8.4.tar.gz

3. 修改Hadoop配置文件
#Master
cd hadoop-2.8.4/etc/hadoop
vim hadoop-env.sh
export JAVA_HOME=/usr/local/src/jdk1.8.0_152

vim yarn-env.sh

export JAVA_HOME=/usr/local/src/jdk1.8.0_152

vim slaves
slave1
slave2

vim core-site.xml

<configuration>
        <property>
                <name>fs.defaultFS</name>
                <value>hdfs://master:9000</value>
        </property>
        <property>
                <name>hadoop.tmp.dir</name>
                <value>file:/usr/local/hadoop-2.8.4/tmp</value>
        </property>
</configuration>

vim 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:/usr/local/hadoop-2.8.4/dfs/name</value>
        </property>
        <property>
                <name>dfs.datanode.data.dir</name>
                <value>file:/usr/local/hadoop-2.8.4/dfs/data</value>
        </property>
        <property>
                <name>dfs.repliction</name>
                <value>3</value>
        </property>
</configuration>

vim mapred-site.xml

<configuration>
&emsp;<property>
&emsp;&emsp;<name>mapreduce.framework.name</name>
&emsp;&emsp;<value>yarn</value>
&emsp;</property>
</configuration>

vim yarn-site.xml

<configuration>
&emsp;&emsp;<property>
&emsp;&emsp;&emsp;&emsp;<name>yarn.nodemanager.aux-services</name>
&emsp;&emsp;&emsp;&emsp;<value>mapreduce_shuffle</value>
&emsp;&emsp;</property>
&emsp;&emsp;<property>
&emsp;&emsp;&emsp;&emsp;name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
&emsp;&emsp;&emsp;&emsp;<value>org.apache.hadoop.mapred.ShuffleHandler</value>
&emsp;&emsp;</property>
&emsp;&emsp;<property>
&emsp;&emsp;&emsp;&emsp;name>yarn.resourcemanager.address</name>
&emsp;&emsp;&emsp;&emsp;<value>master:8032</value>
&emsp;&emsp;</property>
&emsp;&emsp;<property>
&emsp;&emsp;&emsp;&emsp;<name>yarn.resourcemanager.scheduler.address</name>
&emsp;&emsp;&emsp;&emsp;<value>master:8030</value>
&emsp;&emsp;</property>
&emsp;&emsp;<property>
&emsp;&emsp;&emsp;&emsp;<name>yarn.resourcemanager.resource-tracker.address</name>
&emsp;&emsp;&emsp;&emsp;<value>master:8035</value>
&emsp;&emsp;</property>
&emsp;&emsp;<property>
&emsp;&emsp;&emsp;&emsp;<name>yarn.resourcemanager.admin.address</name>
&emsp;&emsp;&emsp;&emsp;<value>master:8033</value>
&emsp;&emsp;</property>
&emsp;&emsp;<property>
&emsp;&emsp;&emsp;&emsp;<name>yarn.resourcemanager.webapp.address</name>
&emsp;&emsp;&emsp;&emsp;<value>master:8088</value>
&emsp;&emsp;</property>
</configuration>

#創建臨時目錄和文件目錄
mkdir /usr/local/hadoop-2.8.4/tmp
mkdir -p /usr/local/hadoop-2.8.4/dfs/name
mkdir -p /usr/local/hadoop-2.8.4/dfs/data

4. 配置環境變量
#Master、Slave1、Slave2
vim ~/.bashrc
HADOOP_HOME=/usr/local/src/hadoop-2.8.2
export PATH=$PATH:$HADOOP_HOME/bin
#刷新環境變量
source ~/.bashrc

5. 拷貝安裝包
#Master
scp -r /usr/local/src/hadoop-2.8.4 root@slave1:/usr/local/src/hadoop-2.8.4
scp -r /usr/local/src/hadoop-2.8.4 root@slave2:/usr/local/src/hadoop-2.8.4

6. 啟動集群
#Master
#初始化Namenode
hadoop namenode -format
技術分享圖片

#啟動集群
./sbin/start-all.sh
技術分享圖片

6. 集群狀態
jps
#Master
技術分享圖片
#Slave1
技術分享圖片
#Slave2
技術分享圖片

7.監控網頁
http://master:8088
技術分享圖片

  1. 測試
    技術分享圖片

  2. 關閉集群
    ./sbin/hadoop stop-all.sh

超詳細的Hadoop2配置詳解