1. 程式人生 > >CentOS7搭建Hadoop2.6完全分散式叢集環境

CentOS7搭建Hadoop2.6完全分散式叢集環境

3臺主機

192.168.30.207 Master

192.168.30.251 Node1

192.168.30.252 Node2

直接用root裝,省事.

有特殊需求自行add user裝.

以下步驟除非特殊說明,否則每臺都必須配置.

1.rpm -ivh XX.rpm 裝JDK 我這裝的 /usr/java/jdk1.8.0_65

   tar -zxvf hadoop-2.6.3.tar.gz 你懂的

   vi /etc/profile 環境變數

export JAVA_HOME=/usr/java/jdk1.8.0_65
export HADOOP_HOME=/hadoop/hadoop-2.6.3
export PATH=$PATH:${HADOOP_HOME}/bin

2.vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=master|node1|node2

3.vi /etc/hosts
192.168.30.207 master
192.168.30.251 node1
192.168.30.252 node2

注意:配置檔案裡面不能有 127.0.0.1 **** 這個配置 否則報錯.

4.hostnamectl set-hostname "master"|"node1"|"node2" 修改靜態瞬態以及靈活hostname.

5.reboot

6.配置免密碼登陸,看下面這個URL:

7.vi /hadoop/hadoop-2.6.3/etc/hadoop/hadoop-env.sh三臺都配


export JAVA_HOME=/usr/java/jdk1.8.0_65

8.vi /hadoop/hadoop-2.6.3/etc/hadoop/core-site.xml
        <property>
                <name>hadoop.tmp.dir</name>
                <value>/hadoop/tmp</value>
                <description>Abase for other temporary directories.</description>
        </property>
        <property>
                <name>fs.defaultFS</name>
                <value>hdfs://master:9000</value>
        </property>
        <property>
                <name>io.file.buffer.size</name>
                <value>4096</value>
        </property>

9.vi /hadoop/hadoop-2.6.3/etc/hadoop/hdfs-site.xml
        <property>
                <name>dfs.replication</name>
                <value>2</value>
                <description>nodes total count</description>
        </property>

10.cp /hadoop/hadoop-2.6.3/etc/hadoop/mapred-site.xml.template /hadoop/hadoop-2.6.3/etc/hadoop/mapred-site.xml

     vi /hadoop/hadoop-2.6.3/etc/hadoop/mapred-site.xml

    <property>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
        <final>true</final>
    </property>
    <property>
        <name>mapreduce.jobtracker.http.address</name>
        <value>master:50030</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>
    <property>
         <name>mapred.job.tracker</name>
         <value>http://master:9001</value>
    </property>

11.vi /hadoop/hadoop-2.6.3/etc/hadoop/yarn-site.xml
    <property>
         <name>yarn.resourcemanager.hostname</name>
         <value>master</value>
    </property>
    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</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>

12.vi /hadoop/hadoop-2.6.3/etc/hadoop/slaves
node1
node2

13.格式化(只在master)

cd /hadoop/hadoop-2.6.3/bin/

./hadoop namenode -format

14.啟動(只在master)

cd /hadoop/hadoop-2.6.3/sbin

./start-all.sh

幾個yes yes yes yes


15.檢視各主機程序

jps 之後如下:

master:

4080 Jps
3649 SecondaryNameNode
3462 NameNode
3798 ResourceManager

node1:

3173 DataNode
3269 NodeManager
3389 Jps

node2:
3062 DataNode
3270 Jps
3149 NodeManager

然後恭喜,安裝完畢.

如果50070和8088頁面打不開請檢查防火牆

systemctl stop firewalld.service

systemctl disable firewalld.service

自選

最後,如果想停止,則:

cd /hadoop/hadoop-2.6.3/sbin

./stop-all.sh