Setting up a Raspberry Pi Cluster Node
To set up a Raspberry Pi node I will follow a specific set of steps so that every Pi is set up similarly. For the initial deployment I will follow this once and then clone the SD Card multiple times. If at a later date more are added I will use this guide to follow a basic setup.
This guide can be followed to set up any headless (no monitor/keyboard/mouse attached) Raspberry Pi.
Burning Raspbian and configuring it
The first step is to burn Raspbian to a SD card, some additional details here. Once this has done, but before you put the SD card into the Raspberry Pi you need to ensure you set up SSH. I recommend following my previous guide to setting up SSH for Raspberry Pi.
Without following this you will need to log onto the Raspberry Pi using a keyboard, mouse, and monitor and set up SSH using the GUI.
Setting up Raspbian to run headless
Since I am not currently planning to connect the Raspberry Pi to a screen I will set it up to focus on setting it up for headless operation.
The system utility raspi-config
can be used to change a number of import settings. It can be run by running `sudo raspi-config`.
Once in the Raspi-config menu I will set the hostname using that option on the menu. Under boot options I will also change it to cli mode. This will stop it booting to the desktop when loading and will conserve CPU and RAM during running.
In the advanced options I will select expand filesystem
. This wont be needed if I have burned the Raspbian image to a SD card but if I clone the SD card to a larger card this is required. If no changes are needed this option will have no effect.
To update the Raspberry Pi you can run the following commands
sudo apt-get update sudo apt-get upgrade
Running apt-get update
will update the package list. This will then allow running apt-get upgrade
to install new packages.
Installing packages and setting up user accounts
Now I have the Raspberry Pi updated and ready to run headless I will install a couple more programs.
Personally to run a headless Raspberry Pi I always install at least the below programs using the command
sudo apt-get install vim htop byobu screen
vim
is my preferred command line editor. It appears its not installed by default so it must be installed first!htop
is a more graphical version of the standard linux tooltop
. Its colour more than wins me over from standard topbyobu
is a very useful addition on top of screen or tmux. It customises how screen/tmux works and adds some useful information along the top/bottomscreen
is my chosen terminal multiplexer that I use with byobu.
Once these programs have been installed I create a new user to run my scripts. This can be done by following my previous “how to create a user” guide.
Once the user has been created I give it the video
group. This is important so I can run vcgencmd commands.
sudo usermod -aG video chewett
In addition to giving my user the video group, I also want to give myself sudo rights.
sudo usermod -aG sudo chewett
This will let be run anything that needs super user rights.
Finally I set up my SSH keys by copying the SSH keys from my bunker-master Raspberry Pi to the newly created image.
mkdir .ssh scp bunker-master:~/.ssh/* .
This I will use to log in via my private key and removes the need to enter my password every time.
Now I have set up my Raspberry Pi Image I can then clone the image to my other SD Cards. Saving this image will give me a standard image that I can deploy to any new slave I want to add into the system.