Tuesday, May 17, 2011

Install Sun Grid Engine (SGE) on Ubuntu Server 11.04

This post follows my previous note on how to "Set Up an MPICH2 Cluster With Ubuntu Server 11.04".

8. Install a Job Scheduler-Sun Grid Engine (SGE)

8.1. Install SGE on master node:
mpiuser@ub0:~$ sudo apt-get install gridengine-client gridengine-common gridengine-master gridengine-qmon gridengine-exec
#remove gridengine-exec from the list if master node is not supposed to run jobs
#during the installation, we need to set the cluster CELL name (such as ‘default’)

8.2. Install SGE on other nodes:
mpiuser@ub1:~$ sudo apt-get install gridengine-client gridengine-exec

#The CELL name is set the same as that of the master node

8.3. Set SGE_ROOT and SGE_CELL environment variables:
$SGE_ROOT refers to the installation path of SGE
$SGE_CELL is cell name which is ‘default’ on our machine
Edit /etc/profile and /etc/bash.bachrc, add the following two lines
export SGE_ROOT=/var/lib/gridengine #this is the path on our machines
export SGE_CELL=default
Source the script: source /etc/profile

8.4. Configure SGE with qmon (This section is modified from a note by [Ref. 1])
8.4.1. Invoke qmon as superuser:
mpiuser@ub0:~$ sudo qmon
#On our machine, qmon failed to start due to missing fonts ‘-adobe-helvetica-…”
# To solve the fonts problem:
mpiuser@ub0:~$ sudo apt-get install xfs xfstt
mpiuser@ub0:~$ sudo apt-get install t1-xfree86-nonfree ttf-xfree86-nonfree ttf-xfree86-nonfree-syriac xfonts-75dpi xfonts-100dpi
#I guess not all of these packages are required actually
#a better fix would be (update on 18/8/2013)
#(Ref: https://www.diigo.com/item/note/yf2q/p2nv)
apt-get install xfs
service xfs start
apt-get install xfonts-75dpi
xset +fp /usr/share/fonts/X11/75dpi
xset fp rehash

mpiuser@ub0:~$ sudo reboot #after reboot, the problem is gone
8.4.2. Configure hosts
"Host Configuration" -> "Administration Host" -> Add master node and other administrative nodes
"Host Configuration" -> "Submit Host" -> Add master node and other submit nodes
"Host Configuration" -> "Execution Host" -> Add slave nodes
->Click on "Done" to finish

8.4.3. Configure user
Add or delete users that are allowed to access SGE here. In this example, a user is added to an existing group and later this group will be allowed to submit jobs. Everything else is left as default values.

"User Configuration" -> "Userset" -> Highlight userset "arusers" and click on "Modify" -> Input user name in "User/Group" field
->Click "Done" to finish

8.4.4. Configure queue
While Host Configuration deals what computing resources are available and User Configuration defines who have access to the resources, this Queue Control defines ways to connect hosts and users.

"Queue Control" -> "Hosts" -> Confirm the execution hosts show up there.

"Queue Control" -> "Cluster Queues" -> Click on "Add" -> Name the queue, add execution nodes to Hostlist;
and
"Use access" -> allow access to user group arusers;
"General Configuration" -> Field "Slots" -> Raise the number to total CPU cores on slave nodes (ok to use a bigger number than actual CPU cores).

"Queue Control" -> "Queue Instances" -> This is the place to manually assign hosts to queues, and control the state (active, suspend ...) of hosts.

8.4.5. Configure parallel environment
"Queue Control" -> "Cluster Queues" -> Select a queue that will run parallel jobs -> Click on "Modify" -> "Parallel Environment" -> Click on icon "PE" below the right and left arrows -> Click on "Add" -> Name the PE, slots = 999, start_proc_args = $SGE_ROOT/mpi/startmpi.sh $pe_hostfile, stop_proc_args = $SGE_ROOT/mpi/stopmpi.sh, allocation_rule=$fill_up, check "Control slaves" to make this variable checked.

Make sure the configured PE is loaded from "Available PE" to "Referenced PE".

Confirm and close all config windows and open "Queue Control" -> "Cluster Queues" -> "Parallel Environment" again, the named PE should show up.

Once created and linked to a queue, PE can be edited from "Queue Control" -> "PE" too.

8.5. Check whether sge hosts are running properly
mpiuser@ub0:~$ qhost #it should list the system info from all nodes
mpiuser@ub0:~$ qconf -sel #it should list the hostnames of nodes
mpiuser@ub0:~$ qconf -sql #it should list the queues
mpiuser@ub0:~$ ps aux | grep sge_qmaster | grep -v grep #check master daemon
mpiuser@ub0:~$ ps aux | grep sge_execd | grep -v grep #check execute daemon
mpiuser@ub1:~$ ps aux | grep sge_ execd | grep -v grep #check execute daemon

#If sge_qmaster or sge_execd daemon is not running, try starting by service
#mpiuser@ub1:~$ sudo service gridengine-master start
#mpiuser@ub1:~$ sudo service gridengine-exec start

#Reboot node(s) if sge_qmaster or sge_execd fails to start

8.6. Run a test script
Make a script named ‘test’ with content:
#!/bin/bash
### Request Bourne shell as shell for job
#$ -S /bin/bash
### Use current directory as working directory
#$ -CWD
### Name the job:
#$ -N test
echo “Running environment:”
env
echo “=============================”
###end of script

To submit the job: qsub test
#a job id returned if successful
Query the job status: qstat
#If the job is running successfully, there will be two output files produced in the current working directory with name test.oXXX (the standard output) and test.eXXX (the standard error), where test is the job name and XXX is the job id.

8.7. Check log messages if error occurs
mpiuser@ub0:~$ less /var/spool/gridengine/qmaster/messages #master node
mpiuser@ub0:~$ less /var/spool/gridengine/execd/ub0/messages #exec node

8.8. Common problems
Problem #1: Output file has a Warning: no access to tty (Bad file descriptor).Thus no job control in this shell.
Solution: This warning happens if you are using the tcsh or csh as shell for submitting job. It is safe to ignore this warning. Alternatively you can qsub -S /bin/bash to run your program in different shell or add a line of ‘#$ -S /bin/bash’ in the job script. [Modified from Ref. 2]
Problem #2: Master host failed to respond properly. Error message is “error: commlib error: access denied (client IP resolved to host name ‘ub0…’. This is not identical to clients host name ‘ub0’) error: unable to contact qmaster using port 6444 on host ‘ub0’”
Solution: Reboot the master node or install the SGE from source code on master node (this possible solution is not confirmed yet). In some situations, this error could be due to that the utility of gethostname (full path is ‘/usr/lib/gridengine/gethostname’ on our machines) returns a different hostname to that from running command ‘hostname -f’. If this is the case (e.g., host having multiple network interfaces), create a file named ‘host_aliases’ under ‘$SGE_ROOT/$SGE_CELL/common’ and populate as follows,
# cat host_aliases
ub0 ub0.my.com ub0-grid
ub1 ub1.my.com ub1-grid
ub2 ub2.my.com ub2-grid
ub3 ub3.my.com ub3-grid
and then restart the gridengine daemon (see man page of sge_host_aliases for details). Check the aliases:
mpiuser@ub0:~$ /usr/lib/gridengine/gethostname -aname ub0-grid
mpiuser@ub0:~$ /usr/lib/gridengine/gethostname -aname ub0
#both of them should return ub0

References
1. Put SGE and MPICH together under Ubuntu 9.10 (http://pka.engr.ccny.cuny.edu/~jmao/node/51)
2. http://system.cs.odu.edu/?page=cluster

5 comments:

Hisham Eldai said...

I have a Ubuntu 11 version on a multi-core machine that I will love to convert to a test environment simulating a Master Node and an Execution node at the same time.

Will you generously advice on whether these settings can apply to my scenario or on what I got to do to realize this ?

Thanking you.

nicolas said...

Very helpful post. Many thanks.

Unknown said...

Thanks! I followed the instructions and sge is working but I have 2 execution hosts only one host is executing the job and other jobs are queued although the 2nd host is idle. do you have any thoughts what causes this behavior?

webappl said...

To Hatem Elshazly,

This is a very old post and glad it helped. I just saw your question and hope you have solved the problem after quite a few months. In case somebody else has similar issues, I give my guess/suggestion to help tackle the potential causes.

First of all, please run commands "qhost" and "qconf -sel" and "qconf -sqL" to check if all hosts are up and the queues are configured.

If the above commands return expected outputs, you need check the cluster environment. One possible reason for your issue is that the user(s) submitting jobs are not allowed to run jobs on the 2nd host, eg, the user accounts do not exist on the 2nd host. Particularly, make sure the user id is the same across host. You can check that with command id. It would be helpful to read a related post of mine and check whether the cluster environment is properly configured (http://webappl.blogspot.com/2011/05/setting-up-mpich2-cluster-with-ubuntu.html). Using a centralized authentication system is a better solution.

Alex

Unknown said...

Hi,

Can the SGE installation be carried out on RHEL6.5/7. I am unable to find a documentation on how to this anywhere. If no, I can setup up the master on Ubuntu but clients must be RHEL (could not find binaries for rhel).

Any help is really appreciated.

Thanks,
Akshay