Spark on Yarn run produces missing jar package errors and solutions

Source: Internet
Author: User

1. Local Operation error and solution

When you run the following command:

./bin/spark-submit   --class Org.apache.spark.examples.mllib.JavaALS   --master local[*]   /opt/cloudera/ Parcels/cdh-5.1.2-1.cdh5.1.2.p0.3/lib/hadoop-yarn/lib/spark-examples_2.10-1.0.0-cdh5.1.2.jar   /user/data/ Netflix_rating 10/user/data/result

The following error will appear:

Exception in thread "main" Java.lang.RuntimeException:java.io.IOException:No FileSystem for Scheme:hdfs at ORG.A Pache.hadoop.mapred.JobConf.getWorkingDirectory (jobconf.java:657) at Org.apache.hadoop.mapred.FileInputFormat.setInputPaths (fileinputformat.java:389) at Org.apache.hadoop.mapred.FileInputFormat.setInputPaths (fileinputformat.java:362) at org.apache.spark.sparkcontext$ $anonfun $22.apply (sparkcontext.scala:546) at org.apache.spark.sparkcontext$$ Anonfun$22.apply (sparkcontext.scala:546) at org.apache.spark.rdd.hadooprdd$ $anonfun $getjobconf$1.apply ( hadooprdd.scala:145) at org.apache.spark.rdd.hadooprdd$ $anonfun $getjobconf$1.apply (hadooprdd.scala:145) at S Cala. Option.map (option.scala:145) at org.apache.spark.rdd.HadoopRDD.getJobConf (hadooprdd.scala:145) at Org.apache . Spark.rdd.HadoopRDD.getPartitions (hadooprdd.scala:168) at org.apache.spark.rdd.rdd$ $anonfun $partitions$2.apply ( rdd.scala:204) at Org.apache.spark.rdd.rdd$ $anonfun $partitions$2.apply (rdd.scala:202) at Scala. Option.getorelse (option.scala:120) at Org.apache.spark.rdd.RDD.partitions (rdd.scala:202) at Org.apache.spark . Rdd. Mappedrdd.getpartitions (mappedrdd.scala:28) at org.apache.spark.rdd.rdd$ $anonfun $partitions$2.apply (RDD.scala : 204) at org.apache.spark.rdd.rdd$ $anonfun $partitions$2.apply (rdd.scala:202) at Scala. Option.getorelse (option.scala:120) at Org.apache.spark.rdd.RDD.partitions (rdd.scala:202) at Org.apache.spark . Rdd. Mappedrdd.getpartitions (mappedrdd.scala:28) at org.apache.spark.rdd.rdd$ $anonfun $partitions$2.apply (RDD.scala : 204) at org.apache.spark.rdd.rdd$ $anonfun $partitions$2.apply (rdd.scala:202) at Scala. Option.getorelse (option.scala:120) at Org.apache.spark.rdd.RDD.partitions (rdd.scala:202) at Org.apache.spark . Mllib.recommendation.ALS.run (als.scala:167) at Org.apache.spark.mllib.recommendation.als$.train (als.scala:599) at Org.apache.spark.mllib.recommendation.ALS.train (Als.scala) at Org.apache.spark.examples.mllib.Java Als.main (javaals.java:80) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at Sun.reflect.Nati Vemethodaccessorimpl.invoke (nativemethodaccessorimpl.java:39) at Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:25) at Java.lang.reflect.Method.invoke (method.java:597) at Org.apache.spa Rk.deploy.sparksubmit$.launch (sparksubmit.scala:292) at Org.apache.spark.deploy.sparksubmit$.main ( sparksubmit.scala:55) at Org.apache.spark.deploy.SparkSubmit.main (Sparksubmit.scala) caused by:java.io.IOException        : No FileSystem for Scheme:hdfs at Org.apache.hadoop.fs.FileSystem.getFileSystemClass (filesystem.java:2385) At Org.apache.hadoop.fs.FileSystem.createFileSystem (filesystem.java:2392) at Org.apache.hadoop.fs.FileSystem.acce ss$200 (filesystem.java:89) at Org.apachE.hadoop.fs.filesystem$cache.getinternal (filesystem.java:2431) at Org.apache.hadoop.fs.filesystem$cache.get ( filesystem.java:2413) at Org.apache.hadoop.fs.FileSystem.get (filesystem.java:368) at Org.apache.hadoop.fs.Fi        Lesystem.get (filesystem.java:167) at Org.apache.hadoop.mapred.JobConf.getWorkingDirectory (jobconf.java:653) ... More

This error occurs because of a jar package that is missing hadoop-hdfs during spark execution, and the use of the--jar or--driver-class-path parameter in spark-submit resolves the problem. When using Hadoop-hdfs, the path refers to the HDFs path.

The correct way to do this is as follows:

./bin/spark-submit   --class Org.apache.spark.examples.mllib.JavaALS   --driver-class-path/opt/cloudera/ Parcels/cdh-5.1.2-1.cdh5.1.2.p0.3/lib/hadoop-hdfs/hadoop-hdfs-2.3.0-cdh5.1.2.jar   --master local[*]   /opt /cloudera/parcels/cdh-5.1.2-1.cdh5.1.2.p0.3/lib/hadoop-yarn/lib/spark-examples_2.10-1.0.0-cdh5.1.2.jar   / User/data/netflix_rating 10/user/data/result or./bin/spark-submit   --class Org.apache.spark.examples.mllib.JavaALS   --jars/opt/cloudera/parcels/cdh-5.1.2-1.cdh5.1.2.p0.3/lib/ Hadoop-hdfs/hadoop-hdfs-2.3.0-cdh5.1.2.jar   --master local[*]   /opt/cloudera/parcels/ Cdh-5.1.2-1.cdh5.1.2.p0.3/lib/hadoop-yarn/lib/spark-examples_2.10-1.0.0-cdh5.1.2.jar   /user/data/netflix_ Rating 10/user/data/result


2. Spark error and solution on yarn

When you run the following command:

./bin/spark-submit   --class org.apache.spark.examples.mllib.JavaALS   --master yarn-cluster   /opt/ Cloudera/parcels/cdh-5.1.2-1.cdh5.1.2.p0.3/lib/hadoop-yarn/lib/spark-examples_2.10-1.0.0-cdh5.1.2.jar   / User/data/netflix_rating 10/user/data/result

The following error will appear:

Exception in thread "main" Java.lang.noclassdeffounderror:org/apache/hadoop/yarn/client/api/impl/yarnclientimpl at        Java.lang.ClassLoader.defineClass1 (Native Method) at Java.lang.ClassLoader.defineClassCond (classloader.java:631) At Java.lang.ClassLoader.defineClass (classloader.java:615) at Java.security.SecureClassLoader.defineClass (Sec ureclassloader.java:141) at Java.net.URLClassLoader.defineClass (urlclassloader.java:283) at Java.net.URLClas sloader.access$000 (urlclassloader.java:58) at Java.net.urlclassloader$1.run (urlclassloader.java:197) at Java . Security. Accesscontroller.doprivileged (Native Method) at Java.net.URLClassLoader.findClass (urlclassloader.java:190) A T Java.lang.ClassLoader.loadClass (classloader.java:306) at Sun.misc.launcher$appclassloader.loadclass ( launcher.java:301) at Java.lang.ClassLoader.loadClass (classloader.java:247) at JAVA.LANG.CLASS.FORNAME0 (Nati ve Method) at JAVA.LAng.        Class.forName (class.java:247) at org.apache.spark.util.utils$ $anonfun $classisloadable$1.apply (Utils.scala:143) At org.apache.spark.util.utils$ $anonfun $classisloadable$1.apply (utils.scala:143) at scala.util.try$.apply (Try.sc ala:161) at org.apache.spark.util.utils$.classisloadable (utils.scala:143) at Org.apache.spark.deploy.SparkSu        Bmit$.createlaunchenv (sparksubmit.scala:158) at Org.apache.spark.deploy.sparksubmit$.main (SparkSubmit.scala:54) At Org.apache.spark.deploy.SparkSubmit.main (Sparksubmit.scala) caused by:java.lang.ClassNotFoundException:        Org.apache.hadoop.yarn.client.api.impl.YarnClientImpl at Java.net.urlclassloader$1.run (urlclassloader.java:202) At java.security.AccessController.doPrivileged (Native Method) at Java.net.URLClassLoader.findClass (urlclassload er.java:190) at Java.lang.ClassLoader.loadClass (classloader.java:306) at Sun.misc.launcher$appclassloader.lo     Adclass (launcher.java:301)   At Java.lang.ClassLoader.loadClass (classloader.java:247) ... More

This error occurs because the jar package in the Hadoop-yarn directory is missing, and the method that resolves this problem can only use the--driver-class-path parameter, because when you perform spark on yarn, you need to advance the The jar package import under the Hadoop-yarn directory .


The correct way to do this is as follows:

./bin/spark-submit   --class org.apache.spark.examples.mllib.JavaALS   --master yarn-cluster   -- Driver-class-path $ (Echo/opt/cloudera/parcels/cdh/lib/hadoop-yarn/*.jar |sed ' s//:/g '):/opt/cloudera/parcels/ Cdh-5.1.2-1.cdh5.1.2.p0.3/lib/hadoop-hdfs/hadoop-hdfs-2.3.0-cdh5.1.2.jar   /opt/cloudera/parcels/ Cdh-5.1.2-1.cdh5.1.2.p0.3/lib/hadoop-yarn/lib/spark-examples_2.10-1.0.0-cdh5.1.2.jar   /user/data/netflix_ Rating 10/user/data/result


The execution result set is as shown in

The/user/data/result/productfeatures/part-00000 data format is:

22,[5.561720883259194, 1.8295046510786157, 1.456597387276617, 0.8851233321058966,-0.6750794769961516, 0.2105431165110079, 1.868136268816477,-0.7426684616337039,-0.5856268982634872, 2.2788288132587358]31,[ 0.9093801231293616, 0.31519780093777366, 1.1875509370524693, 0.40381375438624073, 2.518833489342341, 1.4242427194658087, 2.0950977044322574, 0.9012256614215569, 1.1604700989497398, 0.15791920617498328]76,[ 1.8285525546730474, 0.6330058247735413, 2.5686801366906984, 1.4128062599776998, 1.401816974160943, 0.1596137900376602, 1.5625150218484072,-0.9678843308247949, 2.682242352514027, 1.0599465865866935]152,[ 0.014905493368344078, 0.43308346940343456, 0.2351848253710811, 0.26220235713374834, 0.055210836978533295, 0.21723689234341548, 0.09391052568889097, 0.7231946368850907, 0.02497671848923523, 0.5022350772242716]206,[- 0.5501117679008718, 0.4105849318486638, 1.0876481291363873, 2.233025299808942, 2.1038565118723387, 1.662798954470802, 1.575332336431819, 0.8167712158963146, 1.4536436809654083,-0.5224582242822096] 
the/user/data/result/userfeatures/part-00000 data format is:

22,[0.18595332423070562, 0.26223861694267697, 0.2220917583718615, 0.015729079507204886, 0.4450456773474982, 0.12287125816024044, 0.4644319181495295, 0.38377345920108646, 0.28428991637647794, 0.17875507467819415]31,[ 0.15133710263843259,-0.02354886937021699, 0.10618787396390789, 0.03258147800653979, 0.3556889855610244, 1.021110467423965, 0.3701959855785832, 0.1524124835894395, 0.23381646690418442, -0.012011907243505829]76,[ 0.2344438657777155, 0.03821305024729112, 0.230093903321136, 0.48888224387617607, 0.30121869825786685, 0.48198504753122795, 0.29543641416718835, 0.39299434584620146, 0.27798068299013984, 0.15611605797193095]121,[ 0.2038917971256244, 0.7576071991072084, 0.30603993855416245, 0.41995044224403344, 0.06550681386608997, 0.20395370870960078, 0.3444359097858106, 0.4935457123179016, 0.2041119263872145, 0.3518582534508109]130,[ 0.042995762604581524,-0.21177745644812881, 0.7047019111940551, 0.44978429350262916, 0.18912686527984246, 0.6349887274906566, 0.29651737861710675, 0.49758500548973844, 0.02699514514764544, 0.39330900998421187]152,[1.9989336762046868, 1.2185456627280438,- 0.14465791504370654, 0.32972894935630664,-0.6316151112173617,-0.5568528040594881, 0.007477525352213408,- 0.012087520291972442, 0.4184613236246099,-0.24669307203702268]

3, for Spark on hadoop implementation of travel problems need to go to Hadoop yarn corresponding to the job log to see


Spark on Yarn run produces missing jar package errors and solutions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.