我已经设置了spark,并尝试使用python示例为发现here的wordcount运行spark Submit命令。
以下是我为spark提交运行的命令:-
bin/spark-submit --packages org.apache.spark:spark-streaming-kinesis-asl_2.12:2.4.0 /Users/amitdhawan/Downloads/kinesis_wordcount_asl.py [appname] [streamname] [https://kinesis.us-west-1.amazonaws.com] [us-west-1]
我得到的错误如下:-
Traceback (most recent call last):
File "/Users/amitdhawan/Downloads/kinesis_wordcount_asl.py", line 76, in <module>
ssc, appName, streamName, endpointUrl, regionName, InitialPositionInStream.LATEST, 2)
File "/Users/amitdhawan/Downloads/spark-2.2.3-bin-hadoop2.7/python/lib/pyspark.zip/pyspark/streaming/kinesis.py", line 92, in createStream
File "/Users/amitdhawan/Downloads/spark-2.2.3-bin-hadoop2.7/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py", line 1257, in __call__
File "/Users/amitdhawan/Downloads/spark-2.2.3-bin-hadoop2.7/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o28.createStream.
: java.lang.IllegalArgumentException: Region name '[us-west-1]' is not valid
at org.apache.spark.streaming.kinesis.KinesisUtils$.$anonfun$validateRegion$2(KinesisUtils.scala:561)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.streaming.kinesis.KinesisUtils$.validateRegion(KinesisUtils.scala:561)
at org.apache.spark.streaming.kinesis.KinesisUtils$.$anonfun$createStream$1(KinesisUtils.scala:75)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
at org.apache.spark.streaming.StreamingContext.withNamedScope(StreamingContext.scala:274)
at org.apache.spark.streaming.kinesis.KinesisUtils$.createStream(KinesisUtils.scala:75)
at org.apache.spark.streaming.kinesis.KinesisUtils$.createStream(KinesisUtils.scala:509)
at org.apache.spark.streaming.kinesis.KinesisUtilsPythonHelper.createStream(KinesisUtils.scala:614)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:282)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:238)
at java.lang.Thread.run(Thread.java:745)
不确定我为什么要获取区域无效,因为我已确保aine控制台中的Kinesis流和应用位于us-west-1中。
编辑:-
现在我在运行命令运动流的以下命令中出现错误
bin/run-example streaming.KinesisWordProducerASL streamname https://kinesis.us-west-1.amazonaws.com 1000 10
错误是:-
java.lang.ClassNotFoundException: org.apache.spark.examples.streaming.KinesisWordProducerASL
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.spark.util.Utils$.classForName(Utils.scala:233)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:732)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:180)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:205)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:119)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
不确定如何注册该课程。我还在spark Submit命令中提供了--class参数,但这也无法正常工作。
答案 0 :(得分:0)
使用以下命令解决它:-
bin/spark-submit --packages org.apache.spark:spark-streaming-kinesis-asl_2.11:2.4.0 /Users/amitdhawan/Downloads/kinesis_wordcount_asl.py appname streamname https://kinesis.us-west-1.amazonaws.com us-west-1
注意删除方括号,并将scala的版本从2.12降级到2.11