validate命令---rman進行備份和回複的驗證,validate---rman

來源:互聯網
上載者:User

validate命令---rman進行備份和回複的驗證,validate---rman

rman作為oracle備份與恢複工具,為我們提供了強大的功能,其中包括對資料檔案的物理和邏輯檢測以及備份檔案的有效性檢測。

首先,來看一下rman對資料檔案的檢測。我們知道,rman在備份資料時,會將資料讀入讀緩衝,然會將資料從讀緩衝寫入寫緩衝並最終寫入資料庫。在從讀緩衝到寫緩衝的過程中,rman會進行物理一致性的檢測(db_block_checksum未true)和邏輯一致性檢測(使用了check logical選項)。例如:

SQL> show parameter db_blockNAME     TYPE VALUE------------------------------------ ----------- ------------------------------db_block_buffers     integer 0db_block_checking     string FALSEdb_block_checksum     string TRUEdb_block_size     integer 8192SQL> 

RMAN> backup tablespace test1;Starting backup at 2014-11-06 15:12:49using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetinput datafile fno=00005 name=/home/app/oraten/oradata/oraten/test01.dbfchannel ORA_DISK_1: starting piece 1 at 2014-11-06 15:12:50RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03009: failure of backup command on ORA_DISK_1 channel at 11/06/2014 15:12:51ORA-19566: exceeded limit of 0 corrupt blocks for file /home/app/oraten/oradata/oraten/test01.dbf

有時,我們僅僅希望驗證一下資料檔案是否可以備份,而不想進行真正的備份,這是我們就可以使用validate命令了,如

RMAN> backup validate database;Starting backup at 2014-11-06 15:14:23using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetinput datafile fno=00001 name=/home/app/oraten/oradata/oraten/system01.dbfinput datafile fno=00003 name=/home/app/oraten/oradata/oraten/sysaux01.dbfinput datafile fno=00002 name=/home/app/oraten/oradata/oraten/undotbs01.dbfinput datafile fno=00005 name=/home/app/oraten/oradata/oraten/test01.dbfinput datafile fno=00004 name=/home/app/oraten/oradata/oraten/users01.dbfchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetincluding current control file in backupsetincluding current SPFILE in backupsetchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:03Finished backup at 2014-11-06 15:14:27
注意,這裡並沒有發現test01.dbf的物理損壞塊, 個人認為,rman僅僅只是將資料檔案讀入了讀緩衝,而沒有進行下面的操作,也就是說對於物理塊的檢測其功能是有限的,但,我們可以用其來檢測物理檔案的可讀性和位置等。

下面是官方文檔中的描述:

VALIDATE Causes RMAN to scan the specified files and verify their contents, testing whether this file can be backed up. RMAN creates no output files. Use this 
command periodically to check for physical and logical errors in database files.

使用validate命令可以驗證備份組的有效性,官方文檔:

To examine a backup set and report whether it can be restored. RMAN scans all of the backup pieces in the specified backup sets and looks at the checksums to verify that 
the contents are intact so that the backup can be successfully restored if necessary. Use this command when you suspect that one or more backup pieces in a backup set 
are missing or have been damaged. Use VALIDATE BACKUPSET to specify which backups to test; use the VALIDATE option of the RESTORE command to let RMAN 
choose which backups to validate. For validating image copies, run RESTORE VALIDATE FROM DATAFILECOPY

樣本:

RMAN> run {2> set maxcorrupt for datafile 5 to 2;3> backup database;}
RMAN> validate backupset 84;using channel ORA_DISK_1channel ORA_DISK_1: starting validation of datafile backupsetchannel ORA_DISK_1: reading from backup piece /home/app/oraten/flash_recovery_area/ORATEN/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T152820_b5p8ro7v_.bkpchannel ORA_DISK_1: restored backup piece 1piece handle=/home/app/oraten/flash_recovery_area/ORATEN/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T152820_b5p8ro7v_.bkp tag=TAG20141106T152820channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
validate命令驗證的是備份的物理有效性而不是儲存在備份中的資料區塊的物理有效性。


RESTORE ... PREVIEW

該命令進行restore命令的預演,可以在任何resotre命令後加上preview來進行還原預演,這個命令只是從資料字典讀出需要的備份的中繼資料,不進行檔案的驗證。
You can apply RESTORE ... PREVIEW to any RESTORE operation to create a detailed list of every backup to be used in the requested RESTORE operation, as well as the necessary target SCN for recovery after the RESTORE operation is complete. This command accesses the RMAN repository to query the backup metadata, but does not actually read the backup files to ensure that they can be restored.

RMAN> restore database preview;Starting restore at 2014-11-06 15:44:28using channel ORA_DISK_1List of Backup Sets===================BS Key  Type LV Size       Device Type Elapsed Time Completion Time    ------- ---- -- ---------- ----------- ------------ -------------------84      Full    551.76M    DISK        00:00:18     2014-11-06 15:28:24        BP Key: 52   Status: AVAILABLE  Compressed: NO  Tag: TAG20141106T152820        Piece Name: /home/app/oraten/flash_recovery_area/ORATEN/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T152820_b5p8ro7v_.bkp  List of Datafiles in backup set 84  File LV Type Ckp SCN    Ckp Time            Name  ---- -- ---- ---------- ------------------- ----  1       Full 922948     2014-11-06 15:28:20 /home/app/oraten/oradata/oraten/system01.dbf  2       Full 922948     2014-11-06 15:28:20 /home/app/oraten/oradata/oraten/undotbs01.dbf  3       Full 922948     2014-11-06 15:28:20 /home/app/oraten/oradata/oraten/sysaux01.dbf  4       Full 922948     2014-11-06 15:28:20 /home/app/oraten/oradata/oraten/users01.dbf  5       Full 922948     2014-11-06 15:28:20 /home/app/oraten/oradata/oraten/test01.dbfarchive logs generated after SCN 922948 not found in repositoryMedia recovery start SCN is 922948Recovery must be done beyond SCN 922948 to clear data files fuzzinessFinished restore at 2014-11-06 15:44:28


RECOVER ... TEST:在記憶體中類比recover過程,並不進行真正的recovery,可以用該命令來提起發現recovery中的問題。注意,類比的recovery和正常recovery可能會遇到不同的問題。
A simulated recovery initiated with the RECOVER ... TEST command in RMAN or SQL*Plus. A trial recovery applies redo in a way similar to normal media recovery, but it never writes its changes to disk and it always rolls back its changes. Trial recovery occurs only in memory.
Trial recovery lets you foresee what problems might occur if you were to continue with normal recovery. For problems caused by ongoing memory corruption, trial recovery and normal recovery can encounter different errors.


備份記錄檔,並將備份的記錄檔全部刪除,但是rman命令出錯了

你沒指定備份的路徑或者你預設的路徑不對。RMAN不是你查幾個命令就搞的頂的。
 
Oracle RMAN 備份及恢複步驟

1、切換伺服器歸檔模式,如果已經是歸檔模式可跳過此步:
%sqlplus /nolog (啟動sqlplus)
SQL> conn / as sysdba (以DBA身份串連資料庫)
SQL> shutdown immediate; (立即關閉資料庫)
SQL> startup mount (啟動執行個體並載入資料庫,但不開啟)
SQL> alter database archivelog; (更改資料庫為歸檔模式)
SQL> alter database open; (開啟資料庫)
SQL> alter system archive log start; (啟用自動歸檔)
SQL> exit (退出) 2、串連:
rman target=sys/comeon@orcl; (啟動復原管理員) 3、基本設定:
RMAN> configure default device type to disk; (設定預設的備份裝置為磁碟)
RMAN> configure device type disk parallelism 2; (設定備份的並行層級,通道數)
RMAN> configure channel 1 device type disk fromat '/backup1/backup_%U'; (設定備份的檔案格式,只適用於磁碟裝置)
RMAN> configure channel 2 device type disk fromat '/backup2/backup_%U'; (設定備份的檔案格式,只適用於磁碟裝置)
RMAN> configure controlfile autobackup on; (開啟控制檔案與伺服器參數檔案的自動備份)
RMAN> configure controlfile autobackup format for device type disk to '/backup1/ctl_%F'; (設定控制檔案與伺服器參數檔案自動備份的檔案格式) 4、查看所有設定:
RMAN> show all 5、查看資料庫方案報表:
RMAN> report schema; 6、備份全庫:
RMAN> backup database plus archivelog delete input; (備份全庫及控制檔案、伺服器參數檔案與所有歸檔的重做日誌,並刪除舊的歸檔日誌) 7、備份資料表空間:
RMAN> backup tablespace system plus archivelog delete input; (備份指定資料表空間及歸檔的重做日誌,並刪除舊的歸檔日誌) 8、備份歸檔日誌:
RMAN> backup archivelog all delete input; 9、複製資料檔案:
RMAN> copy datafile 1 to '/oracle/dbs/system.copy'; 10、查看備份和檔案複本:
RMAN> list backup; 11、驗證備份:
RMAN> v......餘下全文>>
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.