Spark KryoException:无法找到类:CassandraSQLRow

时间:2016-03-08 11:11:37

标签: scala apache-spark cassandra spark-cassandra-connector

我正在使用Cassandra 2.1.5(dsc),Spark 1.2.1和spark-cassandra-connector 1.2.1。

当我运行Spark作业(scala脚本)时,我收到以下错误:

  

16/03/08 10:22:03 INFO DAGScheduler:Job 0 failed:reduce at   JsonRDD.scala:57,花了15.051150 s线程" main"   org.apache.spark.SparkException:作业因阶段失败而中止:   阶段1.0中的任务1失败1次,最近失败:丢失任务   阶段1.0中的1.0(TID 4,localhost):com.esotericsoftware.kryo.KryoException:无法找到类:   org.apache.spark.sql.cassandra.CassandraS QLRow

我尝试使用以下内容执行here所述的内容:

/home/ubuntu/spark-1.2.1/bin/spark-submit --driver-class-path /home/ubuntu/.ivy2/cache/com.datastax.spark/spark-cassandra-connector_2.10/jars/spark-cassandra-connector_2.10-1.2.1.jar --conf spark.executor.extraClassPath=/home/ubuntu/.ivy2/cache/com.datastax.spark/spark-cassandra-connector_2.10/jars/spark-cassandra-connector_2.10-1.2.1.jar --class "$class" "$jar"

但只会收到以下错误:

  

线程中的异常" main" java.lang.NoClassDefFoundError:   COM / datastax /驱动器/核心/ ConsistencyLevel           在com.datastax.spark.connector.writer.WriteConf $。(WriteConf.scala:76)           在com.datastax.spark.connector.writer.WriteConf $。(WriteConf.scala)           在com.datastax.spark.connector.util.ConfigCheck $。(ConfigCheck.scala:23)           在com.datastax.spark.connector.util.ConfigCheck $。(ConfigCheck.scala)           在com.datastax.spark.connector.cql.CassandraConnectorConf $ .apply(CassandraConnectorConf.scala:81)           在com.datastax.spark.connector.cql.CassandraConnector $ .apply(CassandraConnector.scala:204)           在com.datastax.spark.connector.RDDFunctions.joinWithCassandraTable $ default $ 5(RDDFunctions.scala:127)           在co.crowdx.aggregation.SignalIO $ .main(SignalIO.scala:92)           在co.crowdx.aggregation.SignalIO.main(SignalIO.scala)           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)           at java.lang.reflect.Method.invoke(Method.java:606)           在org.apache.spark.deploy.SparkSubmit $ .launch(SparkSubmit.scala:358)           在org.apache.spark.deploy.SparkSubmit $ .main(SparkSubmit.scala:75)           在org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

     

引起:java.lang.ClassNotFoundException:   com.datastax.driver.core.ConsistencyLevel

可能是什么问题? (我现在不想升级spark或cassandra)

修改

我尝试运行spark shell以更简单的方式查看问题:

spark-1.2.1/bin/spark-shell --jars /home/ubuntu/.ivy2/cache/com.datastax.spark/spark-cassandra connector_2.10/jars/spark-cassandra-connector_2.10-1.2.1.jar --conf spark.cassandra.connection.host=11.11.11.11

尝试运行简单的命令:

> scala> import org.apache.spark.sql.cassandra.CassandraSQLContext
> import org.apache.spark.sql.cassandra.CassandraSQLContext
> 
> scala> import org.apache.spark.sql.SchemaRDD import
> org.apache.spark.sql.SchemaRDD
> 
> scala> val cc = new CassandraSQLContext(sc) cc:
> org.apache.spark.sql.cassandra.CassandraSQLContext =
> org.apache.spark.sql.cassandra.CassandraSQLContext@1c41c05e
> 
> scala> val rdd = cc.sql("select * from listener.scans_daily_imei_partitioned as a, listener.scans_daily_imei_partitioned as b where a.id=b.id")

我收到以下错误:

  

rdd:org.apache.spark.sql.SchemaRDD = RDD at ScheDRDD [0]   SchemaRDD.scala:108   ==查询计划==   ==物理计划== com.google.common.util.concurrent.ExecutionError:java.lang.NoClassDefFoundError:   COM / datastax /驱动器/芯/ ConsistencyLevel

1 个答案:

答案 0 :(得分:3)

我用自编译的spark-cassandra-connector解决了这个问题:

wget https://github.com/datastax/spark-cassandra-connector/archive/v1.2.1.zip
unzip v1.2.1.zip
cd spark-cassandra-connector-1.2.1
sbt assembly
cp /home/ubuntu/spark-cassandra-connector-1.2.1/spark-cassandra-connector-java/target/scala-2.10/spark-cassandra-connector-java-assembly-1.2.1.jar spark-cassandra-connector-java-assembly-1.2.1-FAT.jar

将火花用作:

/home/ubuntu/spark-1.2.1/bin/spark-submit --driver-class-path /home/ubuntu/spark-cassandra-connector-java-assembly-1.2.1-FAT.jar --conf spark.executor.extraClassPath=/home/ubuntu/spark-cassandra-connector-java-assembly-1.2.1-FAT.jar --class "$class" "$jar"

完美无缺。