Jupyter Notebook (with Apache Spark on YARN over Pseudo Distributed Hadoop)
1.8K
Need a notebook to simulate production loads on Apache Spark on YARN over Pseudo Distributed Hadoop? Otherwise, check an alternate implementation, jupyter-pyspark, which is much smaller in size and ideal for experimentation.
latestDockerfile linksJupyter Notebook 6.5.1 | Apache Spark 3.3.0
Jupyter Notebook 6.4.12 | Apache Spark 3.3.0
Jupyter Notebook 6.4.10 | Apache Spark 3.2.1
Jupyter Notebook 6.4.8 | Apache Spark 3.2.1
Jupyter Notebook 6.4.6 | Apache Spark 3.2.0
Place your notebooks under the notebook directory and run:
docker run --rm -d\
--name jupyter-spark-pseudo\
--hostname jupyter-spark-pseudo\
--env JUPYTER_PORT=8889\
--env YARN_SITE__YARN_NODEMANAGER_RESOURCE_DETECT_HARDWARE_CAPABILITIES=true\
--volume $PWD/notebooks:/home/hdfs/notebooks\
--publish 8032:8032\
--publish 8088:8088\
--publish 8042:8042\
--publish 18080:18080\
--publish 8889:8889\
loum/jupyter-spark-pseudo:latest
To get the URL of your local server:
docker exec -ti jupyter-spark-pseudo bash -c "jupyter notebook list"
NOTE: there's quite a bit happening here so depending on your local setup, you will have to give the services some time to stabilise. A simple check is to run the following:
docker logs jupyter-spark-pseudo... and look for the following output (previous logging omitted for brevity):
... ### Hadoop bootstrap complete starting org.apache.spark.deploy.history.HistoryServer, logging to /tmp/spark/spark--org.apache.spark.deploy.history.HistoryServer-1-zeppelin-spark-pseudo.out
docker stop jupyter-spark-pseudo
With an active Jupyter Notebook server a PySpark instance should be running behind the scenes. To validate, dump the SparkContext help in a Jupyter Notebook cell:
help(sc)
Spark context available as sc.
SparkSession available as spark.
Taken from Spark examples:
import sys
from random import random
from operator import add
partitions = 2
n = 100000 * partitions
def f(_):
x = random() * 2 - 1
y = random() * 2 - 1
return 1 if x ** 2 + y ** 2 <= 1 else 0
count = sc.parallelize(range(1, n + 1), partitions).map(f).reduce(add)
print("Pi is roughly %f" % (4.0 * count / n))
[Stage 0:> (0 + 2) / 2]
Pi is roughly 3.143960
Content type
Image
Digest
sha256:c0f87698a…
Size
2.3 GB
Last updated
almost 4 years ago
docker pull loum/jupyter-spark-pseudo