Spark with Pi Cluster 1
Infrastructure
flowchart TD;
A[Router] -->|Ethernet| B[Switch];
subgraph s1[Cluster];
direction LR;
C[(Pi 1)] <-..-> D[(Pi 2)];
D <-..-> E[(Pi 3)];
C <-..-> E;
end;
B -->|Ethernet| s1;
A -..->|Wifi| F[Laptop]
F <-..-> s1;
Configure SSH for intercommunications
- Change hostname for each pi,
- For each pi, do the same in
/etc/hosts
, comment out 127.0.1.1 raspberrypi
and add lines at the end,
#127.0.1.1 raspberrypi
192.168.0.14 pi41
192.168.0.15 pi42
192.168.0.16 pi43
- For each pi, change the hostname as pi4x in
/etc/hostname
, replace x with another number, like pi41 pi42 pi43,
pi4x
- Reboot each machine now.
- Test:
ssh pi@pi4x
.
- Simplify ssh command via ssh alias,
- In my laptop, edit
~/.ssh/config
, copy to all pis as well,
Host pi41
User pi
Hostname 192.168.0.14
Host pi42
User pi
Hostname 192.168.0.15
Host pi43
User pi
Hostname 192.168.0.16
- Test:
ssh pi4x
- Allow public/private key pairs for ssh among pis and laptop,
- In each pi server, generate a public/private key pairs,
ssh-keygen -t ed25519
# all default is fine
- Copy public key from client to the target server means that you can ssh into the target without any password anymore.
# all server (14)
cat .ssh/id_ed25519.pub >> .ssh/authorized_keys
# all clients (15,16)
cat ~/.ssh/id_ed25519.pub | ssh pi@192.168.0.14 'cat >> .ssh/authorized_keys'
OR
ssh-copy-id -i pi@pi41
ssh-copy-id -i pi@pi42
ssh-copy-id -i pi@pi43
- Copy this
authorized_keys
to every server,
scp ~/.ssh/authorized_keys pi@pi4x:~/.ssh
- Test:
ssh pi41
, it should not require any password anymore.
- Make command shorter,
- Add extra lines in
~/.bashrc
,
alias p1="ssh pi41"
alias p2="ssh pi42"
alias p3="ssh pi43"
- Run the bash file.
source ~/.bashrc
- Test:
p1
should have the same effect as ssh pi41
.
References