python开发,spark接收kafka的输入流时
import cv2import sys
import findspark
findspark.init()
from kafka import KafkaConsumer
from pyspark import SparkContext
from pyspark.streaming import StreamingContext
from pyspark.streaming.kafka import KafkaUtils,TopicAndPartition
if __name__ =="__main__":
print('kaishi')
sc = SparkContext(appName="videostreamprocessor")
ssc = StreamingContext(sc,1)
brokers="localhost:9092"
#from_offsets = {topic_partion: long(offset_data["untilOffset"])}
topic = 'new_topic'
partition = 0
start = 0
topicPartion = TopicAndPartition(topic,partition)
fromOffset = {topicPartion: start}
#kvs = KafkaUtils.createStream(ssc, zkQuorum, "spark-streaming-consumer", {topic: 1})
kvs = KafkaUtils.createDirectStream(ssc, [topic],kafkaParams={"metadata.broker.list": brokers},fromOffsets=fromOffset)
#print(kvs)
运行时一直报这个错,网上说缺少jar包,我也加了这是为什么呢
回答:
这不是少jar包,这是jar的版本不对,要分清楚NotFound和NoClassDef
大数据QQ群:801103655
以上是 python开发,spark接收kafka的输入流时 的全部内容, 来源链接: utcz.com/p/937658.html