搭建Hadoop2.6.4集群 Zookeeper版

集群搭建

Files: hadoop集群搭建
Tags: Mar 10, 2019

1.搭建前提

  • centOS6.7 集群

hadoop1 192.168.111.133

hadoop2 192.168.111.134

hadoop3 192.168.111.135

  • 安装JDK,zookeeper

2.规划

安装目录:/home/hadoop1/apps

数据目录:/hoem/hadoop1/data1/hadoopdata

journal目录:[root@skycloud1 hadoop]# mkdir - p /opt/hadoop-2.6.4/journal

3.上传解压

在这里插入图片描述
tar -zxvf hadoop-2.6.4.tar.gz

4.修改配置文件

  • 修改core-site.xml

    [root@hadoop1 hadoop]# pwd
    /home/hadoop1/apps/hadoop-2.6.4/etc/hadoop
    
    [root@hadoop1 hadoop]# vi core-site.xml 
    
    
    
    fs.defaultFS
    hdfs://hadoop1:9000
    
    
    
    hadoop.tmp.dir
    /home/hadoop1/data1/hadoopdata
    
    
    
    ha.zookeeper.quorum
    hadoop1:2181,hadoop2:2181,hadoop3:2181
    
    
    
  • 修改hadoop-env.sh

    加入以下配置(JDK)

    export JAVA_HOME=/usr/local/jdk1.7.0_80

  • 修改 hdfs-site.xml

    
    
    
    dfs.nameservices
    mycluster
    
    
    
    dfs.ha.namenodes.mycluster
    nn1,nn2
    
    
    
    dfs.namenode.rpc-address.mycluster.nn1
    hadoop1:9000
    
    
    
    dfs.namenode.http-address.mycluster.nn1
    hadoop1:50070
    
    
    
    dfs.namenode.rpc-address.mycluster.nn2
    hadoop2:9000
    
    
    
    dfs.namenode.http-address.mycluster.nn2
    hadoop:50070
    
    
    
    dfs.namenode.shared.edits.dir
    qjournal://hadoop1:8485;hadoop2:8485;hadoop3:8485/mycluster
    
    
    
    dfs.journalnode.edits.dir
    /opt/hadoop-2.6.4/journal
    
    
    
    dfs.ha.automatic-failover.enabled
    true
    
    
    
    dfs.client.failover.proxy.provider.mycluster
    org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider
    
    
    
    dfs.ha.fencing.methods
    
    sshfence
    shell(/bin/true)
    
    
    
    
    dfs.ha.fencing.ssh.private-key-files
    /root/.ssh/id_rsa
    
    
    
    dfs.ha.fencing.ssh.connect-timeout
    30000
    
    
    
  • 修改slaves

    hadoop1
    hadoop2
    hadoop3

  • 修改 mapred-env.sh

    加入以下配置(JDK)

    export JAVA_HOME=/usr/local/jdk1.7.0_80

  • 修改 yarn-site.xml

    
    
    
    yarn.resourcemanager.ha.enabled
    true
    
    
    
    yarn.resourcemanager.cluster-id
    yrc
    
    
    
    yarn.resourcemanager.ha.rm-ids
    rm1,rm2
    
    
    
    yarn.resourcemanager.hostname.rm1
    hadoop1
    
    
    yarn.resourcemanager.hostname.rm2
    hadoop2
    
    
    
    yarn.resourcemanager.zk-address
    hadoop1:2181,hadoop2:2181,hadoop3:2181
    
    
    yarn.nodemanager.aux-services
    mapreduce_shuffle
    
    
    
  • 修改 yarn-env.sh

    添加一下配置(JDK)

    export JAVA_HOME=/usr/local/jdk1.7.0_80/

5.配置hadoop的环境变量

#hadoop
export HADOOP_HOME=/home/hadoop1/apps/hadoop-2.6.4
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:

配置完后查看hadoop版本 hadoop version

6.发送到其它机器上

每台虚拟机中的hadoop安装包的目录以及配置信息必须一致

scp -r ~/apps/hadoop-2.6.4/ hadoop2:~/apps/
scp -r ~/apps/hadoop-2.6.4/ hadoop3:~/apps/

7.启动及bug解决

启动报两个bug:

  • 格式化namenode失败 hadoop namenode -format

    解决办法:

      先用./zkServer.sh start 启动各个zookeeper,再用./ hadoop-daemon.sh start journalnode启动
      各个NodeName上的 JournalNode进程,之后再  hadoop  namenode  -format 就成功
    
  • 在hadoop1上 jps 没有namenode节点

      1、先运行stop-all.sh
      
      2、删除原目录,即core-site.xml下配置的hadoop.tmp.dir所指向的目录,重新建立配置的空目录 格式化namdenode,hadoop namenode -format
      
      3、运行start-all.sh
    

至此集群搭建完:访问:http://192.168.111.133:50070,可看到以下界面
搭建Hadoop2.6.4集群 Zookeeper版_第1张图片

8.启动集群脚本

所在目录:  /home/hadoop1/start_sh

创建脚本:  vi hadoop.sh

脚本内容:
#!/bin/bash
cd /home/hadoop1/apps/hadoop-2.6.4/sbin
./start-all.sh

启动脚本:
sh hadoop.sh

你可能感兴趣的:(hadoop)