设为首页 收藏本站
查看: 567|回复: 0

[经验分享] hadoop(3)Upgrade to YARN and Installation

[复制链接]

尚未签到

发表于 2016-12-6 06:59:04 | 显示全部楼层 |阅读模式
  hadoop(3)Upgrade to YARN and Installation

1. Introduction
Hadoop 1.0
HDFS and MapReduce, HDFS contains NameNode and multiple DataNode, MapReduce contains JobTracker and mutiple TaskTracker.

Hadoop 1.x, 0.21.X, 0.22.x

Hadoop 2.0
YARN(Yet Another Resource Negotiator)
JobTracker ——> ResourceManager, ApplicationMaster
Hadoop 0.23.x, 2.x

1. Installation

Try to build it my self.
Check Protocol Buffer
>protoc --version
libprotoc 2.5.0

Check the Java Version
>java -version
java version "1.6.0_65"

Create binary distribution without native code and without documentation:
>mvn package -Pdist -DskipTests -Dtar

If there is memory issue, then go this command, but till now, there is no memory issue for me
>export MAVEN_OPTS="-Xms256m -Xmx512m"

After build, I get this file in the diet directory. hadoop-2.4.0.tar.gz

Unzip the file
>tar zxvf hadoop-2.4.0.tar.gz
>sudo ln -s /Users/carl/tool/hadoop-2.4.0 /opt/hadoop-2.4.0
>sudo ln -s /opt/hadoop-2.4.0 /opt/hadoop

Edit the environment
export HADOOP_PREFIX=/opt/hadoop
export PATH=/opt/hadoop/bin:$PATH

>hadoop version
Hadoop 2.4.0 Subversion Unknown -r Unknown Compiled by carl on 2014-06-20T21:21Z

2. Standalone Operation
>mkdir input
>cp /opt/hadoop/etc/hadoop/*.xml input/
>hadoop jar /opt/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.4.0.jar grep input output 'dfs[a-z.]+'
>cat output/*

That is NON distribute mode. Single Java Process.

3. Pseudo Distributed Mode
Each Hadoop Daemon runs in a separate Java Process.

Setup ssh
I can directly ssh on my localhost. So I thought I already have done this.
>ssh-keygen -t dsa -P ‘’ -f ~/.ssh/id_dsa
>cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

Configuration
>vi etc/hadoop/core-site.xml

<configuration> 
    <property>       
      <name>fs.defaultFS</name>       
      <value>hdfs://localhost:9000</value> 
    </property>
  </configuration>

>vi etc/hadoop/hdfs-site.xml

<configuration> 
    <property>       
      <name>dfs.replication</name>       
      <value>1</value> 
    </property>
  </configuration>

Run the MapReduce job locally.

Format the filesystem
>hdfs namenode -format

Start the HDFS
>sbin/start-dfs.sh

Visit the overview pages from WEB UI
http://localhost:50070/dfshealth.html#tab-overview

Create the directories on HDFS
>hdfs dfs -mkdir /user
>hdfs dfs -mkdir /user/sillycat

Warning Message
2014-06-23 11:05:44.531 java[10276:1003] Unable to load realm info from SCDynamicStore 14/06/23 11:05:44 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable

I know that I did not compile that native-hadoop library, so never mind.

Put the my local files to HDFS
>hdfs dfs -put etc/hadoop /user/sillycat/input

Run the hadoop command to start the jobs on HDFS
>hadoop jar /opt/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.4.0.jar grep /user/sillycat/input /user/sillycat/output 'dfs[a-z.]+'

Fetch the files from HDFS to local
>hdfs dfs -get /user/sillycat/output /Users/carl/work/hadoop/output2

Check the results from local disk
>cat /Users/carl/work/hadoop/output2/*

Chck the results from HDFS
>hdfs dfs -cat /user/sillycat/output/*

Stop the HDFS
>sbin/stop-dfs.sh

Run MapReduce Job on YARN
Prepare the Configuration
>cp etc/hadoop/mapred-site.xml.template etc/hadoop/mapred-site.xml

>vi etc/hadoop/mapred-site.xml

<configuration> 
    <property>       
      <name>mapreduce.framework.name</name>       
      <value>yarn</value> 
    </property>
  </configuration>


>vi etc/hadoop/yarn-site.xml

<configuration> 
    <property>       
     <name>yarn.nodemanager.aux-services</name>              
     <value>mapreduce_shuffle</value> 
    </property>
  </configuration>

Start the HDFS
>sbin/start-dfs.sh

Start the YARN
>sbin/start-yarn.sh

Web UI to track the jobs
http://localhost:8088/cluster

Setup the configuration files
>hdfs dfs -put /opt/hadoop/etc/hadoop /user/carl/input

Run the tasks
>hadoop jar /opt/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.4.0.jar grep input output 'dfs[a-z.]+'

But after I run the job, I did not see I get a good results. Then I go and check the log file from here.
/HADOOP_HOME/logs/yarn-carl-nodemanager-sparkworker1.local.log

Error Message
java.lang.RuntimeException: No class defined for mapreduce_shffle        at org.apache.hadoop.yarn.server.nodemanager.containermanager.AuxServices.serviceInit(AuxServices.java:109)        at org.apache.hadoop.service.AbstractService.init(AbstractService.java:163)        at org.apache.hadoop.service.CompositeService.serviceInit(CompositeService.java:107)

Solution:
I get a typo in the configuration file. Change that. This should be the right value <value>mapreduce_shuffle</value>

Error Message:
14/06/23 12:20:21 INFO mapreduce.Job: Job job_1403543828091_0003 failed with state FAILED due to: Application application_1403543828091_0003 failed 2 times due to AM Container for appattempt_1403543828091_0003_000002 exited with  exitCode: 127 due to: Exception from container-launch: org.apache.hadoop.util.Shell$ExitCodeException: org.apache.hadoop.util.Shell$ExitCodeException: at org.apache.hadoop.util.Shell.runCommand(Shell.java:505) at org.apache.hadoop.util.Shell.run(Shell.java:418) at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:650)

Solution:
Find the log file from here http://localhost:8042/node/containerlogs/container_1403543828091_0003_01_000001/carl/stderr/?start=-4096

I saw this kind of error
/bin/bash: /bin/java: No such file or directory

>sudo ln -s /usr/bin/java /bin/java

Then run the command to execute the job
>hadoop jar /opt/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.4.0.jar grep input output 'dfs[a-z.]+'

It works.

References:
http://sillycat.iyunv.com/blog/1556106
http://sillycat.iyunv.com/blog/1556107

http://www.iteblog.com/archives/category/hadoop
http://my.oschina.net/leejun2005/blog/97802

Official Document
http://hadoop.apache.org/docs/r2.4.0/
http://www.bizdirusa.com/mirrors/apache/hadoop/common/ download URL

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-310117-1-1.html 上篇帖子: (zz)Debugging Hadoop applications using your Eclipse 下篇帖子: Hadoop中CombineFileInputFormat详解
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表