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

.
.

Installgen - win901 - Title Graphic

Installgen Features and Benefits

Installgen Demo Available for download...

Bookmark This Page

email a friend

.

#!/usr/local/bin/perl
# program: 4_win_920_postinstall_1.pl
# features: This perl script applies the latest patch to the database
# and installs the backup, performance tuning and export
# jobs.
#
# Script Sequence# : 4
# Used By: run manually by DBA using Administrator account
#
# Copyright 2002 by .com Solutions Inc.
#
# --------------- Revision History ---------------
# Date By Changes
# 12-02-2001 dsimpson Initial Release
# 12-17-2001 dsimpson Added creation of RotateOracleAlertLog
# 12-27-2001 dsimpson Added ORACLE_SID environment variable
# service.
# 12-31-2001 dsimpson Corrected OEM/RMAN tablespace paths.
# Added re-copying of tnsnames.ora and listener.ora files.
# 01-01-2001 dsimpson Added creation of batchfile for scheduling of RMAN
# OEM backups - so output gets sent to logfile specified
# in batchfile.
# 04-25-2002 dsimpson Added use of oem sid domain.
# 08-17-2002 dsimpson Commented out Oracle patch version number to allow
# use with Oracle 9.2.0. The patch version will be
# printed when File#52 is run.
# Removed enclosing conditional to if oem_sid = oem_sid code.
# Added change of DBSNMP password in snmp_rw.ora file.
# Corrected name of OEM SID printed on screen prompt when
# registering database into OEM repository and
# specified host:port:SID connection string format.
# Removed perl.exe within AT scheduler commands.
# Added grant of dba role to dba accounts to work-around
# bug id# 2448243 which is specific to 9.2.0.1 (causing
# ORA-1031 on SYS.LT_EXPORT_PKG.system_info_exp during full
# database exports.
# OEM Console opening commands now open a new console
# window in order to get proper environment variables.

# This output file was created by Installgen version 1.38 on Thu Nov 14 17:48:05 2002. By .com Solutions Inc. www.dotcomsolutionsinc.net

use strict;
use Win32;
use Win32::Service;
use Win32::Lanman;
use Win32::AdminMisc;
use File::Copy;

# insure that environment variable is used by this perl script
$ENV{'ORACLE_SID'} = "PROD3";
# list of program and command line parameters to execute via operating system
my @proglist='';
# list of files to delete
my @filelist='';
my $answer='';
my $temp_sql_filename = "temp_sql.sql";
my $tempsqlcode="";
my $double_quote_var = chr(34);

# create the overall database stats table in the SYS schema
my $tempsqlcode_stats_table=<<"EOF";
connect / as SYSDBA
EXEC DBMS_STATS.CREATE_STAT_TABLE(OWNNAME=>'SYS',STATTAB=>'SYSSTATS');
-- make sure that stats can be collected
ALTER SYSTEM SET JOB_QUEUE_PROCESSES = 1;
-- create invalid rows table in SYS for partitioned tables
-- to avoid ORA-14508 error
\@c:\\v901\\rdbms\\admin\\utlvalid.sql
exit;
EOF

# create RMAN catalog in OEM server
my $tempsqlcode_rman_catalog=<<"EOF";
connect catalog rman/rmanpassword\@prod5.world
create catalog tablespace RMANTBS;
exit;
EOF

# create OEM/RMAN tablespaces, rman/oem user accounts
my $tempsqlcode_oemtbs=<<"EOF";
connect / as SYSDBA
CREATE TABLESPACE "OEMTBS" LOGGING DATAFILE 'c:\\u02\\oem1\\oemtbs01.dbf' SIZE 10M AUTOEXTEND ON NEXT 1M MAXSIZE 100M EXTENT MANAGEMENT LOCAL;
CREATE TABLESPACE "RMANTBS" LOGGING DATAFILE 'c:\\u02\\oem1\\rmantbs01.dbf' SIZE 10M AUTOEXTEND ON NEXT 1M MAXSIZE 100M EXTENT MANAGEMENT LOCAL;

create user oemuser identified by oempassword
default tablespace oemtbs
temporary tablespace temp
quota unlimited on oemtbs;
grant connect to oemuser;
grant resource to oemuser;
grant select_catalog_role to oemuser;
grant create trigger to oemuser;
grant create procedure to oemuser;
grant execute any procedure to oemuser;
grant create type to oemuser;
grant execute any type to oemuser;
grant select any table to oemuser;
grant select any dictionary to oemuser;

create user rman identified by rmanpassword
default tablespace rmantbs
temporary tablespace temp
quota unlimited on rmantbs;
grant connect to rman;
grant resource to rman;
grant recovery_catalog_owner to rman;
exit;
EOF


# make sure the Administrator user is running this script
my ($login_name) = Win32::LoginName;

if ($login_name ne "Administrator")
{
# the user running this script is not Administrator - exit
print "You must be logged in as the Administrator user to run this script, exiting....";
# exit immediately!
die
}

# make sure STDOUT and STDERR are not buffered
select (STDOUT);
$|=1;
select (STDERR);
$|=1;

# re-copy listener.ora and tnsnames.ora files - to make sure they did not get
# inadvertantly replaced during OEM/OMS install
@filelist=('c:\\v901\\network\admin\\tnsnames.ora','c:\\v901\\network\admin\\listener.ora');
unlink (@filelist);

# copy the tnsnames.ora file into the correct location
File::Copy::copy('25_win_920_tnsnames_1.ora','c:\\v901\\network\admin\\tnsnames.ora');

# copy the listener.ora file into the correct location
File::Copy::copy('49_listener_ora_1.ora','c:\\v901\\network\\admin\\listener.ora');

print "\n\n";
print "Applying latest Oracle patch ...\n";
print "(installer will run in silent mode after file is decompressed with WinZip)\n";
print "\n\n";
@proglist = ("52_win_920_patch_db_1.pl");
system (@proglist);

# stop/start service
# shut down then start up the service after finishing patch - make sure service is in known state
print "Shutting down and starting up the OracleServicePROD3 after applying the patch.\n";
Win32::Service::StopService('','OracleServicePROD3');

# add 60 second delay to insure previous task completes
print "Waiting 60 seconds to insure previous task of stopping service completes.\n";
sleep(60);

Win32::Service::StartService('','OracleServicePROD3');

# add 60 second delay to insure previous task completes
print "Waiting 60 seconds to insure previous task of starting service completes.\n";
sleep(60);

# the rman_oem_backup variable will be =1 if rman backups are scheduled via OEM/OMS jobs
my $rman_oem_backup=1;

print "\n\n";
print "Adding DBA accounts...\n\n";
print "Changing default Oracle database passwords:\n";
print "username: SYS=syspwd \n";
print "username: SYSTEM=systempwd\n";
print "username: OUTLN=systempwd\n";
print "username: DBSNMP=systempwd\n";
print "\n\n";

# create Oracle DBA accounts, replace default passwords
my $tempsqlcode=<<"EOF";
connect / as SYSDBA
set echo on
spool c:\\v901\\assistants\\dbca\\logs\\postDBCreation.log

-- enable archivelog mode
shutdown immediate;
-- this should not be needed, but re-starting service just to make certain that it didn't stop with instance shutdown
host net start OracleServiceprod3
conn / as sysdba
startup mount pfile="c:\\v901\\database\\initprod3.ora";
alter database archivelog;
alter database open;
alter system archive log start;

-- change default passwords
ALTER USER SYS IDENTIFIED BY syspwd;
ALTER USER SYSTEM IDENTIFIED BY systempwd;
ALTER USER OUTLN IDENTIFIED BY systempwd;
ALTER USER DBSNMP IDENTIFIED BY systempwd;
ALTER USER ORDSYS IDENTIFIED BY "ordsyspwd";
ALTER USER CTXSYS IDENTIFIED BY "ordsyspwd";
ALTER USER MDSYS IDENTIFIED BY "ordsyspwd";
ALTER USER WKSYS IDENTIFIED BY "ordsyspwd";
ALTER USER ctxsys IDENTIFIED BY ordsyspwd ACCOUNT UNLOCK;
ALTER USER wksys IDENTIFIED BY ordsyspwd ACCOUNT UNLOCK;

-- create Oracle dba accounts
create user admin identified by adminpwd
default tablespace users
temporary tablespace temp
quota unlimited on users;
grant connect to admin;
grant resource to admin;
grant exp_full_database to admin;
grant imp_full_database to admin;
grant sysdba to admin;
grant dba to admin;
grant OEM_MONITOR to admin;
-- grant execute on LT_EXPORT_PKG to fix Bug# 1828996 referenced in
-- Oracle Support Note#159695 on 12-27-2001
grant execute on SYS.LT_EXPORT_PKG to EXP_FULL_DATABASE;
create user thedba identified by abcd
default tablespace users
temporary tablespace temp
quota unlimited on users;
grant connect to thedba;
grant resource to thedba;
grant exp_full_database to thedba;
grant imp_full_database to thedba;
grant sysdba to thedba;
grant dba to thedba;
grant OEM_MONITOR to thedba;
-- grant execute on LT_EXPORT_PKG to fix Bug# 1828996 referenced in
-- Oracle Support Note#159695 on 12-27-2001
grant execute on SYS.LT_EXPORT_PKG to EXP_FULL_DATABASE;
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 ("c:\\v901\\bin\\sqlplus.exe /nolog \@$temp_sql_filename");

# change Intelligent Agent password to match DBSNMP Oracle database account password
print "\n";
print "Changing Intelligent Agent password to match DBSNMP Oracle account password...\n";
print "Note: Any existing OEM jobs submitted to this server will be lost.\n";
print "(there shouldn't be any OEM jobs yet - since this is a new server)\n";

system ("c:\\v901\\bin\\agentctl stop");
# wait 30 seconds to make sure agent has stopped - else files can't be removed while in use
print "waiting 30 seconds - to make sure agent has stopped.\n";
sleep(30);
# append dbsnmp password info to snmp_rw.ora file
open (FILE2,">>c:\\v901\\network\\admin\\snmp_rw.ora") || die ("Could not open output file snmp_rw.ora for writing. \n Does the full directory path exist?");
print FILE2 "snmp.connect.PROD3.name=\"dbsnmp\"\n";
print FILE2 "snmp.connect.PROD3.password=\"systempwd\"\n";
close (FILE2);
print "\n";
print "Please verify that the following two lines within the c:\v901/network/admin/snmp_rw.ora file are not repeated more than once:\n";
print "snmp.connect.PROD3.name=\"dbsnmp\"\n";
print "snmp.connect.PROD3.password=\"systempwd\"\n";
print "\n";
print "--------------- snmp_rw.ora file data follows: ---------------\n";
system ("type c:\\v901\\network\\admin\\snmp_rw.ora");
print "--------------- end of snmp_rw.ora file data ---------------\n";
print " Removing services.ora - it will be automatically rebuilt when the agent restarts\n";
system ("del c:\\v901\\network\\agent\\services.ora");
system ("del c:\\v901\\network\\agent\\*.q");
system ("c:\\v901\\bin\\agentctl start");

# move script to c:\server_scripts directory
rename ("13_win_rotateoraclefiles_1.pl","c:\\server_scripts\\rotateoraclefiles.pl");
print "\n\n";
print "This job is being scheduled via the AT scheduler as follows:\n";
print " ******** Rotate Server logs nightly at 11:55PM ********\n";
print "\n\n";
system ("AT 23:55 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\rotateoraclefiles.pl");

# determine if this machine is the OEM server - set up OEM/RMAN Repositories
if ( "prod3" eq "prod5" )
{
# The server running this script is also the OEM/OMS server
# create OMS tablespace and owner account first

# create OEM/RMAN tablespaces, rman/oem user accounts
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_oemtbs);
# close the output file
close (FILE1);
system ("c:\\v901\\bin\\sqlplus.exe /nolog \@$temp_sql_filename");

print "\n\n";
print "Step 1)The Enterprise Manager Configuration Assistant will now\n";
print "be run in order to create the OEM repository on this server. \n";
print "\n";
print "Please peform the following steps within EMCA:\n";
print "Select Configure local Oracle Management Server, press the Next button.\n";
print "Select Create a new repository, press the Next button.\n";
print "Select Custom (do not create a new database), press the Next button.\n";
print "Select In another existing database, press the Next button.\n";
print "On the Select Database for Repository page.\n";
print "Leave the existing SYS account name and password.\n";
print "Enter Service: host1:1521:prod3\n";
print "Press the Next button.\n";
print "Enter User name: oemuser\n";
print "Enter Password: oempassword\n";
print "Confirm password: oempassword, press the Next button.\n";
print "Click Yes button if username is unique, otherwise enter a new user name.\n";
print "Press the Finish button.\n";
print "\n";
print "After EMCA has completed, please press the Return key.\n";
print "\n\n";
system ("c:\\v901\\bin\\emca.bat");
$answer = ;

print "\n\n";
print "Starting the Oracle Management Server.\n";
print "\n\n";
system ("c:\\v901\\bin\\oemctl.bat start oms");

print "\n\n";
print "Starting the Oracle Intelligent Agent on Oracle instance prod3.\n";
print "\n\n";
system ("c:\\v901\\bin\\agentctl.exe start");

print "\n\n";
print "Please start the Oracle Intelligent Agent on each of the other Oracle servers (using: agentctl start), then press the Return key.\n";
print "\n\n";
print "Then press the Return key.\n";
print "\n\n";
$answer = ;

print "Step 2)The Enterprise Manager Console will now\n";
print "be run in order to allow you to create the OEM administrator accounts. \n";
print "\n";
print "Log into the OEM Repository using the following information:\n";
print "username: sysman\n";
print "password: oem_temp\n";
print "Note: Please change the sysman account password to: adminpwd\n";
print "\n";
print "Please create the following OEM account with Super Administrator priviledges:\n";
print "username: admin\n";
print "password: adminpwd\n";
print "\n";
print "After creating this account, please set up preferred credentials for this account for automatic database/host login.\n";
print "\n";
print "Then log out of the Enterprise Manager Console\n";
print "Please press the Return key to continue.\n";
print "\n\n";
system ("start /wait cmd.exe /c c:\\v901\\bin\\oemapp.bat console");
$answer = ;

print "\n\n";
print "Step 3)Use the Enterprise Manager Console to register each database into the OEM Repository.\n";
print "\n";
print "Log back into the Enterprise Manager Console using the new Super Administrator account which was just created.\n";
print "\n";
print "Use the Enterprise Manager Console to discover all of the database nodes and databases.\n";
print "\n";
print "Forward and reverse DNS needs to be set up for each database server host\n";
print "which is managed by OEM.";
print "\n";
print "The Oracle Intelligent Agent needs started on each database server (agentctl start).\n";
print "\n";
print "After all of the database server hosts and instances have been registered into the OEM repository, please press the Return key.\n";
print "\n\n";
system ("start /wait cmd.exe /c c:\\v901\\bin\\oemapp.bat console");
$answer = ;

print "\n\n";
print "Creating RMAN repository in prod5 database database instance.\n";
print "\n\n";

# create RMAN catalog - in OEM server
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_rman_catalog);
# close the output file
close (FILE1);
system ("c:\\v901\\bin\\rman.exe \@$temp_sql_filename");

print "\n\n";
print "Step 4)Run setup script 4_win_920_postinstall_1.pl at each of the production servers to register each database into the RMAN repository.\n";
print "\n";
print "Please press the Return key to continue.\n";
print "\n\n";
$answer = ;

print "\n\n";
print "Step 5)Use the Enterprise Manager Console to schedule the following jobs on the OEM server:\n";
print "\n";

}

if ($rman_oem_backup == 1)
{
# perform the following tasks if RMAN backups are scheduled via
# OEM/OMS jobs

print "\n\n";
print "Starting Oracle Intelligent Agent...\n";
print "\n\n";
system ("c:\\v901\\bin\\agentctl.exe start");

# execute the setup script to register the database into the RMAN repository and create the backup script
print "\n\n";
print "The database prod3 is about to be registered into the RMAN catalog in the prod5 \n";
print "database. Please make sure that the OMS/OEM server containing the RMAN catalog \n";
print "and its database prod5 is running and completely configured.\n";
print "\n";
print "Then press the Return key to continue.\n";
print "\n\n";
$answer = ;
system ("27_win_920_rman_oem_setup_1.pl");

print "\n\n";
print "Please schedule the following jobs via OEM:\n";
print "These jobs should be scheduled as Node/Run OS Command tasks.\n";
print "It is recommended that each job be submitted to the Job Library, then submitted for execution from the library.\n";
print "\n\n";
print " ******** Nighly RMAN full database backup job at 4:03 ********\n";
print "c:\\server_scripts\\prod3_rman_oem_backup_job_1.bat\n";
print "It is recommended that a full backup be immediately scheduled in order to test the OEM job subsystem.\n";
print "\n\n";
# copy RMAN oem backup script to c:\server_scripts directory
File::Copy::copy("62_win_920_prod3_rman_oem_backup_job_1.pl","c:\\server_scripts\\prod3_rman_oem_backup_job_1.pl");

# create .bat file so logfile is written to c:\\server_scripts\\ when using OEM job scheduler
open (FILE1,">c:\\server_scripts\\prod3_rman_oem_backup_job_1.bat") || die ("Could not open output file c:\\server_scripts\\prod3_rman_oem_backup_job_1.bat for writing. \n Does the full directory path exist?");
print FILE1 "perl.exe c:\\server_scripts\\prod3_rman_oem_backup_job_1.pl > c:\\backup\\prod3_rman_oem_backup_job_1.log";
# close the output file
close (FILE1);

print "\n\n";
print " ******** Full Oracle Database Export nightly at 11:50PM ********\n";
print "c:\\server_scripts\\prod3_export_full_db_1.pl\n";
print "\n\n";
print "[***** Note: The Windows username specified in the Preferred Credentials *****]\n";
print "[***** configuration for each node must include the *****]\n";
print "[***** Log on as a batch job User Rights Assignment. *****]\n";
print "[***** This User Right must be manually configured within *****]\n";
print "[***** the Local Security Settings tool in Windows. *****]\n";
print "[***** OEM Jobs will fail with error VNI-2015 without this Right. *****]\n";
# copy export script to c:\server_scripts directory
File::Copy::copy("35_win_prod3_export_full_db_1.pl","c:\\server_scripts\\prod3_export_full_db_1.pl");
# Note batchfile not used for export job because log file is specified within
# export command

print "\n\n";
print "The OEM Console is being launched in another window.\n";
print"Log in with the following account info once the OEM accounts have been created on the OEM server and each of the databases have been discovered.\n";
print "Username: admin\n";
print "Password: adminpwd\n";
print "\n";
print "Press the Return key once these jobs have been scheduled in OEM.\n";
print "\n\n";
system ("c:\\v901\\bin\\oemapp.bat console");
$answer = ;

# ask whether to install performance monitoring scripts via OEM based scheduling
print "\n\n";
print "Install performance monitoring scripts scheduled via OEM?(y/n)";
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y" )
{
# copy script to c:\server_scripts directory
File::Copy::copy("59_win_920_prod3_gather_stats_day_job_1.pl","c:\\server_scripts\\prod3_gather_stats_day_job_1.pl");
File::Copy::copy("60_win_920_prod3_gather_stats_night_job_1.pl","c:\\server_scripts\\prod3_gather_stats_night_job_1.pl");
File::Copy::copy("57_win_920_prod3_import_stats_day_job_1.pl","c:\\server_scripts\\prod3_import_stats_day_job_1.pl");
File::Copy::copy("58_win_920_prod3_import_stats_night_job_1.pl","c:\\server_scripts\\prod3_import_stats_night_job_1.pl");
File::Copy::copy("56_win_920_prod3_schema_stats_job_1.pl","c:\\server_scripts\\prod3_schema_stats_job_1.pl");

print "\n\n";
print "Gather daytime Oracle CBO stats Mondays at 9:00AM\n";
print "c:\\server_scripts\\prod3_gather_stats_day_job_1.pl\n";
print "Gather nightly batch Oracle CBO stats Mondays at 9:00PM\n";
print "c:\\server_scripts\\prod3_gather_stats_night_job_1.pl\n";
print "Import daytime Oracle CBO stats weekdays daily at 5:00AM\n";
print "c:\\server_scripts\\prod3_import_stats_day_job_1.pl\n";
print "Import nightly Oracle CBO stats weekdays daily at 6:00PM\n";
print "c:\\server_scripts\\prod3_import_stats_night_job_1.pl\n";
print "Gather all schema stats Fridays 9:00PM\n";
print "c:\\server_scripts\\prod3_schema_stats_job_1.bat\n";
print "\n\n";
print "DBMS.STATS table being created in SYS schema...\n";

# create .bat file so logfile can be written when using OEM job system
open (FILE1,">c:\\server_scripts\\prod3_schema_stats_job_1.bat") || die ("Could not open output file c:\\server_scripts\\prod3_schema_stats_job_1.bat for writing. \n Does the full directory path exist?");
print FILE1 "perl.exe c:\\server_scripts\\prod3_schema_stats_job_1.pl > c:\\backup\\prod3_schema_stats_job_1.log";
# close the output file
close (FILE1);

# create the overall database stats table in the SYS schema
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_stats_table);
# close the output file
close (FILE1);
system ("c:\\v901\\bin\\sqlplus.exe /nolog \@$temp_sql_filename");
print "Press the Return key once these jobs have been scheduled in OEM.\n";
print "\n\n";
$answer = ;
}
}

else
{

# ask whether to install scripts for non-OEM based scheduling
print "\n\n";
print "Install and schedule controlfile backup to trace script?(y/n)\n";
print "(Note: This task is already included within each backup script and generally does not need scheduled separately.)\n";
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y" )
{
# copy script to c:\server_scripts directory
File::Copy::copy("36_win_prod3_controlfile_backup_to_trace_1.pl","c:\\server_scripts\\prod3_controlfile_backup_to_trace_1.pl");
print "\n\n";
print "This job is being scheduled via the AT scheduler as follows:\n";
print " ******** Nightly backup of controlfile to trace at 11:51PM ********\n";
print "AT 23:51 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\prod3_controlfile_backup_to_trace_1.pl\n";
print "\n\n";
system ("AT 23:51 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\prod3_controlfile_backup_to_trace_1.pl");

}

print "\n\n";
print "Install and schedule RMAN backup script which doesn't use OEM server?(y/n)\n";
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y" )
{

# copy backup script to c:\server_scripts directory
File::Copy::copy("29_win_920_rman_backup_job_1.pl","c:\\server_scripts\\prod3_rman_backup_job_1.pl");

# copy the restore script to c:\server_scripts directory
File::Copy::copy("30_win_920_prod3_rman_restore_db_1.pl","c:\\server_scripts\\prod3_rman_restore_db_1.pl");

# create .bat file so logfile can be specified when using AT scheduler
open (FILE1,">c:\\server_scripts\\prod3_rman_backup_job_1.bat") || die ("Could not open output file c:\\server_scripts\\prod3_rman_backup_job_1.bat for writing. \n Does the full directory path exist?");
print FILE1 "perl.exe c:\\server_scripts\\prod3_rman_backup_job_1.pl > c:\\backup\\prod3_rman_backup_job_1.log";
# close the output file
close (FILE1);

print "\n\n";
print "This job is being scheduled via the AT scheduler as follows:\n";
print " ******** RMAN Full Oracle Database nightly backup at 4:03 ********\n";
print "AT 4:03 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\prod3_rman_backup_job_1.bat\n";
print "\n\n";
system ("AT 4:03 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\prod3_rman_backup_job_1.bat");

}

print "Install and schedule Nightly Full Database Export script - scheduled via AT scheduler?(y/n)\n";
$answer = ;
chop($answer);
if ($answer eq "y" )
{
# copy export script to c:\server_scripts directory
File::Copy::copy("35_win_prod3_export_full_db_1.pl","c:\\server_scripts\\prod3_export_full_db_1.pl");

print "\n\n";
print "This job is being scheduled via the AT scheduler as follows:\n";
print " ******** Full Oracle Database Export nightly at 11:50PM ********\n";
print "AT 23:50 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\prod3_export_full_db_1.pl\n";
print "\n\n";
system ("AT 23:50 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\prod3_export_full_db_1.pl");

}

print "Install and schedule Nightly Closed Database backup job - scheduled via AT scheduler?(y/n)\n";
$answer = ;
chop($answer);
if ($answer eq "y" )
{
# copy closed db backup script to c:\server_scripts directory
File::Copy::copy("31_win_prod3_closed_db_backup_job_1.pl","c:\\server_scripts\\prod3_closed_db_backup_job_1.pl");

# create .bat file so logfile can be specified when using AT scheduler
open (FILE1,">c:\\server_scripts\\prod3_closed_db_backup_job_1.bat") || die ("Could not open output file c:\\server_scripts\\prod3_closed_db_backup_job_1.bat for writing. \n Does the full directory path exist?");
print FILE1 "perl.exe c:\\server_scripts\\prod3_closed_db_backup_job_1.pl > c:\\backup\\prod3_closed_db_backup_job_1.log";
# close the output file
close (FILE1);

print "\n\n";
print "This job is being scheduled via the AT scheduler as follows:\n";
print " ******** Closed Oracle Database backup nightly at 4:03 ********\n";
print "AT 4:03 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\prod3_closed_db_backup_job_1.bat\n";
print "\n\n";
system ("AT 4:03 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\prod3_closed_db_backup_job_1.bat");

}

print "\n\n";
print "Install and schedule Nightly Open Database backup job - scheduled via AT scheduler?(y/n)\n";
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y" )
{
# copy open db backup script to c:\server_scripts directory
File::Copy::copy("33_win_prod3_open_db_backup_job_1.pl","c:\\server_scripts\\prod3_open_db_backup_job_1.pl");

# create .bat file so logfile can be specified when using AT scheduler
open (FILE1,">c:\\server_scripts\\prod3_open_db_backup_job_1.bat") || die ("Could not open output file c:\\server_scripts\\prod3_open_db_backup_job_1.bat for writing. \n Does the full directory path exist?");
print FILE1 "perl.exe c:\\server_scripts\\prod3_open_db_backup_job_1.pl > c:\\backup\\prod3_open_db_backup_job_1.log";
# close the output file
close (FILE1);

print "\n\n";
print "This job is being scheduled via the AT scheduler as follows:\n";
print " ******** Closed Oracle Database backup nightly at 4:03 ********\n";
print "AT 4:03 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\prod3_open_db_backup_job_1.bat\n";
print "\n\n";
system ("AT 4:03 /every:M,T,W,Th,F,S,Su c:\\server_scripts\\prod3_open_db_backup_job_1.bat");

}

# ask whether to install performance monitoring scripts via AT scheduler
print "\n\n";
print "Install and schedule performance monitoring scripts - scheduled via AT scheduler?(y/n)\n";
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y" )
{
# copy scripts to c:\server_scripts directory
File::Copy::copy("59_win_920_prod3_gather_stats_day_job_1.pl","c:\\server_scripts\\prod3_gather_stats_day_job_1.pl");
File::Copy::copy("60_win_920_prod3_gather_stats_night_job_1.pl","c:\\server_scripts\\prod3_gather_stats_night_job_1.pl");
File::Copy::copy("57_win_920_prod3_import_stats_day_job_1.pl","c:\\server_scripts\\prod3_import_stats_day_job_1.pl");
File::Copy::copy("58_win_920_prod3_import_stats_night_job_1.pl","c:\\server_scripts\\prod3_import_stats_night_job_1.pl");
File::Copy::copy("56_win_920_prod3_schema_stats_job_1.pl","c:\\server_scripts\\prod3_schema_stats_job_1.pl");

print "\n\n";
print "These jobs are being scheduled via the AT scheduler as follows:\n";
print " ******* Gather daytime Oracle CBO stats Mondays at 9:00AM ********\n";
print "AT 09:00 /every:M c:\\server_scripts\\prod3_gather_stats_day_job_1.pl\n";
print "\n";
print " ******** Gather nightly batch Oracle CBO stats Mondays at 9:00PM ********\n";
print "AT 21:00 /every:M c:\\server_scripts\\prod3_gather_stats_night_job_1.pl\n";
print "\n";
print " ******** Import daytime Oracle CBO stats weekdays daily at 5:00AM ********\n";
print "AT 05:00 /every:M,T,W,Th,F c:\\server_scripts\\prod3_import_stats_day_job_1.pl\n";
print "\n";
print " ******** Import nightly Oracle CBO stats weekdays daily at 6:00PM ********\n";
print "AT 18:00 /every:M,T,W,Th,F c:\\server_scripts\\prod3_import_stats_night_job_1.pl\n";
print "\n";
print " ******** Gather Oracle CBO schema stats Fridays at 9:00PM ********\n";
print "AT 21:00 /every:F c:\\server_scripts\\prod3_schema_stats_job_1.bat\n";
print "\n\n";
system ("AT 09:00 /every:M c:\\server_scripts\\prod3_gather_stats_day_job_1.pl");
system ("AT 21:00 /every:M c:\\server_scripts\\prod3_gather_stats_night_job_1.pl");
system ("AT 05:00 /every:M,T,W,Th,F c:\\server_scripts\\prod3_import_stats_day_job_1.pl");
system ("AT 18:00 /every:M,T,W,Th,F c:\\server_scripts\\prod3_import_stats_night_job_1.pl");
system ("AT 21:00 /every:F c:\\server_scripts\\prod3_schema_stats_job_1.bat");

# create .bat file so logfile can be specified when using AT scheduler
open (FILE1,">c:\\server_scripts\\prod3_schema_stats_job_1.bat") || die ("Could not open output file c:\\server_scripts\\prod3_schema_stats_job_1.bat for writing. \n Does the full directory path exist?");
print FILE1 "perl.exe c:\\server_scripts\\prod3_schema_stats_job_1.pl > c:\\backup\\prod3_schema_stats_job_1.log";
# close the output file
close (FILE1);

# create the overall database stats table in the SYS schema
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_stats_table);
# close the output file
close (FILE1);
system ("c:\\v901\\bin\\sqlplus.exe /nolog \@$temp_sql_filename");

}
}

# rename tasklist spreadsheet
rename ("40_win_prod3_tasklist_sheet_1.slk","prod3_tasklist_sheet_1.slk");

# rename timeline spreadsheet
rename ("43_win_prod3_backup_timeline_1.slk","prod3_backup_timeline_1.slk");

print "\n\n";
print "Removing script 41_win_remove_oracle_1.pl for safety...\n";
print "\n\n";
@filelist=("41_win_remove_oracle_1.pl");
unlink (@filelist);

print "\n\n";
print "Install and create OracleRotateAlertLogPROD3 Service?(y/n)\n";
print "(This service rotates the Oracle Alert Log during Windows startup.)\n";
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y" )
{
# copy alert log rotation script to c:\server_scripts directory
File::Copy::copy("11_win_prod3_rotate_alert_log_1.pl","c:\\server_scripts\\prod3_rotate_alert_log_1.pl");

print "\n\n";
print "The perl script:c:\\server_scripts\\prod3_rotate_alert_log_1.pl is being \n";
print "installed as service: OracleRotateAlertLogPROD3. \n";
print "(This service will rotate the Oracle Alert log during Windows startup.)\n";
print "\n\n";
if (!Win32::Lanman::CreateService('', '', { name => "OracleRotateAlertLogPROD3",
display => "OracleRotateAlertLogPROD3",
type => &SERVICE_WIN32_OWN_PROCESS,
start => &SERVICE_AUTO_START,
control => &SERVICE_ERROR_IGNORE,
account => 'LocalSystem',
password => '',
filename => "perl c:\\server_scripts\\prod3_rotate_alert_log_1.pl"}))
{
print "Creation of service failed; error: ";
# get the error code
print Win32::Lanman::GetLastError();
exit 1;
}
}

my ($os_string, $os_major, $os_minor, $os_build, $os_ID) = Win32::GetOSVersion();
if ($os_ID == 2)
{
if ($os_major <= 4)
{
# Windows NT
print "\n\n";
print "*******************************************************\n";
print "Since this server is running Windows NT 4, make sure\n";
print "that Internet Explorer 5.0 or higher is installed.\n";
print "This will insure that the Task Scheduler (Mstask.exe) is also installed.\n";
print "*******************************************************\n";
print "\n\n";
}
}

print "\n\n";
print "1) Please open the Scheduled Tasks Control Panel and configure each \n";
print "Oracle related task to Run as the Administrator user \n";
print "(or any other user who is a member of the ORA_DBA group).\n";
print "These jobs will not have permission to log into the Oracle database \n";
print "if this change is not made.\n";
print "\n";
print "2) Check to make sure that each Windows Service for Oracle is\n";
print "configured to start Automatically in the Services Control Panel.\n";
print "Press the Return key once these tasks have been completed.\n";
print "\n\n";
$answer = ;

# delete previously created ORACLE_SID environment variable - if it is not removed, it can
# cause problems with multiple-instances running on the same server
Win32::AdminMisc::DelEnvVar("ORACLE_SID","ENV_SYSTEM",10);

print "\n\n";
print "If there is more than one Oracle Home on this server, \n";
print "please check the System Control Panel to make sure that \n";
print "the ORACLE_SID system environment variable has been deleted.\n";
print "If it still exists, and if there are multiple Oracle Homes on this server, delete it manually.\n";
print "\n";
print "Press the Return key to continue.\n";
print "\n\n";
$answer = ;


.

hline

. .

.

. .
 

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

Legal Notices

.
.   .
.
Home Products Services Downloads Order Support Contact