Wednesday, June 27, 2007

RMAN 1

RMAN channel: An RMAN channel represents one stream of data to a device type, and corresponds to one server session.
Most backup and recovery commands in RMAN are executed by server sessions. Each channel establishes a connection from the RMAN client to a target or auxiliary database instance by starting a server session on the instance. The server session performs the backup, restore, and recovery.
This example restores and recovers the tablespace, using configured channels and
letting RMAN choose the backups to use in restoring the tablespace and any needed
incremental backups and logs from disk or tape.
1. Connect to the target database and the recovery catalog database (if applicable),
and make sure the database is mounted or open. For example:
2. Take the tablespaces affected offline using ALTER TABLESPACE ... OFFLINE
IMMEDIATE if they are not already offline.
RMAN> SQL 'ALTER TABLESPACE users OFFLINE IMMEDIATE';
3. Restore the tablespace or datafile with the RESTORE command, and recover it with
the RECOVER command. (Use configured channels, or if desired, use a RUN block
and allocate channels to improve performance of the RESTORE and RECOVER
commands.)
RMAN> RESTORE TABLESPACE users;
RMAN> RECOVER TABLESPACE users;
4. If RMAN reported no errors during the recovery, then bring the tablespace back
online:
RMAN> SQL 'ALTER TABLESPACE users ONLINE';
At this point the process is complete.
DBID:
In situations requiring the recovery of your SPFILE or control file from autobackup,
such as disaster recovery when you have lost all database files, you will need to use
your DBID.
If you do not have a record of the DBID of your database, there are two places you can
find it without opening your database.
1) The DBID is used in forming the filename for the control file autobackup.
2) C:\Documents and Settings\sbiswas> rman target sys/arkabiswas
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1121177735)
Restore of the Control File from Control File Autobackup
If you are not using a recovery catalog, you must restore your control file from an
autobackup. If you want to restore the control file from autobackup, the database must
be in a NOMOUNT state. You must first set the DBID for your database, and then use
the RESTORE CONTROLFILE FROM AUTOBACKUP command:
RMAN> SET DBID 320066378;
RMAN> RUN {
SET CONTROLFILE AUTOBACKUP FORMAT
FOR DEVICE TYPE DISK TO 'autobackup_format';
RESTORE CONTROLFILE FROM AUTOBACKUP;
}
RMAN uses the autobackup format and DBID to determine where to hunt for the
control file autobackup. If one is found, RMAN restores the control file from that
backup to all of the control file locations listed in the CONTROL_FILES initialization
parameter.
RESTORE... PREVIEW
RESTORE DATABASE PREVIEW;
RESTORE TABLESPACE users PREVIEW;
RESTORE DATAFILE 3 PREVIEW;
RESTORE ARCHIVELOG FROM LOGSEQ 200 PREVIEW;
RESTORE ARCHIVELOG FROM TIME 'SYSDATE-7' PREVIEW;
RESTORE ARCHIVELOG FROM SCN 234546 PREVIEW;
Restoring a Control File When Using a Recovery Catalog
Restoring a lost control file from autobackup is easier when using a recovery catalog
than when using only the control file to store the RMAN repository. The recovery
catalog contains a complete record of your backups, including backups of the control
file. Therefore, you do not have to specify your DBID or control file autobackup
format.
To restore the control file, connect RMAN to the target database and the recovery
catalog, and bring the database to NOMOUNT state. Then issue the RESTORE
CONTROLFILE command with no parameters, as in this example:
% rman TARGET rman/rman CATALOG catdb/catdb
RMAN> RESTORE CONTROLFILE;
The restored control file is written to all locations listed in the CONTROL_FILES
initialization parameter.
The LIST commands allow you to view the backup information of the database, datafile, tablespaces, and controlfiles. Lets view the backups for datafile 4 and the control file.
LIST BACKUP OF DATAFILE 4;
LIST BACKUP OF CONTROLFILE;
create user catowner
identified by catpw
temporary tablespace temp
default tablespace example
quota unlimited on example
quota unlimited on temp;
grant connect, recovery_catalog_owner to catowner;
# rman target sys/arkabiswas
connected to target database: ORCL (DBID=1121177735)
RMAN> backup database include current controlfile;
Starting backup at 18-JUN-06
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=133 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 06/18/2006 01:36:
27
ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 18-JUN-06
channel ORA_DISK_1: finished piece 1 at 18-JUN-06
piece handle=D:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2006_06
_18\O1_MF_NCSNF_TAG20060618T013627_298R6574_.BKP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:09
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 06/18/2006 01:36:
27
ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
So we need to change the database.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145750508 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
RMAN> backup database
2> include current
3> controlfile;
Starting backup at 18-JUN-06
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=128 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.1.0\ORADATA\ORCL\SYSTEM01.DBF
input datafile fno=00003 name=D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\SYSAUX01.DBF
input datafile fno=00005 name=D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\EXAMPLE01.DB
F
input datafile fno=00002 name=D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\UNDOTBS01.DB
F
input datafile fno=00004 name=D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 18-JUN-06
channel ORA_DISK_1: finished piece 1 at 18-JUN-06
piece handle=D:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2006_06
_18\O1_MF_NNNDF_TAG20060618T015506_298S92RQ_.BKP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 18-JUN-06
channel ORA_DISK_1: finished piece 1 at 18-JUN-06
piece handle=D:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2006_06
_18\O1_MF_NCSNF_TAG20060618T015506_298SD4Z2_.BKP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:10
Finished backup at 18-JUN-06
[ If this is a non production database you may want to take it back to "noarchivelog" mode once you're
done with the experiment, so ...]
SQL> alter database open;
Database altered.
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145750508 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
SQL> alter database noarchivelog;
Database altered.
SQL> alter database open;
Database altered.

No comments:

Post a Comment