hadoop集群搭建笔记

以下简单记录了hadoop集群搭建的几个配置文件基本配置,在此基础上进行了mapreduce/yarn的history log拓展配置。

概述

hadoop集群搭建需要配置四个基本xml文件:(HADOOP_HOME/etc/hadoop)

 这四个配置文件将在继承对应的四个default文件上进行用户自定义设置。
 core-site.xml
 hdfs-site.xml
 yarn-site.xml
 mapred-site.xml (cp/mv from mapred-site.xml.template)

以及三个环境相关脚本文件:

主要是添加JAVA_HOME及其他必要的运行环境。
 hadoop-env.sh
 yarn-env.sh
 mapred-env.sh

最后是配置slaves,为了运行集群群起。

实验环境
基于三台centos6.8虚拟机进行搭建,三台节点hostName分别为chdp01、chdp02、chdp03,在此已完成基本网络、DNS配置。

集群规划
三台节点均担任有dataNode以及nodeManager角色,chdp01担任nameNode,chdp02担任secondaryNamNode,chdp03担任resourceManager。

一、配置文件

详细配置展开,配置代码作用见注释。

1、core-site.xml

 
		
        
                 fs.defaultFS
                  hdfs://chdp01:9000
        
        
        
               hadoop.tmp.dir
                /usr/SFT/hadoop-2.7.2/data/tmp
        
                
		
		
				fs.trash.interval
				10
				
						 Number of minutes after which the checkpoint  gets deleted.
						   If zero, the trash feature is disabled.
				 
						
		
				fs.trash.checkpoint.interval
				0
				
						  	  Number of minutes between trash checkpoints.
							  Should be smaller or equal to fs.trash.interval. If zero,
							  the value is set to the value of fs.trash.interval.
				
		
 

2、hdfs-site.xml

 
	    
        
               dfs.replication
                1
         
		
         
                  dfs.namenode.secondary.http-address
                  chdp02:50090
         
 

3 yarn-site.xml

 
		
       
               yarn.nodemanager.aux-services
               mapreduce_shuffle
       
       
       
               yarn.resourcemanager.hostname
               chdp03
       
		
        
        
               yarn.log-aggregation-enable
               true
        
        
        
                yarn.log-aggregation.retain-seconds
                604800
         
         
		
			yarn.log.server.url
			http://chdp01:20000/jobhistory/logs/
		
        
             
        
            yarn.scheduler.maximum-allocation-mb
            2048
        
        
        
            yarn.scheduler.minimum-allocation-mb
            2048
        
        
        
            yarn.nodemanager.vmem-pmem-ratio
            2.1
        
        
        
            mapred.child.java.opts
            -Xmx1024m
        

4 mapred-site


                
                        mapreduce.framework.name
                        yarn
                


        
                mapreduce.jobhistory.address
                chdp01:20001
        

        
                mapreduce.jobhistory.webapp.address
                chdp01:20000
        

5 hadoop-env.sh/yarn-env.sh/mapred-env.sh
在此三者一样的操作,配置JAVA_HOME即可

export JAVA_HOME=/usr/SFT/jdk1.8.0_191

6 slaves

列出需要启动节点ip/domain,注意文件不能有空行,每行后不能有空格,确保规范书写。
chdp01
chdp02
chdp03

注:
1、以上配置文件根据我自己的虚拟机进行配置,具体配置根据自己实际情况进行修改。
2、dataNode与resourceManager的问题: 集群启动时需要在对应的节点上运行批量启动脚本,否则将报错,如:集群环境下启动yarn时成功启动了nodemanager,但未成功启动resourcemanager

二、格式化与启动

1 format
在配置了namenode的节点上运行bin/hdfs namenode format。曾记录过在format阶段出错导致的一些问题与解决,见这篇博客:记一次hadoop namenode 启动失败问题及解决过程(启动几秒钟后又挂了)

2 启动集群

chdp01: start-dfs.sh
chdp02: start-yarn.sh

也可以写个脚本一键启动:(需要注意ssh免密配置,详见这篇博客:Host key verification failed.)
并不推荐使用sbin/start-all.sh启动yarn和hdfs,因为在大多数情况下namenode与resourcemanager不在同一台节点上,此时便会出错( Error starting ResourceManager)。

#strart hdfs and yarn
ssh chdp01 '/usr/SFT/hadoop-2.7.2/sbin/start-dfs.sh'
ssh chdp03 '/usr/SFT/hadoop-2.7.2/sbin/start-yarn.sh'

3 启动日志服务进程

mr-jobhistory-daemon.sh start  historyserver

你可能感兴趣的:(Bigdata,#,install,配置文件书写,集群搭建,hadoop)