Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: schema refreshes (transport tablespace)

Re: schema refreshes (transport tablespace)

From: Paul Vallee <dbalist_at_pythian.com>
Date: Thu, 18 Oct 2001 13:50:50 -0700
Message-ID: <F001.003AF2E8.20011018131522@fatcity.com>

An easier solution might be the use of the wait command:
 
rcp srvr1:/u01/f1  srvr2:/u01/f1
&rcp srvr1:/u01/f2 
srvr2:/u01/f2&
wait<FONT
size=2>rcp srvr1:/u01/f3  srvr2:/u01/f3 <FONT size=2>&rcp srvr1:/u01/f4 
srvr2:/u01/f4&
wait
etc.etc.
 
Best regards,
Paul Vallee -- <A
href="">vallee_at_pythian.com --
877-PYTHIAN
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

  Sent: Thursday, October 18, 2001 3:45   PM
  Subject: RE: schema refreshes (transport   tablespace)   

  This is a script mined from Sun Blueprints (<A   href="">http://www.sun.co.jp/blueprints/0300/oraclescript.pdf).    You feed the script a file name and an optional parallel degree integer.    The input file contains complete commands on each line and your original one   with 50 lines is usable as-is.  I attached the script code just in case   you have a problem with the PDF file.
  Tony Aponte
  #! /bin/sh # <FONT

  size=2>#------------------------------------------------------------- 

# message # Establish a timestamp and
  echo the message to the screen. # Tee the output   (append) to a unique log file. <FONT
  size=2>#------------------------------------------------------------- 

# message() <FONT
  size=2>{ timestamp=&#8216;date +"%D %T"&#8216; <FONT 
  size=2>echo "$timestamp $*" | tee -a $logfile <FONT 
  size=2>return } 

  <FONT
  size=2>#------------------------------------------------------------- 

# get_shell # This function is

  responsible for establishing the next # command to be   processed. Since multiple processes might # be   requesting a command at the same time, it has a built-# <FONT   size=2>in locking mechanism. <FONT
  size=2>#------------------------------------------------------------- 

# get_shell() <FONT

  size=2>{ echo "&#8216;date&#8216; $1 Shell Request $$" >>   $lklogfile # debug locking file <FONT   size=2>while : # until a command or end do   next_shell="" # initialize command if   [ ! -s ${workfile} ] # if empty file (end) then
# break # no more commands fi
# if [ ! -f $lockfile ] # is there a lock?
  then # not yet... echo $$ >
  $lockfile # make one echo "&#8216;date&#8216; $1 Lock Obtained $$"   >> $lklogfile #debug if
  [ "$$" = "&#8216;cat $lockfile&#8216;" ] # double check   that then # we created it last <FONT
  size=2>next_shell=&#8216;sed -e q $workfile&#8216; # first line of   file sed -e 1d $workfile > ${workfile}.tmp # Chop   1st line mv ${workfile}.tmp $workfile <FONT   size=2># rename to work file rm -f $lockfile # turn   off lock echo "&#8216;date&#8216; $1 Shell Issued " >>   $lklogfile #debug return # done, command in   else # variable "next_shell" echo
  "&#8216;date&#8216; $1 Lock FAULTED $$" >> $lklogfile # debug <FONT   size=2>fi # double check faulted # else # locked by   other # echo "&#8216;date&#8216; $1 Lock Wait $$" >>   $lklogfile # debug fi # sleep
  1 # brief pause done # try again <FONT   size=2>return # only if no commands }   <FONT
  size=2>#------------------------------------------------------------- 

# paresh_slave # This code is

  executed by each of the slaves. It basically #   requests a command, executes it, and returns the status. <FONT
  size=2>#------------------------------------------------------------- 

# paresh_slave() <FONT

  size=2>{ shell_count=0 # Commands done by this   slave get_shell $1 # get next command to   execute while test "$next_shell" != ""
# if no command, all done do # got a

  command shell_count=&#8216;expr $shell_count + 1&#8216;
# increment counter message "Slave

  $1: Running Shell $next_shell" # message   $next_shell # execute command <FONT
  size=2>shell_status=$? # get exit status if [   "$shell_status" -gt 0 ] # on error <FONT   size=2>then # then message message "Slave $1: ERROR IN   Shell $next_shell status=$shell_status"   echo "Slave $1: ERROR IN Shell $next_shell <FONT   size=2>status=$shell_status" >> $errfile fi
# # message "Slave $1: Finished Shell
  $next_shell" # message <FONT
  size=2>get_shell $1 # get next command done # all   done message "Slave $1: Done (Executed $shell_count   Shells)" # message return #
  slave complete }
# paresh_driver # This code is

  executed by the top level process only. It # parses   the arguments and spawns the appropriate number # of   slaves. Note that the slaves run this same shell file, <FONT
  size=2># but the slaves execute different code, based on the <FONT 
  size=2># exported variable PARESH. <FONT 
  size=2>#------------------------------------------------------------- 

# paresh_driver() <FONT

  size=2>{ rm -f $lklogfile # start a new log   file if [ "$1" = "" ] # first argument?   then # no? master_file="master.list"
# default value else # yes? if

  [ ! -f "$1" ] # does file exist? then # no?   echo "$0: Unable to find File $1" #
  say so exit 1 # quit else #
  yes? master_file="$1" # use specified filename   fi fi if [
  "$2" = "" ] # Second Argument? then # no?   parallel_count=4# default value else
# Yes? if [ "$2" -lt 1 ] # Less than 1?
  then # Yes? echo "$0: Parallel
  Process Count Must be > 0" # message
  exit 1 # quit else # no?
  parallel_count=$2 # Use Specified Count <FONT   size=2>fi fi message
  "------------------------------" # Startup Banner <FONT 
  size=2>message "Master Process ID: $PARESH" message   "Processing File: $master_file" message "Parallel   Count: $parallel_count" message "Log File:   $logfile" message
  "------------------------------" cp $master_file 
  $workfile # make a copy of commands file while test   $parallel_count -gt 0 # Have we started all slaves? do
# Not yet if [ ! -s $workfile ] # Is there work to
  do? then # No? message "All
  Work Completed - Stopped Spawning at <FONT   size=2>$parallel_count" break # Quit spawning   fi $0 $parallel_count &# spawn a
  slave (with slave #) message "Spawned Slave   $parallel_count [pid $!]" # message <FONT   size=2>parallel_count=&#8216;expr $parallel_count - 1&#8216; #   decrement counter done # Next <FONT
  size=2>wait # Wait for all slaves message "All Done" #   message return # Function Complete <FONT   size=2>}
  <FONT
  size=2>#------------------------------------------------------------- 

# main # This is the main section of

  the program. Because this shell # file calls itself,   it uses a variable to establish whether or # not it is   in Driver Mode or Slave Mode. <FONT
  size=2>#------------------------------------------------------------- 

# if [ "$PARESH" != "" ]# If variable
  is set then # then slave mode <FONT
  size=2>workfile=/tmp/paresh.work.$PARESH # Work file with parent pid   lockfile=/tmp/paresh.lock.$PARESH # Lock file with parent   pid lklogfile=/tmp/paresh.lklog.$PARESH
# LockLog file with # parent

  pid logfile=/tmp/paresh.log.$PARESH # Log File with   parent pid errfile=/tmp/paresh.err.$PARESH # Error   File with parent pid paresh_slave $* # Execute Slave   Code else # PARESH="$$";
  export PARESH # Establish Parent pid <FONT   size=2>workfile=/tmp/paresh.work.$PARESH # Work File with parent pid   lockfile=/tmp/paresh.lock.$PARESH # Lock File with parent   pid lklogfile=/tmp/paresh.lklog.$PARESH
# LockLog File with # parent

  pid logfile=/tmp/paresh.log.$PARESH # Log File with   parent pid errfile=/tmp/paresh.err.$PARESH # Error   File with parent pid rm -f $errfile # remove error   file paresh_driver $* # execute Driver Code   rm -f $workfile # remove work file rm   -f $lklogfile # remove lock log file if [ -f $errfile   ] # Is there was an error then <FONT
  size=2>message "*************************************************" 
  message "FINAL ERROR SUMMARY. Errors logged in   $errfile" cat $errfile | tee -a $logfile   message
  "*************************************************" <FONT 
  size=2>exit 1 fi fi
  exit
  -----Original Message----- From:
  Tatireddy, Shrinivas (MED, Keane) [<A   href="">mailto:Shrinivas.Tatireddy_at_med.ge.com]   Sent: Thursday, October 18, 2001 6:20 AM <FONT   size=2>To: Multiple recipients of list ORACLE-L <FONT   size=2>Subject: schema refreshes (transport tablespace)   Hi lists,
  Can anybody post me the command to run the following:   

  I need to perform rcp at shell (Solaris) for 50 files. This is   part of schema refreshes/mirrorings using transport   tablespace utility.
  I am submitting a file that has 50 rcp commands like   

  rcp srvr1:/u01/f1  srvr2:/u01/f1 <FONT

  size=2>rcp srvr1:/u01/f2  srvr2:/u01/f2 rcp 
  srvr1:/u01/f3  srvr2:/u01/f3 rcp 
  srvr1:/u01/f4  srvr2:/u01/f4 .....upto 50 
  lines.
  when I submit this, system is executing only 1 rcp at a time.   But I need to do rcp 2 files at a time. So I chose   another alternative.
  rcp srvr1:/u01/f1  srvr2:/u01/f1 <FONT
  size=2>rcp srvr1:/u01/f2  srvr2:/u01/f2& rcp 
  srvr1:/u01/f3  srvr2:/u01/f3 rcp 
  srvr1:/u01/f4  srvr2:/u01/f4& .......upt0 50 
  lines.
  But in this , the system is not doing rcp 2 at a time. It is   taking 3 or 4 or 1 at a time.
  Is there a way to execute 2 rcp's at any time. using any shell   command.
  thnx in advance. srinivas    Received on Thu Oct 18 2001 - 15:50:50 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US