Skip to content
Advertisements

RMAN 2.2 Connecting to RMAN and BASIC Backup

To connect to RMAN, you need to establish the following

  • OS Environement Variables.
  • Access to a privileged OS account or schema with sysdba privilege.

You can connect to RMAN either the OS command line interface or through EM.

The following examples assumes you have on to a UNIX and Windows server using the Oracle account .

$ rman target / on Unix.

cmd>rman target /   on Windows.

You must connect to RMAN with either a user that is OS authenticated or a username /pasword that is in the password file.

 While connected as  RMAN, you can startup and shutdown your target database.

C:\Documents and Settings\AZAR>set oracle_sid=riyadh

C:\Documents and Settings\AZAR>rman target /

Recovery Manager: Release 10.2.0.1.0 – Production on Sun Dec 20 11:56:33 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database (not started)

RMAN> startup

Oracle instance started
database mounted
database opened

Total System Global Area     247463936 bytes

Fixed Size                     1248332 bytes
Variable Size                 79692724 bytes
Database Buffers             159383552 bytes
Redo Buffers                   7139328 bytes

RMAN> shutdown immediate

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN>exit

Backup & Restore Database

$rman target /
RMAN messages displaying information about which files are being backed up and wo which file and location.

RMAN> backup database;

Starting backup at 20-DEC-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=139 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYSTEM01.D
BF
input datafile fno=00003 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYSAUX01.D
BF
input datafile fno=00002 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\UNDOTBS01.
DBF
input datafile fno=00004 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\USERS01.DB
F
channel ORA_DISK_1: starting piece 1 at 20-DEC-09
channel ORA_DISK_1: finished piece 1 at 20-DEC-09
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\BACKUPSET\2009_
12_20\O1_MF_NNNDF_TAG20091220T123746_5LVW3H3F_.BKP tag=TAG20091220T123746 commen
t=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:18
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 20-DEC-09
channel ORA_DISK_1: finished piece 1 at 20-DEC-09
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\BACKUPSET\2009_
12_20\O1_MF_NCSNF_TAG20091220T123746_5LVW5VJ3_.BKP tag=TAG20091220T123746 commen
t=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:05
Finished backup at 20-DEC-09

To display information about your backup, use the list backup commands.

RMAN> list backup;
List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
1       Full    517.96M    DISK        00:01:09     20-DEC-09
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20091220T123746
        Piece Name: D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\BACKUPSE
T\2009_12_20\O1_MF_NNNDF_TAG20091220T123746_5LVW3H3F_.BKP
  List of Datafiles in backup set 1
  File LV Type Ckp SCN    Ckp Time  Name
  —- — —- ———- ——— —-
  1       Full 629209     20-DEC-09 D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYST
EM01.DBF
  2       Full 629209     20-DEC-09 D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\UNDO
TBS01.DBF
  3       Full 629209     20-DEC-09 D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYSA
UX01.DBF
  4       Full 629209     20-DEC-09 D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\USER
S01.DBF

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
2       Full    6.80M      DISK        00:00:03     20-DEC-09
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20091220T123746
        Piece Name: D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\BACKUPSE
T\2009_12_20\O1_MF_NCSNF_TAG20091220T123746_5LVW5VJ3_.BKP
  Control File Included: Ckp SCN: 629239       Ckp time: 20-DEC-09
  SPFILE Included: Modification time: 20-DEC-09

RMAN>

 Oracle recommand that you set the NLS_DATE_FORMAT-DD-MON-RRRR HH24:MI:SS AT os LEVEL.

RMAN will allocate a  channel and backup to a default location on disk.

Simulating a Media Failure and  Restore and Recover database :

To simulate media failure, you can rename a datafile at the OS level on your target database server, when starts up, it reads the control file and compares the information to all the datafiles.

C:\Documents and Settings\AZAR>move D:\oracle\product\10.2.0\oradata\riyadh\US
ERS01.DBF D:\oracle\product\10.2.0\oradata\riyadh\USERS01.bk

or

Unix –> $ mv  /oracle/RIYADH/users01.dbf      /oracle/RIYADH/users.bk

C:\Documents and Settings\AZAR>rman target /

Recovery Manager: Release 10.2.0.1.0 – Production on Sun Dec 20 12:57:15 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database (not started)

RMAN> startup

Oracle instance started
database mounted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 12/20/2009 12:57:33
ORA-01157: cannot identify/lock data file 4 – see DBWR trace file
ORA-01110: data file 4: ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\USERS01.DBF’

RMAN> exit
Recovery Manager complete.

Restore and Recover :

  • Restore is the process of copying backup datafiles from the backup files.
  • Recovery is the process of applying transaction information to the datafiles to recover them to the state were in just before the failure occured.

 

C:\Documents and Settings\AZAR>rman target /

Recovery Manager: Release 10.2.0.1.0 – Production on Sun Dec 20 12:58:03 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: RIYADH (DBID=3624306176, not open)

RMAN> restore database;

Starting restore at 20-DEC-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK

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\PRODUCT\10.2.0\ORADATA\RIYADH\SYSTEM01.DBF

restoring datafile 00002 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\UNDOTBS01.DB
F
restoring datafile 00003 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYSAUX01.DBF

restoring datafile 00004 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\USERS01.DBF
channel ORA_DISK_1: reading from backup piece D:\ORACLE\PRODUCT\10.2.0\FLASH_REC
OVERY_AREA\RIYADH\BACKUPSET\2009_12_20\O1_MF_NNNDF_TAG20091220T123746_5LVW3H3F_.
BKP
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\BACKUPSET\2009_
12_20\O1_MF_NNNDF_TAG20091220T123746_5LVW3H3F_.BKP tag=TAG20091220T123746
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 20-DEC-09

RMAN> recover database;

Starting recover at 20-DEC-09
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:06

Finished recover at 20-DEC-09

RMAN> alter database open;

database opened.


 

 

Advertisements
2 Comments Post a comment
  1. Nice explanation Mohammad

    In this situation, you need to not restore the whole database, but only the missed file, using the following command:

    RMAN>restore datafile 4;

    Sure, you can restore the whole database as well, but it will consume a time

    December 21, 2009

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: