RMAN 备份中的redo log切换

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xxzhaobb/article/details/88885204

原文地址:

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/bradv/backing-up-database.html#GUID-5A2AEEA4-CB81-421A-8C4A-805B92DBD8FA

9.7.1.2 About Online Redo Log Switching

Automatic online redo log switching is an important RMAN feature.

To make an open database backup of archived redo logs that includes the most recent online redo log, you can execute the BACKUP command with any of the following clauses:

  • PLUS ARCHIVELOG

  • ARCHIVELOG ALL

  • ARCHIVELOG FROM ...

Before beginning the backup, RMAN switches out of the current redo log group, and archives all online redo logs that have not yet been archived, up to and including the redo log group that was current when the command was issued. This feature ensures that the backup contains all redo generated before the start of the command.

An effective way of backing up archived redo logs is the BACKUP ... PLUS ARCHIVELOG command, which causes RMAN to do the following:

  1. Run the ALTER SYSTEM ARCHIVE LOG CURRENT statement.

  2. Run BACKUP ARCHIVELOG ALL . If backup optimization is enabled, then RMAN skips logs that it has already backed up to the specified device.

  3. Back up the rest of the files specified in the BACKUP command.

  4. Run the ALTER SYSTEM ARCHIVE LOG CURRENT statement.

  5. Back up any remaining archived logs generated during the backup. If backup optimization is not enabled, then RMAN backs up the logs generated in Step 1 plus all the logs generated during the backup.

The preceding steps guarantee that data file backups taken during the command are recoverable to a consistent state. Also, unless the online redo log is archived at the end of the backup, DUPLICATE is not possible with the backup.

测试 :

-- 查看当前的归档日志

SYS@test>archive log list;
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       /data/archivelog/test
Oldest online log sequence     152
Next log sequence to archive   154
Current log sequence	       154
SYS@test>

-- 进行备份,注意备份日志中的current log archived,出现了两次,也就是在开始备份和数据文件备份完毕后,各自进行了一次日志切换,为了确保恢复的时候,数据的一致性。

RMAN> backup tablespace TBS_RMAN plus archivelog;


Starting backup at 29-MAR-19
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=147 RECID=3012 STAMP=1004008655
input archived log thread=1 sequence=148 RECID=3015 STAMP=1004090560
input archived log thread=1 sequence=149 RECID=3014 STAMP=1004090051
input archived log thread=1 sequence=150 RECID=3016 STAMP=1004174739
input archived log thread=1 sequence=151 RECID=3017 STAMP=1004175898
input archived log thread=1 sequence=152 RECID=3018 STAMP=1004176506
input archived log thread=1 sequence=153 RECID=3019 STAMP=1004176525
input archived log thread=1 sequence=154 RECID=3020 STAMP=1004176614
channel ORA_DISK_1: starting piece 1 at 29-MAR-19
channel ORA_DISK_1: finished piece 1 at 29-MAR-19
piece handle=/data/FRA/TEST/TEST/backupset/2019_03_29/o1_mf_annnn_TAG20190329T095654_g9tyv76c_.bkp tag=TAG20190329T095654 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 29-MAR-19

Starting backup at 29-MAR-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/data/test/tbs_rman01.dbf
channel ORA_DISK_1: starting piece 1 at 29-MAR-19
channel ORA_DISK_1: finished piece 1 at 29-MAR-19
piece handle=/data/FRA/TEST/TEST/backupset/2019_03_29/o1_mf_nnndf_TAG20190329T095710_g9tyvq3z_.bkp tag=TAG20190329T095710 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-MAR-19

Starting backup at 29-MAR-19
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=155 RECID=3021 STAMP=1004176635
channel ORA_DISK_1: starting piece 1 at 29-MAR-19
channel ORA_DISK_1: finished piece 1 at 29-MAR-19
piece handle=/data/FRA/TEST/TEST/backupset/2019_03_29/o1_mf_annnn_TAG20190329T095715_g9tyvw1k_.bkp tag=TAG20190329T095715 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-MAR-19

Starting Control File and SPFILE Autobackup at 29-MAR-19
piece handle=/data/FRA/TEST/TEST/autobackup/2019_03_29/o1_mf_s_1004176637_g9tyvz6x_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 29-MAR-19

-- 查看alert log ,发现切了2次日志

2019-03-29T09:56:53.322933+08:00
ALTER SYSTEM ARCHIVE LOG
2019-03-29T09:56:53.356898+08:00
Thread 1 cannot allocate new log, sequence 155
Checkpoint not complete
  Current log# 11 seq# 154 mem# 0: /data/test/redo01.log
2019-03-29T09:56:53.887149+08:00
Thread 1 advanced to log sequence 155 (LGWR switch)
  Current log# 12 seq# 155 mem# 0: /data/test/redo02.log
2019-03-29T09:56:54.054620+08:00
Archived Log entry 3020 added for T-1.S-154 ID 0x889cfa19 LAD:1
2019-03-29T09:57:12.209298+08:00
ALTER SYSTEM ARCHIVE LOG
2019-03-29T09:57:12.233147+08:00
Thread 1 cannot allocate new log, sequence 156
Checkpoint not complete
  Current log# 12 seq# 155 mem# 0: /data/test/redo02.log
2019-03-29T09:57:15.069096+08:00
Thread 1 advanced to log sequence 156 (LGWR switch)
  Current log# 13 seq# 156 mem# 0: /data/test/redo03.log
2019-03-29T09:57:15.287434+08:00
Archived Log entry 3021 added for T-1.S-155 ID 0x889cfa19 LAD:1
2019-03-29T09:57:17.632666+08:00
Starting control autobackup

2019-03-29T09:57:20.237117+08:00
Control autobackup written to DISK device

handle '/data/FRA/TEST/TEST/autobackup/2019_03_29/o1_mf_s_1004176637_g9tyvz6x_.bkp'

-- 再次查看归档日志 ,可以看出切换了2次 。

SYS@test>archive log list;
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       /data/archivelog/test
Oldest online log sequence     152
Next log sequence to archive   154
Current log sequence	       154
SYS@test>
SYS@test>archive log list
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       /data/archivelog/test
Oldest online log sequence     154
Next log sequence to archive   156
Current log sequence	       156
SYS@test>

END 。

猜你喜欢

转载自blog.csdn.net/xxzhaobb/article/details/88885204