2.在每个节点上安装mpich2
- yum install mpich2 -y
- su - yejk
- cd /home/yejk
创建.mpd.conf文件 (文件前加".")
- vim .mpd.conf
- secretword=westos #节点的密码,每台节点都得相同
- chmod 600 .mpd.conf
创建集群节点集合文件mpd.hosts
- vim mpd.hosts
- desktop80.example.com
- desktop83.example.com
注:如果以root用户启动mpd服务, 把mpd.conf文件创建在/etc目录中(不加"."),mpd.hosts放在root主目录中
3.1测试mpich2:
启动mpich2
- mpd
观看启动机器:
- mpdtrace
- desktop80.example.com
退出:
- mpdallexit
3.2运行集群系统
- mpdboot -n 2 -f mpd.hosts 参数-n 2指定了要起动的机器个数,-f mpd.hosts指定了运行mpd.hosts文件中指定的节点。
- mpdtrace
- desktop80.example.com
- desktop83.example.com
- mpdallexit
3.3单机测试
- ./icpi-64
- Enter the number of intervals: (0 quits) 1000000000
- pi is approximately 3.1415926535921401, Error is 0.0000000000023470
- wall clock time = 46.571311
- Enter the number of intervals: (0 quits) 10000
- pi is approximately 3.1415926544231341, Error is 0.0000000008333410
- wall clock time = 0.000542
- Enter the number of intervals: (0 quits) 0
3.4 集群测试
- mpdboot -n 2 -f mpd.hosts
- mpiexec -n 2 /root/icpi-64
- Enter the number of intervals: (0 quits) 1000000000
- pi is approximately 3.1415926535899761, Error is 0.0000000000001830
- wall clock time = 15.530082
- Enter the number of intervals: (0 quits) 10000
- pi is approximately 3.1415926544231323, Error is 0.0000000008333392
- wall clock time = 0.006318
- Enter the number of intervals: (0 quits) 0
- mpdallexit
由上述测试的结果可以看出使用单机单进程运行,intervals设为1000000000,耗时46.571311秒,而用两台机器双进程则只有15.530082秒,明显快很多,并行运算还是
很有效果的。不过,如果我们把intervals改为10000,单机运行只用了0.000542秒,而两台机器却花了0.006318秒,这是因为并行运算过程中,参与运算的机器需要通过网
络传递一些消息,如果计算量不大的话,花在了这上面的时间影响会比较明显,因而反不如单机版的来得快
