Validate command --- rman for backup and reply verification, validate --- rman
As an oracle backup and recovery tool, rman provides us with powerful functions, including physical and logical detection of data files and validity detection of backup files.
First, let's take a look at rman's detection of data files. We know that when rman backs up data, it reads the data into the read cache, and then writes the data from the read cache to the write cache and finally writes the data to the database. During the process from read cache to write cache, rman performs physical consistency detection (db_block_checksum is not true) and logical consistency detection (the check logical option is used ). For example:
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
Sometimes, we just want to verify whether the data file can be backed up, rather than the real backup, we can use the validate Command, as shown in
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
Note: No physical damaged block of test01.dbf is found here,
In my opinion, rman only reads data files into the read cache, but does not perform the following operations. That is to say, it has limited functions for detecting physical blocks. However, we can use it to detect the readability and location of physical files.
The descriptions in the official documentation are as follows:
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.
Use the validate command to verify the validity of the Backup set. Official documentation:
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
Example:
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
The validate command verifies the physical validity of the backup, not the physical validity of the data block stored in the backup.
RESTORE... PREVIEW
This command is used to preview the restore command. You can add preview to any resotre command to restore the preview. This command only reads the required backup metadata from the data dictionary without file verification.
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: simulates the recover process in the memory and does not perform a real recovery. You can use this command to detect problems in the recovery. Note that the simulated recovery and normal recovery may encounter different problems.
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 resume uption, trial recovery and normal recovery can encounter different errors.
Back up the log file and delete all the backup log files, but the rman command has an error.
You have not specified the backup path or your default path is incorrect. RMAN is not the top point for you to check a few commands.
Oracle RMAN backup and recovery steps
1. Switch the server archive mode. skip this step if the archive mode is already used:
% Sqlplus/nolog (start sqlplus)
SQL> conn/as sysdba (connect to the database as DBA)
SQL> shutdown immediate; (close the database immediately)
SQL> startup mount (start the instance and load the database, but do not open it)
SQL> alter database archivelog; (change the database to archive Mode)
SQL> alter database open; (open the database)
SQL> alter system archive log start; (enable automatic archiving)
SQL> exit (exit) 2. Connection:
Rman target = sys/comeon @ orcl; (start recovery manager) 3. Basic settings:
RMAN> configure default device type to disk; (set the default backup device to disk)
RMAN> configure device type disk parallelism 2; (sets the parallel backup level and number of channels)
RMAN> configure channel 1 device type disk fromat '/backup1/backup _ % U'; (sets the backup file format, only applicable to disk devices)
RMAN> configure channel 2 device type disk fromat '/backup2/backup _ % U'; (sets the backup file format, only applicable to disk devices)
RMAN> configure controlfile autobackup on; (enable automatic backup of control file and server parameter file)
RMAN> configure controlfile autobackup format for device type disk to '/backup1/ctl _ % F'; (sets the file format for automatic backup of control files and server parameter files) 4. view all settings:
RMAN> show all 5. view the database solution report:
RMAN> report schema; 6. Full backup:
RMAN> backup database plus archivelog delete input; (back up the full database and control files, server parameter files and all archived redo logs, and delete the old archive logs) 7. Back up the tablespace:
RMAN> backup tablespace system plus archivelog delete input; (backup the specified tablespace and archived redo logs, and delete the old archived logs) 8. Back up the archived logs:
RMAN> backup archivelog all delete input; 9. copy the data file:
RMAN> copy datafile 1 to '/oracle/dbs/system. copy'; 10. View backups and copy files:
RMAN> list backup; 11. Verify the backup:
RMAN> v ...... remaining full text>