Hadoop全分布式安装


 Hadoop的全分布式安装    
  zookeeper管理节点
  Journalnode实时备份
  FailoverControll类实现 切换namenode的状态 active  standby

 

  需要配置的信息(3台云主机)
  【*练习过程中关闭防火墙,里面用到的zookeeper没写配置,到博客里面找找*】
  step1:配置主机名 /etc/hosts
    第一台:hadoop01
    第二台:hadoop02
    第三台:hadoop03
    source 一下
  step2:配置免密登陆
    生成密钥ssh-keygen
    进行复制ssh-copy-id 用户名@主机  需要复制到所有的主机
    然后重启
    #reboot
  step3:配置Hadoop
    配置 hadoop-env.sh 配置完成需要source
    配置 core-site.xml
    配置 hdfs-site.xml
    配置 mapred-site.xml  cp mapred-site.xml.template mapred-site.xml
    配置 yarn-site.xml
    编辑 slaves  添加datanode节点
    编辑环境变量 /etc/profile
  step4:具体配置
   【1】hadoop.env.sh
     JAVA_HOME=/home/preSoftware/jdk1.8
     HADOOP_CONF_DIR=/home/software/hadoop-2.7.1/etc/hadoop
     需要使配置生效 source hadoop.env.sh

 

   【2】core-site.xml
           
           
            fs.defaultFS        
            hdfs://ns
           

           
           
            hadoop.tmp.dir
                  /home/software/hadoop-2.7.1/tmp
           

           
           
                  ha.zookeeper.quorum
           
                  hadoop01:2181,hadoop02:2181,hadoop03:2181
           

                  
   【3】hdfs-site.xml
     
           
                  dfs.nameservices
                  ns
           

     
     
     
      dfs.ha.namenodes.ns
      nn1,nn2
     

     
           
           
                  dfs.namenode.rpc-address.ns.nn1
                  hadoop01:9000
           

     
     
      dfs.namenode.http-address.ns.nn1
      hadoop01:50070
     

 

           
                 
                  dfs.namenode.rpc-address.ns.nn2
                  hadoop02:9000
                 

     
     
      dfs.namenode.http-address.ns.nn2
      hadoop02:50070
     

 

     
     <--,namenode2可以从journalnode集群里的指定位置上获取信息,达到热备效果-->
     
      dfs.namenode.shared.edits.dir
      qjournal://hadoop01:8485;hadoop02:8485;hadoop03:8485/ns
     

 

     
     
      dfs.journalnode.edits.dir
      /home/software/hadoop-2.7.1/tmp/journal
     

 

     
     
      dfs.ha.automatic-failover.enabled
      true
     

     
     
            dfs.client.failover.proxy.provider.ns
            org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider
     

     
     
      dfs.ha.fencing.methods
      sshfence
     

     
     
      dfs.ha.fencing.ssh.private-key-files
      /root/.ssh/id_rsa
     

     
             
                  dfs.namenode.name.dir  
                  file:///home/software/hadoop-2.7.1/tmp/hdfs/name  
           
 
     
       
                  dfs.datanode.data.dir  
                  file:///home/software/hadoop-2.7.1/tmp/hdfs/data  
           

       
       
      dfs.replication  
      3  
     

                  
       
      dfs.permissions  
      false  
     

   【4】mapred-site.xml 
     
       
      mapreduce.framework.name  
      yarn  
     

   【5】yarn-site.xml
     
           
                  yarn.resourcemanager.ha.enabled
                  true
           

 

     
           
                  yarn.resourcemanager.ha.rm-ids
                  rm1,rm2
           

 

     
           
                  yarn.resourcemanager.hostname.rm1
                  hadoop01
           

 

     
           
                  yarn.resourcemanager.hostname.rm2
                  hadoop03
           

 

     
           
                  yarn.resourcemanager.recovery.enabled
                  true
           

 

     
     
                  yarn.resourcemanager.store.class
                  org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore
           

 

     
           
                  yarn.resourcemanager.zk-address
                  hadoop01:2181,hadoop02:2181,hadoop03:2181
           

     
           
                  yarn.resourcemanager.cluster-id
                  ns-yarn
           

 

     
     
             
                  yarn.nodemanager.aux-services  
                  mapreduce_shuffle  
           

 

     
     
           
                  yarn.resourcemanager.hostname
            hadoop03
           

   
   【6】slaves
     
     hadoop01
     hadoop02
     hadoop03
   【7】配置环境变量
     export HADOOP_HOME=/home/software/hadoop-2.7.1
     export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
   【8】创建对应的存储文件的目录
     tmp/{hdfs,journal}   hdfs/{data,name}
  step5:
   选择其中一个节点进行zookeeper格式化注册
   #hdfs zkfc -formatZK
  step6:
   分别启动Journalnode 因为我这里设置hadoop01和hadoop02作为namenode所以只需要启动这两个节点即可
   #hadoop-daemon.sh start journalnode
  step7:
   格式化namenode节点 也就是hadoop01和hadoop02
   #hadoop namenode -format
   INFO common.Storage: Storage directory /home/software/hadoop-2.7.1/tmp/hdfs/name has been successfully formatted.
   出现successfully formatted 表示成功
  step8:
   启动namenode节点 hadoop01和hadoop02
   #hadoop-daemon.sh start namenode
  step9:
   启动datanode  slaves文件中配置的就是datanode节点
   #hadoop-daemon.sh start datanode
  step10:
   启动zkfc实现namenode状态的切换 active(master)和standby(热备)
   #hadoop-daemon.sh start zkfc
  step11:
   在hadoop01节点启动yarn 配置mapred-site.xml 这个命令可以在任何节点运行,只需在其中一个节点运行一次
   #start-yarn.sh
  step12:
   在hadoop03节点上启动resourcemanager     配置在yarn-site.xml
   #yarn-daemon.sh start resourcemanger
  配置完成进行访问
  web: http://ip:50070    ip就是namenode节点的ip
  点击overview 看到一个standby 另外一台是active
  完成

关闭命令 在namenode(active)节点 #stop-all.sh

这个命令一旦运行,所有的namenode和datanode以及Journalnode都将关闭

但是manager*没有关闭我搜了一下关闭命令如下

关闭Resourcemanager       # yarn-daemon.sh stop resourcemanager   
  

你可能感兴趣的:(Hadoop)