PolarSPARC |
Building a Raspberry Pi 3 Cluster
Bhaskar S | 01/05/2019 |
Part 1
Raspberry Pi 3 is a popular and in-expensive single-board quad core ARM-based computer with 1 GB of on-board memory and 100-base ethernet. It has enough of horsepower to run Linux and hence ideal for building a mini-development cluster.
The following are the necessary items needed to build a 5-node Raspberry Pi 3 cluster:
Five Raspberry Pi 3 single-board computers
Five Aluminum Heatsink cooling kits
Five Class 10 64 GB microSDXC cards
Five Ethernet network cables
One Clear and Stackable enclosure kit
In my case, settled for a 4-layer stack since already had a spare Raspberry Pi 3 enclosed in a Premium Black Case lying around
One Multi-port USB Charging Hub with micro USB cables
One Multi-port Ethernet switch (if your home network switch does not have enough of available ports)
In my case, did not need one since have a 24-port Ethernet Switch with enough of free ports to use
One Portable USB card reader (if your desktop does not have a built-in media card reader)
In my case, did not need one since my desktop has a built-in media card reader
Part 2
Now comes the next stage - assemble the items to build the 5-node Raspberry Pi cluster.
The back of the Aluminum Heatsink contains a wax-coated paper that needs to be peeled off to mount on top of the CPU/GPU and the USB/LAN chips on the Raspberry Pi board.
Mount the larger Aluminum Heatsink on top of the CPU/GPU chip and the smaller on top of the USB/LAN chip as shown in the illustration below:
Mount each Raspberry Pi 3 board on a single Clear Plastic layer with the provided screws as shown in the illustration below:
Perform this step on all the remaining units
Mount the provided brass columns on to the 4 sides of the Clear Plastic layer as shown in the illustration below:
Perform this step on all the remaining units
The final finished Clear Plastic Enclosure should look something like the illustration as shown below:
Download the latest stable release of Raspbian Lite operating system (which is a lightweight headless/GUI-less version of Debian Linux) as shown in the illustration below:
At the time of this writing, the version of Rasbian Lite was November 2018. Once the download is complete, extract the image to a known directory (say, /home/polarsparc/Downloads). The image will be called 2018-11-13-raspbian-stretch-lite.img
Download the latest stable release of Etcher. This tool will be used to burn the Raspbian Lite operating system image into each of the microSDXC cards
Insert a microSDXC card into the card reader, launch Etcher, select the Raspbian Lite image (say from /home/polarsparc/Downloads). Then press the Flash! button to burn the image into the microSDXC card as shown in the illustration below:
Once flash operation is complete, remove and re-insert the microSDXC card into the card reader. We will see the /boot directory in the microSDXC card. Create an empty file with the name ssh. This will enable ssh based login
Insert each of the flashed microSDXC cards into each of the Raspberry Pi 3 card slots as shown in the illustration below:
Part 3
Now comes the final stage - prepare each of the Raspberry Pi 3 nodes for operation. Note, we want to connect, power-up, and setup each of the Raspberry Pi 3 cards *ONE* at a time.
Attach one end of the microUSB wire to the power slot on Raspberry Pi 3 and the other end to the USB Charging Hub. Similarly, attached one of the Ethernet cable to the RJ45 slot on Raspberry Pi 3 and the other end to the Ethernet Switch as shown in the illustration below:
Connect a HDMI monitor to the Raspberry Pi 3 using HDMI and power up the USB Charging Hub. The Raspberry Pi 3 should take few seconds to boot up and if all goes well, will present a login prompt. The default user-id is pi and the default password is raspberry. Enter the default user-id and the default password to login. At the system prompt, execute the following command:
$ sudo raspi-config
This will open a screen as shown below:
We will refer to this screen as the MAIN screen
Choose Option 1 in the the MAIN screen to change the current user password. This will open a screen as shown below:
Press enter on <Ok> and you will be prompted for the new password twice (second to confirm). This will open a screen as shown below:
Press enter on <Ok> and you will taken back to the MAIN screen
Choose Option 2 in the the MAIN screen to change the host name. This will open a screen as shown below:
Choose Option N1 to change the host name. This will open a screen as shown below:
Press enter on <Ok> and you will be presented with a new screen with the default hostname of raspberrypi as shown below:
In my case, for this instance, chose the hostname of my-node-2 as shown below:
Press enter on <Ok> and go back to the MAIN screen
Choose Option 4 in the the MAIN screen to change the Locale. This will open a screen as shown below:
Choose Option I1 to change the Locale. This will open a new screen to choose the Locale. Page down to find where the default en_GB.UTF8 is checked. Since am in the US, will uncheck the default and check en_US.UTF8 as shown below:
Press enter on <Ok> and this will open a screen as shown below:
Choose en_US, press enter on <Ok> and go back to the MAIN screen
Choose Option 7 in the the MAIN screen for advanced options. This will open a screen as shown below:
Choose Option A1 ensure the Linux filesystem is expanded to use the full space on the microSDXC card. Once the operation completes, it will open a screen as shown below:
Press enter on <Ok> and go back to the MAIN screen
On the MAIN screen navigate to <Finish> at the bottom and press enter. This will open a screen as shown below:
Press enter on <Yes> to reboot the now configured Raspberry Pi 3
Once the reboot completes, we will see the current ip address assigned to this Raspberry Pi 3 device displayed on the screen, before being presented with the login prompt. Make a note of the ip address. Let us assume the ip address is 192.168.1.200 as an example. Enter the user-id and the password at the login prompt to login. At the command prompt, execute the following command:
$ sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.bak
We want to bind the noted ip address (192.168.1.200) as the static ip address of this Raspberry Pi 3 device. Execute the following command:
$ sudo vi /etc/dhcpcd.conf
Scroll to the middle of the file and uncomment and edit the lines to look like the following:
Save the changes to the file and exit the editor
At the command prompt, execute the following command:
$ sudo shutdown -h now
This will safely shutdown the Raspberry Pi 3 device
Perform the above steps for each of the remaining Raspberry Pi 3 devices. Note that as we boot each of the remaining Raspberry Pi 3 cards, they each will get a different ip address assigned.
Hurray !!! At this point our Raspberry Pi 3 cluster is ready for action.