MpichCluster
Setting Up an MPICH2 Cluster in Ubuntu 8.04 LTS Server (Quick-Note)
(https://wiki.ubuntu.com/MpichCluster)
===========================
1. 更改 /etc/hosts,方便遠端直接快速連結。
===========================
假設有兩個 mpi node,所有 node 的 /etc/hosts 都需修改
master@mpi-1:~$ sudo vi /etc/hosts
master@mpi-2:~$ sudo vi /etc/hosts
10.211.55.5 mpi-1
10.211.55.6 mpi-2
=================================
2. 安裝及設定 NFS,讓各 node 有共享的 master folder。
=================================
master@mpi-1:~$ sudo apt-get install nfs-kernel-server
(在此以 mpi-1 主機作為 master)
設定 NFS 目錄與掛載權限
master@mpi-1:~$ sudo mkdir /mpi
master@mpi-1:~$ sudo vi /etc/exports
/mpi *(rw,sync)
master@mpi-1:~$ sudo chown master:master /mpi
master@mpi-1:~$ sudo /etc/init.d/nfs-kernel-server restart
在其他 node 掛載 mpi-1 master folder
master@mpi-2:~$ sudo mkdir /mpi
master@mpi-2:~$ sudo chown master:master /mpi
master@mpi-2:~$ sudo apt-get install nfs-common
master@mpi-2:~$ sudo mount -t nfs mpi-1:/mpi /mpi
==========================================
3. 安裝 ssh,設定金鑰讓各 node 之間以 master 帳號連結不用輸入密碼。
==========================================
(主要是為了方便往後可在 scripts 裡設定各 node 自動串連)
master@mpi-1:~$ sudo apt-get install ssh
master@mpi-2:~$ sudo apt-get install ssh
master@mpi-1:~$ ssh-keygen -t dsa
master@mpi-1:~$ scp .ssh/id_dsa.pub master@mpi-2:~/mpi-1.pub
master@mpi-2:~$ cat mpi-1.pub >> .ssh/authorized_keys
master@mpi-2:~$ ssh-keygen -t dsa
master@mpi-2:~$ scp .ssh/id_dsa.pub master@mpi-1:~/mpi-2.pub
master@mpi-1:~$ cat mpi-2.pub >> .ssh/authorized_keys
測試登入 (不用輸入密碼)
master@mpi-1:~$ ssh mpi-2
master@mpi-2:~$ ssh mpi-1
============
4. 安裝 MPICH2
============
http://www.mcs.anl.gov/research/projects/mpich2
只要在 mpi-1 master folder 安裝一次即可
master@mpi-1:~$ cd /mpi
master@mpi-1:/mpi $ wget http://www.mcs.anl.gov/research/projects/mpich2/downloads/tarballs/1.1.1p1/mpich2-1.1.1p1.tar.gz
master@mpi-1:/mpi $ sudo apt-get install build-essential
master@mpi-1:/mpi $ mkidr mpich2
master@mpi-1:/mpi $ tar xzvf mpich2-1.1.1p1.tar.gz
master@mpi-1:/mpi $ cd mpich2-1.1.1p1
master@mpi-1:/mpi/mpich2-1.1.1p1 $ ./configure --prefix=/mpi/mpich2
master@mpi-1:/mpi/mpich2-1.1.1p1 $ make
master@mpi-1:/mpi/mpich2-1.1.1p1 $ sudo make install
設定 PATH 環境變數 (每個 node 都要設定)
master@mpi-1:~$ vi .bashrc
master@mpi-2:~$ vi .bashrc
export PATH="/mpi/mpich2/bin:$PATH"
export LD_LIBRARY_PATH="/mpi/mpich2/lib:$LD_LIBRARY_PATH"
在各個 node 上測試程式路徑是否正確
master@mpi-1:~$ which mpd
master@mpi-1:~$ which mpiexec
master@mpi-1:~$ which mpirun
master@mpi-2:~$ which mpd
master@mpi-2:~$ which mpiexec
master@mpi-2:~$ which mpirun
============
5. 設定 MPICH2
============
在各個 node 上建立 .mpd.conf 及 mpd.hosts
master@mpi-1:~$ vi mpd.hosts
master@mpi-2:~$ vi mpd.hosts
mpi-1
mpi-2
master@mpi-1:~$ echo MPD_SECRETWORD=xxx-xx > .mpd.conf
master@mpi-1:~$ chmod 600 .mpd.conf
master@mpi-2:~$ echo MPD_SECRETWORD=xxx-xx > .mpd.conf
master@mpi-2:~$ chmod 600 .mpd.conf
啟動各個 node 的 mpi service
master@mpi-1:~$ mpd &
master@mpi-1:~$ mpdboot -n 2
master@mpi-2:~$ mpd &
master@mpi-2:~$ mpdboot -n 2
在各 node 上檢查是否運行成功
master@mpi-1:~$ mpdtrace
mpi-1
mpi-2
master@mpi-2:~$ mpdtrace
mpi-1
mpi-2
完工
=====================
6. 另外可搭配安裝設定 mpiBLAST
=====================
master@mpi-1:~$ sudo apt-get install libncbi6 libncbi6-dev ncbi-data ncbi-tools-bin ncbi-tools-x11 libncbi6-dbg csh
Installation Guide:
http://www.mpiblast.org/Docs/Install
.









