RMAN:
Recovery Manager (RMAN) is an Oracle utility that can back
up, restore, and recover database files. The product is a feature of the Oracle
database server and does not require separate installation.
Recovery Manager is a client/server application that uses
database server sessions to perform backup and recovery.
RMAN must include the following components:
A TARGET DATABASE:
An Oracle database, To which RMAN is connected with the TARGET keyword. A target database is a database on which RMAN
is performing backup and recovery operations. RMAN always maintains metadata
about its operations on a database in the control file of the database. The
RMAN metadata is known as the RMAN repository.
RMAN CLIENT:
The RMAN executable is automatically installed with the
database and is typically located in the same directory as the other database
executables. For example, the RMAN client on Linux is located in
$ORACLE_HOME/bin.
Some environments use the following optional
components:
A fast recovery area:
A disk location in which the database can store and manage
files related to backup and recovery. You set the fast recovery area location
and size with the DB_RECOVERY_FILE_DEST and DB_RECOVERY_FILE_DEST_SIZE
initialization parameters.
A media manager:
An application required for RMAN to interact with sequential
media devices such as tape libraries. Media management devices are sometimes
called SBT (system backup to tape) devices.
A recovery catalog:
A separate database schema used to record RMAN activity
against one or more target databases. A recovery catalog preserves RMAN
repository metadata if the control file is lost, making it much easier to
restore and recover following the loss of the control file. The database may
overwrite older records in the control file, but RMAN maintains records forever
in the catalog unless the records are deleted by the user.
Connect to RMAN like below
C:\Users\>rman
Recovery Manager: Release 10.2.0.1.0
- Production on Tue May 26 12:35:45 2015
Copyright (c) 1982, 2005,
Oracle. All rights reserved.
RMAN> connect target sys@XE
target database Password:
connected to target database: XE
(DBID=2761439438)
RMAN> exit
Recovery Manager complete.
C:\Users\>rman target
sys/cherry@XE
Recovery Manager: Release 10.2.0.1.0
- Production on Tue May 26 12:40:37 2015
Copyright (c) 1982, 2005,
Oracle. All rights reserved.
connected to target database: XE
(DBID=2761439438)
The following
example appends the output from an RMAN session to a text file at
/tmp/msglog.log & D:\DATA_XE\RMAN\msglog.log
Windows:
C:\Users\>rman TARGET
sys/cherry@XE LOG 'D:\DATA_XE\RMAN\msglog.log' APPEND
Linux:
$rman
TARGET / LOG /tmp/msglog.log APPEND
Backing Up a
Database in NOARCHIVELOG Mode using RMAN
If a database runs in NOARCHIVELOG mode. For the backup to
be consistent, the database must be mounted after a consistent shutdown. No
recovery is required after restoring the backup.
SQL> shut immediate
SQL> startup mount
RMAN> backup database format ‘D: \DATA_XE\RMAN\’
Once backup completed successfully.
SQL> Alter database open.
NOTE: if the database is in noarchivelog mode. We can only
take backup in the mount state using RMAN. We cannot take in open state. Please
see below example.
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 805306368 bytes
Fixed Size 1289996 bytes
Variable Size 218104052 bytes
Database Buffers 583008256 bytes
Redo Buffers 2904064 bytes
Database mounted.
SQL> alter database noarchivelog;
Database altered.
SQL> alter database open;
Database altered.
C:\Users\ >rman
Recovery Manager: Release 10.2.0.1.0 -
Production on Tue May 26 14:52:23 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect target sys@XE
target database Password:
connected to target database: XE
(DBID=2761439438)
RMAN> backup database;
Starting backup at 26-MAY-15
using target database control file instead
of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=25 devtype=DISK
channel ORA_DISK_1: starting full datafile
backupset
channel ORA_DISK_1: specifying datafile(s)
in backupset
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE
STACK FOLLOWS ===============
RMAN-00571:
===========================================================
RMAN-03009: failure of backup command on
ORA_DISK_1 channel at 05/26/2015 14:52:51
ORA-19602: cannot backup or copy active
file in NOARCHIVELOG mode
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE BACKUP OPTIMIZATION OFF; #
default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; #
default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR
DEVICE TYPE DISK TO 'D:\DATA_XE\RMAN%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1
BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE
TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR
DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK
FORMAT
'D:\DATA_XE\RMAN\XE_%U/%d/%t/%s/%p';
CONFIGURE MAXSETSIZE TO UNLIMITED; #
default
CONFIGURE ENCRYPTION FOR DATABASE OFF; #
default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; #
default
CONFIGURE ARCHIVELOG DELETION POLICY TO
NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'D:\XE\APP\ORACLE\PRODUCT\10.2.0\SERVER\DATABASE\SNCFXE.ORA'; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK
FORMAT 'D:\DATA_XE\RMAN\XE_%U';
CONFIGURE
CHANNEL 1 DEVICE TYPE DISK FORMAT
'D:\DATA_XE\RMANXE_%U%d%t%s%p';
FORMAT:
The most common substitution variable is %U, which
generates a unique name. Others include %d for the
DB_NAME, %t for the backup set time stamp, %s for the
backup set number, and %p for the backup piece number.
TAG:
Specifies a user-defined string as a label for the backup.
If you do not specify a tag , then RMAN assigns a default tag with the date and
time. Tags are always stored in the RMAN repository in uppercase.
RMAN> backup
database TAG 'XE_DB_BACKUP';
Starting backup at 26-MAY-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full data file backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00003 name=D:\XE\ORADATA\XE\SYSAUX.DBF
input datafile fno=00001 name=D:\XE\ORADATA\XE\SYSTEM.DBF
input datafile fno=00005 name=D:\DATA_XE\DF\TEST.01.DBF
input datafile fno=00004 name=D:\XE\ORADATA\XE\USERS.DBF
input datafile fno=00002 name=D:\XE\ORADATA\XE\UNDO.DBF
channel ORA_DISK_1: starting piece 1 at 26-MAY-15
channel ORA_DISK_1: finished piece 1 at 26-MAY-15
piece handle=D:\DATA_XE\RMANXE_0RQ7TOGL_1_1XE880730645271 tag=XE_DB_BACKUP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 26-MAY-15
Starting Control File and SPFILE Autobackup at 26-MAY-15
piece handle=D:\DATA_XE\RMANC-2761439438-20150526-06 comment=NONE
Finished Control File and SPFILE Autobackup at 26-MAY-15
INCREMENTAL
BACKUP:
An incremental backup is a type of backup that only copies
files that have changed since the last backup but an incremental backup at
level 0 is identical in content to a full backup. A level 1 incremental backup
contains only blocks changed after a previous incremental backup.
If we specify BACKUP INCREMENTAL, then RMAN creates an
incremental backup of a database. Incremental backups capture block-level
changes to a database made after a previous incremental backup. Incremental
backups are generally smaller and faster to make than full database backups.
Recovery with incremental backups is faster than using redo logs alone.
NOTE: If no level 0 backup exists in either the current
or parent database incarnation when you run a level 1 backup, then RMAN makes a
level 0 backup automatically.
NOTE: You cannot make incremental backups when a NOARCHIVELOG
database is open, although you can make incremental backups when the database
is mounted after a consistent shutdown.
RMAN> backup incremental level 0 database; -
Consider as a full database backup.
Please below marked in RED
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21 Incr 0 670.46M DISK 00:00:57 26-MAY-15
BP Key: 21 Status: AVAILABLE Compressed: NO Tag: TAG20150526T202511
Piece Name: D:\DATA_XE\RMANXE_0TQ7UA58_1_1XE880748712291
List of Datafiles in backup set 21
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 0 Incr 536121 26-MAY-15 D:\XE\ORADATA\XE\SYSTEM.DBF
Please below marked in RED
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21 Incr 0 670.46M DISK 00:00:57 26-MAY-15
BP Key: 21 Status: AVAILABLE Compressed: NO Tag: TAG20150526T202511
Piece Name: D:\DATA_XE\RMANXE_0TQ7UA58_1_1XE880748712291
List of Datafiles in backup set 21
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 0 Incr 536121 26-MAY-15 D:\XE\ORADATA\XE\SYSTEM.DBF
RMAN> backup incremental level 1 database;
- Here it will back up only the modified blocks
after level 0 backup.
Please below marked in RED:
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
23 Incr 1 328.00K DISK 00:00:20 26-MAY-15
BP Key: 23 Status: AVAILABLE Compressed: NO Tag: TAG20150526T204006
Piece Name: D:\DATA_XE\RMANXE_0VQ7UB17_1_1XE880749607311
List of Datafiles in backup set 23
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 1 Incr 536516 26-MAY-15 D:\XE\ORADATA\XE\SYSTEM.DBF
RMAN>BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE; - A level 1 backup can be a cumulative incremental
backup, which includes all blocks changed since the most recent level 0 backup
NOTE: When restoring
incremental backups, RMAN uses the level 0 backup as the starting point, then
updates changed blocks based on level 1 backups where possible to avoid reapplying
changes from redo one at a time. Recovering with incremental backups requires
no additional effort on your part. If incremental backups are available, then
RMAN uses them during recovery.
Validating Database Files and Backups:
The VALIDATE command to confirm that all database files exist,
are in their correct location, and are free of physical corruption. The CHECK
LOGICAL option also checks for logical block corruption.
Following commands to validate all database files and archived redo log
files for physical and logical corruption:
RMAN>BACKUP
VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL;
Validate backup sets, as shown in the following example:
RMAN>
VALIDATE BACKUPSET 21;
using channel ORA_DISK_1
channel ORA_DISK_1: starting validation of datafile backupset
channel ORA_DISK_1: reading from backup piece D:\DATA_XE\RMANXE_0TQ7UA58_1_1XE880748712291
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\DATA_XE\RMANXE_0TQ7UA58_1_1XE880748712291
tag=TAG20150526T202511
channel ORA_DISK_1: validation complete, elapsed time: 00:00:09
Reporting
on RMAN Operations:
Run the LIST BACKUP and LIST COPY commands to display information about
backups and data file copies listed in the repository.
RMAN>
LIST BACKUP OF DATABASE BY BACKUP; - Organizes the output by backup
set. This is the default mode of presentation.
RMAN>
LIST BACKUP BY FILE; - List the backup according to which file was
backed up.
RMAN>
LIST BACKUP SUMMARY; - Displays summary output.
Additional LIST Options:
Lists backups that are
recorded in the RMAN repository but that were not present at the expected
location on disk or tape during the last CROSSCHECK command. An expired
backup may have been deleted by an operating system utility.
RMAN>
LIST EXPIRED COPY;
Lists data file backups or copies that have status AVAILABLE in the
RMAN repository and that can be restored and recovered.
RMAN>
LIST BACKUP RECOVERABLE;
Can display specific objects, as
in the following examples:
RMAN>
LIST BACKUP OF DATABASE;
RMAN>
LIST COPY OF DATAFILE 1, 2;
RMAN>
LIST BACKUP OF ARCHIVELOG FROM SEQUENCE 10;
RMAN>
LIST BACKUPSET OF DATAFILE 1;
RMAN>
REPORT SCHEMA;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace
RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 340 SYSTEM *** D:\XE\ORADATA\XE\SYSTEM.DBF
2 90 UNDO *** D:\XE\ORADATA\XE\UNDO.DBF
3 450 SYSAUX *** D:\XE\ORADATA\XE\SYSAUX.DBF
4 100 USERS *** D:\XE\ORADATA\XE\USERS.DBF
5 200 TEST *** D:\DATA_XE\DF\TEST.01.DBF
List of Temporary Files
=======================
File Size(MB) Tablespace
Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 D:\XE\ORADATA\XE\TEMP.DBF
RMAN>
REPORT OBSOLETE;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 22 26-MAY-15
Backup Piece 22
26-MAY-15
D:\DATA_XE\RMANC-2761439438-20150526-07
RMAN>
REPORT UNRECOVERABLE;
Report of files that need backup due to unrecoverable operations
File Type of Backup Required Name
---- ----------------------- -----------------------------------
RMAN> REPORT NEED BACKUP DATABASE;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
1 1 D:\XE\ORADATA\XE\SYSTEM.DBF
2 1 D:\XE\ORADATA\XE\UNDO.DBF
3 1 D:\XE\ORADATA\XE\SYSAUX.DBF
4 1 D:\XE\ORADATA\XE\USERS.DBF
5 1 D:\DATA_XE\DF\TEST.01.DBF
Comments
Post a Comment