1.深入理解 Hadoop (七)YARN资源管理和调度详解
2.å¦ä½åå¸å¼è¿è¡mapreduceç¨åº
深入理解 Hadoop (七)YARN资源管理和调度详解
Hadoop最初为批处理设计,其资源管理与调度仅支持FIFO机制。然而,随着Hadoop的普及与用户量的增加,单个集群内的应用程序类型与数量激增,FIFO调度机制难以高效利用资源,zabbix源码安装详解也无法满足不同应用的服务质量需求,故需设计适用于多用户的资源调度系统。
YARN采用双层资源调度模型:ResourceManager中的资源调度器分配资源给ApplicationMaster,由YARN决定;ApplicationMaster再将资源分配给内部任务Task,用户自定。YARN作为统一调度系统,满足调度规范的分布式应用皆可在其中运行,调度规范包括定义ApplicationMaster向RM申请资源,AM自行完成Container至Task分配。源码之家的源码有病毒吗YARN采用拉模型实现异步资源分配,RM分配资源后暂存缓冲区,等待AM通过心跳获取。
Hadoop-2.x版本中YARN提供三种资源调度器,分别为...
YARN的队列管理机制包括用户权限管理与系统资源管理两部分。CapacityScheduler的核心特点包括...
YARN的更多理解请参考官方文档:...
在分布式资源调度系统中,资源分配保证机制常见有...
YARN采用增量资源分配,安卓源码和sdk源码下载避免浪费但不会出现资源饿死现象。YARN默认资源分配算法为DefaultResourceCalculator,专注于内存调度。DRF算法将最大最小公平算法应用于主资源上,解决多维资源调度问题。实例分析中,系统中有9个CPU和GB RAM,影视APP源码前后端整套源码两个用户分别运行两种任务,所需资源分别为...
资源抢占模型允许每个队列设定最小与最大资源量,以确保资源紧缺与极端情况下的需求。资源调度器在负载轻队列空闲时会暂时分配资源给负载重队列,仅在队列突然收到新提交应用程序时,调度器将资源归还给该队列,避免长时间等待。asp下载站源码sp源码
YARN最初采用平级队列资源管理,新版本改用层级队列管理,优点包括...
CapacityScheduler配置文件capacity-scheduler.xml包含资源最低保证、使用上限与用户资源限制等参数。管理员修改配置文件后需运行"yarn rmadmin -refreshQueues"。
ResourceScheduler作为ResourceManager中的关键组件,负责资源管理和调度,采用可插拔策略设计。初始化、接收应用和资源调度等关键功能实现,RM收到NodeManager心跳信息后,向CapacityScheduler发送事件,调度器执行一系列操作。
CapacityScheduler源码解读涉及树型结构与深度优先遍历算法,以保证队列优先级。其核心方法包括...
在资源分配逻辑中,用户提交应用后,AM申请资源,资源表示为Container,包含优先级、资源量、容器数目等信息。YARN采用三级资源分配策略,按队列、应用与容器顺序分配空闲资源。
对比FairScheduler,二者均以队列为单位划分资源,支持资源最低保证、上限与用户限制。最大最小公平算法用于资源分配,确保资源公平性。
最大最小公平算法分配示意图展示了资源分配过程与公平性保证。
å¦ä½åå¸å¼è¿è¡mapreduceç¨åº
ããä¸ã é¦å è¦ç¥éæ¤åæ 转载
ããè¥å¨windowsçEclipseå·¥ç¨ä¸ç´æ¥å¯å¨mapreducç¨åºï¼éè¦å æhadoopé群çé ç½®ç®å½ä¸çxmlé½æ·è´å°srcç®å½ä¸ï¼è®©ç¨åºèªå¨è¯»åé群çå°ååå»è¿è¡åå¸å¼è¿è¡(æ¨ä¹å¯ä»¥èªå·±åjava代ç å»è®¾ç½®jobçconfigurationå±æ§)ã
ããè¥ä¸æ·è´ï¼å·¥ç¨ä¸binç®å½æ²¡æå®æ´çxmlé ç½®æ件ï¼åwindowsæ§è¡çmapreduceç¨åºå ¨é¨éè¿æ¬æºçjvmæ§è¡ï¼ä½ä¸åä¹æ¯å¸¦æâlocal"åç¼çä½ä¸ï¼å¦ job_local_ã è¿ä¸æ¯çæ£çåå¸å¼è¿è¡mapreduceç¨åºã
ãã估计å¾ç 究org.apache.hadoop.conf.Configurationçæºç ï¼åæ£xmlé ç½®æ件ä¼å½±åæ§è¡mapreduce使ç¨çæ件系ç»æ¯æ¬æºçwindowsæ件系ç»è¿æ¯è¿ç¨çhdfsç³»ç»; è¿æå½±åæ§è¡mapreduceçmapperåreducerçæ¯æ¬æºçjvmè¿æ¯é群éé¢æºå¨çjvm
ããäºã æ¬æçç»è®º
ãã第ä¸ç¹å°±æ¯ï¼ windowsä¸æ§è¡mapreduceï¼å¿ é¡»æjarå å°ææslaveèç¹æè½æ£ç¡®åå¸å¼è¿è¡mapreduceç¨åºãï¼ææ个éæ±æ¯è¦windowsä¸è§¦åä¸ä¸ªmapreduceåå¸å¼è¿è¡ï¼
ãã第äºç¹å°±æ¯ï¼ Linuxä¸ï¼åªéæ·è´jaræ件å°é群masterä¸,æ§è¡å½ä»¤hadoop jarPackage.jar MainClassNameå³å¯åå¸å¼è¿è¡mapreduceç¨åºã
ãã第ä¸ç¹å°±æ¯ï¼ æ¨è使ç¨éä¸ï¼å®ç°äºèªå¨æjarå 并ä¸ä¼ ï¼åå¸å¼æ§è¡çmapreduceç¨åºã
ããéä¸ã æ¨è使ç¨æ¤æ¹æ³ï¼å®ç°äºèªå¨æjarå 并ä¸ä¼ ï¼åå¸å¼æ§è¡çmapreduceç¨åºï¼
ãã请å åèåæäºç¯ï¼
ããHadoopä½ä¸æ交åæï¼ä¸ï¼~~ï¼äºï¼
ããå¼ç¨åæçé件ä¸EJob.javaå°ä½ çå·¥ç¨ä¸ï¼ç¶åmainä¸æ·»å å¦ä¸æ¹æ³å代ç ã
ããpublic static File createPack() throws IOException {
ããFile jarFile = EJob.createTempJar("bin");
ããClassLoader classLoader = EJob.getClassLoader();
ããThread.currentThread().setContextClassLoader(classLoader);
ããreturn jarFile;
ãã}
ããå¨ä½ä¸å¯å¨ä»£ç ä¸ä½¿ç¨æå ï¼
ããJob job = Job.getInstance(conf, "testAnaAction");
ããæ·»å ï¼
ããString jarPath = createPack().getPath();
ããjob.setJar(jarPath);
ããå³å¯å®ç°ç´æ¥run as java application å¨windowsè·åå¸å¼çmapreduceç¨åºï¼ä¸ç¨æå·¥ä¸ä¼ jaræ件ã
ããéäºãå¾åºç»è®ºçæµè¯è¿ç¨
ããï¼æªæ空ç书ï¼åªè½éè¿æ笨çæµè¯æ¹æ³å¾åºç»è®ºäºï¼
ããä¸. ç´æ¥éè¿windowsä¸Eclipseå³å»mainç¨åºçjavaæ件ï¼ç¶å"run as application"æéæ©hadoopæ件"run on hadoop"æ¥è§¦åæ§è¡MapReduceç¨åºçæµè¯ã
ãã1ï¼å¦æä¸æjarå å°è¿é群任ælinuxæºå¨ä¸ï¼å®æ¥éå¦ä¸ï¼
ãã[work] -- ::, - org.apache.hadoop.mapreduce.Job - [main] INFO org.apache.hadoop.mapreduce.Job - map 0% reduce 0%
ãã[work] -- ::, - org.apache.hadoop.mapreduce.Job - [main] INFO org.apache.hadoop.mapreduce.Job - Task Id : attempt___m__0, Status : FAILED
ããError: java.lang.RuntimeException: java.lang.ClassNotFoundException: Class bookCount.BookCount$BookCountMapper not found
ããat org.apache.hadoop.conf.Configuration.getClass(Configuration.java:)
ããat org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:)
ããat org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:)
ããat org.apache.hadoop.mapred.MapTask.run(MapTask.java:)
ããat org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:)
ããat java.security.AccessController.doPrivileged(Native Method)
ããat javax.security.auth.Subject.doAs(Subject.java:)
ããat org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:)
ããat org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:)
ããCaused by: java.lang.ClassNotFoundException: Class bookCount.BookCount$BookCountMapper not found
ããat org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:)
ããat org.apache.hadoop.conf.Configuration.getClass(Configuration.java:)
ãã... 8 more
ãã# Error:åéå¤ä¸æ¬¡
ãã-- ::, - org.apache.hadoop.mapreduce.Job - [main] INFO org.apache.hadoop.mapreduce.Job - map % reduce %
ããç°è±¡å°±æ¯ï¼æ¥éï¼æ è¿åº¦ï¼æ è¿è¡ç»æã
ãã
ãã2ï¼æ·è´jarå å°âåªæ¯âé群masterç$HADOOP_HOME/share/hadoop/mapreduce/ç®å½ä¸ï¼ç´æ¥éè¿windowsçeclipse "run as application"åéè¿hadoopæ件"run on hadoop"æ¥è§¦åæ§è¡ï¼å®æ¥éåä¸ã
ããç°è±¡å°±æ¯ï¼æ¥éï¼æ è¿åº¦ï¼æ è¿è¡ç»æã
ãã3ï¼æ·è´jarå å°é群æäºslaveç$HADOOP_HOME/share/hadoop/mapreduce/ç®å½ä¸ï¼ç´æ¥éè¿windowsçeclipse "run as application"åéè¿hadoopæ件"run on hadoop"æ¥è§¦åæ§è¡
ããåæ¥éï¼
ããError: java.lang.RuntimeException: java.lang.ClassNotFoundException: Class bookCount.BookCount$BookCountMapper not found
ããat org.apache.hadoop.conf.Configuration.getClass(Configuration.java:)
ããat org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:)
ããåæ¥éï¼
ããError: java.lang.RuntimeException: java.lang.ClassNotFoundException: Class bookCount.BookCount$BookCountReducer not found
ãã
ããç°è±¡å°±æ¯ï¼ææ¥éï¼ä½ä»ç¶æè¿åº¦ï¼æè¿è¡ç»æã
ãã4ï¼æ·è´jarå å°é群ææslaveç$HADOOP_HOME/share/hadoop/mapreduce/ç®å½ä¸ï¼ç´æ¥éè¿windowsçeclipse "run as application"åéè¿hadoopæ件"run on hadoop"æ¥è§¦åæ§è¡ï¼
ããç°è±¡å°±æ¯ï¼æ æ¥éï¼æè¿åº¦ï¼æè¿è¡ç»æã
ãã第ä¸ç¹ç»è®ºå°±æ¯ï¼ windowsä¸æ§è¡mapreduceï¼å¿ é¡»æjarå å°ææslaveèç¹æè½æ£ç¡®åå¸å¼è¿è¡mapreduceç¨åºã
ããäº å¨Linuxä¸çéè¿ä»¥ä¸å½ä»¤è§¦åMapReduceç¨åºçæµè¯ã
ããhadoop jar $HADOOP_HOME/share/hadoop/mapreduce/bookCount.jar bookCount.BookCount
ãã
ãã1ï¼åªæ·è´å°masterï¼å¨masterä¸æ§è¡ã
ããç°è±¡å°±æ¯ï¼æ æ¥éï¼æè¿åº¦ï¼æè¿è¡ç»æã
ãã2ï¼æ·è´é便ä¸ä¸ªslaveèç¹,å¨slaveä¸æ§è¡ã
ããç°è±¡å°±æ¯ï¼æ æ¥éï¼æè¿åº¦ï¼æè¿è¡ç»æã
ããä½æäºèç¹ä¸è¿è¡ä¼æ¥éå¦ä¸ï¼ä¸è¿è¡ç»æãï¼
ãã// :: INFO mapreduce.JobSubmitter: Cleaning up the staging area /tmp/hadoop-yarn/staging/hduser/.staging/job__
ããException in thread "main" java.lang.NoSuchFieldError: DEFAULT_MAPREDUCE_APPLICATION_CLASSPATH
ããat org.apache.hadoop.mapreduce.v2.util.MRApps.setMRFrameworkClasspath(MRApps.java:)
ããat org.apache.hadoop.mapreduce.v2.util.MRApps.setClasspath(MRApps.java:)
ããat org.apache.hadoop.mapred.YARNRunner.createApplicationSubmissionContext(YARNRunner.java:)
ããat org.apache.hadoop.mapred.YARNRunner.submitJob(YARNRunner.java:)
ããat org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:)
ããat org.apache.hadoop.mapreduce.Job$.run(Job.java:)
ããat org.apache.hadoop.mapreduce.Job$.run(Job.java:)
ããat java.security.AccessController.doPrivileged(Native Method)
ããat javax.security.auth.Subject.doAs(Subject.java:)
ããat org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:)
ããat org.apache.hadoop.mapreduce.Job.submit(Job.java:)
ããat org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:)
ããat com.etrans.anaSpeed.AnaActionMr.run(AnaActionMr.java:)
ããat org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:)
ããat com.etrans.anaSpeed.AnaActionMr.main(AnaActionMr.java:)
ããat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
ããat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:)
ããat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:)
ããat java.lang.reflect.Method.invoke(Method.java:)
ããat org.apache.hadoop.util.RunJar.main(RunJar.java:)
ãã第äºç¹ç»è®ºå°±æ¯ï¼ Linuxä¸ï¼åªéæ·è´jaræ件å°é群masterä¸,æ§è¡å½ä»¤hadoop jarPackage.jar MainClassNameå³å¯åå¸å¼è¿è¡mapreduceç¨åºã