数据仓库中数据的存储周期(11gdataguard增量恢复处理GAP五)

前面介绍了18c/19c通过增量恢复处理gap的步骤,通过recover from service 命令的确很简单,那么目前11g环境中如何通过增量恢复处理dataguard产生的GAP呢。下文详细介绍步骤。

环境介绍源库和目标库均为11.2.0.4 文件系统 单机-单机

参考文档:

《11g Steps to perform for Rolling Forward a Physical Standby Database using RMAN Incremental Backup. (Doc ID 836986.1)》

实验步骤如下:

  • 1、模拟gap

1、取消应用 SQL> ALTER database recover managed standby database cancel; Database altered. 2、取消日志传输 SQL> alter system set log_archive_dest_state_2=defer; System altered. 3、主库模拟数据

数据仓库中数据的存储周期(11gdataguard增量恢复处理GAP五)(1)

4、主库删除相关归档文件 rm -fr 对应的归档日志 5、备库启动日志应用 alter database recover managed standby database disconnect; 6、确认gap

数据仓库中数据的存储周期(11gdataguard增量恢复处理GAP五)(2)

  • 2、备库检查

1、停止standby的mrp进程 SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; Database altered. 2、查看standby的最小scn值 SQL> SELECT CURRENT_SCN FROM V$DATABASE; CURRENT_SCN ----------- 1263648 SQL> select min(checkpoint_change#) from v$datafile_header; MIN(CHECKPOINT_CHANGE#) ----------------------- 1263648 SQL> select min(checkpoint_change#) from v$datafile_header where file# not in (select file# from v$datafile where enabled = 'READ ONLY'); 选择上述语句中最先的scn值作为主库增量备份的起点。

  • 3、主库检查

确认基于此SCN值后有无新增的数据文件如果有的话需要先恢复对应的数据文件- 后面单独写个文章介绍 SQL> SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# > 1263648; 没有返回则表示无新增数据文件。继续下一步

数据仓库中数据的存储周期(11gdataguard增量恢复处理GAP五)(3)

  • 4、主库增量备份

RMAN> BACKUP INCREMENTAL FROM SCN 1263648 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';

  • 5、发送备份到备库

Oracle@db02:/oradata>scp /tmp/ForStandby_0* 192.168.100.120:/tmp oracle@192.168.100.120's password: ForStandby_030to1b4_1_1 100% 424KB 424.0KB/s 00:00 ForStandby_040to1bu_1_1

  • 6、备库执行catalog

RMAN> CATALOG START WITH '/tmp/ForStandby';

  • 7、备库执行增量恢复

1、启动备数据库到mount模式 2、执行恢复 RMAN> recover database noredo; Starting recover at 17-MAY-22 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=15 device type=DISK channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /oradata/racdb/system01.dbf destination for restore of datafile 00002: /oradata/racdb/sysaux01.dbf destination for restore of datafile 00003: /oradata/racdb/undotbs01.dbf destination for restore of datafile 00004: /oradata/racdb/users01.dbf destination for restore of datafile 00005: /oradata/racdb/test01.dbf channel ORA_DISK_1: reading from backup piece /tmp/ForStandby_030to1b4_1_1 channel ORA_DISK_1: piece handle=/tmp/ForStandby_030to1b4_1_1 tag=FORSTANDBY channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished recover at 17-MAY-22

  • 8、主库备份控制文件并发送到备库

RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/tmp/ForStandbyCTRL.bck'; oracle@db02:/oradata>scp /tmp/ForStandbyCTRL.bck 192.168.100.120:/tmp

  • 9、记录备库的文件路径信息

spool standby_datafile_names.txt set pagesize 1000; set lines 200 col name format a60 select file#, name from v$datafile order by file# ; spool off

10、备库恢复控制文件

SQL> shutdown immediate; ORA-01109: database not open Database dismounted. ORACLE instance shut down. SQL> startup nomount; 启动到nomount模式 ORACLE instance started. Total System Global Area 2505338880 bytes Fixed Size 2255832 bytes Variable Size 603980840 bytes Database Buffers 1879048192 bytes Redo Buffers 20054016 bytes SQL> quit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options oracle@db01:/home/oracle>rman target / Recovery Manager: Release 11.2.0.4.0 - Production on Tue May 17 15:27:49 2022 copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: RACDB (not mounted) RMAN> RESTORE STANDBY CONTROLFILE FROM '/tmp/ForStandbyCTRL.bck'; 恢复控制文件 Starting restore at 17-MAY-22 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=134 device type=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output file name=/oradata/racdb/control01.ctl output file name=/oradata/racdb/control02.ctl Finished restore at 17-MAY-22 RMAN> alter database mount; database mounted released channel: ORA_DISK_1 RMAN> report schema; 查看当前控制文件记录的路径是否和第9步骤记录的一致 如果路径和控制文件记录一致则不需要switch to copy操作,如果不一致需要执行switch database to copy 更新控制文件。

11、启动恢复

SQL> alter database recover managed standby database disconnect; Database altered.

数据仓库中数据的存储周期(11gdataguard增量恢复处理GAP五)(4)

至此增量恢复完成,从库可以和主库正常进行同步。

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页