Hadoop 2.x伪分布式环境搭建详细步骤
本文以图文结合的方式详细介绍了Hadoop2.x伪分布式环境搭建的全过程,供大家参考,具体内容如下
1、修改hadoop-env.sh、yarn-env.sh、mapred-env.sh
方法:使用notepad++(beifeng用户)打开这三个文件
添加代码:exportJAVA_HOME=/opt/modules/jdk1.7.0_67
2、修改core-site.xml、hdfs-site.xml、yarn-site.xml、mapred-site.xml配置文件
1)修改core-site.xml
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://Hadoop-senior02.beifeng.com:8020</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/opt/modules/hadoop-2.5.0/data</value> </property> </configuration>
2)修改hdfs-site.xml
<configuration> <property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>dfs.namenode.http-address</name> <value>Hadoop-senior02.beifeng.com:50070</value> </property> </configuration>
3)修改yarn-site.xml
<configuration> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.resourcemanager.hostname</name> <value>Hadoop-senior02.beifeng.com</value> </property> <property> <name>yarn.log-aggregation-enable</name> <value>true</value> </property> <property> <name>yarn.log-aggregation.retain-seconds</name> <value>86400</value> </property> </configuration>
4)修改mapred-site.xml
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>0.0.0.0:19888</value> </property> </configuration>
3、启动hdfs
1)格式化namenode:$bin/hdfsnamenode-format
2)启动namenode:$sbin/hadoop-daemon.shstartnamenode
3)启动datanode:$sbin/hadoop-daemon.shstartdatanode
4)hdfs监控web页面:http://hadoop-senior02.beifeng.com:50070
4、启动yarn
1)启动resourcemanager:$sbin/yarn-daemon.shstartresourcemanager
2)启动nodemanager:sbin/yarn-daemon.shstartnodemanager
3)yarn监控web页面:http://hadoop-senior02.beifeng.com:8088
5、测试wordcountjar包
1)定位路径:/opt/modules/hadoop-2.5.0
2)代码测试:bin/yarnjarshare/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.0.jarwordcount/input/sort.txt/output6/
运行过程:
16/05/0806:39:13INFOclient.RMProxy:ConnectingtoResourceManageratHadoop-senior02.beifeng.com/192.168.241.130:8032
16/05/0806:39:15INFOinput.FileInputFormat:Totalinputpathstoprocess:1
16/05/0806:39:15INFOmapreduce.JobSubmitter:numberofsplits:1
16/05/0806:39:15INFOmapreduce.JobSubmitter:Submittingtokensforjob:job_1462660542807_0001
16/05/0806:39:16INFOimpl.YarnClientImpl:Submittedapplicationapplication_1462660542807_0001
16/05/0806:39:16INFOmapreduce.Job:Theurltotrackthejob:http://Hadoop-senior02.beifeng.com:8088/proxy/application_1462660542807_0001/
16/05/0806:39:16INFOmapreduce.Job:Runningjob:job_1462660542807_0001
16/05/0806:39:36INFOmapreduce.Job:Jobjob_1462660542807_0001runninginubermode:false
16/05/0806:39:36INFOmapreduce.Job:map0%reduce0%
16/05/0806:39:48INFOmapreduce.Job:map100%reduce0%
16/05/0806:40:04INFOmapreduce.Job:map100%reduce100%
16/05/0806:40:04INFOmapreduce.Job:Jobjob_1462660542807_0001completedsuccessfully
16/05/0806:40:04INFOmapreduce.Job:Counters:49
3)结果查看:bin/hdfsdfs-text/output6/par*
运行结果:
hadoop2
jps 1
mapreduce 2
yarn 1
6、MapReduce历史服务器
1)启动:sbin/mr-jobhistory-daemon.shstarthistoryserver
2)webui界面:http://hadoop-senior02.beifeng.com:19888
7、hdfs、yarn、mapreduce功能
1)hdfs:分布式文件系统,高容错性的文件系统,适合部署在廉价的机器上。
hdfs是一个主从结构,分为namenode和datanode,其中namenode是命名空间,datanode是存储空间,datanode以数据块的形式进行存储,每个数据块128M
2)yarn:通用资源管理系统,为上层应用提供统一的资源管理和调度。
yarn分为resourcemanager和nodemanager,resourcemanager负责资源调度和分配,nodemanager负责数据处理和资源
3)mapreduce:MapReduce是一种计算模型,分为Map(映射)和Reduce(归约)。
map将每一行数据处理后,以键值对的形式出现,并传给reduce;reduce将map传过来的数据进行汇总和统计。
以上就是本文的全部内容,希望对大家的学习有所帮助。