How to archive log files when using RMAN backup
I went to a customer yesterday to deploy RMAN backup. when I ran the shell script, I was prompted that I could not find the archive log, because the customer only performed EXPDP logical export backup for the database before, in addition, the archive of the previous day is automatically deleted every day, and the size of each archive is about MB, because the disk space is insufficient.
In my script, the backup database format 'xxx' plus archivelog format 'xxx' is used. When executing the RMAN script, because archive logs are backed up before the database is backed up, in the output log of the script, the system prompts that the archive log of 35xxx cannot be found, currently, the oldest physical archive log has reached 36xxx. That is to say, more than 1000 logs have been physically deleted by OS scripts, it was verified that the number of archives generated every day was about 40, so about MB of archived logs a day was entered into RMAN to perform crosscheck on archived logs, more than 7000 archive logs are found to be "failed" (physically deleted). The command is: RMAN> crosscheck archivelog all; then archive These expired logs, delete RMAN> delete noprompt expired archivelog all from the control file information; then run the script again, and the backup will be smooth. Archive logs will be backed up first, and then the database will be backed up, finally, the control file and spfile
-------------------------------------- Recommended reading --------------------------------------
RMAN: Configure an archive log deletion policy
Basic Oracle tutorial-copying a database through RMAN
Reference for RMAN backup policy formulation
RMAN backup learning notes
Oracle Database Backup encryption RMAN Encryption
-------------------------------------- Split line --------------------------------------
After I came back, I did another test and found that even if the archived log file was not failted, the backup still went smoothly. Let's take a look at my own test: 1. first, move the archived log to another directory (the simulated log is physically deleted) [oracle @ ora10g ~] $ Cd $ ORACLE_BASE/flash_recovery_area/ORA10G/archivelog [oracle @ ora10g archivelog] $ lltotal 8drwxr-x --- 2 oracle oinstall 4096 Sep 24 2014_09_24
[Oracle @ ora10g archivelog] $ mv 2014_09_24/*. [oracle @ ora10g archivelog] $ lltotal 6636drwxr-x --- 2 oracle oinstall 4096 Sep 24 2014_09_24
-Rw-r ----- 1 oracle oinstall 597504 Sep 24 o1_mf_1_10_b24ho39f _. arc-rw-r ----- 1 oracle oinstall 5473792 Sep 24 o1_mf_1_3_b24gz52r _. arc-rw-r ----- 1 oracle oinstall 373248 Sep 24 o1_mf_1_4_b24gz81d _. arc-rw-r ----- 1 oracle oinstall 180224 Sep 24 o1_mf_1_5_b24gzbb6 _. arc-rw-r ----- 1 oracle oinstall 33792 Sep 24 o1_mf_1_6_b24gzd6y _. arc-rw-r ----- 1 oracle oinstall 26624 Sep 24 o1_mf_1_7_b24gzky8 _. arc-rw-r ----- 1 oracle oinstall 1536 Sep 24 o1_mf_1_8_b24gzqnt _. arc-rw-r ----- 1 oracle oinstall 57344 Sep 24 o1_mf_00009_b24hjflc _. there are a total of 8 archive log files "deleted" in arc. 2. go to RMAN and perform cross-validation on archived logs [oracle @ ora10g archivelog] $ exitexithost command complete RMAN> crosscheck archivelog all; released channel: ORA_DISK_1allocated channel: ORA_DISK_1channel ORA_DISK_1: sid = 145 devtype = DISKvalidation failed for archived log
Archive log filename =/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/o1_mf_1_3_b24gz52r _. arc recid = 208 stamp = 859116904 validation failed for archived logarchive log filename =/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/validation _. arc recid = 209 stamp = 859116904 validation failed for archived logarchive log filename =/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/validation _. arc recid = 210 stamp = 859116906 validation failed for archived logarchive log filename =/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/validation _. arc recid = 211 stamp = 859116908 validation failed for archived logarchive log filename =/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/validation _. arc recid = 212 stamp = 859116914 validation failed for archived logarchive log filename =/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/validation _. arc recid = 213 stamp = 859116919 validation failed for archived logarchive log filename =/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/validation _. arc recid = 214 stamp = 859117453 validation failed for archived logarchive log filename =/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/validation _. arc recid = 215 stamp = 859117603 Crosschecked 8 objects 3. without deleting the expired archive, directly run the RMAN backup script. This time, no error is reported and the xxx archive cannot be found. Instead, the backup is completed directly and the backup set 297 is generated, different from what customers encounter
-- After the backup is complete, view the generated backup set
[Oracle @ ora10g ~] $ Cd/u01/orabackup/backupsets/[oracle @ ora10g backupsets] $ ll-lrthtotal 1.6g.....other backup sets (omitted) -rw-r ----- 1 oracle oinstall 606 K Sep 24 ora10g-4175411955_20140924_859118422_297.arc-rw-r ----- 1 oracle oinstall 166 M Sep 24 ora10g-4175411955_20140924_859118425_298.db-rw-r ----- 1 oracle oinstall 610 K Sep 24 ora10g-4175411955_20140924_859118562_299.arc-rw-r ----- 1 oracle oinstall 7.3 M sep 24 ora10g-c-4175411955-20140924-01.ctl can see, after all the backups are completed, two log backup sets (arc), one Database Backup set (db), and the control file backup set (ctl) are generated. Note the following details, because I have written the % s parameter in the script, we can find the order of RMAN backup from the time and sequence generated by the backup set above: 1. back up the archive log files of existing databases that can be backed up. back up the database 3. switch the log to back up the archived logs after the full database backup is completed (even if you do not use RMAN> SQL "alter system archive log current"; to manually switch) 4. for control file backup (including spfile, generated in the same backup set), we can take a look at the detailed log output to have a deeper understanding of this sequence: starting backup at 24-914current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting compressed archive log backupsetchannel ORA_DISK_1: specifying archive log (s) in backup setinput archive log thread = 1 sequence = 11 recid = 216 stamp = 859118422 channel ORA_DISK_1: starting piece 1 at 24-914channel ORA_DISK_1: finished piece 1 at 24-914 piece handle =/u01/orabackup/backupsets/ora10g-4175411955_20140924_859118422_297.arc tag = ARC_BAK comment = NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00: 00: 03 Finished backup at 24-914 Starting backup at 24-914using channel ORA_DISK_1channel ORA_DISK_1: starting compressed full datafile backupsetchannel ORA_DISK_1: specifying datafile (s) in backupsetinput datafile fno = 00001 name =/u01/app/oracle/oradata/ora10g/system01.dbfinput datafile fno = 00003 name =/u01/app/oracle/oradata/ora10g/export datafile fno = 00002 name =/u01/app/oracle/oradata/ora10g/undotbs01.dbfinput datafile fno = 00005 name =/u01/app/oracle/oradata/ora10g/example01.dbfinput datafile fno = 00006 name /u01/app/oracle/oradata/ora10g/zlm01.dbfinput datafile fno = 00004 name =/u01/app/oracle/oradata/ora10g/users01.dbfchannel ORA_DISK_1: starting piece 1 at 24-914channel ORA_DISK_1: finished piece 1 at 24-914 piece handle =/u01/orabackup/backupsets/ora10g-4175411955_20140924_859118425_298.db tag = login comment = NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00: 02: 16 Finished backup at 24-914 Starting backup at 24-914current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting compressed archive log backupsetchannel ORA_DISK_1: specifying archive log (s) in backup setinput archive log thread = 1 sequence = 12 recid = 217 stamp = 859118561 channel ORA_DISK_1: starting piece 1 at 24-914channel ORA_DISK_1: finished piece 1 at 24-914 piece handle =/u01/orabackup/backupsets/ora10g-4175411955_20140924_859118562_299.arc tag = ARC_BAK comment = NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00: 00: 02 Finished backup at 24-914 Starting Control File and SPFILE Autobackup at 24-914 piece handle =/u01/orabackup/backupsets/ora10g-c-4175411955-20140924-01.ctl comment = NONEFinished Control File and SPFILE Autobackup at 24-914
For more details, please continue to read the highlights on the next page: