MpichCluster

Differences between revisions 2 and 3
Revision 2 as of 2007-07-05 16:37:30
Size: 7580
Editor: 85
Comment:
Revision 3 as of 2007-07-29 21:32:11
Size: 4735
Editor: 85
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= برپا سازی کلاستر MPICH2 در اوبونتو ۷.۰۴ =

تهیه کننده: '''[:OmidAlemi:امید عالمی]'''
= Setting up an MPICH2 Cluster in Ubuntu =

Creator: '''[:OmidAlemi: Omid Alemi]'''
Line 8: Line 8:
این راهنما برای برپایی یک کلاستر ساده در اوبونتو ۷.۰۴ است. درواقع این راهنما راه اندازی یک کلاستر را در ساده ترین حالت بشما آموزش می دهد.

در اینجا ما ۴ گره داریم که روی هر کدام اوبونتو نصب است. نام های آن ها ub2, ub1, ub0 و ub3 است.







== ۱. تعریف اسامی گره ها در etc/hosts/ ==
فایل etc/hosts/ خود را به صورت زیر ویرایش می کنیم:
[[en]]
This how-to describes a guide to building a simple MPICH cluster in ubuntu.

Here we have 4 nodes running ubuntu 7.04 with these host names: ub0,ub1,ub2,ub3;



== 1. Defining hostnames in etc/hosts/ ==

Edit /etc/hosts like these:
Line 31: Line 28:
دقت کنید که محتوات فایل فوق به صورت زیر نباشد:

[[en]]
Note that the file shouldn't be like this:
Line 45: Line 41:
== ۲. نصب NFS ==
برای نصب سرور NFS دستور زیر را در خط فرمان اجرا می کنیم:

[[en]]
== 2. Installing NFS ==

To Install NFS just run this in terminal:
Line 54: Line 50:
== ۳. به اشتراک گذاری پوشه اصلی ==
پوشه ای را در تمامی گره ها ایجاد می کنیم. برنامه ها و داده های ما در این پوشه قرار خواهند گرفت:
[[en]]
== 3. Sharing Master Folder ==
Make a folder in all nodes, we'll store our data and programs in this folder.
Line 63: Line 59:
سپس آن را در گره اصلی توسط NFS برای گره های دیگر به اشتراک می گذاریم:
[[en]]
And then we share it over nodes on the master node.
Line 72: Line 68:
''دقت کنید که برنامه ها و دیگر داده های ما فقط در mirror/ گره اصلی ذخیره میشوند و گره های دیگر توسط گره اصلی به آنها دسترسی دارند.''
== ۴. ماونت کردن mirror/ در گره های دیگر ==


[[en]]

Note than we store out data and programs only in master node and other nodes will access them with NFS.
== 4. Mounting /master in nodes ==
Line 85: Line 79:
بهتر است که fstab را تنظیم کنیم تا این کار به طور خودکار در هربار راه اندازی سیستم انجام شود.

== ۵. تعریف کاربر مورد نظر برای اجرای برنامه های mpi ==
کاربری با نام واحد برای تمامی گره ها تعریف می کنیم به طوری که پوشه خانگی آن در mirror/ باشد. دقت کنید که userid این کاربر باید در تمام گره ها یکسان باشد.

در اینجا ما آن را ''' mpiu ''' می نامیم!

همچنین این کاربر را مالک mirror/ می کنیم:

[[en]]
it's better to change fstab in order to mount it on every boot.

== 5. Defining a user for running MPI programs==
We define a user with same name and same userid in all nodes with a home directory in /mirror.

Here we name it "mpiu"! Also we change the owner of /mirror to mpiu:
Line 102: Line 92:
== ۶. نصب سرور SSH ==
دستور زیر را برای نصب OpenSSH Server در همه گره ها اجرا می کنیم:
[[en]]
== 6. Installing SSH Server ==
Run this command in all nodes in order to install OpenSSH Server
Line 111: Line 101:
== ۷. تنظیم SSH برای برقراری ارتباط بدون کلمه عبور بین گره ها ==
ابتدا با کاربر جدید وارد می شویم :
[[en]]
== 7. Setting up SSH with no pass phrase for communicating between nodes ==
First we login with our new user:
Line 120: Line 110:
سپس کلید DSA را برای کاربر mpiu می سازیم:

[[en]]
Then we generate DSA key for mpiu:

Line 129: Line 119:
در اینجا از شما passphrase خواسته می شود که باید آن را خالی بگذارید.

سپس کلید ساخته شده را در لیست کلیدهای مورد تایید قرار می دهیم:
[[en]]
Leave passphrase empty.

Next we add this key to authorized keys:
Line 140: Line 130:
به دلیل اینکه پوشه خانگی کاربر ما در همه گره ها یکی است (در گره اصلی)‌ نیازی به اجرای دستورات فوق در تک تک گره ها نیست.

برای امتحان درستی عملکرد SSH دستور زیر را اجرا می کنیم:
[[en]]
As the home directory of mpiu in all nodes is the same (/mirror/mpiu) , there is no need to run these commands on all nodes.

To test SSH run:
Line 150: Line 140:
این دستور باید بدون درخواست کلمه عبور نام گره مورد نظر (ub1) را چاپ کند.

== ۸. نصب کامپایر GCC ==
بسته build-essential را نصب می کنیم
[[en]]
It should return remote hostname without asking for passphrase.

== 8. Installing GCC ==
Install build-essential package:
Line 161: Line 151:
== ۹. نصب دیگر کامپایلرها ==
برای نصب MPICH باید از قبل کامپایلرهای مورد مورد نیاز نصب شده باشند.

در این مرحله باید کامپایلرهای مورد نیاز خود مانند Intel Fortran و ... را نصب کنیم.

== ۱۰. نصب MPICH2 ==
کد منبع MPICH2 را از سایت http://www-unix.mcs.anl.gov/mpi/mpich دریافت کنید.

فایل tar. را در پوشه mirror/ باز می کنیم.همچنین پوشه ای برای نصب mpich ایجاد می کنیم.

[[en]]
== 9.Installing Other Compilers ==
Other prefered compilers should be installed before installing MPICH.

In this step we install other compilers such as Inter Fortran, SGI compiler , ... .

== 10. Installing MPICH2 ==
Download MPICH2 source code from http://www-unix.mcs.anl.gov/mpi/mpich .

Extract .tar.bz2 file in /mirror. Also make a folder for MPICH installation.
Line 183: Line 171:
برای تنظیمات بیشتر قبل از کامپایل می توانید فایل README داخل بسته را مطاله کنید.

بعد از اجرای موفقیت آمیز دستورات فوق خطوط زیر را به فایل mirror/mpiu/.bashrc/ اضافه می کنیم:

[[en]]
For more information about compilation see README file in source package.

After successfully compiling and installing mpich, add these lines to "/mirror/mpiu/.bashrc/"
Line 197: Line 183:
سپس دستور زیر را در هر گره اجرا می کنیم تا برای اجرای mpdboot نیاز به تعریف مسیر mpd نداشته باشیم:

[[en]]
Next we run this command in order to define MPICH installation path to SSH.
Line 205: Line 190:


برای بررسی صحت نصب دستورات زیر را اجرا می کنیم:
[[en]]
For testing our installation run:
Line 218: Line 200:
== ۱۱. برپاسازی MPD ==
فایل mpd.hosts را در پوشه خانه mpiu با محتویات زیر ایجاد می کنیم . این فایل حاوی فهرست گره هاست.
[[en]]
== 11. setting up MPD ==
Create mpd.hosts in mpiu's home directory with nodes names:
Line 229: Line 211:

سپس دستورات زیر را اجرا می کنیم:
[[en]]
and run :
Line 239: Line 219:
حالا برای آزمایش MPD دستورات زیر را اجرا می کنیم . خروجی باید نام گره فعلی باشد:
[[en]]
To test MPD run above commands. The output should be the current hostname.
Line 249: Line 229:
بعد از اینکه همه چیز با موفقیت انجام شد mpd daemon را اجرا می کنیم:


[[en]]
After all run mpd daemon:
Line 260: Line 237:
بعد از اجرای دستور فوق باید نام تمامی گره ها در خروجی چاپ شود.

تعدادی برنامه نمونه در mpich2-1.0.5/examples قرار دارند که یکی از آن ها را اجرا می کنیم:
[[en]]
The output should be name of all nodes.

There are some examples in "mpich2-1.0.5/examples", we'll run one :
Line 271: Line 248:
That's it!
Line 273: Line 250:
برای اطلاعات بیشتر می توانید به سایت زیر سری بزنید:
[[en]]
For more information visit:

Setting up an MPICH2 Cluster in Ubuntu

Creator: [:OmidAlemi: Omid Alemi]

omid.alemi@gmail.com

This how-to describes a guide to building a simple MPICH cluster in ubuntu.

Here we have 4 nodes running ubuntu 7.04 with these host names: ub0,ub1,ub2,ub3;

1. Defining hostnames in etc/hosts/

Edit /etc/hosts like these:

127.0.0.1     localhost
192.168.133.100 ub0
192.168.133.101 ub1
192.168.133.102 ub2
192.168.133.103 ub3

Note that the file shouldn't be like this:

127.0.0.1     localhost
127.0.1.1     ub0
192.168.133.100 ub0
192.168.133.101 ub1
192.168.133.102 ub2
192.168.133.103 ub3

2. Installing NFS

To Install NFS just run this in terminal:

omid@ub0:~$ sudo apt-get install nfs-kernel-server

3. Sharing Master Folder

Make a folder in all nodes, we'll store our data and programs in this folder.

omid@ub0:~$ sudo mkdir /mirror

And then we share it over nodes on the master node.

omid@ub0:~$ sudo echo  /mirror *(rw,sync) >> /etc/exports

Note than we store out data and programs only in master node and other nodes will access them with NFS.

4. Mounting /master in nodes

omid@ub1:~$sudo mount ub0:/mirror /mirror
omid@ub2:~$sudo mount ub0:/mirror /mirror
omid@ub3:~$sudo mount ub0:/mirror /mirror

it's better to change fstab in order to mount it on every boot.

== 5. Defining a user for running MPI programs== We define a user with same name and same userid in all nodes with a home directory in /mirror.

Here we name it "mpiu"! Also we change the owner of /mirror to mpiu:

omid@ub0:~$ sudo chown mpiu /mirror

6. Installing SSH Server

Run this command in all nodes in order to install OpenSSH Server

omid@ub0:~$ sudo apt­-get install openssh­server

7. Setting up SSH with no pass phrase for communicating between nodes

First we login with our new user:

omid@ub0:~$ su - mpiu

Then we generate DSA key for mpiu:

mpiu@ub0:~$ ssh­-keygen ­-t dsa

Leave passphrase empty.

Next we add this key to authorized keys:

mpiu@ub0:~$ cd .ssh
mpiu@ub0:~/.ssh$ cat id_pub.dsa >> authorized_keys

As the home directory of mpiu in all nodes is the same (/mirror/mpiu) , there is no need to run these commands on all nodes.

To test SSH run:

mpiu@ub0:~$ ssh ub1 hostname

It should return remote hostname without asking for passphrase.

8. Installing GCC

Install build-essential package:

mpiu@ub0:~$ sudo apt-get install build-essential

9.Installing Other Compilers

Other prefered compilers should be installed before installing MPICH.

In this step we install other compilers such as Inter Fortran, SGI compiler , ... .

10. Installing MPICH2

Download MPICH2 source code from http://www-unix.mcs.anl.gov/mpi/mpich .

Extract .tar.bz2 file in /mirror. Also make a folder for MPICH installation.

mpiu@ub3:/mirror$ mkidr mpich2
mpiu@ub3:/mirror$ tar xvf mpich2-­1.0.5p3.tar.gz
mpiu@ub3:/mirror$ cd mpich2­-1.0.5p3
mpiu@ub3:/mirror/mpich2­-1.0.5p3$ ./configure --­prefix=/mirror/mpich2 
mpiu@ub3:/mirror/mpich2­-1.0.5p3$ make
mpiu@ub3:/mirror/mpich2­-1.0.5p3$ sudo make install

For more information about compilation see README file in source package.

After successfully compiling and installing mpich, add these lines to "/mirror/mpiu/.bashrc/"

export PATH=/mirror/mpich2/bin:$PATH
export PATH
LD_LIBRARY_PATH="/mirror/mpich2/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH

Next we run this command in order to define MPICH installation path to SSH.

mpiu@ub0:~$ sudo echo /mirror/mpich2/bin >> /etc/environment

For testing our installation run:

mpiu@ub0:~$  which mpd
mpiu@ub0:~$  which mpiexec
mpiu@ub0:~$  which mpirun

11. setting up MPD

Create mpd.hosts in mpiu's home directory with nodes names:

ub3
ub2
ub1
ub0

and run :

mpiu@ub0:~$ echo secretword=something   >> ~/.mpd.conf
mpiu@ub0:~$ chmod 600 .mpd.conf

To test MPD run above commands. The output should be the current hostname.

mpiu@ub0:~$ mpd &
mpiu@ub0:~$ mpdtrace
mpiu@ub0:~$ mpdallexit

After all run mpd daemon:

mpiu@ub0:~$ mpdboot ­-np 4
mpiu@ub0:~$ mpdtrace

The output should be name of all nodes.

There are some examples in "mpich2-1.0.5/examples", we'll run one :

mpiu@ub0:~$ mpiexec -n 4 cpi

That's it!


For more information visit:

http://www-unix.mcs.anl.gov/mpi/mpich/

MpichCluster (last edited 2008-08-06 16:31:26 by localhost)