|
Sun Grid Engine Information Center Using Files and Scripts for Administration TasksYou can use the QMON graphical user interface to perform all administrative tasks in the Grid Engine system. You can also administer a Grid Engine system through commands that you type at a shell prompt and call from within shell scripts. Many experienced administrators find that using files and scripts is a more flexible, quicker, and more powerful way to change settings. This section describes how to use files and scripts to add or modify Grid Engine system objects such as queues, hosts, and environments. Using Files to Add or Modify ObjectsTo add objects according to specifications that you create in a file, use the qconf command with the following options:
To modify objects according to specifications you create in a file, use the qconf command with the following options:
Use these options in combination with the qconf -s command to take an existing object and modify it. You can then update the existing object or create a new object. Example – Modifying the Migration Command of a Checkpoint Environment
#!/bin/sh
# ckptmod.sh: modify the migration command
# of a checkpointing environment
# Usage: ckptmod.sh <checkpoint-env-name> <full-path-to-command>
TMPFILE=tmp/ckptmod.$$
CKPT=$1
MIGMETHOD=$2
qconf -sckpt $CKPT | grep -v '^migr_command' > $TMPFILE
echo "migr_command $MIGMETHOD" >> $TMPFILE
qconf -Mckpt $TMPFILE
rm $TMPFILE
Using Files to Modify Queues, Hosts, and EnvironmentsYou can modify individual queues, hosts, parallel environments, and checkpointing environments from the command line. Use the qconf command in combination with other commands. If you have already prepared a file, type the qconf command with appropriate options:
If you have not prepared a file, type the qconf command with appropriate options:
Both -M and -m mean modify, but the uppercase -M denotes modification from an existing file, whereas the lowercase -m does not. Instead, the lowercase -m opens a temporary file in an editor. When you save any changes that you make to this file and exit the editor, the system immediately reflects those changes. To change many objects at once, or you want to change object configuration non-interactively, use the qconf command with the options that modify object attributes. The following commands make modifications according to specifications in a file:
qconf -Aattr {queue | exechost | pe | ckpt} <filename>
qconf -Mattr {queue | exechost | pe | ckpt} <filename>
qconf -Rattr {queue | exechost | pe | ckpt} <filename>
qconf -Dattr {queue | exechost | pe | ckpt} <filename>
The following commands make modifications according to specifications on the command line:
qconf -aattr {queue | exechost | pe | ckpt} <attribute> <value> {<queue-list> | <host-list>}
qconf -mattr {queue | exechost | pe | ckpt} <attribute> <value> {<queue-list> | <host-list>}
qconf -rattr {queue | exechost | pe | ckpt} <attribute> <value> {<queue-list> | <host-list>}
qconf -dattr {queue | exechost | pe | ckpt} <attribute> <value> {<queue-list> | <host-list>}
In the above commands, filename, attribute, and value mean the following:
The following options modify object attributes:
The -aattr, -mattr, and -dattr options enable you to operate on individual values in a list of values. The -rattr option replaces the entire list of values with the new one that you specify, either on the command line or in the file. Example – Changing the Queue TypeThe following command changes the queue type of tcf27-e019.q to batch only: % qconf -rattr queue qtype batch tcf27-e019.q Example – Modifying the Queue Type and the Shell Start BehaviorThe following command uses the file new.cfg to modify the queue type and the shell start behavior of tcf27-e019.q: % cat new.cfg qtype batch interactive checkpointing shell_start_mode unix_behavior % qconf -Rattr queue new.cfg tcf27-e019.q Example – Adding Resource AttributesThe following command adds the resource attribute scratch1 with a value of 1000M and the resource attribute long with a value of 2:
% qconf -rattr exechost complex_values scratch1=1000M,long=2 tcf27-e019
Example – Attaching a Resource Attribute to a HostThe following command attaches the resource attribute short to the host with a value of 4:
% qconf -aattr exechost complex_values short=4 tcf27-e019
Example – Changing a Resource ValueThe following command changes the value of scratch1 to 500M, leaving other values unchanged: % qconf -mattr exechost complex_values scratch-=500M tcf27-e019 Example – Deleting a Resource AttributeThe following command deletes the resource attribute long:
% qconf -dattr exechost complex_values long tcf27-e019
Example – Adding a Queue to the List of Queues for a Checkpointing EnvironmentThe following command adds tcf27-b011.q to the list of queues for the checkpointing environment sph: % qconf -aattr ckpt queue_list tcf27-b011.q sph Example – Changing the Number of Slots in a Parallel EnvironmentThe following command changes the number of slots in the parallel environment make to 50: % qconf -mattr pe slots 50 make Targeting Queue Instances With the qselect CommandThe qselect command outputs a list of queue instances. If you specify options, qselect lists only the queue instances that match the criteria that you specify. You can use qselect in combination with the qconf command to target specific queue instances that you want to modify. Example – Listing QueuesThe following command lists all queue instances on Linux machines: % qselect -l arch=glinux The following command lists all queue instances on machines with two CPUs: % qselect -l num_proc=2 The following command lists all queue instances on all four-CPU 64-bit Solaris machines: % qselect -l arch=solaris64,num_proc=4 The following command lists queue instances that provide an application license. The queue instances were previously configured. % qselect -l app_lic=TRUE You can combine qselect with qconf to do wide-reaching changes with a single command line. To do this, put the entire qselect command inside backward quotation marks (` `) and use it in place of the queue-list variable on the qconf command line. Example – Using qselect in qconf CommandsThe following command sets the prolog script to sol_prolog.sh on all queue instances on Solaris machines: % qconf -mattr queue prolog /usr/local/scripts/sol_prolog.sh `qselect -l arch=solaris` The following command sets the attribute fluent_license to two on all queue instances on two-processor systems: % qconf -mattr queue complex_values fluent_license=2 `qselect -l num_proc=2` The most flexible way to automate the configuration of queue instances is to use the qconf command with the qselect command. With the combination of these commands, you can build up your own custom administration scripts. Using Files to Modify a Global Configuration or the SchedulerTo change a global configuration, use the qconf -mconf command. To change the scheduler, use the qconf -msconf command. Both of these commands open a temporary file in an editor. When you exit the editor, any changes that you save to this temporary file are processed by the system and take effect immediately. The editor used to open the temporary file is the editor specified by the EDITOR environment variable. If this variable is undefined, the vi editor is used by default. You can use the EDITOR environment variable to automate the behavior of the qconf command. Change the value of this variable to point to an editor program that modifies a file whose name is given by the first argument. After the editor modifies the temporary file and exits, the system reads in the modifications, which take effect immediately.
You can use this technique with any qconf -m... command. However, the technique is especially useful for administration of the scheduler and the global configuration, as you cannot automate the procedure in any other way. Example – Modifying the Schedule IntervalThe following example modifies the schedule interval of the scheduler: #!/bin/ksh # sched_int.sh: modify the schedule interval # usage: sched_int.sh <n>, where <n> is # the new interval, in seconds. n < 60 TMPFILE=/tmp/sched_int.$$ if [ $MOD_SGE_SCHED_INT ]; then grep -v schedule_interval $1 > $TMPFILE echo "schedule_interval 0:0:$MOD_SGE_SCHED_INT" >> $TMPFILE # sleep to ensure modification time changes sleep 1 mv $TMPFILE $1 else export EDITOR=$0 export MOD_SGE_SCHED_INT=$1 qconf -msconf fi This script modifies the EDITOR environment to point to itself. The script then calls the qconf -msconf command. This second nested invocation of the script modifies the temporary file specified by the first argument and then exits. The Grid Engine system automatically reads in the changes, and the first invocation of the script terminates. |