Hardware Reference
In-Depth Information
ond card into your second Raspberry Pi and boot it. You should now have two Rasp-
berry Pis on. Unless otherwise stated, all the commands that follow are typed from
the Master Pi that you built first.
Use SSH Instead of Password Login Between the Pis
Using RSA will give you a much quicker login. Working on the master Pi node:
$ cd ~
$ ssh-keygen -t rsa -C “raspberrypi@raspberrypi”
This sets a default location of
/home/pi/.ssh/id_rsa
to store the key. Enter a pass-
phrase (e.g.,
myfirstpicluster
). If you leave this blank, you'll have bad security, but
you won't have to type passphrases any more.
Next, copy the keys to the Raspberry Pi:
$ cat ~/.ssh/id_rsa.pub | ssh pi@192.168.1.162 "mkdir .ssh;cat >> .ssh/
authorized_keys"
Log on to your second Pi and enter:
$ ls -al ~/.ssh
You should see a file called
authorized_keys
. This file is your ticket to No-Login Heaven
on the nodes. Now add the new Pi to
machinefile
. Log into it and get its IP address
(
ifconfig
). Working on the Master Raspberry Pi (the first one you built),
machine
file
should now have both of the IP addresses for your Raspberry Pis—for example:
192.168.1.161
192.168.1.162
Again it's time to run a little C code. Like before, you'll find the CPI example in the
examples subdirectory of where you built MPI. The first time, you will need to enter
the passphrase for the key you generated (unless you left it blank) and the password
for the second Pi:
$ cd /home/pi/mpi_testing
$ mpiexec -f machinefile -n 2 ~/mpich_build/examples/cpi
Process 0 of 2 is on raspberrypi
Process 1 of 2 is on raspberrypi
pi is approximately 3.1415926544231318, Error is 0.0000000008333387
If you repeat this a second time, you won't need to type any passwords. Note that you
have
not
changed the hostnames yet (so yes, the previous code
is
running on the two
machines, but they both have the same hostname at the moment).
If you want to rename each machine, you can do it from the Master node: