转自:http://wuyanzan60688.blog.163.com/blog/static/12777616320132851924235/
MPI作为一种通过消息传递进行并行计算的框架,在很多科学计算上有很重要的应用,这次因为GraphLab环境搭建时的需要,花了三个来小时的时间进行了初步的搭建摸索,感觉很有意思!
#tar -zxvf mpich2-1.0.8.tar.gz
#./configure (我让它默认安装到/usr/local/bin下,不需要设置安装路径)
#make
#make install
注意:对于集群的每一个机器都要安装,当然你如果用NFS挂载也可以,我没这样用。#touch /etc/mpd.conf
#chmod 600 /etc/mpd.conf
#echo secretword=myword >> /etc/mpd.conf
到此为止,单机安装就算完成了,可以进行单机测试# mpd &
[1]4457
# mpdtrace
vm4
# mpdallexit
node9 #主服务器
vm4 #子节点
在主机中测试部署是否成功:# mpdboot -n 2 -f /root/mpd.hosts
# mpdtrace
node9
vm4
# ./icpi
Enter the number of intervals:(0 quits)10000000000
pi is approximately 3.1415926535895782,Erroris0.0000000000002149
wall clock time =45.378959
Enter the number of intervals:(0 quits)1000
pi is approximately 3.1415927369231227,Erroris0.0000000833333296
wall clock time =0.000149
[root@node9 wyztest]# mpiexec -n 2 ./icpi
Enter the number of intervals:(0 quits)10000000000
pi is approximately 3.1415926535895737,Erroris0.0000000000002194
wall clock time =22.696655
Enter the number of intervals:(0 quits)0
Enter the number of intervals:(0 quits)1000
pi is approximately 3.1415927369231254,Erroris0.0000000833333322
wall clock time =0.001589
/usr/local/bin/mpdlib.py:8:DeprecationWarning:The popen2 moduleis deprecated.Use the subprocess module.
import sys, os, signal, popen2, socket,select, inspect
/usr/local/bin/mpdlib.py:15:DeprecationWarning: the md5 moduleis deprecated;use hashlib instead
from md5 importnewas md5new
#ssh node2
ssh: node2: Temporary failure in name resolution
#ssh 192.168.169.2 则成功
原因:/etc/hosts中配置不完全192.168.168.9 node9
192.168.169.2 node2
[root@node9 source]# mpdboot -n 2 -f /root/mpd.hosts
mpdboot_node9 (handle_mpd_output 401): failed to connect to mpd on node2
[root@node2 .ssh]# iptables -F
[root@node2 .ssh]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination