分类: Oracle
2008-10-10 11:45:29
Oracle 10g includes many RMAN enhancements making it a more complete tool, inlcuding:
RESTORE
and RECOVERY
commands. ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/u01/app/oracle/flash_recovery_area'; ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 2G; ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET = 1440;
RUN { RECOVER COPY OF DATABASE WITH TAG 'incr_backup' UNTIL TIME 'SYSDATE - 7'; BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_backup' DATABASE; }
RECOVER COPY...
line will not do anything until the script has been running for more than 7 days. The BACKUP INCREMENTAL
line will perform a complete backup (level 0) the first day it is run, with all subsequent backups being level 1 incremental backups. After 7 days, the RECOVER COPY...
line will start to take effect, merging all incremental backups older than 7 days into the level 0 backup, effectively moving the level 0 backup forward. The effect of this is that you will permanently have a 7 day recovery window with a 7 day old level 0 backup and 6 level 1 incremental backups. Notice that the tag must be used to identify which incremental backups apply to which image copies.RUN { BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_backup' DATABASE; RECOVER COPY OF DATABASE WITH TAG 'incr_backup'; }
SELECT status FROM v$block_change_tracking;
ALTER DATABASE
command:ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
DB_CREATE_FILE_DEST
parameter. An alternate location can be specified using the following command:ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/u01/oradata/MYSID/rman_change_track.f' REUSE;
ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;
ALTER DATABASE RENAME FILE
command. If the instance cannot be restarted you can simply disable and re-enable change tracking to create a new file. This method does result in the loss of any current change information.BACKUP
command has been extended to allow it to initiate backups of image copies in addition to backupsets. As a result the COPY
command has been deprecated in favour of this new syntax.BACKUP AS COPY DATABASE; BACKUP AS COPY TABLESPACE users; BACKUP AS COPY DATAFILE 1;
CATALOG
commands in RMAN. This allows backup files to be moved to alternate locations or manually archived to tape and brought back for restore operations. In Oracle 9i this functionality was only availabale for controlfile copies, archivelog copies and datafile copies. In addition, there are some shortcuts to allow multiple files to be cataloged using a single command. The following examples give the general idea:# Catalog specific backup piece. CATALOG BACKUPPIECE '/backup/MYSID/01dmsbj4_1_1.bcp'; # Catalog all files and the contents of directories which # begin with the pattern "/backup/MYSID/arch". CATALOG START WITH '/backup/MYSID/arch'; # Catalog all files in the current recovery area. CATALOG RECOVERY AREA NOPROMPT; # Catalog all files in the current recovery area. # This is an exact synonym of the previous command. CATALOG DB_RECOVERY_FILE_DEST NOPROMPT;
NOPROMPT
clause supresses user confirmation for all matching files.LIST BACKUP
and LIST COPY
. This view relies on the DBMS_RCVMAN.SETDATABASE
procedure being run to set the database. AUXILIARY DESTINATION
clause shown below.RECOVER TABLESPACE users UNTIL LOGSEQ 2400 THREAD 1 AUXILIARY DESTINATION '/u01/oradata/auxdest';
BACKUP TABLESPACE users; SQL "ALTER TABLESPACE users ONLINE";
CONVERT TABLESPACE
allows tablespaces to be transported between platforms with different byte orders. The mechanism for transporting a tablespaces is unchanged, this command merely converts the tablespace to allow the transport to work.V$TRANSPORTABLE_PLATFORM
view. The platform of the local server is not listed as no conversion in necessary for a matching platform.SQL> SELECT platform_name FROM v$transportable_platform; PLATFORM_NAME ------------------------------------ Solaris[tm] OE (32-bit) ... ... Microsoft Windows 64-bit for AMD 15 rows selected.
# Conversion on a Solaris source host to a Linux destincation file. CONVERT TABLESPACE my_tablespace TO PLATFORM 'Linux IA (32-bit)' FORMAT='/tmp/transport_linux/%U'; # Conversion on a Linux destination host from a Solaris source file. CONVERT DATAFILE= '/tmp/transport_solaris/my_ts_file01.dbf', '/tmp/transport_solaris/my_ts_file02.dbf' FROM PLATFORM 'Solaris[tm] OE (32-bit)' DB_FILE_NAME_CONVERT '/tmp/transport_solaris','/u01/oradata/MYDB';
FORMAT
clause. In the second example the specified datafiles are converted to the local servers platform and placed in the correct directory specified by the DB_FILE_NAME_CONVERT
clause.GLOBAL
clause prior the word SCRIPT
. Examples of it's usage are shown below:CREATE GLOBAL SCRIPT full_backup { BACKUP DATABASE PLUS ARCHIVELOG; DELETE FORCE NOPROMPT OBSOLETE; } CREATE GLOBAL SCRIPT full_backup FROM FILE 'full_backup.txt'; RUN { EXECUTE GLOBAL SCRIPT full_backup; } PRINT GLOBAL SCRIPT full_backup; LIST GLOBAL SCRIPT NAMES; LIST ALL SCRIPT NAMES; # Global and local scripts. REPLACE GLOBAL SCRIPT full_backup { BACKUP DATABASE PLUS ARCHIVELOG; DELETE FORCE NOPROMPT OBSOLETE; } REPLACE GLOBAL SCRIPT full_backup FROM FILE 'full_backup.txt'; DELETE GLOBAL SCRIPT 'full_backup';
AS COMPRESSED BACKUPSET
option of the BACKUP
command allows RMAN to perform binary compression of backupsets. The resulting backupsets do not need to be uncompressed during recovery. It is most useful in the following circumstances:CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; CONFIGURE DEFAULT DEVICE TYPE TO DISK; CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/backups/MYSID/%d_DB_%u_%s_%p';
AS COMPRESSED BACKUPSET
option can be used explicitly in the backup command:# Whole database and archivelogs. BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG; # Datafiles 1 and 5 only. BACKUP AS COMPRESSED BACKUPSET DATAFILE 1,5;
CONFIGURE
command:# Configure compression. CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET; # Whole database and archivelogs. BACKUP DATABASE PLUS ARCHIVELOG;
PREVIEW
option of the RESTORE
command allows you to identify the backups required to complete a specific restore operation. The output generated by the command is in the same format as the LIST
command. In addition the PREVIEW SUMMARY
command can be used to produce a summary report with the same format as the LIST SUMMARY
command. The following examples show how these commands are used:# Preview RESTORE DATABASE PREVIEW; RESTORE TABLESPACE users PREVIEW; # Preview Summary RESTORE DATABASE PREVIEW SUMMARY; RESTORE TABLESPACE users PREVIEW SUMMARY;
DURATION
clause of the of the BACKUP
command restricts the total time available for a backup to complete. At the end of the time window backup is interrupted with any incomplete backupsets discarded. All complete backupsets aer kept and used for future restore operations. The following examples show how it is used:BACKUP DURATION 2:00 TABLESPACE users; BACKUP DURATION 5:00 DATABASE PLUS ARCHIVELOGS;
PROXY
clause is ignored and a regular backup is performed. Using the PROXY ONLY
results in an error of a proxy backup cannot be performed.
OPEN RESTLOGS
operation is issued. As a result it is no longer necessary to create a new backup after OPEN RESTLOGS
operations.
RECOVER
, BLOCKRECOVER
, and FLASHBACK DATABASE
) RMAN automatically looks for another copy of the file. If one is not available RMAN will use older versions of the file if available. Only if a suitable copy of the file cannot be found will an error be produced. Successful failover operations result in an associated output message.