Main menu: Spark Scala Tutorial
In this Spark Scala tutorial you will learn,
How to install Apache Spark on Mac OS.
By the end of this tutorial you will be able to run Apache Spark with Scala on Mac machine.
You will also download Eclispe for Scala IDE.
To install Apache Spark on windows machine visit this.
You will be installing Apache Spark using Homebrew.
So install Homebrew if you don’t have it, visit: https://brew.sh/ and copy paste the command on your terminal and run it.
Installing Apache Spark
Open terminal and type command brew install apache-spark and hit Enter.
Create a log4j.properties file. Type cd /usr/local/Cellar/apache-spark/2.3.1/libexec/conf and hit Enter. Please change the version according to your downloaded version. Spark 2.3.1 is the version installed for me.
Type cp log4j.properties.template log4j.properties and hit Enter.
Edit the log4j.properties file and change the log level from INFO to ERROR on log4j.rootCategory. We are just changing the log level from INFO to ERROR only.
Download Scala IDE
Install the Scala IDE from here.
Open the IDE once, just to check if it's running fine. You should see panels like this;
Test it out!
Open terminal and go to the directory where apache-spark was installed to (such as cd /usr/local/Cellar/apache-spark/2.3.1/libexec/) and then type ls to get a directory listing.
Look for a text file, like README.md or CHANGES.txt.
Type command spark-shell and hit Enter.
At this point you should see a scala> prompt. If not, double check the steps above.
Type val rdd = sc.textFile("README.md") or whatever text file you’ve found and hit Enter. You have just created a rdd of readme text file. Now type rdd.count() and hit Enter to count the number of lines in text file.
You should get a count of number of lines in that file! Congratulations, you just ran your first Spark program! Don't worry about the commands, I will explain them.
You’ve got everything set up! If you have any question please don't forget to mention in the comments section below.
Main Menu | Next: Just enough Scala for Spark
1. Apache Spark and Scala Installation
2. Getting Familiar with Scala IDE
3. Spark data structure basics
4. Spark Shell
5. Reading data files in Spark
6. Writing data files in Spark
7. Spark streaming