.com Solutions Inc. - logo  
Products - Header Buttons
.
Repgen bullet item 7b Installgen bullet item 7b FmPro Migratorbullet item 7b CGIScripter
.
.
.

.
.

Installgen - sol901 - Title Graphic

Installgen Features and Benefits

Installgen Demo Available for download...

.

#!/usr/local/bin/perl
# program: prod1_file_replicator_job_1.pl (renamed from 82_prod1_file_replicator_job_1.pl)
# features: This script compares archivelog directories on
# the primary and standby servers and copies new logs
# from the primary server to the standby server.
# Archivelog files are not copied until Oracle
# has completed writing them on the primary server.
#
# Notes: This script is expected to be scheduled to run
# regularly on the primary server. The standby server's
# archivelog directory is expected to be mounted via
# an NFS share available to the primary server.
# This script should generally only be required for use
# with standby databases on Oracle 8.0.5. Oracle 8.1.5 and
# higher support copying of files automatically via the RFS process.
#
# Requires: network mounting of primary server's archivelog directory
# prod1_file_replicator_job.pm (renamed from 83_prod1_file_replicator_job_1.pm)
#
# Script Sequence#: 82
# Used By: run hourly via oracle UNIX account CRON job - on primary server
# Usage:
# ******** Copy Primary Database Archivelogs to Standby Every Hour ********
# 01 * * * 0-6 /opt/server_scripts/prod1_file_replicator_job_1.pl
#
# Copyright 2002 by .com Solutions Inc.
#
# --------------- Revision History ---------------
# Date By Changes
# 01-19-2002 dsimpson Initial Release
# 05-25-2002 dsimpson Updated for use on Solaris.

# This output file was created by Installgen version 1.38 on Sun Nov 10 14:51:56 2002. By .com Solutions Inc. www.dotcomsolutionsinc.net

use strict;
use File::Copy;
use File::stat;
use prod1_file_replicator_job qw(primary_archivelog_directory_path standby_archivelog_directory_path);

my $primary_archivelog_directory_path=primary_archivelog_directory_path();
my $standby_archivelog_directory_path=standby_archivelog_directory_path();
my @primary_directory_list=();
my @standby_directory_list=();
my %lookup_table=();
my %difference_list_sizes1=(); # 1st test of file sizes
my %difference_list_sizes2=(); # 2nd test of file sizes - after 2 minute delay
my @files_to_copy=();
my $filename_item=();
my $filename_size=();
my $inode='';
my $temp_path1='';
my $temp_path2='';

# get directory listing of primary server archivelogs directory
opendir(DIR1,$primary_archivelog_directory_path) || die ("Unable to open directory: $primary_archivelog_directory_path");
@primary_directory_list=readdir(DIR1);
closedir(DIR1);

# get directory listing of standby server archivelogs directory
opendir(DIR2,$standby_archivelog_directory_path) || die ("Unable to open directory: $standby_archivelog_directory_path");
@standby_directory_list=readdir(DIR2);
closedir(DIR2);

# list files in standby server directory
# build lookup table as a hash
foreach $filename_item (@standby_directory_list)
{
$temp_path2 = $standby_archivelog_directory_path."/".$filename_item;
if (-f $temp_path2 )
{
# skip directories - only copy files
$lookup_table{$filename_item}=1;
print "Standby server file: $temp_path2\n";
}
}

# find archivelog files (and file sizes) in primary server directory which are not in standby server directory
foreach $filename_item (@primary_directory_list)
{
unless ($lookup_table{$filename_item})
{
$temp_path1 = $primary_archivelog_directory_path."/".$filename_item;
if (-f $temp_path1)
{
# only look at filenames - not symlinks or directories

print "Primary server file: $temp_path1\n";
# filename is not in lookup_table - so add it to difference_list1 and difference_list2
# get file size for each item on difference list
$inode=stat($temp_path1);
$difference_list_sizes1{$filename_item}=$inode->size;
# populate the 2nd list now
$difference_list_sizes2{$filename_item}=0;
}
}
}

# wait for 2 minutes to see if file sizes change
# to make certain that partly-written archivelog files
# are not copied
print "waiting 2 minutes - to make sure files aren't currently being written.\n";
sleep(120);

# list file sizes again for primary server new files
foreach $filename_item (keys %difference_list_sizes2)
{
$temp_path1 = $primary_archivelog_directory_path."/".$filename_item;
if (!-d $temp_path1)
{
# skip directories
$inode=stat($temp_path1);
$difference_list_sizes2{$filename_item}=$inode->size;
}
}

# compare file sizes - create list of files which have not changed in size
foreach $filename_item (keys %difference_list_sizes1)
{
if ($difference_list_sizes1{$filename_item} == $difference_list_sizes2{$filename_item})
{
# file size is unchanged - add to list of files to copy
print "File which needs copied to standby: $filename_item\n";
push (@files_to_copy,$filename_item) if $difference_list_sizes2{$filename_item} > 0;
}
}

# copy files with unchanged file sizes from primary to standby server
foreach $filename_item (@files_to_copy)
{
$temp_path1 = $primary_archivelog_directory_path."/".$filename_item;
$temp_path2 = $standby_archivelog_directory_path."/".$filename_item;
print "Copying file: $temp_path1 to $temp_path2\n";
File::Copy::copy("$temp_path1","$temp_path2");
}



.

hline

. .

.

. .
 

Home | Products | Services | Downloads | Order | Support | Contact

Legal Notices

.
.   .
.
Home Products Services Downloads Order Support Contact