Install Spark under Windows

Source: Internet
Author: User

1. Install Scala, download link Https://downloads.lightbend.com/scala/2.12.3/scala-2.12.3.msi

Create the system variable Scala_home to C:\Program Files (x86) \scala, and then add%scala_home%\bin to the system path variable

Then open the cmd window and run Scala, you should see the following information

2. Install JDK, download link, http://www.oracle.com/technetwork/java/javase/downloads/index.html, spark2.2 request jdk8, so download

Java SE 8u144

Create the system variable Java_home to C:\Program files\java\jdk1.8.0_144 and add%java_home%\bin to the system path variable

Create system variable classpath, content is%java_homt%\lib;%java_homt%\lib\tools.jar;

Open the cmd window, enter Java-version,

3. Install Spark, download link http://spark.apache.org/downloads.html

Click the 4th step of the link to download, and then extract the contents of the content into the C:\Spark folder,

Create system variable spark_home, content C:\Spark\bin, add%spark_home% and%spark_home%\sbin to system variable path

4. Install Hadoop winutils, download link https://github.com/steveloughran/winutils, select the Hadoop version number you want, For example 2.8.1, you only need to download Winutils.exe and then copy to the C:\Hadoop\bin folder.

Create system variable Hadoop_home, C:\Hadoop, add%hadoop_home%\bin to PATH variable

5. Open cmd as Administrator , run Spark-shell, run Winutils.exe chmod 777–r If you encounter errors such as access rights C:\tmp\hive

6. Open cmd as Administrator , run Spark-shell, you should see the following interface

Most importantly, you have to see spark context available as ' sc ' (master = local[*], app id = local-1507235397368). words

7. Spark Hello World Example

After the scala> prompt, enter run

Val textfile = Sc.textfile (file:///Spark/README.md)

Val tokenizedfiledata = Textfile.flatmap (Line=>line.split (""))

Val countprep = Tokenizedfiledata.map (word=> (word,1))

Val counts = Countprep.reducebykey ((accumvalue, newvalue) =>accumvalue+newvalue)

var sortedcounts = Counts.sortby (kvpair=>kvpair._2,false)

Sortedcounts.saveastextfile (File:///OutputData/ReadMeWordCount)

Open the C drive, you should see the Outputdata folder, inside the Readmewordcount folder, inside the contents of

View files part-00000 and part-00001, which are the number of occurrences of each word in the readme.md file.

Install Spark under Windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.