Part-B Assignment No. 3
Part-B Assignment No. 3
----------------------------------------------------------------------------------------------------------------
Group B
Assignment No: 3
----------------------------------------------------------------------------------------------------------------
Theory:
● Steps to Install Scala
● Apache Spark Framework Installation
● Souce Code
1) Install Scala
Step 2) Install Scala from the apt repository by running the following commands to search for
scala and install it.
Apache Spark is an open-source, distributed processing system used for big data workloads. It
utilizes in-memory caching, and optimized query execution for fast analytic queries against data
of any size.
Step 1) Now go to the official Apache Spark download page and grab the latest version (i.e.
3.2.1) at the time of writing this article. Alternatively, you can use the wget command to
download the file directly in the terminal.
wget https://apachemirror.wuchna.com/spark/spark-3.2.1/spark-3.2.1-bin-hadoop2.7.tgz
Step 4) Now you have to set a few environmental variables in .profile file before starting up the
spark.
Step 5) To make sure that these new environment variables are reachable within the shell and
available to Apache Spark, it is also mandatory to run the following command to take recent
changes into effect.
source ~/.profile
Step 6) ls -l /opt/spark
Step 7) Run the following command to start the Spark master service and slave service.
start-master.sh
start-workers.sh spark://localhost:7077
(if workers not starting then remove and install openssh:
sudo apt-get remove openssh-client openssh-server
sudo apt-get install openssh-client openssh-server)
Step 8) Once the service is started go to the browser and type the following URL access spark
page. From the page, you can see my master and slave service is started.
http://localhost:8080/
Step 9) You can also check if spark-shell works fine by launching the spark-shell command.
Spark-shell
Source Code:
object ExampleString {
def main(args: Array[String]) {
}
}
/**declare a variable*/
var number= (-100);
if(number==0){
println("number is zero");
}
else if(number>0){
println("number is positive");
}
else{
println("number is negative");
}
}
}
object ExFindLargest {
def main(args: Array[String]) {
var number1=20;
var number2=30;
var x = 10;
if( number1>number2){
println("Largest number is:" + number1);
}
else{
println("Largest number is:" + number2);
}
}
}
Assignment Questions
1. Write down steps to install scala.