
Installgen
Features and Benefits
Installgen
Demo Available for download...
Bookmark This Page

#!/usr/local/bin/perl
# script: 78_sol_920_prod1_standby_standbysetup_1.pl
# Features: This perl script sets up the standby server in a standby database configuration.
# Tasks include:
# copying updated versions of the tnsnames.ora, init.ora
# listener.ora, status monitoring, change role files from
# the NFS shared directory, and starting the database
# in managed recovery mode.
#
# Required Files: 78_sol_920_prod1_standby_standbysetup_1.pl
# 79_prod1_standby_status_1.pl
# 80_sol_prod1_standbydb_change_role_1.pl
# 72_prod1_client_taf_tnsnames_1.ora
# 74_sol_prod1_standby_listener_1.ora
# 81_prod1_standby_startup_script_1
# 11_sol_920_dbora_1.sh
# 13_sol_rotateoraclefiles_1.sh
# 73_sol_prod1_standby_etc_profile_1.sh
# 10_sol_etc_profile_1.sh
# 46_sol_oratab_1.txt
# 86_sqlnet_1.ora
# 28_sol_oratab_standby_1.txt
# 88_sol_standby_primary_listener_1.ora
#
# Script Sequence#: 78
# Used By: run manually by DBA
# Copyright 2002 by .com Solutions Inc.
#
# ---------------------- Revision History ---------------
# Date By Changes
# 01-18-2002 dsimpson Initial Release
# 05-18-2002 dsimpson Re-wrote for use on Solaris.
# 10-21-2002 dsimpson Updated for use on Mac OS X.
# Added chmod 755 for /etc/profile, /etc/profile-primary
# 11-09-2002 dsimpson Changed Perl getlogin() to ENV{'LOGNAME'}
# when verifying logged in user running this script.
# Added setting of ORACLE_SID env variable
# prior to starting standby instance in nomount mode.
# This output file was created by Installgen version 1.38 on Sun Nov 10 14:20:50 2002. By .com Solutions Inc. www.dotcomsolutionsinc.net
use strict;
use File::Copy;
use File::Path;
# insure that environment variables are used by this perl script
#$ENV{'ORACLE_SID'} = "PROD1";
#$ENV{'ORACLE_HOME'} = "/u01/v901";
#$ENV{'LD_LIBRARY_PATH'} = "/u01/v901/lib:/u01/v901/lib64:/usr/dt/lib";
#$ENV{'NLS_LANG'} = "AMERICAN_AMERICA.US7ASCII";
# list of program and command line parameters to execute via operating system
my @proglist='';
# list of files to delete
my @filelist='';
my $answer='';
my $answer2='';
my $pause1='';
my $pause2='';
my $mount_point='';
my $temp_sql_filename = "temp_sql.sql";
my $tempsqlcode="";
my $admin_account_name='';
my $admin_account_password='';
my $server_hostname="ultra1";
my $hostname_path_full = "/u01/v901" . "/network/admin/hostname";
# make sure the oracle user is running this script
my ($login_name) = $ENV{'LOGNAME'};
if ($login_name ne "oracle")
{
# the user running this script is not oracle - exit
print "You must be logged in as the oracle user to run this script, exiting....";
# exit immediately!
die
}
# make sure STDOUT and STDERR are not buffered
select (STDOUT);
$|=1;
select (STDERR);
$|=1;
print "\n";
print "Preparing to create directories on standby\n";
print "server to match the primary server.\n";
# make sure that all needed directories are created
# create /u01 directory
if (!-d '/u01')
{
# directory does not exist - prompt to create /u01
print "\n";
print 'Create /u01 directory?(y/n)';
print "\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01 directory
File::Path::mkpath ('/u01',1,0744);
}
}
# create /u01/prod1 directory for tablespace files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for tablespace files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for tablespace files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for tablespace files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for tablespace files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for tablespace files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for tablespace files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for tablespace files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for controlfiles
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for controlfiles
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for controlfiles
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for redo log files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for redo log files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for redo log files
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for redo log files multiplexed
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for redo log files multiplexed
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
# create /u01/prod1 directory for redo log files multiplexed
if (!-d '/u01/prod1')
{
# directory does not exist - prompt to create /u01/prod1 directory
print "\n\n";
print 'Create /u01/prod1 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/prod1 directory
File::Path::mkpath ('/u01/prod1',1,0744);
}
}
print "1) If any directories could not be created by the.\n";
print "previous statements, open a root terminal session\n";
print "to create those directories now.\n";
print "2) Set the ownership of each new directory to:\n";
print "chmod oracle:dba\n";
print "\n";
print "Please press the return key after these steps have been done.\n";
print "\n\n";
$answer2 = ;
# share standby database directories with enough space to copy all files
print "\n\n";
print "Prepare to copy data from the primary server via NFS.\n";
print "\n";
print "1)(On the standby server.)In a root terminal session,\n";
print "add the following lines to the /etc/dfs/dfstab file:\n";
print "share -F nfs -o rw=blade1 /backup\n";
print "share -F nfs -o rw=blade1 /archive\n";
print "Start up the NFS server\n";
print "/etc/rc3.d/S15nfs.server start\n";
print "Check to make sure that the directory is shared\n";
print "dfshares\n";
print "Note: The /backup directory on this standby server must be.\n";
print "large enough for a full database backup of the primary server\n";
print "unless the RMAN backup is being done via a media manager.\n";
print "\n";
print "Please press the return key after these steps have been done.\n";
print "\n\n";
$answer2 = ;
# ask whether to remove old files
print "\n\n";
print "Remove all old Oracle datafiles on the standby server?(y/n)\n";
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y" )
{
my $tempsqlcode=<<"EOF";
connect / as sysdba
-- make sure instance is down first
shutdown abort
quit
EOF
open (FILE1,">$temp_sql_filename") || die ("Could not open output file $temp_sql_filename for writing. \n Does the full directory path exist?");
print FILE1 ($tempsqlcode);
# close the output file
close (FILE1);
system ("/u01/v901/bin/sqlplus /nolog \@$temp_sql_filename");
# remove old controlfiles on standby server - with same names/paths as prod1 instance
@filelist=("/u01/prod1/control01.ctl","/u01/prod1/control02.ctl","/u01/prod1/control03.ctl");
unlink (@filelist);
# remove old temp datafiles on standby server
@filelist=("/u01/prod1/temp01.dbf");
unlink (@filelist);
# remove old non-temp datafiles on standby server
@filelist=("/u01/prod1/system01.dbf","/u01/prod1/tools01.dbf","/u01/prod1/users01.dbf","/u01/prod1/rbs01.dbf","/u01/prod1/indx01.dbf","/u01/prod1/xdb01.dbf","/u01/prod1/drsys01.dbf");
unlink (@filelist);
# remove old redo log files on standby server
@filelist=("/u01/prod1/redo01.log","/u01/prod1/redo01g1f2.log","/u01/prod1/redo02.log","/u01/prod1/redo02g2f2.log","/u01/prod1/redo03.log","/u01/prod1/redo03g3f2.log");
unlink (@filelist);
}
# create udump, cdump, bdump directories
if (!-d '/u01/udump')
{
# directory does not exist - prompt to create /u01/udump directory
print "\n\n";
print 'Create /u01/udump directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/udump directory
@proglist = ("mkdir",'/u01/udump');
system (@proglist);
}
}
if (!-d '/u01/bdump')
{
# directory does not exist - prompt to create /u01/bdump directory
print "\n\n";
print 'Create /u01/bdump directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/bdump directory
@proglist = ("mkdir",'/u01/bdump');
system (@proglist);
}
}
if (!-d '/u01/cdump')
{
# directory does not exist - prompt to create /u01/cdump directory
print "\n\n";
print 'Create /u01/cdump directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create /u01/cdump directory
@proglist = ("mkdir",'/u01/cdump');
system (@proglist);
}
}
# create UTL_FILE directory
if (!-d '/backup/utl_file_dir')
{
# create UTL_FILE directory
@proglist = ("mkdir",'/backup/utl_file_dir');
system (@proglist);
}
# prompt to wait for script 77_sol_920_prod1_primary_standbysetup_1.pl to run
print "\n\n";
print "1)If the existing datafiles on the standby server were not\n";
print "removed successfully, remove these files manually.\n";
print "The following controlfiles should have been removed:\n";
print "/u01/prod1/control01.ctl
/u01/prod1/control02.ctl
/u01/prod1/control03.ctl
\n";
print "The following datafiles should have been removed:\n";
print "/u01/prod1/system01.dbf
/u01/prod1/tools01.dbf
/u01/prod1/users01.dbf
/u01/prod1/rbs01.dbf
/u01/prod1/indx01.dbf
/u01/prod1/xdb01.dbf
/u01/prod1/drsys01.dbf
";
print "/u01/prod1/temp01.dbf
\n";
print "The following redo log files should have been removed:\n";
print "/u01/prod1/redo01.log
/u01/prod1/redo02.log
/u01/prod1/redo03.log
\n";
print "2)Continue executing the 77_sol_920_prod1_primary_standbysetup_1.pl script on the primary server.\n";
print "\n";
print "Then press the Return key to continue.\n";
print "\n\n";
$answer = ;
$mount_point = "/backup";
# create a hostname file in order to keep track of which server upon which 80_sol_prod1_standbydb_change_role_1.pl is running
print "Writing $hostname_path_full
";
open (FILE1,">$hostname_path_full") || die ("Could not open output file $hostname_path_full for writing.
Does the full directory path exist?");
print FILE1 $server_hostname;
close FILE1;
# copy primary tnsnames.ora file to /u01/v901/network/admin - backup original file
print "\n";
print "Copying 70_prod1_primary_tnsnames_1.ora to /u01/v901/network/admin/tnsnames.ora (backing up existing file as orig-tnsnames.ora).\n";
print "\n";
rename ("/u01/v901/network/admin/tnsnames.ora","/u01/v901/network/admin/orig-tnsnames.ora");
File::Copy::copy("$mount_point/70_prod1_primary_tnsnames_1.ora","/u01/v901/network/admin/tnsnames.ora");
# copy the failover version of the tnsnames.ora file - for switchover/failover situations
# this version of the tnsnames.ora file is used on the standby and primary servers when the standby server becomes the primary server
print "\n";
print "Copying 71_prod1_failover_tnsnames_1.ora to /u01/v901/network/admin/tnsnames.ora-primary.\n";
print "\n";
File::Copy::copy("$mount_point/71_prod1_failover_tnsnames_1.ora","/u01/v901/network/admin/tnsnames.ora-primary");
# copy standby listener.ora file to /u01/v901/network/admin - for use in standby mode
print "\n";
print "Copying 74_sol_prod1_standby_listener_1.ora to /u01/v901/network/admin/listener.ora.\n";
print "\n";
File::Copy::copy("$mount_point/74_sol_prod1_standby_listener_1.ora","/u01/v901/network/admin/listener.ora");
# copy standby listener.ora file to /u01/v901/network/admin - for switchover/failover situations
print "\n";
print "Copying 88_sol_standby_primary_listener_1.ora to /u01/v901/network/admin/listener.ora-primary.\n";
print "\n";
File::Copy::copy("$mount_point/88_sol_standby_primary_listener_1.ora","/u01/v901/network/admin/listener.ora-primary");
# copy sqlnet.ora file to /u01/v901/network/admin
print "\n";
print "Copying 86_sqlnet_1.ora to /u01/v901/network/admin/sqlnet.ora.\n";
print "\n";
File::Copy::copy("$mount_point/86_sqlnet_1.ora","/u01/v901/network/admin/sqlnet.ora");
# copy 46_sol_oratab_1.txt file to /var/opt/oracle/oratab-primary
print "\n";
print "Copying 46_sol_oratab_1.txt to /var/opt/oracle/oratab-primary.\n";
print "\n";
File::Copy::copy("$mount_point/46_sol_oratab_1.txt","/var/opt/oracle/oratab-primary");
# copy 28_sol_oratab_standby_1.txt file to /var/opt/oracle/oratab
print "\n";
print "Copying 28_sol_oratab_standby_1.txt to /var/opt/oracle/oratab.\n";
print "\n";
File::Copy::copy("$mount_point/28_sol_oratab_standby_1.txt","/var/opt/oracle/oratab");
# copy standby init.ora file to /u01/v901/dbs/initprod1s.ora
print "\n";
print "Copying 76_sol_920_prod1_standby_init_1.ora to /u01/v901/dbs/initprod1s.ora.\n";
print "\n";
File::Copy::copy("$mount_point/76_sol_920_prod1_standby_init_1.ora","/u01/v901/dbs/initprod1s.ora");
# copy primary init.ora file to /u01/v901/dbs/initprod1.ora - for failover/switchover situations
print "\n";
print "Copying 75_sol_920_prod1_primary_init_1.ora to /u01/v901/dbs/initprod1.ora.\n";
print "\n";
File::Copy::copy("$mount_point/75_sol_920_prod1_primary_init_1.ora","/u01/v901/dbs/initprod1.ora");
# copy the change role script to /opt/server_scripts/prod1_standbydb_change_role.pl
print "\n";
print "Copying 80_sol_prod1_standbydb_change_role_1.pl to /opt/server_scripts/prod1_standbydb_change_role.pl.\n";
print "\n";
File::Copy::copy("$mount_point/80_sol_prod1_standbydb_change_role_1.pl","/opt/server_scripts/prod1_standbydb_change_role.pl");
# copy the standby startup script to /opt/server_scripts/S81_prod1_standby_startup_script
print "\n";
print "Copying 81_prod1_standby_startup_script_1 to /opt/server_scripts/S81_prod1_standby_startup_script.\n";
print "\n";
File::Copy::copy("$mount_point/81_prod1_standby_startup_script_1","/opt/server_scripts/S81_prod1_standby_startup_script");
# copy the Rotate logs script to /opt/server_scripts/rotateoraclefiles.sh
print "\n";
print "Copying 13_sol_rotateoraclefiles_1.sh to /opt/server_scripts/rotateoraclefiles.sh.\n";
print "\n";
File::Copy::copy("$mount_point/13_sol_rotateoraclefiles_1.sh","/opt/server_scripts/rotateoraclefiles.sh");
# copy each of the setup files to /export/oracle so that they are available for future use
system ("cp $mount_point/*.ora /export/oracle");
system ("cp $mount_point/*.sh /export/oracle");
system ("cp $mount_point/*.pl /export/oracle");
system ("cp $mount_point/*.txt /export/oracle");
# rename current orapw file
print "\n";
print "Renaming /u01/v901/dbs/orapw to /u01/v901/dbs/old-orapwprod1.ora.\n";
print "\n";
rename("/u01/v901/dbs/orapw","/u01/v901/dbs/old-orapwprod1.ora");
# root tasks - install new /etc/profile, startup script
print "\n";
print "From a root terminal session, execute the following commands:\n";
print "rm /etc/profile\n";
print "rm /etc/rc3.d/K81_prod1_standby_startup_script\n";
print "cp $mount_point/73_sol_prod1_standby_etc_profile_1.sh /etc/profile\n";
print "cp $mount_point/10_sol_etc_profile_1.sh /etc/profile-primary\n";
print "cp $mount_point/81_prod1_standby_startup_script_1 /etc/rc3.d/S81_prod1_standby_startup_script\n";
print "ln -s /etc/rc3.d/S81_prod1_standby_startup_script /etc/rc0.d/K81_prod1_standby_startup_script\n";
print "chmod +x /etc/rc3.d/S81_prod1_standby_startup_script\n";
print "chmod +x /etc/rc0.d/K81_prod1_standby_startup_script\n";
print "chown oracle:dba /etc/init.d/dbora\n";
print "chown oracle:dba /etc/rc3.d/S88dbora\n";
print "mv /etc/rc3.d/S88dbora /etc/rc3.d/disabled-S88dbora\n";
print "chown oracle:dba /etc/rc3.d/S81_prod1_standby_startup_script\n";
print "\n";
print "Then press the Return key after these tasks have been completed.\n";
$answer = ;
print "\n";
print "Starting standby instance in nomount mode...\n";
print "\n";
# startup standby instance prod1 in nomount mode - to prevent ORA-1034
my $tempsqlcode=<<"EOF";
connect / as sysdba
-- make sure instance is down first
shutdown abort
STARTUP NOMOUNT pfile='/u01/v901/dbs/initprod1s.ora';
shutdown immediate
-- remove old orapw file
host rm /u01/v901/dbs/old-orapwprod1.ora
-- create new orapw file
host /u01/v901/bin/orapwd file=/u01/v901/dbs/orapw password=s9_21sv entries=20
-- now startup in nomount mode - since there are no files yet
STARTUP NOMOUNT pfile='/u01/v901/dbs/initprod1s.ora';
quit
EOF
open (FILE1,">$temp_sql_filename") || die ("Could not open output file $temp_sql_filename for writing. \n Does the full directory path exist?");
print FILE1 ($tempsqlcode);
# close the output file
close (FILE1);
system ("ORACLE_SID=prod1s;export ORACLE_SID;/u01/v901/bin/sqlplus /nolog \@$temp_sql_filename");
# stop/start listener and agent
print "\n\n";
print "Stopping/Starting Listener and Oracle Intelligent Agent..\n";
print "\n\n";
system ("/u01/v901/bin/lsnrctl stop");
system ("/u01/v901/bin/lsnrctl start");
system ("/u01/v901/bin/agentctl stop");
system ("/u01/v901/bin/agentctl start");
# install status_pl script in /opt/server_scripts
# copy the status monitoring perl script
print "\n";
print "Copying 79_prod1_standby_status_1.pl to /opt/server_scripts/prod1_standby_status.pl.\n";
print "\n";
File::Copy::copy("$mount_point/79_prod1_standby_status_1.pl","/opt/server_scripts/prod1_standby_status.pl");
# create CRON jobs for execution of monitoring and file rotation scripts
print "\n\n";
print "From an oracle UNIX terminal session, enter the following CRON jobs:\n";
print " ******** Monitor standby database status nightly at 11:50PM ********\n";
print "50 23 * * 0-6 /opt/server_scripts/prod1_standby_status.pl\n";
print "\n";
print " ******** Rotate Oracle Server logs nightly at 11:55PM ********\n";
print "55 23 * * 0-6 /opt/server_scripts/rotateoraclefiles.sh\n";
print "\n";
print "Enter a CRON job for either (but not both) of the following scripts:\n";
print " ******** Move Primary Database Archivelogs Every 4 Hours ********\n";
print "02 0,4,8,12,16,20 * * 0-6 /opt/server_scripts/prod1_archivelog_move_job.pl\n";
print "\n";
print " ******** RMAN Backup of Archivelogs Every 4 Hours ********\n";
print "02 0,4,8,12,16,20 * * 0-6 /opt/server_scripts/prod1_rman_archivelog_backup_job.sh\n";
print "\n";
print "Press the Return key after these tasks have been completed.\n";
$answer = ;
# Note: The format of each archivelog file is expected to be *.arc in order
# to copy the archivelogs from the mount point to the archive directory on the
# standby server
print "\n";
print "Copying archivelog files from $mount_point to /archive/.\n";
print "\n";
system ("cp $mount_point/*.arc /archive/");
# prompt to wait for script 77_sol_920_prod1_primary_standbysetup_1.pl to run - again
print "\n\n";
print "1)Continue executing the 77_sol_920_prod1_primary_standbysetup_1.pl\n";
print "script on the primary server.\n";
print "[An RMAN restore will be done to create the standby instance.]\n";
print "\n";
print "After RMAN has created the standby instance, press the Return key to continue.\n";
print "\n\n";
$answer = ;
# start database in managed recovery mode - with or without a delay - with session disconnect
print "\n\n";
print "Starting standby database in managed recovery mode...\n";
print "\n\n";
my $tempsqlcode=<<"EOF";
connect / as SYSDBA
set echo on
SHUTDOWN IMMEDIATE
STARTUP NOMOUNT pfile='/u01/v901/dbs/initprod1s.ora';
ALTER DATABASE MOUNT STANDBY DATABASE;
-- DELAY 0 for no delay
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DELAY 240 PARALLEL 8 DISCONNECT FROM SESSION;
SELECT process, status, thread#, sequence#, block#, blocks FROM v\$managed_standby;
exit;
EOF
open (FILE1,">$temp_sql_filename") || die ("Could not open output file $temp_sql_filename for writing. \n Does the full directory path exist?");
print FILE1 ($tempsqlcode);
# close the output file
close (FILE1);
system ("ORACLE_SID=prod1s;export ORACLE_SID;/u01/v901/bin/sqlplus /nolog \@$temp_sql_filename");
# ask whether to remove archivelog and backup files from shared folder
print "\n";
print "Remove archivelog (*.arc) and backup (*.bak) files from shared folder: $mount_point?(y/n)";
print "\n";
$answer = ;
chop($answer);
if ($answer eq "y" )
{
# delete archivelog files from mount point - only if requested
system ("rm $mount_point/*.arc");
system ("rm $mount_point/*.bak");
}
# make all perl and shell scripts executable in /opt/server_scripts
system ("chmod +x /opt/server_scripts/*.pl");
system ("chmod +x /opt/server_scripts/*.sh");
print "\n\n";
print "** All Done **\n";
print "** The standby database is now set up and **\n";
print "** operating in managed recovery mode.**\n";
print "\n";
print "Use script /opt/server_scripts/prod1_standbydb_change_role.pl to change \n";
print "the role of either the primary or standby databases. \n";
print "\n";
print "Script prod1_standby_status.pl has been configured as a CRON job \n";
print "to monitor the status of the primary and standby databases. \n";
print "\n";
print "Remove any unneeded backup or archivelog files which\n";
print "were copied from the primary server.\n";
print "\n\n";

