Only one SparkContext may be running in this JVM (see SPARK-2243). To ignore this error, set spark.d

Only one SparkContext may be running in this JVM (see SPARK-2243). To ignore this error, set spark.driver.allowMultipleContexts = true. The currently running SparkContext was created at:XXX

解决:
该报错是因为创建了多个sparkContext, 一般是因为在创建StreamingContext的时候使用了SparkContext而非SparkConf

val conf = new SparkConf().setAppName("SparkStreamingAndKafka").setMaster("local[2]")
val sc = new SparkContext(conf)
val ssc = new StreamingContext(conf, Seconds(5))

将val sc = new SparkContext(conf)注释掉

猜你喜欢

转载自blog.csdn.net/qq_35078688/article/details/85689261