如何解决11.0.2和16.0的Guava之间的冲突时,使用纱,Spark和Spark-Cassandra-连接器?

jtjikinw  于 2022-11-05  发布在  Cassandra
关注(0)|答案(1)|浏览(171)

我的yarn的版本是hadop-2.4.0.x,spark是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

启动后,我在提示符下输入下面的scala:

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使用guava-11.0.2,但spark-cassandra-connector_2.10-1.5.0-M2使用guava-16.0.1
如何解决这种错误,任何建议将不胜感激!
更新
我很抱歉测试了这么长时间!
现在,对于spark-submit,我在我的测试Yarn簇下成功地测试了这个分辨率Making Hadoop 2.6 + Spark-Cassandra Driver Play Nice Together

sqxo8psd

sqxo8psd1#

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

HADOOP_USER_CLASSPATH_FIRST=true

在Spark配置中,还有一个属性可以设置为true spark.driver.userClassPathFirst,但它仍然是一个实验性的属性,仅在集群模式下使用(请查看spark documentation)。

相关问题