<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://info319.wiki.uib.no/index.php?action=history&amp;feed=atom&amp;title=Spark_preparations</id>
	<title>Spark preparations - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://info319.wiki.uib.no/index.php?action=history&amp;feed=atom&amp;title=Spark_preparations"/>
	<link rel="alternate" type="text/html" href="http://info319.wiki.uib.no/index.php?title=Spark_preparations&amp;action=history"/>
	<updated>2026-06-18T03:11:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>http://info319.wiki.uib.no/index.php?title=Spark_preparations&amp;diff=137&amp;oldid=prev</id>
		<title>Vimala: Created page with &quot;===Downloading=== Create a Spark folder on your computer, preferrably next your Hadoop folder, if you have one. * &#039;&#039;&#039;Linux:&#039;&#039;&#039; Anywhere should do. I have created a root folder...&quot;</title>
		<link rel="alternate" type="text/html" href="http://info319.wiki.uib.no/index.php?title=Spark_preparations&amp;diff=137&amp;oldid=prev"/>
		<updated>2018-08-31T12:27:08Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;===Downloading=== Create a Spark folder on your computer, preferrably next your Hadoop folder, if you have one. * &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; Anywhere should do. I have created a root folder...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;===Downloading===&lt;br /&gt;
Create a Spark folder on your computer, preferrably next your Hadoop folder, if you have one.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; Anywhere should do. I have created a root folder called &amp;#039;&amp;#039;/opt&amp;#039;&amp;#039; and given myself full permission:&lt;br /&gt;
    sudo mkdir /opt&lt;br /&gt;
    sudo chmod u+rwx /opt&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows&amp;#039;&amp;#039;&amp;#039; has limits on file path lengths and some Linux programs do not like spaces in paths. I created a root folder called &amp;#039;&amp;#039;C:\Programs&amp;#039;&amp;#039; and gave my self full rights to it (which must be done as &amp;#039;&amp;#039;Administrator&amp;#039;&amp;#039;).&lt;br /&gt;
&lt;br /&gt;
Download an Apache Spark-archive from:&lt;br /&gt;
    https://spark.apache.org/downloads.html&lt;br /&gt;
for example this one:&lt;br /&gt;
    https://d3kbcqa49mib13.cloudfront.net/spark-2.2.0-bin-hadoop2.7.tgz&lt;br /&gt;
We will not need any source code archive.&lt;br /&gt;
&lt;br /&gt;
===Unpacking===&lt;br /&gt;
Unpack the archive into your &amp;#039;&amp;#039;Spark installation folder&amp;#039;&amp;#039;, which should be a sub-folder of the one you just created:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows:&amp;#039;&amp;#039;&amp;#039; I unpacked the archive into &amp;#039;&amp;#039;C:\Programs\spark-2.2.0-bin-hadoop2.7&amp;#039;&amp;#039;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; Copy the &amp;#039;&amp;#039;spark-2.2.0-bin-hadoop2.7&amp;#039;&amp;#039;-file into your new folder (e.g., &amp;#039;&amp;#039;/opt&amp;#039;&amp;#039;), and unpack it into, e.g., &amp;#039;&amp;#039;/opt/spark-2.2.0-bin-hadoop2.7&amp;#039;&amp;#039;):&lt;br /&gt;
    cd /opt&lt;br /&gt;
    tar zxf spark-2.2.0-bin-hadoop2.7.tar.gz&lt;br /&gt;
&lt;br /&gt;
On &amp;#039;&amp;#039;&amp;#039;Windows&amp;#039;&amp;#039;&amp;#039; you may need two additional executable files: &amp;#039;&amp;#039;hadoop.dll&amp;#039;&amp;#039; and &amp;#039;&amp;#039;winutils.exe&amp;#039;&amp;#039; (for an explanation see https://wiki.apache.org/hadoop/WindowsProblems). Maybe they are already on your PATH because you installed them with Hadoop earlier. &lt;br /&gt;
&lt;br /&gt;
Otherwise, you need to download them. Downloading executables is always risky, so continue at your own peril. I downloaded them from here: https://github.com/steveloughran/winutils/tree/master/hadoop-2.8.1 and put then in the &amp;#039;&amp;#039;.../bin&amp;#039;&amp;#039; subfolder of my Spark installation folder (i.e., under &amp;#039;&amp;#039;C:\Programs\spark-2.2.0-bin-hadoop2.7\bin&amp;#039;&amp;#039;).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;(To be checked: I am not sure Spark still needs hadoop.dll . Also, there are both 32- and 64-bit versions of &amp;#039;&amp;#039;winutils.exe&amp;#039;&amp;#039;, according to https://hernandezpaul.wordpress.com/2016/01/24/apache-spark-installation-on-windows-10/ .)&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
You need Java and a Java SDK (Software Development Kit). I have used a recent version of Java 8. To check if you have a Java SDK and which version it is, do:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
    which javac&lt;br /&gt;
    javac -version&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows:&amp;#039;&amp;#039;&amp;#039; In a &amp;#039;&amp;#039;Command Prompt&amp;#039;&amp;#039; window, do&lt;br /&gt;
    javac -version&lt;br /&gt;
&lt;br /&gt;
To install a recent Java 8:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
    sudo apt install openjdk-8-jdk&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows:&amp;#039;&amp;#039;&amp;#039; Download an installer from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html . It is best to install Java too into a folder with no space in its name, like &amp;#039;&amp;#039;C:\Programs\Java\jdk1.8.0_121&amp;#039;&amp;#039;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;MacOS:&amp;#039;&amp;#039;&amp;#039; Use an online tutorial for this. (The above link has installers for Windows too.)&lt;br /&gt;
&lt;br /&gt;
In a console (or command prompt, or terminal) window, check that it works:&lt;br /&gt;
    javac -version&lt;br /&gt;
&lt;br /&gt;
===Scala===&lt;br /&gt;
Scala is another programming language that runs on Java Virtual Machines (and thus can build on many of Java&amp;#039;s APIs). It adds &amp;#039;&amp;#039;functional programming&amp;#039;&amp;#039; on top of a Java-like syntax (version 8 of Java has since added functional programming too, but &amp;#039;&amp;#039;spark-shell&amp;#039;&amp;#039;, which we will use later, remains Scala-based.)&lt;br /&gt;
&lt;br /&gt;
To check if you have Scala and which version it is, do:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
    which scala &lt;br /&gt;
    scala -version&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows:&amp;#039;&amp;#039;&amp;#039; In a &amp;#039;&amp;#039;Command Prompt&amp;#039;&amp;#039; window, do&lt;br /&gt;
    scala -version&lt;br /&gt;
&lt;br /&gt;
To install a recent Scala:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
    sudo apt install scala&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows:&amp;#039;&amp;#039;&amp;#039; Download an installer from http://www.scala-lang.org/download/ , but skip point 2 and go down to &amp;#039;&amp;#039;Other ways to download Scala&amp;#039;&amp;#039;. I used this link:&lt;br /&gt;
    https://downloads.lightbend.com/scala/2.12.3/scala-2.12.3.tgz&lt;br /&gt;
Again, it is best to install Scala into a folder with no space in its name, like &amp;#039;&amp;#039;C:\Programs\scala-2.12.3&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
In a console (or command prompt, or terminal) window, check that it works:&lt;br /&gt;
    scala -version&lt;br /&gt;
&lt;br /&gt;
===Environment variables===&lt;br /&gt;
You need to add the Scala binaries folder to your PATH. The nicest way is to go via a SCALA_HOME environment variable. To see if SCALA_HOME is set:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;echo $SCALA_HOME&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows:&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;echo %SCALA_HOME%&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If it is set correctly, the SCALA_HOME folder will have a &amp;#039;&amp;#039;bin/&amp;#039;&amp;#039; subfolder containing files called &amp;#039;&amp;#039;scala&amp;#039;&amp;#039;, &amp;#039;&amp;#039;scalac&amp;#039;&amp;#039;, and so on. If it is not set, you need to find out where Scala has been installed to: &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; Check &amp;#039;&amp;#039;/usr/share/scala&amp;#039;&amp;#039;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows:&amp;#039;&amp;#039;&amp;#039; Check &amp;#039;&amp;#039;C:\Programs-or-Program Files\scala-something...&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
To set SCALA_HOME:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; Add this line to your &amp;#039;&amp;#039;~/.bashrc&amp;#039;&amp;#039;-file:&lt;br /&gt;
    export SCALA_HOME=/path/to/your/scala/installation/folder&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows:&amp;#039;&amp;#039;&amp;#039; Here it is hidden away. On Windows 10, in the &amp;#039;&amp;#039;Start&amp;#039;&amp;#039; menu, open &amp;#039;&amp;#039;Settings&amp;#039;&amp;#039; (the cog wheel), go to &amp;#039;&amp;#039;System -&amp;gt; About -&amp;gt; System info -&amp;gt; Advanced system settings -&amp;gt; Environment Variables&amp;#039;&amp;#039;. Here you can add and edit environment variables.&lt;br /&gt;
&lt;br /&gt;
You need to do the same thing for SPARK_HOME. It is good practice to always set environment variables like JAVA_HOME, SCALA_HOME, HADOOP_HOME, SPARK_HOME, etc. even when you do not need them immediately: other well-behaved packages you install later may be able to use them if they are set, thus saving you time and avoiding errors. Each such variable should point to an installation folder with a &amp;#039;&amp;#039;bin&amp;#039;&amp;#039; folder inside it, but not to the inner &amp;#039;&amp;#039;bin&amp;#039;&amp;#039;-folder itself.&lt;br /&gt;
&lt;br /&gt;
On &amp;#039;&amp;#039;&amp;#039;Windows&amp;#039;&amp;#039;&amp;#039;, remember that some Linux programs do not like spaces in paths. See the [[Hadoop preparations]] for a way around this problem if you run into it.&lt;br /&gt;
&lt;br /&gt;
===Modifying your PATH===&lt;br /&gt;
You need to change PATH to include SCALA_HOME/bin and SPARK_HOME/bin.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; Add this line to the end of &amp;#039;&amp;#039;~/.bashrc&amp;#039;&amp;#039;:&lt;br /&gt;
    export PATH=$SCALA_HOME/bin:$SPARK_HOME/bin:$PATH&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows:&amp;#039;&amp;#039;&amp;#039; You must go into the &amp;#039;&amp;#039;Environment variables&amp;#039;&amp;#039; tool again and edit &amp;#039;&amp;#039;PATH&amp;#039;&amp;#039;. You can use variable expressions such as &amp;#039;&amp;#039;%SCALA_HOME%\bin&amp;#039;&amp;#039; and &amp;#039;&amp;#039;%SPARK_HOME%\bin&amp;#039;&amp;#039; to define new variables.&lt;br /&gt;
&lt;br /&gt;
To put the new environment variable in effect:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Linux:&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
    source ~/.bashrc&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Windows:&amp;#039;&amp;#039;&amp;#039; Close the Command Prompt window and open a new one.&lt;br /&gt;
&lt;br /&gt;
Finally, on &amp;#039;&amp;#039;&amp;#039;Windows&amp;#039;&amp;#039;&amp;#039; you now need to run these commands:&lt;br /&gt;
    winutils chmod 777 /tmp&lt;br /&gt;
    winutils chmod 777 /tmp/hive&lt;br /&gt;
(You make have to run the &amp;#039;&amp;#039;Command Prompt&amp;#039;&amp;#039; windows &amp;#039;&amp;#039;as Administration&amp;#039;&amp;#039; to do this.)&lt;br /&gt;
&lt;br /&gt;
===Running the Spark shell===&lt;br /&gt;
Go to your home folder (you do not need to run Spark from its installation folder) and check that it works:&lt;br /&gt;
    cd ~&lt;br /&gt;
    spark-shell&lt;br /&gt;
You will get a lot of warnings, because we have not tailored Spark properly, but we will ignore them for now. In the end you should see a &amp;#039;&amp;#039;Welcome to Spark&amp;#039;&amp;#039; banner with some version information and a &amp;#039;&amp;#039;spark-shell&amp;#039;&amp;#039; command prompt:&lt;br /&gt;
    scala&amp;gt;&lt;br /&gt;
Type &amp;#039;&amp;#039;:quit&amp;#039;&amp;#039; or use &amp;#039;&amp;#039;Ctrl-D&amp;#039;&amp;#039; to terminate the spark-shell (the latter is the standard way to kill a Linux shell).&lt;br /&gt;
&lt;br /&gt;
You are now ready to [[Running Spark | get started with Apache Spark]].&lt;/div&gt;</summary>
		<author><name>Vimala</name></author>
	</entry>
</feed>