1、将主节点公钥发送给其他节点
登录主节点
ssh raspi00
生成公钥
输入以下:ssh-keygen -t rsa -P ‘’ -f ~/.ssh/id_rsa ,按回车
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
批量发送
运行脚本文件run.sh
vim run.sh
for ip in $(cat /root/ip.txt)
do
echo "=======Batch the file to the host $ip=========="
sshpass -p123456 ssh-copy-id $ip #-p选项后跟的是要拷贝主机的密码
echo -e "##########################END##########################\n"
done
测试
sh run.sh
2、测试MPI环境
编译
mpic++ -o hello_mpi hello_mpi.cpp
发送可执行文件至其他节点
../scripts/cluster-cptonodes hello_mpi raspihostfile5
../scripts/cluster-cptonodes
是已经写好的脚本文件,以raspi00为主节点,如下如所示。
raspihostfile5
如下所示:
执行
mpirun -np 20 --hostfile raspihostfile5 hello_mpi