Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 11, 2016
0 parents commit d42a816
Show file tree
Hide file tree
Showing 21 changed files with 322 additions and 0 deletions.
Binary file added 3677.pdf
Binary file not shown.
Binary file added 3678.pdf
Binary file not shown.
Binary file added 9781590598511.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions Chapter09/r_9_1.txt
@@ -0,0 +1,102 @@
# Beginning of Script
# Start of Configurable Section
export ORACLE_HOME=/opt/oracle/10.2/db_1
export ORACLE_SID=PRODB1
export TOOLHOME=/opt/oracle/tools
export BACKUP_MEDIA=DISK
export BACKUP_TYPE=FULL_DB_BKUP
export MAXPIECESIZE=16G
# End of Configurable Section
# Start of site specific parameters
export BACKUP_MOUNTPOINT=/oraback
export DBAEMAIL="dbas@proligence.com"
export DBAPAGER="dba.ops@proligence.com"
export LOG_SERVER=prolin2
export LOG_USER=oracle
export LOG_DIR=/dbalogs
export CATALOG_CONN=${ORACLE_SID}/${ORACLE_SID}@catalog
# End of site specific parameters
export LOC_PREFIX=$BACKUP_MOUNTPOINT/loc
export TMPDIR=/tmp
export NLS_DATE_FORMAT="MM/DD/YY HH24:MI:SS"
export TIMESTAMP=`date +%T-%m-%d-%Y`
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/lib
export LIBPATH=$ORACLE_HOME/lib:/usr/lib:/lib
export SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib:/lib
export LOG=${TOOLHOME}/log
LOG=${LOG}/log/${ORACLE_SID}_${BACKUP_TYPE}_${BACKUP_MEDIA}_${TIMESTAMP}.log
export TMPLOG=$TOOLHOME/log/tmplog.$$
echo `date` "Starting $BACKUP_TYPE Backup of $ORACLE_SID \
to $BACKUP_MEDIA" > $LOG
export LOCKFILE=$TOOLHOME/${ORACLE_SID}_${BACKUP_TYPE}_${BACKUP_MEDIA}.lock
if [ -f $LOCKFILE ]; then
echo `date` "Script running. Exiting ..." >> $LOG
else
echo "Do NOT delete this file. Used for RMAN locking" > $LOCKFILE
$ORACLE_HOME/bin/rman log=$TMPLOG <<EOF
connect target /
connect catalog $CATALOG_CONN
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'${ORACLE_HOME}/dbs/SNAPSHOT_${ORACLE_SID}_${TIMESTAMP}_CTL';
run
{
allocate channel c1 type disk
format '${LOC_PREFIX}1/${ORACLE_SID}_${BACKUP_TYPE}_${TIMESTAMP}_%p_%s.rman'
maxpiecesize ${MAXPIECESIZE};
allocate channel c2 type disk
format '${LOC_PREFIX}2/${ORACLE_SID}_${BACKUP_TYPE}_${TIMESTAMP}_%p_%s.rman'
maxpiecesize ${MAXPIECESIZE};
allocate channel c3 type disk
format '${LOC_PREFIX}3/${ORACLE_SID}_${BACKUP_TYPE}_${TIMESTAMP}_%p_%s.rman'
maxpiecesize ${MAXPIECESIZE};
allocate channel c4 type disk
format '${LOC_PREFIX}4/${ORACLE_SID}_${BACKUP_TYPE}_${TIMESTAMP}_%p_%s.rman'
maxpiecesize ${MAXPIECESIZE};
allocate channel c5 type disk
format '${LOC_PREFIX}5/${ORACLE_SID}_${BACKUP_TYPE}_${TIMESTAMP}_%p_%s.rman'
maxpiecesize ${MAXPIECESIZE};
allocate channel c6 type disk
format '${LOC_PREFIX}6/${ORACLE_SID}_${BACKUP_TYPE}_${TIMESTAMP}_%p_%s.rman'
maxpiecesize ${MAXPIECESIZE};
allocate channel c7 type disk
format '${LOC_PREFIX}7/${ORACLE_SID}_${BACKUP_TYPE}_${TIMESTAMP}_%p_%s.rman'
maxpiecesize ${MAXPIECESIZE};
allocate channel c8 type disk
format '${LOC_PREFIX}8/${ORACLE_SID}_${BACKUP_TYPE}_${TIMESTAMP}_%p_%s.rman'
maxpiecesize ${MAXPIECESIZE};
backup
incremental level 0
tag = 'LVL0_DB_BKP'
database
include current controlfile;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
release channel c8;
allocate channel d2 type disk format
'${LOC_PREFIX}8/CTLBKP_${ORACLE_SID}_${TIMESTAMP}.CTL';
backup current controlfile;
release channel d2;
}
exit
EOF
RC=$?
cat $TMPLOG >> $LOG
rm $LOCKFILE
echo `date` "Script lock file removed" >> $LOG
if [ $RC -ne "0" ]; then
mailx -s "RMAN $BACKUP_TYPE $ORACLE_SID $BACKUP_MEDIA Failed" \
$DBAEMAIL,$DBAPAGER < $LOG
else
cp $LOG ${LOC_PREFIX}1
mailx -s "RMAN $BACKUP_TYPE $ORACLE_SID $BACKUP_MEDIA Successful" \
$DBAEMAIL < $LOG
fi
scp $LOG \
${LOG_USER}@${LOG_SERVER}:${LOG_DIR}/${ORACLE_SID}/.
rm $TMPLOG
fi
10 changes: 10 additions & 0 deletions Chapter09/r_9_10.txt
@@ -0,0 +1,10 @@
create script full_disk_db
comment 'Full Backup as Backupset to Disk'
{
allocate channel c1 type disk
format 'c:\backup\rman_%U.rman';
backup
database
include current controlfile;
release channel c1;
}
56 changes: 56 additions & 0 deletions Chapter09/r_9_2.txt
@@ -0,0 +1,56 @@
@ECHO OFF
:: Beginning of Script
:: Start of Configurable Section
set ORACLE_HOME=C:\oracle\product\10.2\db_1
set ORACLE_SID=MOBDB10
set TOOLHOME=C:\TOOLS
set BACKUP_MEDIA=DISK
set BACKUP_TYPE=FULL_DB_BKUP
set MAXPIECESIZE=16G
set BACKUP_MOUNTPOINT=c:\oracle\flash
set DBAEMAIL="dbas@proligence.com"
set DBAPAGER="dba.ops@proligence.com"
set CATALOG_CONN=%ORACLE_SID%/%ORACLE_SID%@catalog
set MS=mail.proligence.com
::
:: end of Configurable Section
::
set BACKUP_LOC_PREFIX=%BACKUP_MOUNTPOINT%\loc
set TMPDIR=C:\temp
set NLS_DATE_FORMAT="MM/DD/YY HH24:MI:SS"
realdate /d /s="set curdate=" > %TOOLHOME%\tmp_dt.bat
realdate /t /s="set curtime=" > %TOOLHOME%\tmp_tm.bat
call %TOOLHOME%\tmp_dt.bat
call %TOOLHOME%\tmp_tm.bat
::
::
set LOG=%TOOLHOME%\%ORACLE_SID%_%BACKUP_TYPE%_%BACKUP_MEDIA% ?_
%CURDATE%_%CURTIME%.log
set TMPLOG=%TOOLHOME%\tmplog.$$
::
:: Build the Command File
set FORMATSTRING=%BACKUP_LOC_PREFIX%1\%ORACLE_SID%_%%u_%%p.rman
set CMDFILE=%TOOLHOME%\%ORACLE_SID%.rman
echo run { > %CMDFILE%
echo allocate channel c1 type disk >> %CMDFILE%
echo format '%FORMATSTRING%' >> %CMDFILE%
echo maxpiecesize %MAXPIECESIZE%; >> %CMDFILE%
echo backup >> %CMDFILE%
echo tablespace users; >> %CMDFILE%
echo release channel c1; >> %CMDFILE%
echo } >> %CMDFILE%
:: End of Command File Generation
::
echo Starting the script > %LOG%
%ORACLE_HOME%\bin\rman target=/ catalog=%CATALOG_CONN% @%CMDFILE% ?
msglog=%TMPLOG%
::
:: Merge the Logfiles
type %TMPLOG% >> %LOG%
:: Check for errors
::
echo THE OUTPUT WAS %ERRORLEVEL% >> %LOG%
findstr /i "error" %LOG%
if errorlevel 0 if not errorlevel 1 bmail -s %MS% -t %DBAPAGER% ?
-f "Database" -m %LOG%
@echo on
9 changes: 9 additions & 0 deletions Chapter09/r_9_7.txt
@@ -0,0 +1,9 @@
create script full_disk_db
{
allocate channel c1 type disk
format 'c:\oracle\flash\loc1\rman_%U.rman';
backup
database
include current controlfile;
release channel c1;
}
11 changes: 11 additions & 0 deletions Chapter09/r_9_8.txt
@@ -0,0 +1,11 @@
create global script gs_arc_disk_bkup
comment 'Global Script to Backup Arc Logs Delete Input'
{
allocate channel c1 type disk
format 'C:\oraback\%U.rman';
backup
archivelog
all
delete input;
release channel c1;
}
9 changes: 9 additions & 0 deletions Chapter09/r_9_9.txt
@@ -0,0 +1,9 @@
replace script full_disk_db
{
allocate channel c1 type disk
format 'c:\backup\rman_%U.rman';
backup
database
include current controlfile;
release channel c1;
}
1 change: 1 addition & 0 deletions Chapter11/r_11_1.txt
@@ -0,0 +1 @@
select file#, status, error,recover from v$datafile_header;
4 changes: 4 additions & 0 deletions Chapter11/r_11_4.txt
@@ -0,0 +1,4 @@
connect target /
startup mount;
restore database;
recover database test;
8 changes: 8 additions & 0 deletions Chapter11/r_11_8.txt
@@ -0,0 +1,8 @@
run{
set newname for datafile 4 to '/ora01/BRDSTN/data_ts01.dbf';
set newname for datafile 5 to '/ora01/BRDSTN/data_ts02.dbf';
restore tablespace data_ts;
switch datafile all; # Updates repository with new datafile location.
recover tablespace data_ts;
alter database open;
}
12 changes: 12 additions & 0 deletions Chapter11/r_11_intro_a.txt
@@ -0,0 +1,12 @@
SELECT
a.thread#, b.open_mode, a.status,
CASE
WHEN ((b.open_mode='MOUNTED') AND (a.status='OPEN')) THEN 'Crash Recovery req.'
WHEN ((b.open_mode='MOUNTED') AND (a.status='CLOSED')) THEN 'No Crash Rec. req.'
WHEN ((b.open_mode='READ WRITE') AND (a.status='OPEN')) THEN 'Inst. already open'
ELSE 'huh?'
END STATUS
FROM v$thread a,
v$database b,
v$instance c
WHERE a.thread# = c.thread#;
13 changes: 13 additions & 0 deletions Chapter11/r_11_intro_b.txt
@@ -0,0 +1,13 @@
SELECT
a.name,
a.checkpoint_change#,
b.checkpoint_change#,
CASE
WHEN ((a.checkpoint_change# - b.checkpoint_change#) = 0) THEN 'Startup Normal'
WHEN ((a.checkpoint_change# - b.checkpoint_change#) > 0) THEN 'Media Recovery'
WHEN ((a.checkpoint_change# - b.checkpoint_change#) < 0) THEN 'Old Control File'
ELSE 'what the ?'
END STATUS
FROM v$datafile a, -- control file SCN for datafile
v$datafile_header b -- datafile header SCN
WHERE a.file# = b.file#;
7 changes: 7 additions & 0 deletions Chapter12/r_12_2.txt
@@ -0,0 +1,7 @@
connect target /
startup mount;
restore database until time
"to_date('05-oct-2006 14:00:00', 'dd-mon-rrrr hh24:mi:ss')";
recover database until time
"to_date('05-oct-2006 14:00:00', 'dd-mon-rrrr hh24:mi:ss')";
alter database open resetlogs;
7 changes: 7 additions & 0 deletions Chapter12/r_12_3.txt
@@ -0,0 +1,7 @@
select sequence#, first_change#, first_time
from v$log_history
order by first_time;

select sequence#, first_change#, first_time
from v$archived_log
order by first_time;
3 changes: 3 additions & 0 deletions Chapter12/r_12_intro_a.txt
@@ -0,0 +1,3 @@
select file#, status, checkpoint_change#,
to_char(checkpoint_time,'dd-mon-rrrr hh24:mi:ss')
from v$datafile_header;
27 changes: 27 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,27 @@
Freeware License, some rights reserved

Copyright (c) 2007 Sam Alapati, Darl Kuhn, and Arup Nanda

Permission is hereby granted, free of charge, to anyone obtaining a copy
of this software and associated documentation files (the "Software"),
to work with the Software within the limits of freeware distribution and fair use.
This includes the rights to use, copy, and modify the Software for personal use.
Users are also allowed and encouraged to submit corrections and modifications
to the Software for the benefit of other users.

It is not allowed to reuse, modify, or redistribute the Software for
commercial use in any way, or for a user�s educational materials such as books
or blog articles without prior permission from the copyright holder.

The above copyright notice and this permission notice need to be included
in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


15 changes: 15 additions & 0 deletions README.md
@@ -0,0 +1,15 @@
#Apress Source Code

This repository accompanies [*RMAN Recipes for Oracle Database 11g*](http://www.apress.com/9781590598511) by Sam Alapati, Darl Kuhn, and Arup Nanda (Apress, 2007).

![Cover image](9781590598511.jpg)

Download the files as a zip using the green button, or clone the repository to your machine using Git.

##Releases

Release v1.0 corresponds to the code in the published book, without corrections or updates.

##Contributions

See the file Contributing.md for more information on how you can contribute to this repository.
14 changes: 14 additions & 0 deletions README.txt
@@ -0,0 +1,14 @@
This is the README.txt for RMAN Recipes for Oracle Database 11g, first edition.

The scripts are located in the Chapter folders. For the most part, we used
this naming convention:

r_11_1.txt (indicates recipe 11.1)
r_11_2.txt (indicates recipe 11.2)

If you have any questions, corrections, or suggestions, please email
me directly at:

darl.kuhn@gmail.com

thanks.
14 changes: 14 additions & 0 deletions contributing.md
@@ -0,0 +1,14 @@
# Contributing to Apress Source Code

Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers.

## How to Contribute

1. Make sure you have a GitHub account.
2. Fork the repository for the relevant book.
3. Create a new branch on which to make your change, e.g.
`git checkout -b my_code_contribution`
4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted.
5. Submit a pull request.

Thank you for your contribution!

0 comments on commit d42a816

Please sign in to comment.