美文网首页
1.4 集群搭建

1.4 集群搭建

作者: 猫头木有鹰 | 来源:发表于2018-01-26 22:42 被阅读0次
    解压安装,配置环境变量

       sudo chown -R admin:admin /opt/software/hadoop-2.7.2.tar.gz
       sudo chmod -R 755 /opt/software/hadoop-2.7.2.tar.gz
       tar -zxvf /opt/software/hadoop-2.7.2.tar.gz -C /opt/module
       cd /opt/module/hadoop-2.7.2
       sudo vim /etc/profile
       vim ~/.bashrc

    # HADOOP_ENV
    HADOOP_HOME=$BASE_DIR/hadoop-2.5.0-cdh5.3.6
    PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
    export HADOOP_HOME PATH
    

       source /etc/profile
       source ~/.bashrc

    修改配置

       vim etc/hadoop/core-site.xml

    <!-- 定义hdfs的namenode节点 -->
       <property>
               <name>fs.defaultFS</name>
               <value>hdfs://hadoop102:9000</value>
       </property>
     <!-- hdfs 的是数据存放目录 -->
       <property>
               <name>hadoop.tmp.dir</name>
               <value>/opt/module/hadoop-2.7.2/data/tmp</value>
       </property>
    
    

           vim etc/hadoop/hdfs-site.xml

      <!-- 定义hdfs重要性略次于namenode节点的sn节点 -->
     <property>
               <name>dfs.namenode.secondary.http-address</name>
               <value>hadoop103:50090</value>
     </property>   
    <!-- hdfs存放数据的副本数 -->
     <property>
               <name>dfs.replication</name>
               <value>3</value>
       </property>
    

           vim etc/hadoop/yarn-site.xml

    <!-- RM 资源管理节点 -->
     <property>
             <name>yarn.resourcemanager.hostname</name>
             <value>hadoop104</value>
     </property> 
     
    <!-- yarn 资源管理器洗牌策略 -->
     <property>
             <name>yarn.nodemanager.aux-services</name>
             <value>mapreduce_shuffle</value>
     </property>
    

           vim etc/hadoop/mapred-site.xml

     <!-- 声明 MR 运行在yarn上-->   
     <property>
            <name>mapreduce.framework.name</name>
            <value>yarn</value>
     </property>
    

           vim /opt/module/hadoop-2.7.2/etc/hadoop/slaves

    hadoop102
    hadoop103
    hadoop104
    
    集群分发

    方案1:
       scp -r /opt/module/hadoop-2.7.2 hadoop103:/opt/module
       scp -r /opt/module/hadoop-2.7.2 hadoop104:/opt/module
    方案2:
       sudo vim /usr/local/bin/xsync

    #!/bin/bash
    
    if (( $# == 0 ));then
      echo "no args"       
      exit 0
    fi
    
    USER=`whoami`
    DIR=`cd -P $(dirname $1);pwd`
    TARGET=`basename $1`
    MYSELF=`hostname`
    
    for (( host = 102 ; host <= 104 ; host++ ))
    do
     if  [ $MYSELF != hadoop$host ];then
          echo "-------- Send $DIR/$TARGET to $USER@hadoop$host ---------"
          rsync -rvl $DIR/$TARGET $USER@hadoop$host:$DIR
     fi
    done
    
    exit 0
    

          sudo chown admin:admin /usr/local/bin/xsync
          sudo chmod 755 /usr/local/bin/xsync
          xsync /opt/module/hadoop-2.7.2

    格式化

     [admin@hadoop102 hadoop-2.7.2]$ bin/hdfs namenode -format

    启动服务

    方案1:逐个节点启动
      sbin/hadoop-daemon.sh start|stop namenode|datanode|secondarynamenode
      sbin/yarn-daemon.sh start|stop resourcemanager|nodemanager
    方案2:逐模块启动(Nn节点启动hdfs,Rm节点启动yarn)
      [admin@hadoop102 hadoop-2.7.2]$ sbin/start-dfs.sh
      [admin@hadoop102 hadoop-2.7.2]$ sbin/stop-dfs.sh
      [admin@hadoop104 hadoop-2.7.2]$ sbin/start-yarn.sh
      [admin@hadoop104 hadoop-2.7.2]$ sbin/stop-yarn.sh
    方案3:群起
      [admin@hadoop102 hadoop-2.7.2]$ sbin/start-all.sh
      [admin@hadoop102 hadoop-2.7.2]$ sbin/stop-all.sh

    查看运行状态

    【jps 查看进程】
      [admin@hadoop102 hadoop-2.7.2]$ jps
    【浏览器查看端口服务】
    http://hadoop102:50070

    hdfs.jpeg http://hadoop104:8088
    yarn.jpeg

    相关文章

      网友评论

          本文标题:1.4 集群搭建

          本文链接:https://www.haomeiwen.com/subject/erhgaxtx.html