如何解决使用纱线,火花和火花cassandra连接器时番石榴11.0.2和16.0之间的冲突?

时间:2016-03-15 06:24:37

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

当我执行以下命令时,

我的纱线版本为hadop-2.4.0.x,火花为spark-1.5.1-bin-hadoop2.4,spark-cassandra-connector为spark-cassandra-connector_2.10-1.5.0-M2

bin/spark-shell --driver-class-path $(echo lib/*.jar | sed 's/ /:/g')  --master yarn-client 
--deploy-mode client --conf spark.cassandra.connection.host=192.21.0.209 
--conf spark.cassandra.auth.username=username --conf spark.cassandra.auth.password=password --conf spark.sql.dialect=sql 
--jars lib/guava-16.0.jar,spark-cassandra-connector_2.10-1.5.0-M2.jar,lib/cassandra-driver-core-2.2.0-rc3.jar

启动后,我在提示符下输入以下标量:

import org.apache.spark.sql.cassandra.CassandraSQLContext
import org.apache.spark.sql.{DataFrame, SaveMode}
import org.apache.spark.{Logging, SparkConf, SparkContext}
import org.joda.time.{DateTime, Days, LocalDate}
val cc = new CassandraSQLContext(sc)

val rdd: DataFrame = cc.sql("select user_id,tag_models,dmp_province," +
"zp_gender,zp_age,zp_edu,stg_stage,zp_income,type " +
"from user_center.users_test") 

我收到了经典错误:

Caused by: java.lang.NoSuchMethodError:  
com.google.common.util.concurrent.Futures.withFallback
(Lcom/google/common/util/concurrent/ListenableFuture;
Lcom/google/common/util/concurrent/FutureFallback;
Ljava/util/concurrent/Executor;)
Lcom/google/common/util/concurrent/ListenableFuture;

googlestackoverflower中搜索此错误后,我知道不同版本的guava之间的冲突导致此错误,并发现hadoop 2.4使用{{1但是spark-cassandra-connector_2.10-1.5.0-M2使用guava-11.0.2

如何解决此类错误,任何建议都将不胜感激!

更新

我很抱歉很长时间的测试!

现在,对于spark-submit,我在我的测试纱簇

下成功测试了这个分辨率Making Hadoop 2.6 + Spark-Cassandra Driver Play Nice Together

1 个答案:

答案 0 :(得分:1)

在Hadoop配置中,将以下属性添加到hadoop-env.sh

HADOOP_USER_CLASSPATH_FIRST=true

在Spark配置中,还有一个属性可以将其设置为true spark.driver.userClassPathFirst,但它仍然是实验性的,仅在群集模式下使用(请查看spark documentation)。就个人而言,我还没有尝试过这个属性,但是因为它在文档中提出我认为值得一提