Sunteți pe pagina 1din 31

xercise - 1 TIME BASED RECOVERY

1. SHUTDOWN THE DATABASE


2. TAKE OFFLINE WHOLE BACKUP
3. CREATE TABLE IN USERS TABLESPACE
4. INSERT DATA INTO THE TABLE
5. COMMIT
6. SELECT TO_CHAR(SYSDATE,'YYYY/MM/DD HH24:MI:SS') FROM DUAL
7. ALTER SYSTEM SWITCH LOGFILE
8. INSERT FURTHER SOME ROWS INTO THE TABLE
9. COMMIT
10. DROP THE TABLE
11. SHUTDOWN IMMEDIATE
12. COPY ALL DATAFILE FROM BACKUP
13. STARTUP MOUNT
14. RECOVER DATABASE UNTIL TIME '2006-06-11 18:00:00'
15. ALTER DATABASE OPEN RESETLOGS
16. SELECT * FROM TABLE
17. SHUTDOWN IMMEDIATE AND TAKE OFFLINE WHOLE BACKUP

Exercise - 2 CHANGED BASED RECOVERY

1. SHUTDOWN THE DATABASE


2. TAKE OFFLINE WHOLE BACKUP
3. CREATE TABLE IN USERS TABLESPACE
4. INSERT DATA INTO THE TABLE
5. COMMIT
6. SELECT TO CHECKPOINT_CHANGE# FROM V$DATABASE
7. ALTER SYSTEM SWITCH LOGFILE
8. INSERT FURTHER SOME ROWS INTO THE TABLE
9. COMMIT
10. DROP THE TABLE
11. SHUTDOWN IMMEDIATE
12. COPY ALL DATAFILE FROM BACKUP
13. STARTUP MOUNT
14. RECOVER DATABASE UNTIL SCN / CHANGE 99999
15. ALTER DATABASE OPEN RESETLOGS
16. SELECT * FROM TABLE
17. SHUTDOWN IMMEDIATE AND TAKE OFFLINE WHOLE BACKUP

Exercise - 3 CANCEL BASED RECOVERY


1. SHUTDOWN THE DATABASE
2. TAKE OFFLINE WHOLE BACKUP
3. CREATE TABLE IN USERS TABLESPACE
4. INSERT DATA INTO THE TABLE
5. COMMIT
6. ARCHIVE LOG LIST
7. ALTER SYSTEM SWITCH LOGFILE
8. INSERT FURTHER SOME ROWS INTO THE TABLE
9. COMMIT
10. DROP THE TABLE
11. SHUTDOWN IMMEDIATE
12. COPY ALL DATAFILE FROM BACKUP
13. STARTUP MOUNT
14. RECOVER DATABASE UNTIL CANCEL
15. ALTER DATABASE OPEN RESETLOGS
16. SELECT * FROM TABLE
17. SHUTDOWN IMMEDIATE AND TAKE OFFLINE WHOLE BACKUP

=====================

BACKUP PROCESS FLOW

==================

1. Connect to the target database and the repository.

2. Shut down the target database and start up in mount mode, if performing a

cold backup.

3. Allocate a communication channel.

4. Issue a backup command, which can specify one or more datafiles, a

tablespace, the entire database, the control file, or the archive logs.

5. Locate the target files specified by the backup command.

6. Copy the target files to the backup location.

7. Update the entries in the repository.

8. Deallocate the communications channel.

=========================

The Restore Process FloW

=========================

1. Connect to the target database and the repository.

2. Shut down the target database and start up in mount mode, if performing a

cold restore.

3. Allocate a communication channel.

4. Check the repository to determine the correct current configuration of the

target database.

5. Compare the repository�s version of the target database�s configuration to the

files that actually exist to determine which files are missing.


6. Find the backup files in their backup location.

7. Copy the backup files from their backup location to their original location, if

it is still available, or to an alternative location if the original location is


not

available.

8. Update the entries in the repository.

9. Deallocate the communications channel.

BACKUP DATABASE;

BACKUP TABLESPACE users, tools;

BACKUP (SPFILE) (CURRENT CONTROL FILE);

BACKUP BACKUPSET 12;

BACKUP DATAFILECOPY '/tmp/system01.dbf';

BACKUP DEVICE TYPE sbt DATABASE PLUS ARCHIVELOG;

CONFIGURE DEVICE TYPE sbt PARALLELISM 2;

CONFIGURE DEFAULT DEVICE TYPE TO sbt;

CONFIGURE CHANNEL 1 DEVICE TYPE sbt RATE 700K;

CONFIGURE CHANNEL 2 DEVICE TYPE sbt RATE 1M;

BACKUP

(TABLESPACE system, undotbs

CHANNEL ORA_SBT_TAPE_1)

(TABLESPACE users, tools, indx

CHANNEL ORA_SBT_TAPE_2);
RUN

ALLOCATE CHANNEL ORA_SBT_TAPE_1 DEVICE TYPE sbt;

BACKUP DATABASE;

CONFIGURE DEFAULT DEVICE DEVICE TYPE TO sbt;

CONFIGURE DEVICE TYPE sbt PARALLELISM 2;

CONFIGURE CHANNEL 1 DEVICE TYPE sbt CONNECT 'node1'


PARMS='ENV=(NSR_SERVER=bksvr1)';

CONFIGURE CHANNEL 2 DEVICE TYPE sbt CONNECT 'node2'


PARMS='ENV=(NSR_SERVER=bksvr1)';

CONFIGURE DEVICE TYPE DISK PARALLELISM 3;

CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE = 2M;

CONFIGURE CHANNEL 3 DEVICE TYPE DISK MAXPIECESIZE = 900K;

BACKUP DATABASE;

BACKUP TABLESPACE users, tools;

BACKUP (SPFILE) (CURRENT CONTROL FILE);

BACKUP BACKUPSET 12;

BACKUP DATAFILECOPY '/tmp/system01.dbf';

CREATE SCRIPT TRGT_FULL

ALLOCATE CHANNEL t1 DEVICE TYPE sbt MAXOPENFILES 4 PARMS='...';

ALLOCATE CHANNEL t2 DEVICE TYPE sbt MAXOPENFILES 4 PARMS='...';

ALLOCATE CHANNEL t3 DEVICE TYPE sbt MAXOPENFILES 4 PARMS='...';


BACKUP FILESPERSET 64

DATABASE FORMAT 'TRGT.FULL.%d.%s.%p';

RUN

ALLOCATE CHANNEL ch1 DEVICE TYPE DISK FORMAT = '/backup/df/%U';

ALLOCATE CHANNEL ch2 DEVICE TYPE DISK FORMAT = '/backup/cf/%U';

ALLOCATE CHANNEL ch3 DEVICE TYPE sbt;

BACKUP

# channel ch1 backs up datafiles to /backup/df directory

DATAFILE 1,2,3,4

CHANNEL ch1

# channel ch2 backs up control file copy to /backup/cf directory

CONTROLFILECOPY '/tmp/control01.ctl'

CHANNEL ch2

# channel ch3 backs up archived redo logs to tape

ARCHIVELOG FROM TIME 'SYSDATE-14'

CHANNEL ch3;

backup incremental level 0 database;

CREATE TABLE test_inc (col1 NUMBER)

TABLESPACE users;

backup incremental level 1 database;


BACKUP ARCHIVELOG ALL;

BACKUP ARCHIVELOG ALL DELETE ALL INPUT;

BACKUP ARCHIVELOG FROM TIME 'SYSDATE-30' UNTIL TIME 'SYSDATE-7';

BACKUP ARCHIVELOG FROM SCN = 52456 DELETE ALL INPUT;

BACKUP ARCHIVELOG LIKE 'ARC0003%.001;

BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;

backup archivelog all delete all input;

REPORT SCHEMA;

REPORT SCHEMA AT TIME '15-JAN-2003 08:00:00';

REPORT SCHEMA AT SCN=45614;

REPORT SCHEMA AT SEQUENCE=15 THREAD=1;

CROSSCHECK BACKUP TAG full_weekly;

CROSSCHECK BACKUPSET 433,434,435,436;

CROSSCHECK BACKUPPIECE 887,888,889;

CROSSCHECK BACKUP;

CROSSCHECK BACKUP OF CONTROLFILE;

=========================
===========

Rman incomple

=================

sQL> connect testuser/testpassword

Connected.

SQL> select count(*) from test_table;

select count(*) from test_table

ERROR at line 1:

ORA-01578: ORACLE data block corrupted (file # 4, block # 2015)

ORA-01110: data file 4: 'D:\ORACLE_DATA\DATAFILES\ORCL\USERS01.DBF'

Since we know the file and block number, we can perform block level recovery using
RMAN. This is best illustrated by example:

C:\>rman target /

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: ORCL (DBID=1507972899)

--restore AND recover specific block

RMAN> blockrecover datafile 4 block 2015;


=================

SQL> select first_change# from v$log where group#=3 ;

FIRST_CHANGE#

-------------

370255

rman target /

RMAN> restore database until scn 370254;

RMAN> alter database open resetlogs;

==========

Recovery from missing or corrupted control file

1-

startup

ORACLE instance started.

Total System Global Area 135338868 bytes

Fixed Size 453492 bytes


Variable Size 109051904 bytes

Database Buffers 25165824 bytes

Redo Buffers 667648 bytes

ORA-00205: error in identifying controlfile, check alert log for more info

2-On checking the alert log, as suggested, we find the following:

ORA-00202: controlfile: 'e:\oracle_dup_dest\controlfile\ORCL\control02.ctl'

ORA-27046: file size is not a multiple of logical block size

OSD-04012: file size mismatch (OS 5447783

The above corruption was introduced by manually editing the control file when the
database was closed.

The solution is simple, provided you have at least one uncorrupted control file -
replace the corrupted control file with a copy using operating system commands.
Remember to rename the copied file. The database should now start up without any
problems.

3-C:\>rman target /

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: ORCL (not mounted)

-- set DBID - get this from the name of the controlfile autobackup.

-- For example, if autobackup name is

-- CTL_SP_BAK_C-1507972899-20050124-00 the the DBID is

-- 1507972899. This step will not be required if the instance is

-- started up from RMAN


4-RMAN> set dbid 1507972899

executing command: SET DBID

--restore controlfile from autobackup. The backup is not at the default

--location so the path must be specified

5-RMAN> restore controlfile from 'e:\backup\CTL_SP_BAK_C-1507972899-20050124-00';

Starting restore at 26/JAN/05

using channel ORA_DISK_1

channel ORA_DISK_1: restoring controlfile

channel ORA_DISK_1: restore complete

replicating controlfile

input filename=D:\ORACLE_DATA\CONTROLFILE\ORCL\CONTROL01.CTL

output filename=E:\ORACLE_DUP_DEST\CONTROLFILE\ORCL\CONTROL02.CTL

output filename=C:\ORACLE_DUP_DEST\CONTROLFILE\ORCL\CONTROL03.CTL

Finished restore at 26/JAN/05

-- Now that control files have been restored, the instance can mount the

-- database.

6-RMAN> mount database;

database mounted
-- All datafiles must be restored, since the controlfile is older than the current

-- datafiles. Datafile restore must be followed by recovery up to the current log.

7-RMAN> restore database;

Starting restore at 26/JAN/05

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to D:\ORACLE_DATA\DATAFILES\ORCL\SYSTEM01.DBF

restoring datafile 00004 to D:\ORACLE_DATA\DATAFILES\ORCL\USERS01.DBF

channel ORA_DISK_1: restored backup piece 1

piece handle=E:\BACKUP\0DGB0I79_1_1.BAK tag=TAG20050124T115832 params=NULL

channel ORA_DISK_1: restore complete

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00002 to D:\ORACLE_DATA\DATAFILES\ORCL\UNDOTBS01.DBF

restoring datafile 00003 to D:\ORACLE_DATA\DATAFILES\ORCL\TOOLS01.DBF

channel ORA_DISK_1: restored backup piece 1

piece handle=E:\BACKUP\0CGB0I78_1_1.BAK tag=TAG20050124T115832 params=NULL

channel ORA_DISK_1: restore complete

Finished restore at 26/JAN/05

--Database must be recovered because all datafiles have been restored from

-- backup

8-RMAN> recover database;


Starting recover at 26/JAN/05

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 2 is already on disk as file


E:\ORACLE_ARCHIVE\ORCL\1_2.ARC

archive log thread 1 sequence 4 is already on disk as file


D:\ORACLE_DATA\LOGS\ORCL\REDO02A.LOG

archive log thread 1 sequence 5 is already on disk as file


D:\ORACLE_DATA\LOGS\ORCL\REDO01A.LOG

archive log thread 1 sequence 6 is already on disk as file


D:\ORACLE_DATA\LOGS\ORCL\REDO03A.LOG

archive log filename=E:\ORACLE_ARCHIVE\ORCL\1_2.ARC thread=1 sequence=2

archive log filename=E:\ORACLE_ARCHIVE\ORCL\1_3.ARC thread=1 sequence=3

archive log filename=E:\ORACLE_DATA\LOGS\ORCL\REDO02A.LOG thread=1 sequence=4

archive log filename=E:\ORACLE_DATA\LOGS\ORCL\REDO01A.LOG thread=1 sequence=5

archive log filename=E:\ORACLE_DATA\LOGS\ORCL\REDO03A.LOG thread=1 sequence=6

media recovery complete

Finished recover at 26/JAN/05

-- Recovery completed. The database must be opened with RESETLOGS

-- because a backup control file was used. Can also use

-- "alter database open resetlogs" instead.

9-RMAN> open resetlogs database;

database opened

restore incomp
RUN {

ALLOCATE CHANNEL ch1 DEVICE

TYPE sbt;

SET UNTIL SCN 1024;

RESTORE DATABASE;

RECOVER DATABASE;

ALTER DATABASE OPEN RESETLOGS;

run { set until time ="to_date('03/03/2006 16:58:01','mm/dd/yyyy hh24:mi:ss')";

restore database;

recover database;

To restore the database to its default location using a recovery catalog:

Start RMAN and connect to the target database and, optionally, the recovery
catalog database. C:\>rman target mike/1234@mike catalog rman/rman@infomax

If the database is open, shut it down and then mount it: RMAN> shutdown
immediate;

RMAN> startup mount;

After allocating channels, restore the database: RMAN>run {


allocate channel ch1 type disk;

allocate channel ch2 type disk;

allocate channel ch3 type disk;

restore database;

Or, for example, this job restores the database in anticipation of an incomplete
recovery until

December 15, 1998 at 9 a.m.

RMAN>run {

set until time 'Dec 15 1998 09:00:00';

allocate channel ch1 type 'sbt_tape';

restore database;

====================

To restore a tablespace to its default location using a recovery catalog:

Start RMAN and connect to the target database and, optionally, the recovery
catalog database. C:\>rman target catalog rman/rman@abc

After allocating channels, do the following: Take the tablespace that you want to
recover offline. Restore the tablespace.

RMAN> run {

sql 'ALTER TABLESPACE user_data OFFLINE TEMPORARY';

allocate channel ch1 type disk;

restore tablespace user_data;

}
To restore a tablespace to a new location:

run {

allocate channel ch1 type disk;

sql 'ALTER TABLESPACE user_data OFFLINE TEMPORARY';

# restore the datafile to a new location

set newname for datafile '/disk1/oracle/tbs_1.f' to '/disk2/oracle/tbs_1.f';

restore tablespace tbs_1;

# make the control file recognize the restored file as current

switch datafile all;

You will need to perform media recovery on the restored tablespace.

To restore the control file to its default location using a recovery catalog:

Start RMAN and connect to the target and recovery catalog databases. For example,
enter: C:\>rman target / catalog rman/rman@infomax

Start the instance without mounting the database: RMAN> startup nomount;

If for some reason you need to restore a control file created before a certain
date, issue a set until command for that date. Otherwise, do the following:

RMAN>

run {

# To restore a control file created before a certain date, issue the


following

# set command using a valid date for 'date_string'. You can also specify an
SCN
# or log sequence number.

# set until time = 'date_string';

allocate channel ch1 type 'sbt_tape';

restore controlfile;

alter database mount;

NOTE: RMAN automatically replicates to the control file to the locations specified
by the CONTROL_FILES initialization parameter.

To restore the control file to a new location without a recovery catalog:


C:\>rman target mike/1234@mike nocatalog

RMAN> startup mount;

run {

# To restore a control file created before a certain date, issue the following

# set command using a valid date for 'date_string'. You can also specify an SCN

# or log sequence number.

# set until time = 'date_string';

allocate channel ch1 type 'sbt_tape';

# restore control file to new location

restore controlfile to '/oracle/dbs/cf1.ctl';

shutdown immediate;

# replicate the control file manually to locations in parameter file

replicate controlfile from '/oracle/dbs/cf1.ctl';

startup mount;

If you need to perform media recovery on the datafiles after restoring the control
file, see "Performing Complete Recovery" or "Performing Incomplete Recovery".
To restore archived redo logs:

Start RMAN and connect to the target database and, optionally, the recovery
catalog database. For example, enter:

C:\>rman target catalog rman/rman@infomax

If the database is open, shut it down and then mount it: RMAN> shutdown
immediate;

RMAN> startup mount;

If desired, specify the new location for the restored archived redo logs using set
archivelog destination. Otherwise, do the following: RMAN> run {

# Optionally, set a new location for the restored logs.

set archivelog destination to '/oracle/temp_restore';

allocate channel ch1 type disk;

restore archivelog all;

=============================================

RMAN> run {

set until time "TO_DATE('04/04/01

9:00:00','MM/DD/YY HH24:MI:SS')";

allocate channel ch1 type disk;


restore database;

recover database;

alter database open resetlogs;

Or RMAN> run {

set until scn 1000;

allocate channel ch1 type disk;

restore database;

recover database;

alter database open resetlogs;

Or RMAN> run {

set until logseq 6 thread 1;

allocate channel ch1 type disk;

restore database;

recover database;

alter database open resetlogs;

eset the database: RMAN> reset database;

Immediately back up the database. Because the database is a new incarnation, the
pre-RESETLOGS backups are not usable. For example, enter:

RMAN> run {

allocate channel ch1 type 'sbt_tape';

backup database;

}
CONFIGURE RETENTION POLICY TO REDUNDANCY 5;

CONFIGURE RETENTION POLICY TO RECOVER WINDOW OF 30 DAYS;

SHOW RETENTION POLICY;

RMAN configuration parameters are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 3;

CONFIGURE RETENTION POLICY TO NONE

========

CONFIGURE DEFAULT DEVICE TYPE TO DISK;

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT

'D:\oracle\oradata\ora92\ora92_bak\%d_%s_%p.bak';

CONFIGURE DEVICE TYPE DISK PARALLELISM 4;

=========

%d Specifies the name of the target database.

%D Specifies the current day of the month using the format DD.

%F Combines the database identifier (DBID), day, month, year, and a sequential
number into a unique and repeatable generated name.

%M Specifies the month number using the format MM.

%p Specifies the backup piece number within a single backup set. The first set
will

automatically use the value 1, and the value is incremented for each subsequent

piece in the set.

%s Specifies the backup set number. This number is actually stored in the control

file of the target database and is incremented for each backup set created for

the target database.

%t Specifies the timestamp of the backup set.

%T Specifies a full year, month, and date using the format YYYYMMDD.

%u Instructs RMAN to generate a unique name for each output file.

%U Shorthand for %u_%p_%c. This combination guarantees uniqueness for all

backup sets generated for a single target database.

%Y Specifies the current year using the format YYYY.

================

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO

'%F';

=======

CONFIGURE RETENTION POLICY CLEAR;

CONFIGURE DEFAULT DEVICE TYPE CLEAR;

CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR;

CONFIGURE CONTROLFILE AUTOBACKUP CLEAR;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK

CLEAR;

CONFIGURE BACKUP OPTIMIZATION CLEAR;


CONFIGURE EXCLUDE FOR TABLESPACE users CLEAR;

============

CONFIGURE BACKUP OPTIMIZATION ON;

CONFIGURE EXCLUDE FOR TABLESPACE example;

======

CROSSCHECK BACKUP;

CROSSCHECK BACKUP OF CONTROLFILE;

CROSSCHECK BACKUP OF TABLESPACE system;

CROSSCHECK BACKUP OF DATAFILE

'D:\oracle\oradata\ora92\tools01.dbf';

CROSSCHECK COPY OF CONTROLFILE;

Exercise - 10 Connect RMAN without Catalog

1. RMAN TARGET SYS/SYS [NOCATALOG]

2. REPORT SCHEMA

3. SHOW ALL

4. CONFIGURE AUTO BACKUP

5. CONFIGURE PARALLELISM

Exercise - 11 Connect RMAN with Catalog

1. CREATE TABLESPACE RMAN OR TOOLS WITH DATAFILE 50M

2. CREATE USER RMAN WITH DEFAULT TABLESPACE RMAN

3. GRANT CONNECT,RESOURCE,RECOVERY_CATALOG_OWNER TO RMAN


4. RMAN RCVCAT RMAN/RMAN TARGET SYS/SYS

5. CREATE CATALOG

6. REGISTER DATABASE

Exercise - 12 CONFIGURING RMAN

1. RMAN rcvcat rman/rman target sys/sys

2 REPORT SCHEMA

3 SHOW ALL

4 To set the retention policy to maintain five set of current backups,


issue the following command :

CONFIGURE RETENTION POLICY TO REDUNDANCY 5;

.To set the retention policy to maintain 30 day�s worth of current backups
CONFIGURE RETENTION POLICY TO RECOVER WINDOW OF 30 DAYS

4. To set auto backup on issue the following command

CONFIGURE CONTROLFILE AUTOBACKUP ON;

6. CONFIGURE DEFAULT DEVICE TYPE TO DISK;

7. CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT


�D:\ORACLE\ORADATA\BACKUP\%d_%d_%p.BAK

8. CONFIGURE DEVICE TYPE DISK PARALLELISM 4;

9. CONFIGURE EXCLUDE FOR TABLESPACE USERS

10. CONFIGURE BACKUP OPTIMIZATION ON;

Exercise - 13 CLEARING RMAN CONFIGURATION

1. CONFIGURE RETENTION POLICY TO REDUNDANCY 5 CLEAR

2. CONFIGURE RETENTION POLICY TO RECOVER WINDOW OF 30 DAYS CLEAR

3. CONFIGURE CONTROLFILE AUTOBACKUP ON CLEAR;

4. CONFIGURE DEFAULT DEVICE TYPE TO DISK CLEAR;

6. CONFIGURE DEVICE TYPE DISK PARALLELISM 4 CLEAR;

7. CONFIGURE EXCLUDE FOR TABLESPACE USERS CLEAR


8. CONFIGURE BACKUP OPTIMIZATION ON CLEAR;

1-RMAN> run {

allocate channel ch1 type disk;

backup

(datafile 1,2,3,4,5,6

filesperset 3)

datafilecopy 'c:\oracle\copy\datafile_1.dbf';

2-RMAN> list backup;

To back up the current control file:

RMAN> run {

allocate channel ch1 type 'sbt_tape';

backup current controlfile

tag = mondayPMbackup;

Backing Up Archived Redo Logs:

run {

allocate channel ch1 type 'sbt_tape';

backup archivelog all # Backs up all archived redo logs.

delete input; # Optionally, delete the input logs

You can also specify a range of archived redo logs by time, SCN, or log sequence
number. This example backs up all archived logs created more than 7 and less than
30 days ago:
RMAN> run {

allocate channel ch1 type disk;

backup archivelog

from time 'SYSDATE-30' until time 'SYSDATE-7';

==========

Allocate a channel before issuing the backup command. This example makes a level 0
backup of the database: run {

allocate channel ch1 type disk;

backup

incremental level = 0

database;

========

This example makes a differential level 1 backup of the SYSTEM tablespace and
datafile sales.dbf. It will only back up those data blocks changed since the most
recent level 1 or level 0 backup: run {

allocate channel ch1 type disk;

backup

incremental level = 1

tablespace system

datafile '/oracle/dbs/sales.dbf';

===

This example makes a cumulative level 2 backup of the tablespace TBS_2. It will
only back up those data blocks changed since the most recent level 1 or level 0
backup: run {

allocate channel ch1 type disk;

backup
incremental level = 2 cumulative # specify cumulative option

tablespace tbs_1;

=============

this command either changes the recovery catalog record to status DELETED or
removes the record altogether.

RMAN> allocate channel for delete type disk;

deletes the backup piece with key 101, the control file copy with key 63, and all
archived logs through log sequence 300 from disk: RMAN> change backuppiece 101
delete;

RMAN> change controlfilecopy 63 delete;

RMAN> change archivelog until logseq = 300 delete;

Release the allocated maintenance channel:

RMAN> release channel;

===============

Exercise � 14 Performing cold backup

1. rman target sys/sys nocatalog

2. shutdown immediate
3. startup mount

4. backup database

5. verify the backup taken

6. sql �alter database open�

Exercise � 15 Performing image copy

1. rman target sys/sys nocatalog

2. shutdown immediate

3. startup mount

4. copy datafile 1 to �d:\baclup\system-image.dbf�

5. sql �alter database open�

Exercise � 16 Performing hot backup

1. rman target sys/sys nocatalog

2. backup database

Exercise � 17 Performing backup archivelogs

1. rman target sys/sys nocatalog

2. backup archivelog all;

3. backup archivelog all delete all input;

4. backup archivelog from time �sysdate-30� until time �sysdate-7�;

5. backup archivelog like �ARC003%.001�;

Exercise � 18 Performing database backup along with archivelogs

1. rman target sys/sys nocatalog


2. backup database plus archivelog;

3. backup database plus archivelog delete input;

4. backup database plus archivelog all delete all input;

Exercise � 19 Performing incremental level 0 backup

1. rman target sys/sys rcvcat rman/rman

2. backup incremental level 0 database;

Exercise � 20 Performing incremental level 1 backup;

1. Find the size of backup file just generated

2. rman target sys/sys rcvcat rman/rman

3. Create a table from sql prompt

4. backup incremental level 1 database;

5. Find the size of backup file

Exercise � 21 Create Stored Script

1. rman rcvcat rman/rman target sys/sys

2. create script full_database_backup

Backup database plus archivelog all delete input;

Exercise � 22 Run the stored script


1. rman rcvcat rman/rman target sys/sys

2. run {execute script full_database_backup;}

Exercise � 23 REPORT COMMANDS

1. rman target sys/sys rcvcat rman/rman

2. report schema;

3. report need backup;

4. report unrecoverable;

5. report obsolete;

Exercise � 24 LIST COMMANDS

1. rman target sys/sys rcvcat rman/rman

2. list backup of tablespace users;

3. list backup of datafile 1;

4. list backup of controlfile;

5. list backup of spfile;

6. list backup of archivelog;

7. list incarnation of database �oracle�;

Exercise � 25 CROSSCHECK AND DELETE BACKUP SETS

1. rman target sys/sys rcvcat rman/rman

2. crosscheck backup;

3. crosscheck backup of controlfile;

4. crosscheck backup of tablespace system;

5. crosscheck backupset 433,434,435,436

6. crosscheck backuppiece 887,888,889

7. delete expired;

8. delete obsolete;
9. delete backup;

export and import

Exercise - 5 Full Database Export

1. RUN THIS COMMAND AT COMMAND PROMPT

2. EXP USERID=�SYS/SYS AS SYSDBA� FILE=C:\EXPORT\EXP_FULL.DMP


LOG=C:\EXPORT\EXP_FULL.LOG FULL=Y DIRECT=Y

3. SEE THE LOG FILE

Exercise - 6 SCHEMA EXPORT

4. RUN THIS COMMAND AT COMMAND PROMPT

5. EXP USERID=�SYS/SYS AS SYSDBA� FILE=C:\EXPORT\EXP_FULL.DMP


LOG=C:\EXPORT\EXP_FULL.LOG OWNER=SCOTT DIRECT=Y

6. SEE THE LOG FILE

Exercise - 7 TABLESPACE EXPORT

7. RUN THIS COMMAND AT COMMAND PROMPT

8. EXP USERID=�SYS/SYS AS SYSDBA� FILE=C:\EXPORT\EXP_TBS.DMP


LOG=C:\EXPORT\EXP_TBS.LOG TABLESPACES=USERS DIRECT=Y

9. SEE THE LOG FILE

Exercise - 8 TABLE EXPORT

10. RUN THIS COMMAND AT COMMAND PROMPT


11. EXP USERID=�SYS/SYS AS SYSDBA� FILE=C:\EXPORT\EXP_TABLE.DMP
LOG=C:\EXPORT\EXP_TABLE.LOG TABLES=SCOTT.EMP DIRECT=Y

12. SEE THE LOG FILE

Exercise - 9 IMPORTING DATA INTO DATABASE

1. TO DETERMINE THE CURRENT STATUS OF RMAN TABLESPACE

2. Before Transporting a set of tablespace, Ensure that tablespace is in


self-contained and this is done with TRANSPORT_SET_CHECK procedure of DBMS_TTS
package. EXEC DBMS_TTS.TRANSPORT_SET_CHECK(�RMAN�)

3. To determine if any issues were discovered, issue the following command :


SELECT * FROM TRANSPORT_SET_VIOLATION

4. Oracle will display the message �no rows selected�. This means that there are
no dependencies between object in RMAN tablespace and objects in other
tablespaeces, so RMAN tablespace can be transported.

5. Before transporting a tablespace, the tablespace must be in read only state.


ALTER TABLESPACE RMAN READ ONLY;

6. exp userid=�sys/sys as sysdba� file=c:\export\tts_rman.dmp


log=c:\export\tts_rman.log transport_tablespace=y tablespaces=RMAN

7. Because your system has only one database, you will assume that the datafile
and export file have both been copied to another system, and you are
about to import the tablespace into another database. However, before importing
the tablespace, you must first drop the existing RMAN tablespace from the
database.

8. You will now use the export file you have just created to import the RMAN
tablespace into the database:

Imp userid=�sys/sys as sysdba� file=:\export\tts_rman.dmp


log=c:\export\tts_rman.log transport_tablespace=y tablespaces=RMAN
datafile=d:\oracle\oradata\rman01.dbf

Once you press enter, the import process will begin. The output may look as if
individual tables were being imported. However only the metadata concering those
tables are imported into the data dictionary.
9. ALTER TABLESPACE RMAN READ WRITE

S-ar putea să vă placă și