Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer...

18
Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid Version 0.21 (25 October 2005) By: James Ruff I. Overview The purpose for this assignment is to familiarize you with the Sun Grid Engine. To complete this task, a basic knowledge of bash scripting and Java will be required. This handout will provide several examples of using the Sun Grid Engine. Towards the end of this assignment, you will be asked to make modifications to given bash scripts and create your own job to be sent to the grid. II. Software Requirements for the User At least one of the tools that we will be using during the course of the assignment is GUI (Graphical User Interface) based. Therefore, some X environment will have to be enabled on the computer you are working at. Linux users will not need to install extra software. Windows users, on the other hand, must install Cygwin. For information about installing Cygwin, please refer to Appendix A. For those users who are using PuTTY as their SSH client, you must enable X11 forwarding before connecting to the remote server. This is done by checking the “Enable X11 Forwarding” in the SSH->X11 menu. To get the GUI data to appear, load up Cygwin and type ‘startx’ at the command prompt. From inside PuTTY, you can run any GUI application once this has been completed. (For example, running the GUI version of Emacs can be done by typing in ‘emacs’ into the PuTTY window.) III. Assignment Specifics We will: Explore the different commands to use Sun Grid Engine. Submit a simple job from the command line. 1

Transcript of Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer...

Page 1: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

Assignment Sun Grid Engine:Using Sun Grid Engine to Submit a Job to the Grid

Version 0.21 (25 October 2005)By: James Ruff

I. Overview

The purpose for this assignment is to familiarize you with the Sun Grid Engine. To complete this task, a basic knowledge of bash scripting and Java will be required. This handout will provide several examples of using the Sun Grid Engine. Towards the end of this assignment, you will be asked to make modifications to given bash scripts and create your own job to be sent to the grid.

II. Software Requirements for the User

At least one of the tools that we will be using during the course of the assignment is GUI (Graphical User Interface) based. Therefore, some X environment will have to be enabled on the computer you are working at. Linux users will not need to install extra software. Windows users, on the other hand, must install Cygwin. For information about installing Cygwin, please refer to Appendix A.

For those users who are using PuTTY as their SSH client, you must enable X11 forwarding before connecting to the remote server. This is done by checking the “Enable X11 Forwarding” in the SSH->X11 menu. To get the GUI data to appear, load up Cygwin and type ‘startx’ at the command prompt. From inside PuTTY, you can run any GUI application once this has been completed. (For example, running the GUI version of Emacs can be done by typing in ‘emacs’ into the PuTTY window.)

III. Assignment Specifics

We will: Explore the different commands to use Sun Grid Engine. Submit a simple job from the command line. Use a GUI (Graphical User Interface) to submit a simple job. Create a new job to be submitted. Submit the new job from the command line and GUI. Create a Java program to submit as a job and submit the job. Use GRAM to submit a job to Sun Grid Engine.

IV. Exploring Sun Grid Engine

Sun Grid Engine uses shell scripts to execute jobs on the grid. There are several commands that will become increasingly more useful as this assignment progresses. For each command that we will use, there is a brief explanation of what the command does.

1

Page 2: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

qrsh – This command takes one argument, which is a binary file that exists in the system environment variable called $PATH. This command is then executed through Sun Grid Engine, on some machine that is in the local cluster.

qstat – This command lists all of the jobs that are currently in the queue. qsub – Submits a shell script (taken as an argument) to the local cluster. qdel – Removes a job from the queue. This command takes one argument of interest:

the job identification number for the job that should be removed from the queue. qhost – Lists all of the computers (hosts) that make up the queue. qmon – Displays a GUI that can be used to do a wide variety of tasks. qhold – Takes a job id as an argument. Places the job on hold until notified.

The first command of interest is the qrsh command. At the prompt, type in the following command:

[[email protected] someone]$ qrsh hostname

The output should appear almost instantaneous. It is probable that the result will be the hostname of a different machine than you are currently running from. This means that the machine listed, received the command, completed it, and then forwarded back the output from the command.

To receive a list of the possible results from qrsh, type in the following command:

[[email protected] someone]$ qhost

A sample output of the command would look like the following:

HOSTNAME ARCH NCPU LOAD MEMTOT MEMUSE SWAPTO SWAPUS-------------------------------------------------------------------------------global - - - - - - -bashful.cs.wcu.edu lx24-x86 2 0.00 1003.0M 74.5M 1.9G 0.0dopey.cs.wcu.edu lx24-x86 2 0.00 1003.0M 82.0M 1.9G 0.0grumpy.cs.wcu.edu lx24-x86 2 0.00 1003.0M 81.9M 1.9G 0.0happy.cs.wcu.edu lx24-x86 2 0.00 1003.0M 82.4M 1.9G 0.0sleepy.cs.wcu.edu lx24-x86 2 0.00 1003.0M 79.2M 1.9G 0.0sneezy.cs.wcu.edu lx24-x86 2 0.00 1003.0M 82.0M 1.9G 0.0snowwhite.cs.wcu.edu lx24-x86 2 0.01 1003.0M 402.3M 1.9G 0.0

Notice that this command provides the system architecture, the number of processors, the current load, the amount of ram, the amount of ram being used, the swap size, and the current swap usage of each machine. The hostname ‘global’ should be ignored.

You can try out several different commands from the command line to see how they respond. For example:

[[email protected] someone]$ qrsh w[[email protected] someone]$ qrsh dir[[email protected] someone]$ qrsh ps aux

2

Page 3: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

V. Submitting a Simple Job

Sun Grid Engine comes with several example jobs that can be used to test the environment. One such example is called ‘simple.sh’. This file is located in /usr/local/sge/examples/jobs/. The content of the file is provided below:

#!/bin/sh###___INFO__MARK_BEGIN__############################################################################ The Contents of this file are made available subject to the terms of# the Sun Industry Standards Source License Version 1.2## Sun Microsystems Inc., March, 2001### Sun Industry Standards Source License Version 1.2# =================================================# The contents of this file are subject to the Sun Industry Standards# Source License Version 1.2 (the "License"); You may not use this file# except in compliance with the License. You may obtain a copy of the# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html## Software provided under this License is provided on an "AS IS" basis,# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.# See the License for the specific provisions governing your rights and# obligations concerning the Software.## The Initial Developer of the Original Code is: Sun Microsystems, Inc.## Copyright: 2001 by Sun Microsystems, Inc.## All Rights Reserved.############################################################################___INFO__MARK_END__

# This is a simple example of a SGE batch script

# request Bourne shell as shell for job#$ -S /bin/sh

## print date and timedate# Sleep for 20 secondssleep 20# print date and time againdate

3

Page 4: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

To submit this job to the local cluster, we must type in the following command:

[[email protected] someone]$ qsub \/usr/local/sge/examples/jobs/simple.sh

You should receive output similar to the following:

Your job 167 ("simple.sh") has been submitted.

You can now check on the process of your job. This is done using the qstat command:

[[email protected] someone]$ qstat

The output could look similar to the following:

job-ID prior name user state submit/start at queue slots ja-task-ID-------------------------------------------------------------------------------------- 168 0.00000 simple.sh student qw 07/01/2005 14:22:18 1

The above output means that the job is in state ‘queued and waiting’. Once the command returns no output (or your job disappears from the output), you know that the job has completed. Two files will be created in your home directory from running this command. The filename will differ depending on the job id you were given earlier. The two files are simple.sh.o(id) and simple.sh.e(id). The file with the extension with the ‘o’ is the output from your submission. The file with the extension with the ‘e’ is the error reporting from the submission.

To look at the contents of the file, you may use a text editor or cat.

[[email protected] someone]$ cat simple.sh.o(id)Fri Jul 1 14:22:33 EDT 2005Fri Jul 1 14:22:53 EDT 2005

VI. Submitting the Job with a Graphical User Interface

Sun Grid Engine includes a Graphical User Interface that can be used to submit a job. From the command line, type in the following command:

[[email protected] someone]$ qmon >/dev/null 2>&1 &

This command will run the command qmon and transfer all of the standard output and errors to /dev/null. Furthermore, the command will be back grounded so you can get access to the command prompt while the Graphical User Interface is running.

You should receive a screen that looks like the following:

4

Page 5: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

A brief description of the buttons will be provided below:

This button is used for job control. You can find out which jobs are currently waiting to be run, which jobs are running, and which jobs recently finished.This button is used to find out information about the queues. You can find out how many machines are in your cluster. You can also find machine specific information about each machine that is in the cluster.This button is used to submit a new job. You can choose several different options from the dialog that appears. One important option is which e-mail address should receive notification that a job has completed. This button is used for complex configuration. It will not be used for this or future assignments.This button is used for configuring the hosts that reside on the cluster. No user should use this button.

This button is used for configuring the cluster. This button should not be used.

This button is used to configure the scheduler. This button should not be used.

This button is used for configuring different calendars for jobs to run. This button should not be used.This button is used for configuring the users on the cluster. This button should not be used.

This button is used for setting up parallel features. This button should not be used.

This button is used to configure checkpoints. This button should not be used.

This button is used to configure policies for the cluster. This button should not be used.

This button is used to configure projects. This button should not be used.

Allows the user to search the cluster for messages.

5

Page 6: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

Exits the program.

To submit a button, click on the button that looks like a mouse. ( ) You should receive a screen that looks similar to the following:

In the text box for “Job Script”, type in /usr/local/sge/examples/jobs/simple.sh. In the “Job Name” text box, type in your first initial followed by your last name. Click the box called “Merge Output”. The “stdout” textbox should read ‘myquisubmission.yourusername’. You should also click the box that says “Start Job Immediately”. Click the advanced tab, to bring up a window that looks like the following:

6

Page 7: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

Check the box labeled “End of Job” and type in your e-mail address in the “Mail To” box. Once this is completed, hit “Submit”. In your terminal window, type in the following: (quickly!)

[[email protected] someone]$ qstat You should see your job listed along with its status. Once the job is completed, you can look at your file by typing the following command:

[[email protected] someone]$ cat mysubmission.yourusername

Congratulations, you have submitted your first job to the cluster using a graphical user interface!

VII. Creating a Custom Job

In this step, we will be designing our own job to run on the local cluster. For this step, we will be using the binary called cal. This binary displays, to standard output, the current month. By adding arguments to this binary, you can display a yearly calendar in any year, or Julian dates for a year. For example,

[[email protected] someone]$ cal July 2005Su Mo Tu We Th Fr Sa

7

Page 8: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

1 2 3 4 5 6 7 8 910 11 12 13 14 15 1617 18 19 20 21 22 2324 25 26 27 28 29 3031

[[email protected] someone]$ cal –j July 2005Sun Mon Tue Wed Thu Fri Sat 182 183184 185 186 187 188 189 190191 192 193 194 195 196 197198 199 200 201 202 203 204205 206 207 208 209 210 211212

[[email protected] someone]$ cal 2005 2005

January February MarchSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 1 2 3 4 5 1 2 3 4 5 2 3 4 5 6 7 8 6 7 8 9 10 11 12 6 7 8 9 10 11 12 9 10 11 12 13 14 15 13 14 15 16 17 18 19 13 14 15 16 17 18 1916 17 18 19 20 21 22 20 21 22 23 24 25 26 20 21 22 23 24 25 2623 24 25 26 27 28 29 27 28 27 28 29 30 3130 31 April May JuneSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 1 2 3 4 5 6 7 1 2 3 4 3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 1110 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 1817 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 2524 25 26 27 28 29 30 29 30 31 26 27 28 29 30

July August SeptemberSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 1 2 3 4 5 6 1 2 3 3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 1010 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 1717 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 2424 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 3031 October November DecemberSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 1 2 3 4 5 1 2 3 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10

8

Page 9: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 1716 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 2423 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 3130 31

Using a shell script called ‘yourusername.sh’, create a script that does the following: sleeps for 20 seconds, prints out the current month’s calendar, sleeps for 30 seconds, prints out the current month’s calendar using Julian dates, sleeps for 5 seconds, prints out the calendar for the year 2006 in Julian dates.

Using the previous examples, submit this script using the command line and the graphical user interface.

VIII. Creating a Java Program for Submission

Up until now, we have only been using pre-defined binaries on the Linux architecture. Now, you must design a Java class with the following properties:

Your Java program will need to send its output to both the console and to a text file. Your Java program needs to gather information about the machine it will be run on. You

will use the InetAddress class in java.net package to query the machine’s IP address, Hostname, and Canonical Hostname. This information needs to be displayed. (More information on InetAddress is available from the Java API, located at http://java.sun.com/reference/api)

You will need to time your java program from start of execution until the program is finished. You can use System.currentTimeMillis() to get the time in milliseconds since midnight, January 1, 1970. This information also needs to be displayed.

Your Java program will also need to perform plenty of work to be worthy of being submitted as a job. Your program should create an array of two dimensional points with random coordinates. Your array should hold at least 25 points. Your program must accept a command line argument that specifies how many points to allocate in the array. You will need to set the argument in the submit description files you create. The points in the array represent a continuous set of joined lines. Each point and the point immediately following it represent a line segment. Your Java program should calculate the distance between a point and the point that is next in the array. In Figure 1 below, the shortest distance (shown as a green line) is from P1 to P2, and the longest distance (shown as a blue line) is between P2 and P3. The distance formula is shown at the top of Figure 1. Your program should display all the distances calculated and display the smallest and largest distances found.

9

Page 10: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

As with any good program, the output should be legible and properly formatted so that the user can see exactly what the program accomplished.

Include, in your write up, a brief explanation of how your program works, along with the output from your program.

To run this program, we must have Java already installed on the cluster. Furthermore, the directory that you are using to run the program should also be shared across the cluster. The submission script for this program is pretty simple:

#!/bin/shjavac YourClassName.javajava YourClassName $1

The ‘$1’ represents the arguments that are passed to the script from the command line. In the case of this script, it will be the website that should be checked against.

IX. Job Submission to Sun Grid Engine through GRAM

In Assignment 3, we used GRAM to submit jobs to the job manager called ‘fork’. Gridwise Technologies, with the help of several others, have developed a package that will allow for GRAM to interact with Sun Grid Engine. Although the commands used are slightly changed, the same exact communication process occurs.

Assuming that there is already a container running on the server you are using and you have a valid proxy, the following command will submit the ‘/usr/bin/uptime’ binary to the Sun Grid Engine.

[[email protected] someone]$ globusrun-ws –submit \–streaming -Ft SGE –c /usr/bin/uptime

The output from this command should be similar to the following:

10

Page 11: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

Delegating user credentials...Done.Submitting job...Done.Job ID: uuid: some_job_identification_numberTermination time: 07/19/2005 15:16 GMTCurrent job state: PendingCurrent job state: ActiveCurrent job state: CleanUp-Hold 11:16:15 up 2 days, 5:31, 3 users, load average: 0.28, 0.06, 0.02Current job state: CleanUpCurrent job state: DoneDestroying job...Done.Cleaning up any delegated credentials...Done.

When submitting to SGE, you never know which machine you are executing on. For example, executing the following command can yield different results:

[[email protected] someone]$ globusrun-ws –submit \–streaming -Ft SGE –c /bin/hostname

All of the previous job submissions may be done through GRAM as well. Since the shell scripts previously written are executables themselves, the following command will submit our shell scripts to SGE:

[[email protected] someone]$ globusrun-ws –submit \–streaming -Ft SGE –c shellscriptname.sh

To complete this assignment, submit each of the Java programs that you have written to Sun Grid Engine through GRAM. As a part of the write-up, please include the output from these commands.

Appendix A. Cygwin Installation

The first step is to download the Cygwin package from http://www.cygwin.com. Unfortunately, the package is large (several hundred megabytes). Consequently, a DSL or higher bandwidth Internet connection is strongly recommended for downloading the software.

The download of the initial file, setup.exe is relatively small (around 250 kilobytes). However, the rest of the installation will include downloading many other files.

Installation Steps Via Pictures:

11

Page 12: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

12

Page 13: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

*When asked to choose a download mirror, please select the closest one to your location.

*Click on the X11 icon to do a complete Install.

13

Page 14: Assignment Sun Grid Engine: - University of North …dl.uncw.edu/digilib/Computer Science/Net-Centric... · Web viewSun Grid Engine uses shell scripts to execute jobs on the grid.

Assignment Sun Grid Engine: Using Sun Grid Engine to Submit a Job to the Grid

*Warning: This step takes around 15-20 minutes to complete. When you get to the 99% completion indication, it may appear that nothing is happening for an extended period of time. This is not a problem since there are several scripts that need to run at the end of the installation.

Appendix B. Resources

The random point project was developed by Jeffrey House, for the Condor assignment from the Grid Computing Course, Fall 2004.

Appendix C. Example SGE Installation

Master Host

Execution Host / Administration

Host

Submission Host

Shadow Master Host

Execution Host /

Administration Host /

Submission Host

Execution Host /

Administration Host /

Submission Host

Execution Host /

Administration Host /

Submission Host

Master Host

Execution Host / Administration

Host

Submission Host

Shadow Master Host

Execution Host /

Administration Host /

Submission Host

Execution Host /

Administration Host /

Submission Host

Execution Host /

Administration Host /

Submission Host

14