Beruflich Dokumente
Kultur Dokumente
Objectives
Target database:
o An Oracle database to which RMAN connects with TARGET as
the keyword.
o The target is the database on which RMAN is performing
backup/recovery operations.
/u01/student/dbockstd
dbockstd/@sobora2.isg.siue.edu=>rman target /
RMAN> exit
Initialization Parameters
A number of PFILE initialization parameters are important for controlling
backups.
db_name='USER350'
db_recovery_file_dest='/u01/app/oracle/fast_recovery_ar
ea'
db_recovery_file_dest_size=1G
RMAN Features
Major features of RMAN not available with traditional backup methods
(operating system) or that improve significantly on traditional backup
methods include:
Oracle data blocks. This slightly increases the CPU time required for
backup and recovery.
Backup Types
Full backup includes all blocks of every datafile essentially a bitfor-bit copy.
Image Copies these are full backups done with operating system
commands such as the LINUX/UNIX cp command, or the RMAN
backup as copy commands.
This table gives a list of common RMAN commands see the Oracle
Database Recovery Manager Reference for a complete listing.
Command
Description
BACKUP
CHANGE
CONFIGURE
CREATE
CATALOG
CROSSCHEC
K
DELETE
FLASHBACK
LIST
RECOVER
REGISTER
DATABASE
REPORT
RESTORE
RUN
SET
SHOW
SHUTDOWN
STARTUP
SQL
dbockstd/@sobora2.isg.siue.edu=>rman
RMAN>
RMAN>
Notice the target database control file is being used instead of a recovery
catalog.
RMAN>
Retention Policy
Backups can be retained by either recovery window or by redundancy.
RMAN>
Device Type
If the default device is DISK and no pathname is specified, RMAN uses the
Fast Recovery Area for all backups.
Keeping all backups on disk can become inefficient. This example shows
configuring a tape device the actual specification for the configuration is
specific to each installation depending on the tape backup software and
hardware.
Sbt is the device type for any tape backup system for any vendor.
Backup Compression
This command demonstrates how to compress backups to save disk
space.
RMAN>
Backup Operations
Full Database Backup - ARCHIVELOG Mode
In ARCHIVELOG mode, you can backup a database while it is open.
=========================================================
========================================
EXAMPLE:
Here is the sequence of commands for a consistent backup
(NOARCHIVELOG mode) of the USER350 database owned by dbockstd.
ARCHIVE
------STOPPED
dbockstd/@sobora2.isg.siue.edu=>rman
Shutdown the database immediate, restart it with FORCE option, and then
shutdown immediate again to ensure it is shut down in a consistent state.
Now mount the database.
First shutdown.
Fixed Size
1068937216 bytes
2235208 bytes
Variable Size
616563896 bytes
Database Buffers
444596224 bytes
Redo Buffers
Second shutdown.
5541888 bytes
Fixed Size
1068937216 bytes
2235208 bytes
Variable Size
616563896 bytes
Database Buffers
444596224 bytes
Redo Buffers
5541888 bytes
piece
handle=/u01/app/oracle/fast_recovery_area/USER350/backu
pset/2013_07_10/o1_mf_nnndf_TAG20130710T132207_8xv9lj60
_.bkp tag=TAG20130710T132207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup
set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 10-JUL-13
channel ORA_DISK_1: finished piece 1 at 10-JUL-13
piece
handle=/u01/app/oracle/fast_recovery_area/USER350/backu
pset/2013_07_10/o1_mf_ncnnf_TAG20130710T132207_8xv9lr94
_.bkp tag=TAG20130710T132207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
Finished backup at 10-JUL-13
database opened
RMAN> exit
The complete backup took less than one minute for this small student
database.
The backup set contains a directory for the current backup (2013_07_10)
and the backup set pieces are in that directory.
$ cd /u01/app/oracle/fast_recovery_area
$ ls
USER302
USER350
USER303
$ cd USER350
$ ls
backupset
$ ls -al
total 12
USER304
USER305
USER310
USER312
drwxr-x---
drwxrwxr-x
drwxr-x---
$ cd backupset
$ ls -al
total 12
drwxr-x---
drwxr-x---
drwxr-x---
$ cd 2013_07_10
$ ls -al
total 363164
drwxr-x---
2 oracle dba
drwxr-x---
3 oracle dba
=========================================================
======================================
This statement does a full database backup using backupsets to copy all
database files to the Fast Recovery Area. If the database was started with
an SPFILE, then the second command shown below would also backup the
SPFILE; otherwise, it produces an error message.
RMAN>
The LIST command for RMAN will show backups cataloged within
the target database control file and the RMAN repository.
Full
346.97M
DISK
00:00:05
BP Key: 1
Status: AVAILABLE
Tag: TAG20130710T132207
10-
Compressed: NO
Piece Name:
/u01/app/oracle/fast_recovery_area/USER350/backupset/20
13_07_10/o1_mf_nnndf_TAG20130710T132207_8xv9lj60_.bkp
List of Datafiles in backup set 1
File LV Type Ckp SCN
Ckp Time
Name
5
Full 620734
10-JUL-13
/u02/student/dbockstd/oradata/USER350data01.dbf
6
Full 620734
10-JUL-13
/u03/student/dbockstd/oradata/USER350index01.dbf
7
Full 620734
10-JUL-13
/u02/student/dbockstd/oradata/USER350comp_data.dbf
8
Full 620734
10-JUL-13
/u01/student/dbockstd/oradata/USER350undo02.dbf
Full
7.30M
DISK
BP Key: 2
Status: AVAILABLE
Tag: TAG20130710T132207
00:00:01
10-
Compressed: NO
Piece Name:
/u01/app/oracle/fast_recovery_area/USER350/backupset/20
13_07_10/o1_mf_ncnnf_TAG20130710T132207_8xv9lr94_.bkp
Control File Included: Ckp SCN: 620734
time: 10-JUL-13
Validating Backups
It is important to know if a backup is valid.
Ckp
VALIDATE command -- confirm that all database files exist, are in their
correct location, and are free of physical corruption.
19396
41600
File Name:
/u01/student/dbockstd/oradata/USER350system01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ---------------Data
14806
Index
4807
Other
2591
22661
41600
File Name:
/u01/student/dbockstd/oradata/USER350sysaux01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ---------------Data
7680
Index
6456
Other
4803
513
640
File Name:
/u02/student/dbockstd/oradata/USER350users01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ---------------Data
Index
Other
127
7436
7680
File Name:
/u02/student/dbockstd/oradata/USER350data01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ---------------Data
63
Index
28
Other
153
74
256
File Name:
/u03/student/dbockstd/oradata/USER350index01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data
Index
13
Other
169
121
128
File Name:
/u02/student/dbockstd/oradata/USER350comp_data.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ---------------Data
Index
Other
106
4432
File Name:
/u01/student/dbockstd/oradata/USER350undo02.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ---------------Data
Index
Other
4326
464
DELETE lists files and prompts for confirmation before deleting when
running RMAN interactively.
Tablespace Backup
A tablespace backup should be made as soon as a tablespace is added to
a database this will reduce the time required for restoring the tablespace
if media failure occurs.
RMAN>
Datafile Backup
Individual datafiles may be backed up when it is impractical to backup an
entire tablespace within a single RMAN session.
Image Copy
Backup of copies of the database that are bit-for-bit are automatically
recorded in the RMAN repository this is an advantage over using the O/S
commands.
Incremental Backup
The initial incremental backup is a level 0 incremental backup.
Recovery Operations
RMAN can perform recovery at various levels including recovering
individual blocks, tablespaces, datafiles, or an entire database.
RB segs Datafile
2
325
SYSAUX
***
/u01/student/dbockstd/oradata/USER350sysaux01.dbf
4
5
USERS
***
/u02/student/dbockstd/oradata/USER350users01.dbf
5
60
DATA01
***
/u02/student/dbockstd/oradata/USER350data01.dbf
6
2
INDEX01
***
/u03/student/dbockstd/oradata/USER350index01.dbf
7
1
COMP_DATA
***
/u02/student/dbockstd/oradata/USER350comp_data.dbf
8
34
UNDO02
***
/u01/student/dbockstd/oradata/USER350undo02.dbf
Maxsize(MB)
3. Run the RESTORE DATABASE command with the PREVIEW option. This
will provide a summary .
List of Backups
===============
Key
TY LV S Device Type Completion Time #Pieces
#Copies Compressed Tag
------- -- -- - ----------- --------------- ------------- ---------- --1
NO
F A DISK
10-JUL-13
TAG20130710T132207
Affected datafiles remain online and available to users (except for the
corrupt database blocks).
RMAN must know the datafile number and block number within a
datafile that is corrupt.
Control files can be restored from backups if you lose all copies of the
control files an unlikely event if you have multiple disk drives.
If you are not using a recovery catalog, use the FROM filename clause.
After recovering a control file, you must perform media recover of the
database and open the database with RESETLOGS option see the
media recover documentation on the Oracle web site.
Restoring a Tablespace
To restore/recover a tablespace, the tablespace must be forced offline,
restored and recovered, then brought back online.
Restoring a Datafile
Restoring a datafile is similar to restoring a tablespace.
Take the tablespace for the datafile offline, restore and recover the
datafile, and bring the tablespace back online.
Tablespace created.
Create a user named RMAN that will handle backup and recovery
operations and allocate privileges to this user.
User created.
Grant succeeded.
Start the RMAN software with a connection to the catalog. Note the
error message that the recovery catalog is not yet installed.
dbock/@DBORCL=>rman catalog
rman/rman001@DBORCL.siue.edu
Example: This example shows starting up the RMAN utility for the
dbockstd database while specifying that the catalog repository is in the
DBORCL database and the name of the repository owner is the rman user
account (rman@DBORCL). The system prompts for the password of the
rman user account. At this point the utility is ready for the DBA to enter a
command.
RMAN>
Registering a Database
Each database for RMAN backup/recovery must be registered in the
RMAN repository if the repository is used.
RMAN>
RMAN-00571:
=======================================================
====
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
=======================================================
====
RMAN-03009: failure of register command on default
channel at 07/10/2013 11:01:06
RMAN-20002: target database already registered in
recovery catalog
END OF NOTES