As I said in my last post this step is fairly easy and overall gave me the least amount of trouble.
- Setting up a Hyperledger Fabric development environment on a Raspberry Pi
- Building Hyperledger Fabric on Raspberry Pi
- Setting up a Docker Swarm on Raspberry Pi
- Deploying a Hyperledger Fabric network on the Swarm with Docker Stack and testing with BYFN.
Before we dive in I want to mention some prerequisite equipment you’ll need. You should have at least 3 Raspberry Pis (<– this looks so wrong to me… Pies?) to setup up a true Raspberry Pi Docker Swarm. This means you’ll need SD card for each and a way to power them, I recommend a USB power hub like this (something with 60 watts and 6 ports).
Establishing the Master
If you’ve been following along with this series you should already have a RasPi setup to do your builds we’ll use this same RasPi as our Swarm Master. I recommend connecting to your master via SSH so you can copy the token from the following command.
docker swarm init
Setup your additional Raspis
Now that we have a master and our join token lets setup our workers. This process should feel pretty similar to the setup from step 1, because it is.
- Put Raspbian Lite on your SD card (I’m using Raspbian Stretch Lite and Etcher).
- Bootup & Login
- Default User: pi
- Default Pass: raspberry
- Perform initial config of your RasPi
- Change the password
- Network Options:
- Change the hostname (something like hyperledger-swarm-nodeX <– this will be important in the next step if yours are different than mine)
- Connect to WiFi (unless you want to use a switch and wires…)
- Localisation Options (Optional):
- Set the timezone
- Localise the keyboard to the US
- Set the WiFi country to the US
- Interface Options:
- Enable SSH
- Advanced Options:
- Memory Split = 16 (MB)
- Ensure your WiFi is up (ifconfig – make sure you have an IP on wlan0)
- Update and upgrade
sudo apt-get update
sudo apt-get dist-upgrade
- Reboot after upgrade
- Install Docker
curl -sSL https://get.docker.com | sh
- Create a new user
sudo adduser *username*
sudo usermod -aG sudo *username*
sudo usermod -aG docker *username*
- Install git
sudo apt-get install git
Some of my RasPis are old and finicky…
If you run into issues with Hash Sum mismatches or notice that things like apt-get update take FOREVER check your wifi signal (sudo iwlist wlan0 scan). 2 of my 5 RasPis have issues with their on board WiFi now. I’m not sure if the issue is hardware or Stretch related… but I put a dongle from my old RasPi 2 on one of my 3s and plugged ethernet into the other one and that seemed to resolve the issue.
Add Nodes to the Swarm
Once the RasPi is configured ssh into it and paste in the docker swarm join command and token that was outputed from the swarm init command into your terminal.
docker swarm join --token SWMTKN-1-xxxxxxxx 192.168.1.xxx:2377
This node joined a swarm as a worker.
Once all of your nodes have been added check your master node and confirm that it’s got all of them registered.
docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
bwspa23y1q9u8vf9o47z4nzl7 * hyperledger-swarm-master Ready Active Leader
jprbnpd43aob1fdwb5gcxv5ke hyperledger-swarm-node1 Ready Active
u19qeett9ycr0qg4mpjimv3zk hyperledger-swarm-node2 Ready Active
84cbc1zwt385bplvvwl38kcah hyperledger-swarm-node3 Ready Active
That’s it now we are ready for the grand finale, running the E2E test on our swarm. See you on the next one.