DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Big Data
  4. Getting Started With Alluxio and Spark in 5 Minutes

Getting Started With Alluxio and Spark in 5 Minutes

In this quick post, you'll learn how to get Alluxio and Spark up and running on your machine.

Calvin Jia user avatar by
Calvin Jia
·
Apr. 03, 19 · Tutorial
Like (9)
Save
Tweet
Share
11.49K Views

Join the DZone community and get the full member experience.

Join For Free

Co-authored by Alex Ma.

Introduction

Apache Spark has brought significant innovation to Big Data computing, but its results are even more extraordinary when paired with Alluxio. Alluxio provides Spark with a reliable data sharing layer, enabling Spark to excel at performing application logic while Alluxio handles storage. Bazaarvoice uses the combination of Spark and Alluxio to provide a real-time big data platform that has the ability to not only handle the intake of 1.5 billion page views during peak events like Black Friday but also provides real-time analytics against it (read more). At this scale, the gain in speed is an enabler for new workloads. We’ve established a clean and simple way to integrate Alluxio and Spark.

This blog is for those who are new to and interested in how to leverage Alluxio with Spark, and all of the examples will be reproducible on your local machine with simple steps.

Getting Started

To get started with Alluxio and Spark, you will first need to download a distribution for the two systems, install Java 8 and download sample data to work through the exercises.

  • Alluxio 1.8.1
  • Spark 2.4.0
  • Install Java - JDK 8
  • Sample data file

Download Alluxio and Spark to a working directory. The sample data files can be downloaded and unpacked there as well or in /tmp, the full path to the sample files must be referenced from Spark.

Setting Up Alluxio

  • Turn on remote login service so that ssh localhost can succeed.

remote login

  • To avoid the need to repeatedly input the password, you can add the public SSH key for the host into ~/.ssh/authorized_keys. See this tutorial for more details.

Download, extract, and start a precompiled release of Alluxio from the Alluxio website.

$ tar -zxf alluxio-1.8.1-bin.tar.gz
$ cd alluxio-1.8.1
$ bin/alluxio bootstrap-conf localhost
$ bin/alluxio-start.sh local -f

Verify that the Alluxio system is running by visiting the web UI at localhost:19999/home.

Setting Up Spark

Extract the precompiled release of Spark:

$ tar -zxf spark-2.4.0-bin-hadoop2.7.tgz
$ cd spark-2.4.0-bin-hadoop2.7

Start the spark-shell program by running the following command from the Spark project directory. In the interactive shell you can manipulate data from various sources, in this case, it will be the local file system.

Integrating Alluxio and Spark

Spark needs an Alluxio client jar which let's Spark programs talk with Alluxio; this is the point of integration between the two systems. Specify it with the --driver-class-path parameter followed by the path to the client jar which is located in the client directory of the Alluxio package.

$ cd spark-2.4.0-bin-hadoop2.7
$ bin/spark-shell --driver-class-path <PATH>/alluxio-1.8.1/client/alluxio-1.8.1-client.jar

Running a Simple Example

As a first example, we will run Alluxio with Spark reading data from local storage to get familiar with the integration between the two systems. The sample data file that was downloaded earlier contains files filled with randomly generated words from an English dictionary 2GB in size.

$ cd /tmp
$ tar -zxf sample-2g.tar.gz

Process the 2GB sample file in Spark and count how many lines are in it. Make sure to specify the correct path.

scala> val file = sc.textFile("/tmp/sample-2g")
scala> file.count()

Alluxio can also be used as a source or sink for your data. You can save the file to Alluxio and similarly run the same operations on the data from Alluxio, as you would for your local file system.

scala> file.saveAsTextFile("alluxio://localhost:19998/sample-2g")
scala> val alluxioFile = sc.textFile("alluxio://localhost:19998/sample-2g")
scala> alluxioFile.count()

Conclusion

This is an introduction to using Alluxio with Spark. Our next blog will go into additional details around the benefits of leveraging Alluxio with Spark:

  • Data sharing between multiple jobs: Only one job needs to incur the slow read from cold data.
  • Resilience against job failures: Data is preserved in Alluxio across job failures or restarts.
  • Managed storage: Alluxio optimizes the utilization of allocated storage across applications.
Alluxio Big data

Published at DZone with permission of Calvin Jia, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Secrets Management
  • The 31 Flavors of Data Lineage and Why Vanilla Doesn’t Cut It
  • Core Machine Learning Metrics
  • Apache Kafka vs. Memphis.dev

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: