Requirements:
Systems with same configurations (say Ubuntu 12.10)
Steps:
Add the nodes to the hosts file
All nodes should have a static local IP address set.
Edit the hosts file (
sudo gedit /etc/hosts) like below ,do this for all nodes,127.0.0.1 localhost
192.168.1.6 master
192.168.1.7 node1
192.168.1.8 node2
192.168.1.9 node3
Make sure it doesn’t look like this:
127.0.0.1 localhost
127.0.1.1 master
192.168.1.7 node1
192.168.1.8 node2
192.168.1.9 node3
neither like this:
127.0.0.1 localhost
127.0.1.1 master
192.168.1.6 master
192.168.1.7 node1
192.168.1.8 node2
192.168.1.9 node3
Otherwise other nodes will try to connect to localhost when trying to reach the master node.
Once saved, you can use the host names to connect to the other nodes,
$ ping -c 3 master
PING master (192.168.1.6) 56(84) bytes of data.
64 bytes from master (192.168.1.6): icmp_req=1 ttl=64 time=0.606 ms
64 bytes from master (192.168.1.6): icmp_req=2 ttl=64 time=0.552 ms
64 bytes from master (192.168.1.6): icmp_req=3 ttl=64 time=0.549 ms
--- master ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.549/0.569/0.606/0.026 ms
Try this with different nodes on different nodes. You should get a response similar to the above.
In this tutorial,
master is used as the master node. Once the cluster has been set up, the master node will be used to start jobs on the cluster. The master node will be used to spawn jobs on the cluster. The compute nodes are node1 to node3 and will thus execute the jobs.Defining a user for running MPI job
The command below creates a new user with username “mpiuser” and user ID 999. Giving a user ID below 1000 prevents the user from showing up in the login screen for desktop versions of Ubuntu. It is important that all MPI users have the same username and user ID. The user IDs for the MPI users need to be the same because we give access to the MPI user on the NFS directory later. Permissions on NFS directories are checked with user IDs. Create the user like this,
$ sudo adduser mpiuser --uid 999
You may use a different user ID (as long as it is the same for all MPI users). Enter a password for the user when prompted. It’s recommended to give the same password on all nodes so you have to remember just one password. The above command should also create a new directory
/home/mpiuser. This is the home directory for user mpiuser and we will use it to execute jobs on the cluster.Install and setup the Network File System
Files and programs used for MPI jobs (jobs that are run in parallel on the cluster) need to be available to all nodes, so we give all nodes access to a part of the file system on the master node. Network File System (NFS) enables you to mount part of a remote file system so you can access it as if it is a local directory. To install NFS, run the following command on the master node:
master:~$ sudo apt-get install nfs-kernel-server
And in order to make it possible to mount a Network File System on the compute nodes, the
nfs-common package needs to be installed on all compute nodes:$ sudo apt-get install nfs-common
We will use NFS to share the MPI user’s home directory (i.e.
/home/mpiuser) with the compute nodes. It is important that this directory is owned by the MPI user so that all MPI users can access this directory. But since we created this home directory with the adduser command earlier, it is already owned by the MPI user,master:~$ ls -l /home/ | grep mpiuser
drwxr-xr-x 7 mpiuser mpiuser 4096 May 11 15:47 mpiuser
If you use a different directory that is not currently owned by the MPI user, you must change it’s ownership as follows,
master:~$ sudo chown mpiuser:mpiuser /path/to/shared/dir
Now we share the
/home/mpiuser directory of the master node with all other nodes. For this the file /etc/exports on the master node needs to be edited. Add the following line to this file,/home/mpiuser *(rw,sync,no_subtree_check)
You can read the man page to learn more about the exports file (
man exports). After the first install you may need to restart the NFS daemon:master:~$ sudo service nfs-kernel-server restart
This also exports the directores listed in
/etc/exports. In the future when the /etc/exports file is modified, you need to run the following command to export the directories listed in /etc/exports:master:~$ sudo exportfs -a
The
/home/mpiuser directory should now be shared through NFS. In order to test this, you can run the following command from a compute node:$ showmount -e master
In this case this should print the path
/home/mpiuser. All data files and programs that will be used for running an MPI job must be placed in this directory on the master node. The other nodes will then be able to access these files through NFS.
The firewall is by default enabled on Ubuntu. The firewall will block access when a client tries to access an NFS shared directory. So you need to add a rule with UFW (a tool for managing the firewall) to allow access from a specific subnet. If the IP addresses in your network have the format
192.168.1.*, then192.168.1.0 is the subnet. Run the following command to allow incoming access from a specific subnet,master:~$ sudo ufw allow from 192.168.1.0/24
You need to run this on the master node and replace “192.168.1.0” by the subnet for your network.
You should then be able to mount
master:/home/mpiuser on the compute nodes. Run the following commands to test this,node1:~$ sudo mount master:/home/mpiuser /home/mpiuser
node2:~$ sudo mount master:/home/mpiuser /home/mpiuser
node3:~$ sudo mount master:/home/mpiuser /home/mpiuser
If this fails or hangs, restart the compute node and try again. If the above command runs without a problem, you should test whether
/home/mpiuser on any compute node actually has the content from /home/mpiuser of the master node. You can test this by creating a file in master:/home/mpiuser and check if that same file appears in node*:/home/mpiuser (where node* is any compute node).
If mounting the NFS shared directory works, we can make it so that the
master:/home/mpiuser directory is automatically mounted when the compute nodes are booted. For this the file /etc/fstab needs to be edited. Add the following line to the fstab file of all compute nodes,master:/home/mpiuser /home/mpiuser nfs
Again, read the man page of fstab if you want to know the details (
man fstab). Reboot the compute nodes and list the contents of the /home/mpiuserdirectory on each compute node to check if you have access to the data on the master node,$ ls /home/mpiuser
This should lists the files from the
Reference:
http://byobu.info/article/Building_a_simple_Beowulf_cluster_with_Ubuntu/
/home/mpiuser directory of the master node. If it doesn’t immediately, wait a few seconds and try again. It might take some time for the system to initialize the connection with the master node.Reference:
http://byobu.info/article/Building_a_simple_Beowulf_cluster_with_Ubuntu/
No comments:
Post a Comment