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: Auto log apply to standby db using Perl

RE: Auto log apply to standby db using Perl

From: Jack C. Applewhite <japplewhite_at_inetprofit.com>
Date: Wed, 29 Aug 2001 11:01:16 -0700
Message-ID: <F001.0037BBA4.20010829111536@fatcity.com>

Rob
(Jo?),
<SPAN

class=156590918-29082001> 
This
is from the Oracle8i docs (Chapter 5 of "Oracle8i Standby Database Concepts and Administration"), but it's so basic that I believe it would apply to 8.0
<SPAN

class=156590918-29082001> 
<SPAN

class=156590918-29082001>...
<SPAN

class=156590918-29082001>9.Write a script that you can periodically run to check the log files in the managed recovery directory and move          the log files
that have a specified timestamp to the manual recovery directory. If new redo logs are being moved,         
start the manual recovery mode and apply the newly moved redo logs.

 
<SPAN

class=156590918-29082001>         
The following PERL script performs what is outlined in this step:

 
<SPAN

class=156590918-29082001>         
#!/usr/local/bin/perl
 
<SPAN

class=156590918-29082001>         
#How many hours the standby database should lag behind the primary database          $LAG_HOUR =
4;
 
<SPAN

class=156590918-29082001>         
#The manual recovery
directory          $DEST_DIR =
'/fs2/oracle/stdby/';
 
<SPAN

class=156590918-29082001>         
#The flag for whether there are new logs to be applied.          $needApply =
0;
 
<SPAN

class=156590918-29082001>         
#Check the managed recovery
directory          while (
</fs2/oracle/stby_log/*.arc> )

{             
# Get the timestamp of the
file             
$file_time =
(stat($_))[9];             
# See if the file is "old
enough"             
if ( time-$file_time > $LAG_HOUR*60*60 )

{                  

print  "mv $_
$DEST_DIR\n";                  

system "mv $_
$DEST_DIR";                  

$needApply =
1;               
}          
}          #If redo logs were 

moved in this round, apply
them          if ( $needApply
== 1 )
{             
system
"/usr/Lagged_Standby/ApplyLog";          }
 
<SPAN

class=156590918-29082001>         
The SHELL script (/usr/Lagged_Standby/ApplyLog) used to apply the redo logs consists of the following:
 
<SPAN

class=156590918-29082001>         
sqlplus internal << EOF
 
<SPAN

class=156590918-29082001>             
recover automatic standby
database;             
cancel             
exit
 
<SPAN

class=156590918-29082001>         
EOF
 
<SPAN

class=156590918-29082001>       10.Refer to your platform-specific documentation for information on how to create a job that is triggered at
specific          times
throughout the day.
 
<SPAN

class=156590918-29082001>         
For example, in UNIX, you can write a CRON job file. Issue the man crontab command at the UNIX         
command shell to get help on how to write a CRON job file. ...
 
<SPAN

class=156590918-29082001>Jack
--------------------------------Jack C. 
ApplewhiteDatabase Administrator/DeveloperOCP Oracle8 DBAiNetProfit, Inc.Austin,
Texaswww.iNetProfit.comjapplewhite_at_inetprofit.com(512)327-9068

  <FONT face=Tahoma
  size=2>-----Original Message-----From: root_at_fatcity.com   [mailto:root_at_fatcity.com]On Behalf Of Jo KingSent:   Wednesday, August 29, 2001 1:23 PMTo: Multiple recipients of list   ORACLE-LSubject: Auto log apply to standby db using   Perl

   
   
          Environment 

  is NT4 with Oracle 8.0.5.
   
          I wish to
  automate the procedure for applying the archive logs to a           standby
  database. The logs are automatically transferred to standby           destination
  'area'.
          I am
  planning to use Perl (currently learning) to perform <FONT   face=Arial size=2>this. After 
         
  gaining connectivity to database via svrmgr30 and<FONT face=Arial   size=2> issuing command : -
         
           recover automatic standby
  database; 
           I'm
  NOT sure how to go about coding (
  'stacking') responses to ..
          "Archive
  file not found message..". when there are no   longer any more
          archive
  files to apply.
   
         I wish
  to respond cancel to the standard message : -          
          Enter
  <RET>...........<CANCEL>....
         and
  then exit out of svrmgr30.
   
          If anybody
  has a Perl script for handling such a situation (or similar) or    

          could give
  me an example on how to achieve, I'd be   very grateful.
   
  <FONT face=Arial
  size=2>        <FONT face=Arial
  size=2>/Rob 
    Received on Wed Aug 29 2001 - 13:01:16 CDT

Original text of this message

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