How to handle archived log files and RMAN log files when using rman backup

Source: Internet
Author: User

How to handle archived log files and RMAN 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 is about 40, and the archive logs generated every day is about MB.
Therefore, Start RMAN to perform crosscheck on the archive logs and find that more than 7000 archive logs are "failed" (physically deleted). The command is as follows: RMAN> crosscheck archivelog all;
Then, delete RMAN> delete noprompt expired archivelog all from the control file;
Then run the script again, and the backup will be smooth. First, the archiving log is backed up, then the database is backed up, and finally the control file and spfile are used.
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 _. arc
Eight archived log files are deleted"
2. Go to RMAN to 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. Run the RMAN backup script without deleting expired archives.This time, no error is reported and the xxx archive cannot be found. Instead, the backup is completed directly and 297 backup set is generated, which is different from the situation encountered by the customer.
-- 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
As you can see, the backups are all completed, and two archived log backup sets (arc), one Database Backup set (db), and the control file backup set (ctl) are created ), note that 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 generated 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. backup of control files (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
Four backup sets are generated for sequential execution. However, from the log, RMAN switches archive logs after the database is backed up, but actually, this is true, because at this moment I have not switched to archive databases. In fact, after RMAN backs up the database, it backs up the archive logs after switching the logs. This is to allow as many database changes as possible to be written to the disk to facilitate future recovery using backup sets.
DML operations on databases ensure consistency by writing online redo logfile. even undo data is written into redo logs, which are called undo redo logs, undo's redo vector and redo's redo vector are merged into a redo record and written into the online redo logfile. The purpose of archiving logs is to refresh the online redo logfile, archive the content to be refreshed first. Since the redo content contains changes to the database, archive logs must be used for recover during restoration, push the database to a consistent state.
RMAN is a non-consistent backup. You can back up the database in the open state of the database. To make the database of the non-consistent backup consistent, you only need to archive the log. Then, when RMAN switches the log, it can ensure that the latest changes to the database are written to the archive log and backed up. Archive before the backup time, it is no longer needed.
Considering that backing up all archives will waste a lot of disk space, and this is not necessary, we can delete some archives before RMAN backup so that the archive backup set can be smaller, in case of insufficient disk space, you must note that you can use the following command to delete an archive:
-- Delete the archive seven days agoRMAN> delete noprompt archivelog all completed before 'sysdate-7'; or RMAN> delete noprompt archivelog until time 'sysdate-7 ';
-- Delete the archive seven hours agoRMAN> delete noprompt archivelog all completed before 'sysdate-100'; or RMAN> delete noprompt archivelog until time 'sysdate-100 ';
Note the syntax difference. The former has the all keyword, while the latter does not. It cannot be used interchangeably. Otherwise, an error is returned:
RMAN> delete noprompt archivelog all until time 'sysdate-7 ';
RMAN-00571: ========================================================== ============================== RMAN-00569: ================ error message stack follows ============================ RMAN-00571: ========================================================== ============================== RMAN-00558: error encountered while parsing input commandsRMAN-01009: syntax error: found "until": expecting one of: "backed, completed, device, like,;, tag" RMAN-01007: at line 1 column 32 file: standard input

RMAN> delete noprompt archivelog completed before 'sysdate-100 ';
RMAN-00571: ========================================================== ============================== RMAN-00569: ================ error message stack follows ============================ RMAN-00571: ========================================================== ============================== RMAN-00558: error encountered while parsing input commandsRMAN-01009: syntax error: found "completed": expecting one of: "all, double-quoted-string, from, high, integer, like, logseq, low, scn, sequence, single-quoted-string, time, until "RMAN-01007: at line 1 column 28 file: standard input
After deletion, remember to perform crosscheck and Remove invalid archive log records from the control file.
RMAN> crosscheck achivelog all; RMAN> delete noprompt expired archivelog all;

Compression features can also be reused during backup (RMAN> backup as compressed backupset ...), make the backup set smaller, but the possible side effect is that the backup and recovery time will take longer, depending on the disk space and time which is more important. In this way, our backup set is the most streamlined.




Accidentally deleted the archive log, but now the rman recovery prompt requires archiving logs, how can it be restored? Guidance

The above backup and recovery process does not need to stop the database. For different problems and different recovery steps, rman will apply all the archived logs you have backed up. Logs archived between and are automatically generated.

Which of the following is the default backup location for rman backup archiving logs?

Sys @ STARTREK> select name from v $ archived_log where rownum <2; NAME------------------------------------------------------------------------------------------C: \ APP \ FENGJUN \ FAST_RECOVERY_AREA \ STARTREK \ ARCHIVELOG \ 2013_09_28 \ O1_MF_1_5_94DY2B47 _. when ARCdba executes the preceding SQL statement, you can see where you put the archive.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.