내 Mac에서 all-spark 노트북 도커 이미지를 사용하여 apree toree 및 scala (https://github.com/jupyter/docker-stacks/tree/master/all-spark-notebook)를 사용하고 있습니다. nc -lk 9999
Scala Spark Streaming via Apache Toree
그래서 나는를 시작 : 1) netcast 프로그램) 포트 9999 2에서 수신하는 sparkstreaming 객체를 시작하려면 시작 :에
나는 불꽃의 문서의 기본 스트리밍 예제를 테스트하기 위해 노력하고, 느릅 나무 참여 컨테이너는 9999 포트 바인딩 : 나는 "포트가 이미 사용"가지고 그것을 연결을 시도, 다음
$ sudo docker run -it --rm -p 9999:9999 -p 8888:8888 -e GRANT_SUDO=yes --user root --pid=host -e TINI_SUBREAPER=true -v $HOME/Informatique/notebooks:/home/jovyan/work:rw jupyter/all-spark-notebook
그러나이 오류 :
$ nc -lk 9999
nc: Address already in use
,
는 또한 컨테이너에 자신을 넣어 시도 :
[email protected]:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0bd6b70bacfa jupyter/all-spark-notebook "tini -- start-not..." 23 seconds ago Up 22 seconds 0.0.0.0:8888->8888/tcp, 0.0.0.0:9999->9999/tcp wonderful_brattain
[email protected]:~$ docker exec -ti wonderful_brattain /bin/bash
[email protected]:~/work# nc -lk 9999
bash: nc: command not found
[email protected]:~/work# sudo apt-get update
[email protected]:~/work# sudo apt-get install netcat-traditional
[email protected]:~/work# nc -lk 9999
aaaa aaa aaa
bb bbb bbb
cc cc cc
하지만 스칼라 노트북에 표시 아무것도 없다 :
import org.apache.spark._
import org.apache.spark.streaming._
import org.apache.spark.streaming.StreamingContext._
val conf = new SparkConf().setMaster("local[2]").setAppName("NetworkWordCount")
val ssc = new StreamingContext(sc, Seconds(1))
val lines = ssc.socketTextStream("localhost", 9999)
val words = lines.flatMap(_.split(" "))
import org.apache.spark.streaming.StreamingContext._ // not necessary since Spark 1.3
// Count each word in each batch
val pairs = words.map(word => (word, 1))
val wordCounts = pairs.reduceByKey(_ + _)
// Print the first ten elements of each RDD generated in this DStream to the console
wordCounts.print()
과 :
ssc.start() // Start the computation
ssc.awaitTermination() // Wait for the computation to terminate
을 제공합니다
-------------------------------------------
Time: 1485880101000 ms
-------------------------------------------
-------------------------------------------
Time: 1485880102000 ms
-------------------------------------------
-------------------------------------------
Time: 1485880103000 ms
-------------------------------------------
-------------------------------------------
Time: 1485880104000 ms
-------------------------------------------
이러한 네트워크 문제를 어떻게 처리합니까?