Then create the recovery catalog:CONNECT sys/password@w2k1 AS SYSDBA -- Create tablepsace to hold repository CREATE TABLESPACE "RMAN" DATAFILE 'C:ORACLEORADATAW2K1RMAN01.DBF' SIZE 6208K REUSE AUTOEXTEND ON NEXT 64K MAXSIZE 32767M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; -- Create rman schema owner CREATE USER rman IDENTIFIED BY rman TEMPORARY TABLESPACE temp DEFAULT TABLESPACE rman QUOTA UNLIMITED ON rman; GRANT connect, resource, recovery_catalog_owner TO rman;
C:>rman catalog=rman/rman@w2k1 Recovery Manager: Release 9.2.0.1.0 - Production Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. connected to recovery catalog database recovery catalog is not installed RMAN> create catalog tablespace "RMAN"; recovery catalog created RMAN> exit Recovery Manager complete. C:>
Existing user-created backups can be added to the catalog using:C:>rman catalog=rman/rman@w2k1 target=sys/password@w2k2 Recovery Manager: Release 9.2.0.1.0 - Production Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. connected to target database: W2K2 (DBID=1371963417) connected to recovery catalog database RMAN> register database; database registered in recovery catalog starting full resync of recovery catalog full resync complete RMAN>
RMAN> catalog datafilecopy 'C:OracleOradataTSH1.dbf'; RMAN> catalog archivelog 'log1', 'log2', 'log3', ... 'logN';
Next we perform a complete database backup using a single command:RMAN> configure retention policy to recovery window of 7 days; RMAN> configure default device type to disk; RMAN> configure controlfile autobackup on; RMAN> configure channel device type disk format 'C:OracleAdminW2K2Backup%d_DB_%u_%s_%p';
RMAN> run {
2> backup database plus archivelog;
3> delete noprompt obsolete;
4> }The recovery catalog should be resyncronized on a regular basis so that changes to the database structure and presence of new archive logs is recorded. Some commands perform partial and full resyncs implicitly, but if you are in doubt you can perform a full resync using the follwoing command:RMAN> resync catalog;
run {
shutdown immediate; # use abort if this fails
startup mount;
restore database;
recover database;
alter database open;
}This will result in all datafiles being restored then recovered. RMAN will apply archive logs as necessary until the recovery is complete. At that point the database is opened. If the tempfiles are still present you can issue a command like like the following for each of them:sql "ALTER TABLESPACE temp ADD
TEMPFILE ''C:OracleoradataW2K2temp01.dbf''
REUSE";If the tempfiles are missing they must be recreated as follows:sql "ALTER TABLESPACE temp ADD
TEMPFILE ''C:OracleoradataW2K2temp01.dbf''
SIZE 100M
AUTOEXTEND ON NEXT 64K";run {
sql 'ALTER TABLESPACE users OFFLINE IMMEDIATE';
restore tablespace users;
recover tablespace users;
sql 'ALTER TABLESPACE users ONLINE';
}run {
shutdown immediate;
startup mount;
set until time 'Nov 15 2000 09:00:00';
# set until scn 1000; # alternatively, you can specify SCN
# set until sequence 9923; # alternatively, you can specify log sequence number
restore database;
recover database;
alter database open resetlogs;
}The incomplete recovery requires the database to be opened using the RESETLOGS option.Once in RMAN do the following:C:>rman catalog=rman/rman@w2k1 target=sys/password@w2k2
From SQL*Plus as SYS get the last archived SCN using:startup nomount; restore controlfile; alter database mount;
SQL> SELECT archivelog_change#-1 FROM v$database;
ARCHIVELOG_CHANGE#-1
--------------------
1048438
1 row selected.
SQL>Back in RMAN do the following:run {
set until scn 1048438;
restore database;
recover database;
alter database open resetlogs;
}If the "until scn" were not set the following type of error would be produced once a redo log was referenced:With the database open all missing tempfiles must be replaced:RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 03/18/2003 09:33:19 RMAN-06045: media recovery requesting unknown log: thread 1 scn 1048439
sql "ALTER TABLESPACE temp ADD
TEMPFILE ''C:OracleoradataW2K2temp01.dbf''
SIZE 100M
AUTOEXTEND ON NEXT 64K";Once the database is fully recovered a new backup should be perfomed.list incarnation; reset database to incarnation x;
It's worth spending some time looking at all the reporting capabilities whilst deciding whether you should switch from shell scripting to RMAN. It might just influence your decision.# Show all backup details list backup; # Show items that beed 7 days worth of # archivelogs to recover completely report need backup days = 7 database; # Show/Delete items not needed for recovery report obsolete; delete obsolete; # Show/Delete items not needed for point-in-time # recovery within the last week report obsolete recovery window of 7 days; delete obsolete recovery window of 7 days; # Show/Delete items with more than 2 newer copies available report obsolete redundancy = 2 device type disk; delete obsolete redundancy = 2 device type disk; # Show datafiles that connot currently be recovered report unrecoverable database; report unrecoverable tablespace 'USERS';
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/330796/viewspace-872095/ ,如需转载,请注明出处,否则将追究法律责任。