Bespin is a software library that contains reference implementations of "big data" algorithms in MapReduce and Spark. It provides sample code for many of the algorithms we'll be discussing in class and also provides starting points for the assignments. You'll want to familiarize yourself with the library.
A single-node Hadoop cluster (also called "local" mode) comes
pre-configured in the linux.student.cs.uwaterloo.ca
environment. We will ensure that everything works correctly in this
environment.
TL;DR. Just set up your environment as follows (in bash; adapt accordingly for your shell of choice):
export PATH=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin:/u3/cs451/packages/spark/bin:/u3/cs451/packages/hadoop/bin:/u3/cs451/packages/maven/bin:/u3/cs451/packages/scala/bin:$PATH export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
Note that we do not advise you to add the above lines to
your shell config file (e.g., .bash_profile
), but rather
to set up your environment explicitly every time you log
in. The reason for this is to reduce the possibility of conflicts when
you start using the Datasci cluster (see below).
Alternative: these commands live in ~cs451/pub/setup.bash
so you can just run
source ~cs451/pub/setup.bashIt's easier than copy & pasting those two lines.every time. And I've included a guard that only runs them if you're on one of the student.cs Ubuntu hosts. So it is safe to add to your
.bashrc
.
Details. For the course we need Java, Scala, Hadoop, Spark,
and Maven. Java is already available in the default user environment
(but we need to point to the right version). The rest of the packages
are installed in /u3/cs451/packages/
. The
directories scala
, hadoop
, spark
,
and maven
are actually symlinks to specific
versions. This is so that we can transparently change the links to
point to different versions if necessary without affecting downstream
users. Currently, the versions are:
In addition to using the single-node Hadoop cluster
on linux.student.cs.uwaterloo.ca
, you may wish to install
all necessary software packages locally on your own machine. We
provide basic installation instructions here, but the course staff
cannot provide technical support due to the size of the class and the
idiosyncrasies of individual systems. We will be responsible for
making sure everything works properly in the Linux Student CS
Environment (above), but can only offer limited help with your own system. It's pretty straight forward in Ubuntu (whether running natively or using WSL under Windows).
Both Hadoop and Spark work fine on Mac OS X and Linux, but may be difficult to get working on Windows (I very strongly suggest that you use WSL, where it's easy). Note that to run Hadoop and Spark on your local machine comfortably, you'll need at least 4 GB memory and plenty of disk space (at least 10 GB).
You'll also need Java (Must use JDK 1.8), Scala (must use Scala 2.12.20 EXACTLY since Maven is picky about versions), and Maven (any reasonably recent version).
The versions of the packages installed
on linux.student.cs.uwaterloo.ca
are as follows:
Download the above packages, unpack the tarball, add their
respective bin/
directories to your path (and your shell
config), and you should be go to go.
Alternatively, you can also install the various packages using a
package manager, e.g., apt-get
, MacPorts, etc. However,
make sure you get the right version.
brew
for OS X.)
javac -version
say?
update-alternatives --list javac
to see all versions of java that are installed. If you see that 1.8.0 is installed, then you can make it the default:
sudo update-alternatives --set java {wherever it said java 8 was installed}/bin/java
sudo update-alternatives --set javac {wherever it said java 8 was installed}/bin/javac
(I don't know the non-ubuntu alternatives for update-alternatives
)
If you got "command not found" or the alternatives list did not contain Java 8, you can install it like this: sudo apt install openjdk-8-jdk
. If you have multiple versions installed now you will need to do the update-alternatives commands above.
wget https://github.com/scala/scala/releases/download/v2.12.20/scala-2.12.20.deb
. For OS X the above link has instructions for using brew
or port
to install it.
If you have the .deb file downloaded then run sudo apt install ./scala-2.12.20.deb
sudo apt install maven
The version doesn't matter so whatever version is in the distro's repository is fine.
/opt/hadoop
for example. Or extract it in your home directory and it'll be at ~/hadoop-.../ Or anywhere you want. Just remember where you put it.
/opt/spark
for example. Or anywhere you want.
export HADOOP_HOME={path where you unzipped hadoop}
export SPARK_HOME={path where you unzipped spark}
export PATH=$HADOOP_HOME/bin:$SPARK_HOME/bin:$PATH
You *might* also need to do this to $SPARK_HOME/conf/spark-env.sh
: add/uncomment the line
export SPARK_DIST_CLASSPATH=$(hadoop classpath)
I have a note that says to do it, but this might be out of date.
spark-shell
You should get a scala prompt.
See if it runs Spark code without errors:
scala> sc.parallelize(Array(1,2,3,4,5)).map(_*2).collect
res0: Array[Int] = Array(2, 4, 6, 8, 10)
At that point you're good to go!
In addition to running "toy" Hadoop on a single node (which obviously defeats the point of a distributed framework), we're going to using the school's modest Hadoop teaching cluster called Datasci.
Actually, I've been told some courses' setup scripts modify your startup - so if you only had to run it once, instead of each login, it probably messed with your environment and you'll have to undo this!
Accounts are already set up for students enrolled in the course. You should be able to log into the cluster as follows:
ssh <your userid>@datasci-login.cs.uwaterloo.ca
NOTE: You must configure a public/private keypair. You can find directions here: MFCF - Creating SSH keys. Datasci shares the file system with student.cs so adding to your authorized_keys file on student.cs will also add it to datasci.
If you're using PuTTY on Windows, the program to use is called "PuTTYGen". Save the private key somewhere, and copy public key text shown into "~/.ssh/authorized_keys". Unlike under Linux, putty does not default to trying private keys, you have to configure this manually. Under "Connection" > "SSH" > "Auth", enter the location of your private key in the box labeled "Private key for authentication".
Warning: datasci-login only accepts connections from on-campus. To connect from home you must use a VPN, like the School of Computer Science VPN. Follow the directions on that page to get started. The campus VPN should also work. Note: You can also ssh to student.cs from off-campus then ssh to datasci-login, but you really should install the VPN as you also need to be on the VPN to view the cluster monitoring page!
NOTE: Do not set up the environment in Datasci. The path is already set.