兄弟連大數據培訓和大家一起探究Jupyter配置
Spark
開發環境
簡介
為Jupyter配置Spark開發環境,可以安裝全家桶–Spark Kernel或Toree,也可按需安裝相關組件。
考慮到一般人更喜歡一步到位,並且Toree將會代替Spark Kernel,故直接且僅需安裝Toree即可,不過下面還是給出了所有的安裝方法。
Spark Kernel的安裝
參照Spark Kernel支持的語言,安裝好Spark Kernel后,其默認可以支持Scala,Python,R,SQL,對應的Spark實現分別是Scala with Spark,Python with PySpark,R With SparkR,Spark SQL。
參照上述鏈接,要切換語言時,只需簡單的在語句前面加上%%scala/%%pyspark即可。當然,什么都不加時,默認語言為Scala。
另外,啟動Jupyter后,可直接在http://localhost:4040/jobs/監控所有作業。
Spark Kernel(舊的項目)
參照下面的安裝步驟進行即可,就是有些繁瑣。
Getting Started with theSpark Kernel
Guide to Integrating theSpark Kernel with Jupyter
Toree(新項目)
根據Spark Kernel的介紹,自從Spark Kernel變成Apache的孵化項目后,其最新倉庫已經 遷移到了incubator-toree。
安裝時,參照Quick Start What isApache Toree ,僅需兩條命令即可完成安裝。
pip install toree
jupyter toree install--spark_home=your-spark-home12
值得注意的是:
Toree雖然還在孵化中,但已經能完成上述Spark Kernel的全部功能,即可支持PySpark,Spark SQL等。
該kernel安裝在/usr/local/share/jupyter/kernels/apache_toree_scala目錄下
Spark組件單獨安裝
除了安裝上面的方法安裝Spark的全家桶外,還可以按需對各組件進行安裝。
Scala Kernel的安裝
參照jupyter-scala安裝即可。
PySpark的安裝
PySpark: How to install andIntegrate with the Jupyter Notebook
Integrate Apache Spark withlatest IPython Notebook (Jupyter 4.x)
Running Spark ApplicationsUsing IPython and Jupyter Notebooks