ERROR StreamingContext: Error starting the context, marking it as stopped

问题描述:

今天帮别人调试flume+kafka+sparkstreaming的整合,在运行的时候报了以下错误:

ERROR StreamingContext: Error starting the context, marking it as stopped
org.apache.kafka.common.KafkaException: Failed to construct kafka consumer
    at org.apache.kafka.clients.consumer.KafkaConsumer.(KafkaConsumer.java:702)
    at org.apache.kafka.clients.consumer.KafkaConsumer.(KafkaConsumer.java:557)
    at org.apache.kafka.clients.consumer.KafkaConsumer.(KafkaConsumer.java:540)
    at org.apache.spark.streaming.kafka010.Subscribe.onStart(ConsumerStrategy.scala:84)
    at org.apache.spark.streaming.kafka010.DirectKafkaInputDStream.consumer(DirectKafkaInputDStream.scala:70)
    at org.apache.spark.streaming.kafka010.DirectKafkaInputDStream.start(DirectKafkaInputDStream.scala:240)
    at org.apache.spark.streaming.DStreamGraph$$anonfun$start$7.apply(DStreamGraph.scala:54)
    at org.apache.spark.streaming.DStreamGraph$$anonfun$start$7.apply(DStreamGraph.scala:54)
    at scala.collection.parallel.mutable.ParArray$ParArrayIterator.foreach_quick(ParArray.scala:143)
    at scala.collection.parallel.mutable.ParArray$ParArrayIterator.foreach(ParArray.scala:136)
    at scala.collection.parallel.ParIterableLike$Foreach.leaf(ParIterableLike.scala:972)
    at scala.collection.parallel.Task$$anonfun$tryLeaf$1.apply$mcV$sp(Tasks.scala:49)
    at scala.collection.parallel.Task$$anonfun$tryLeaf$1.apply(Tasks.scala:48)
    at scala.collection.parallel.Task$$anonfun$tryLeaf$1.apply(Tasks.scala:48)
    at scala.collection.parallel.Task$class.tryLeaf(Tasks.scala:51)
    at scala.collection.parallel.ParIterableLike$Foreach.tryLeaf(ParIterableLike.scala:969)
    at scala.collection.parallel.AdaptiveWorkStealingTasks$WrappedTask$class.compute(Tasks.scala:152)
    at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$WrappedTask.compute(Tasks.scala:443)
    at scala.concurrent.forkjoin.RecursiveAction.exec(RecursiveAction.java:160)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
    at ... run in separate thread using org.apache.spark.util.ThreadUtils ... ()
    at org.apache.spark.streaming.StreamingContext.liftedTree1$1(StreamingContext.scala:578)
    at org.apache.spark.streaming.StreamingContext.start(StreamingContext.scala:572)
    at com.yxf.kafka.kafkaStreaming1$.main(kafkaStreaming1.scala:68)
    at com.yxf.kafka.kafkaStreaming1.main(kafkaStreaming1.scala)
Caused by: org.apache.kafka.common.config.ConfigException: No resolvable bootstrap urls given in bootstrap.servers
    at org.apache.kafka.clients.ClientUtils.parseAndValidateAddresses(ClientUtils.java:59)
    at org.apache.kafka.clients.consumer.KafkaConsumer.(KafkaConsumer.java:620)
    at org.apache.kafka.clients.consumer.KafkaConsumer.(KafkaConsumer.java:557)

大概就是sparkstreaming程序连接不上kafka集群,刚开始没注意到下面的url报错提示,以为是kafka集群出了问题,浪费了很长时间。

问题解决:

主要是windows上的hosts文件没有配置映射关系,将文件夹:

C:\Windows\System32\drivers\etc

 下的hosts文件里面添加映射关系就好了。

192.168.221.101 node01
192.168.221.102 node02
192.168.221.103 node03

这是个小问题,但是却被我疏忽了,从而浪费了很多时间,希望大家可以跳过此坑

你可能感兴趣的:(ERROR StreamingContext: Error starting the context, marking it as stopped)