温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

修复由于主库NOLOGGING操作引起的备库ORA-01578和ORA-26040错误

发布时间:2020-08-01 06:19:17 来源:网络 阅读:753 作者:小麦苗best 栏目:关系型数据库

修复由于主库NOLOGGING操作引起的备库ORA-01578和ORA-26040错误




ORA-01578和ORA-26040--NOLOGGING操作引起的坏块-错误解释和解决方案 http://blog.itpub.net/26736162/viewspace-2152783/




众所周知 , DG 数据同步是基于日志流的 , 这也是为什么在配置 DG 阶段需要 将主库设置为 FORCE LOGGING 的原因 。但是 , 这也会带来很多问题 , SQL 执行效率 慢 ,例如:当我们使用数据泵进行迁移时我们希望最少停机时间完成,这时候我们就可能会考虑到以最小日志导入的方式以加快导入速度,然后重新同步备库。

在一些场景中,我们会去使用 nologging 操作去节省大量数据插入的时间,而这种操作所带来的问题就是,如果该库在有备库的情况下,因为主库的 nologging 插入操作不会生成 redo ,所以不会在备库上传输和应用,这会导致备库的数据出现问题。

在一个具有主备关系的主库上将 force_logging 设置为 nologging 模式,随后创建一张表,设置为 nologging 模式

SQL> alter database no force logging;

SQL> create table DEMO tablespace users pctfree 99 as select rownum n from xmltable('1 to 100');

SQL> alter table DEMO nologging;

之后使用 /* +append*/ 插入数据并提交

SQL> insert /*+ append */ into DEMO select rownum n from xmltable('1 to 1000');

SQL> commit

这时候在备库对该表进行查询会看到如下报错信息

SQL>select count(1) from demo;

select count(1) from demo

                 *

ERROR at line 1:

ORA-01578: ORACLE data block corrupted (file # 4, block # 819)

ORA-01110: data file 4: '/data/data1/ORCL2/datafile/o1_mf_users_3ft1e9qb_.dbf'

ORA-26040: Data block was loaded using the NOLOGGING option

 

1.1   11g

在 Oracle 11g 中 ,如果遇到这样的问题,可以通过在备库恢复有问题的数据文件来解决问题 。 而要修复这个问题,需要将包含缺少的数据的数据文件从主库复制到物理备库。

、查询主库

SQL> SELECT NAME, UNRECOVERABLE_CHANGE# FROM V$DATAFILE;

NAME                                        UNRECOVERABLE_CHANGE#

-------------------------------------------- ---------------------

+DATADG/orcl/datafile/system.270.972381717                            0

+DATADG/orcl/datafile/sysaux.265.972381717                            0

+DATADG/orcl/datafile/undotbs1.261.972381717                            0

+DATADG/orcl/datafile/users.259.972381717                          6252054

+DATADG/orcl/datafile/example.264.972381807                            0

+DATADG/orcl/datafile/undotbs2.258.972381927                            0

+DATADG/orcl/datafile/example.266.972400297                            0

+DATADG/orcl/datafile/ax.268.973612569                                0

、查询备库

sys@ORCL>SELECT NAME, UNRECOVERABLE_CHANGE# FROM V$DATAFILE;

NAME                                        UNRECOVERABLE_CHANGE#

--------------------------------------------- ---------------------

/data/data1/ORCL2/datafile/o1_mf_system_3dt1e9op_.dbf                       0

/data/data1/ORCL2/datafile/o1_mf_sysaux_3ct1e9nb_.dbf                       0

/data/data1/ORCL2/datafile/o1_mf_undotbs1_3gt1e9qq_.dbf                     0

/data/data1/ORCL2/datafile/o1_mf_users_3ft1e9qb_.dbf                     5383754

/data/data1/ORCL2/datafile/o1_mf_example_3et1e9ps_.dbf                      0

/data/data1/ORCL2/datafile/o1_mf_undotbs2_3ht1e9r1_.dbf                     0

/data/data1/ORCL2/datafile/o1_mf_example_3at1e9nb_.dbf                      0

/data/data1/ORCL2/datafile/o1_mf_ax_3bt1e9nb_.dbf                       0

、比较主数据库和备用数据库的查询结果

在两个查询结果中比较 UNRECOVERABLE_CHANGE# 列的值。如果主库中 UNRECOVERABLE_CHANGE #列的值大于备库中的同一列,则需要将这些数据文件在备库恢复。

将主库对应的数据文件拷贝至备库 

SQL> alter tablespace users begin backup ;

SQL> exit

ASMCMD>cp +DATADG/orcl/datafile/users.259.972381717 /tmp

$ scp /tmp/users.259.972381717 10.10.60.123:/data/data1/ORCL2/datafile/

SQL> alter tablespace users end backup ;

备库将旧的数据文件 RENAME 至新的数据文件 

SQL> startup mount force

SQL> alter database recover managed standby database cancel;

SQL> alter system set standby_file_management=manual; # 在备库执行 rename 操作时,需要此参数为manual

SQL> alter database  rename file '/data/data1/ORCL2/datafile/o1_mf_users_3ft1e9qb_.dbf' to '/data/data1/ORCL2/datafile/users.259.972381717';

SQL> alter system set standby_file_management=auto;

SQL> alter database recover managed standby database using current logfile disconnect from session;

之后就可以在备库查询到实例表 DEMO

SQL> select count(1) from demo;

  COUNT(1)

----------

    1 00

1.2   12.1

对于这种情况,在 12.1 版本中, RMAN 提供了一种便捷的方式让我们不需要在主库上进行数据文件的备份传输而可以在备库使用 restore database (or datafile ) from service 去从主库进行恢复。

当然, Oracle 的 RMAN 是足够聪明的:如果数据文件是正常的状态, RMAN 可以根据它们的数据文件头进行跳跃恢复。如果,由于 nologging 操作导致某些块被标记为损坏的,那么这部分数据文件就是需要恢复的,然后怎么办?在恢复命令中有 FORCE 选项。但我们可能并不需要它。因为有些时候数据文件是同步的,实时日志应用进程还是在运行的。这个时候,为了恢复,我们需要停止应用。

一旦我们停止了应用,那么就不需要执行 RESOTORE DATABASE FORCE 操作,因为现在数据文件的状态是过旧的,就算你不加 FORCE 选项 RMAN 也是不会跳过这些数据文件的。

备库关掉实时日志应用,并开启至 mount 状态。

SQL> alter database recover managed standby database cancel;

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started

备库登陆 RMAN, 使用 restore database (or datafile ) from service 进行恢复

RMAN> restore database from service 'primary_db'; # 这里的 primary_db, 为备库至主库的 tns 连接串的别名

Starting restore at 2018-05-03 17:00:35

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=29 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: using network backup set from service primary_db

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to /data/data1/ORCL2/datafile/o1_mf_system_02t1t9ck_.dbf

channel ORA_DISK_1: restore complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: using network backup set from service primary_db

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00003 to /data/data1/ORCL2/datafile/o1_mf_sysaux_03t1t9d3_.dbf

channel ORA_DISK_1: restore complete, elapsed time: 00:00:15

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: using network backup set from service primary_db

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00004 to /data/data1/ORCL2/datafile/o1_mf_undotbs1_04t1t9di_.dbf

channel ORA_DISK_1: restore complete, elapsed time: 00:00:02

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: using network backup set from service primary_db

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00006 to /data/data1/ORCL2/datafile/o1_mf_users_05t1t9dm_.dbf

channel ORA_DISK_1: restore complete, elapsed time: 00:00:15

Finished restore at 2018-05-03 17:01:34

当然要记得去起库并开启实时日志应用进程!


1.3   12.2 

在 12.2 中, Oracle 提供了一种更方便的方式去进行恢复主库会将未记录的块的列表发送至备库,并记录在备库控制文件中,我们可以从备库的 v$nonlogged_block 这个视图查看到相关信息。不需要发送主库的整个数据文件,而是在 RMAN执行一个简单的命令来恢复它们:

RECOVER DATABASE NONLOGGED BLOCK

停止备库实时日志应用

SQL> alter database recover managed standby database cancel;

备库登陆 RMAN 执行

RECOVER DATABASE NONLOGGED BLOCK

注意:执行此步骤前请确认主备库的 log_archive_config 参数已经设置

RMAN> recover database nonlogged block;

Starting recover at 2018-05-03 14:54:22

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=56 device type=DISK

starting recovery of nonlogged blocks

List of Datafiles

=================

File Status Nonlogged Blocks Blocks Examined Blocks Skipped

---- ------ ---------------- --------------- --------------

1    OK     0                0               107519        

3    OK     0                0               262399        

4    OK     0                0               149759        

5    OK     0                0               31999         

6    OK     0                0               42239         

7    OK     0                16707           21532         

8    OK     0                0               12799         

9    OK     0                0               76799         

18   OK     0                0               33279         

19   OK     0                0               57599         

20   OK     0                0               24959         

21   OK     0                0               33279         

22   OK     0                0               51199         

23   OK     0                0               12799         

29   OK     0                0               1310719       

30   OK     0                0               12799         

31   OK     0                0               33279         

32   OK     0                0               52479         

33   OK     0                0               923519        

34   OK     0                16822           8777          

35   OK     0                0               12799         

37   OK     0                0               24959         

Details of nonlogged blocks can be queried from v$nonlogged_block view

recovery of nonlogged blocks complete, elapsed time: 00:00:08

Finished recover at 2018-05-03 14:54:32

最后别忘了开启实时日志应用进程。

综上来看, 12.2 中这个特性在数据仓库等一些场景是可以尝试的。以往我们开启 force logging 造成大量的 redo 日志并且影响一部分 dml 语句的执行效率。在 12.2 我们可以尝试使用 nonlogging 操作去节省大量数据插入的时间,然后在系统空闲时间进行备库恢复操作。但是注意这种操作也存在弊端,这样你的备库的可用性就大大降低了。凡事总有取舍!




https://docs.oracle.com/cd/B28359_01/server.111/b28294/scenarios.htm#i1015738


13.4.2  Recovery Steps for Physical Standby Databases

When the archived redo log file is copied to the standby site and applied to the physical standby database, a portion of the datafile is unusable and is marked as being unrecoverable. When you either fail over to the physical standby database, or open the standby database for read-only access, and attempt to read the range of blocks that are marked as  UNRECOVERABLE , you will see error messages similar to the following:

ORA-01578: ORACLE data block corrupted (file # 1, block # 2521) ORA-01110: data file 1: '/oracle/dbs/stdby/tbs_1.dbf' ORA-26040: Data block was loaded using the NOLOGGING option

To recover after the  NOLOGGING  clause is specified, you need to copy the datafile that contains the missing redo data from the primary site to the physical standby site. Perform the following steps:


Step 1   Determine which datafiles should be copied.

Follow these steps:

  1. Query the primary database:

    SQL> SELECT NAME, UNRECOVERABLE_CHANGE# FROM V$DATAFILE; NAME                                                  UNRECOVERABLE ----------------------------------------------------- ------------- /oracle/dbs/tbs_1.dbf                                       5216 /oracle/dbs/tbs_2.dbf                                          0 /oracle/dbs/tbs_3.dbf                                          0 /oracle/dbs/tbs_4.dbf                                          0 4 rows selected.
  2. Query the standby database:

    SQL> SELECT NAME, UNRECOVERABLE_CHANGE# FROM V$DATAFILE; NAME                                                  UNRECOVERABLE ----------------------------------------------------- ------------- /oracle/dbs/stdby/tbs_1.dbf                                 5186 /oracle/dbs/stdby/tbs_2.dbf                                    0 /oracle/dbs/stdby/tbs_3.dbf                                    0 /oracle/dbs/stdby/tbs_4.dbf                                    0 4 rows selected.
  3. Compare the query results of the primary and standby databases.

    Compare the value of the  UNRECOVERABLE_CHANGE#  column in both query results. If the value of the UNRECOVERABLE_CHANGE#  column in the primary database is greater than the same column in the standby database, then the datafile needs to be copied from the primary site to the standby site.

    In this example, the value of the  UNRECOVERABLE_CHANGE#  in the primary database for the  tbs_1.dbf  datafile is greater, so you need to copy the  tbs_1.dbf  datafile to the standby site.

Step 2   On the primary site, back up the datafile you need to copy to the standby site.

Issue the following SQL statements:

SQL> ALTER TABLESPACE system BEGIN BACKUP; SQL> EXIT; % cp tbs_1.dbf /backup SQL> ALTER TABLESPACE system END BACKUP;

Step 3   Copy the datafile to the standby database.

Copy the datafile that contains the missing redo data from the primary site to location on the physical standby site where files related to recovery are stored.

Step 4   On the standby database, restart Redo Apply.

Issue the following SQL statement:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

You might get the following error messages (possibly in the alert log) when you try to restart Redo Apply:

ORA-00308: cannot open archived log 'standby1' ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3 ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: '/oracle/dbs/stdby/tbs_1.dbf'

If you get the  ORA-00308  error and Redo Apply does not terminate automatically, you can cancel recovery by issuing the following statement from another terminal window:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

These error messages are returned when one or more log files in the archive gap have not been successfully applied. If you receive these errors, manually resolve the gaps, and repeat Step  4 . See  Section 6.3.3.1  for information about manually resolving an archive gap.

13.4.3  Determining If a Back up Is Required After Unrecoverable Operations

If you performed unrecoverable operations on your primary database, determine if a new backup operation is required by following these steps:

  1. Query the  V$DATAFILE  view on the primary database to determine the  system change number (SCN)  or the time at which the Oracle database generated the most recent invalidated redo data.

  2. Issue the following SQL statement on the primary database to determine if you need to perform another backup:

    SELECT UNRECOVERABLE_CHANGE#,         TO_CHAR(UNRECOVERABLE_TIME, 'mm-dd-yyyy hh:mi:ss')  FROM   V$DATAFILE;
  3. If the query in the previous step reports an unrecoverable time for a datafile that is more recent than the time when the datafile was last backed up, then make another backup of the datafile in question.

See  Oracle Database Reference  for more information about the  V$DATAFILE  view.




https://docs.oracle.com/cd/B28359_01/server.111/b28294/manage_ls.htm#i1016645



10.5.5  Adding  or Re-Creating Tables On a Logical Standby Database

Typically, you use the  DBMS_LOGSTDBY.INSTANTIATE_TABLE  procedure to  re-create a table after an unrecoverable operation. You can also use this procedure to enable SQL Apply on a table that was formerly skipped.

Before you can create a table, it must meet the requirements described in  Section 4.1.2, "Ensure Table Rows in the Primary Database Can Be Uniquely Identified" . Then, you can use the following steps to re-create a table named  HR.EMPLOYEES  and resume SQL Apply. The directions assume that there is already a database link  BOSTON  defined to access the primary database.

The following list shows how to re-create a table and restart SQL Apply on that table:

  1. Stop SQL Apply:

    SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;
  2. Ensure no operations are being skipped for the table in question by querying the  DBA_LOGSTDBY_SKIP  view:

    SQL> SELECT * FROM DBA_LOGSTDBY_SKIP; ERROR  STATEMENT_OPT        OWNER          NAME                PROC -----  -------------------  -------------  ----------------    ----- N      SCHEMA_DDL           HR             EMPLOYEES N      DML                  HR             EMPLOYEES N      SCHEMA_DDL           OE             TEST_ORDER N      DML                  OE             TEST_ORDER

    Because you already have skip rules associated with the table that you want to re-create on the logical standby database, you must first delete those rules. You can accomplish that by calling the  DBMS_LOGSTDBY.UNSKIP procedure. For example:

    SQL> EXECUTE DBMS_LOGSTDBY.UNSKIP(stmt => 'DML', -      schema_name => 'HR', -      object_name => 'EMPLOYEES');
    SQL> EXECUTE DBMS_LOGSTDBY.UNSKIP(stmt => 'SCHEMA_DDL', -      schema_name => 'HR', -      object_name => 'EMPLOYEES');
  3. Re-create the table  HR.EMPLOYEES  with all its data in the logical standby database by using the DBMS_LOGSTDBY.INSTANTIATE_TABLE  procedure. For example:

    SQL> EXECUTE DBMS_LOGSTDBY.INSTANTIATE_TABLE(schema_name => 'HR', -      object_name => 'EMPLOYEES', -      dblink => 'BOSTON');
  4. Start SQL Apply:

    SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;

    See Also:

    Oracle Database PL/SQL Packages and Types Reference  for information about the DBMS_LOGSTDBY.UNSKIP  and the  DBMS_LOGSTDBY.INSTANTIATE_TABLE  procedures

To ensure a consistent view across the newly instantiated table and the rest of the database, wait for SQL Apply to catch up with the primary database before querying this table. You can do this by performing the following steps:

  1. On the primary database, determine the current SCN by querying the  V$DATABASE  view:

    SQL> SELECT CURRENT_SCN FROM V$DATABASE@BOSTON; CURRENT_SCN --------------------- 345162788
  2. Make sure SQL Apply has applied all transactions committed before the  CURRENT_SCN  returned in the previous query:

    SQL> SELECT APPLIED_SCN FROM V$LOGSTDBY_PROGRESS; APPLIED_SCN -------------------------- 345161345

    When the  APPLIED_SCN  returned in this query is greater than the  CURRENT_SCN  returned in the first query, it is safe to query the newly re-created table.





Rolling a Standby Forward using an RMAN Incremental Backup To Fix The Nologging Changes (文档 ID 958181.1)

In this Document 


Purpose

Scope

Details

STEPS

1. Follow this step-by-step procedure to roll forward a physical standby database for which nologging changes have been  applied to a small subset of the database:





2. Follow this step-by-step procedure to roll forward a physical standby database for which nologging changes have been applied to a large portion of the database:

References


APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.2.0.1 to 12.1.0.2 [Release 10.2 to 12.1] 
Information in this document applies to any platform. 
***Checked for relevance on 16-July-2015***  
***Checked for relevance on 27-Oct-2016***

PURPOSE

This document describes a method of rolling forward a standby database using incremental backups to fix the ORA-1578 and the ORA-26040 errors that were cuased due to Nologging/Unrecoverable operation.

SCOPE

When a segment is defined with the NOLOGGING attribute and if a NOLOGGING/UNRECOVERABLE operation updates the segment, the online redo log file is updated with minimal information to invalidate the affected blocks when a RECOVERY is later performed.

This kind of NOLOGGING/UNRECOVERABLE will mark the affected blocks as corrupt during the media recovery on the standby database.Now, when you either activate the standby database, or open the standby database with the read-only option, and attempt to read the range of blocks that are marked as "UNRECOVERABLE," you see error messages similar to the following:

ORA-01578: ORACLE data block corrupted (file # 1, block # 2521) 
ORA-01110: data file 1: '/vobs/oracle/dbs/stdby/tbs_1.f' 
ORA-26040: Data block was loaded using the NOLOGGING option

In this article we will be checking the steps to fix the nologging changes have been applied to a small subset of the database and the  nologging changes have been applied to a large portion of the database:

A look-a-like procedure is documented in :

   Oracle® Data Guard Concepts and Administration 11g Release 1 (11.1) Part Number B28294-03

   Section 13.4 Recovering After the NOLOGGING Clause Is Specified

   http://download.oracle.com/docs/cd/B28359_01/server.111/b28294/scenarios.htm#i1015738

DETAILS

STEPS

1. Follow this step-by-step procedure to roll forward a physical standby database for which nologging changes have been  applied to a small subset of the database:

1. List the files that have had nologging changes applied by querying the V$DATAFILE view on the standby database. For example:

SQL> SELECT FILE#, FIRST_NONLOGGED_SCN FROM V$DATAFILE WHERE FIRST_NONLOGGED_SCN > 0;

FILE#      FIRST_NONLOGGED_SCN 
---------- ------------------- 
         4              225979 
         5              230184


2. Stop Redo Apply on the standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

3. On the standby database, offline the datafiles (recorded in step 0) that have had nologging changes. Taking these datafiles offline ensures redo data is not skipped for the corrupt blocks while the incremental backups are performed.

SQL> ALTER DATABASE DATAFILE 4 OFFLINE FOR DROP; 
SQL> ALTER DATABASE DATAFILE 5 OFFLINE FOR DROP;

4. Start Redo Apply on the standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

5. While connected to the primary database as the RMAN target, create an incremental backup for each datafile listed in the FIRST_NONLOGGED_SCN column (recorded in step 0). For example:

RMAN> BACKUP INCREMENTAL FROM SCN 225979 DATAFILE 4 FORMAT '/tmp/ForStandby_%U' TAG 'FOR STANDBY'; 
RMAN> BACKUP INCREMENTAL FROM SCN 230184 DATAFILE 5 FORMAT '/tmp/ForStandby_%U' TAG 'FOR STANDBY';

6. Transfer all backup sets created on the primary system to the standby system. (Note that there may be more than one backup file created.)

% scp /tmp/ForStandby_* standby:/tmp

7. While connected to the physical standby database as the RMAN target, catalog all incremental backup pieces. For example:

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

8. Stop Redo Apply on the standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

9. Online the datafiles on the standby database

SQL> ALTER DATABASE DATAFILE 4 ONLINE; 
SQL> ALTER DATABASE DATAFILE 5 ONLINE;

10. While connected to the physical standby database as the RMAN target, apply the incremental backup sets:

RMAN> RECOVER DATAFILE 4, 5 NOREDO;

11. Query the V$DATAFILE view on the standby database to verify there are no datafiles with nologged changes. The following query should return zero rows

SQL> SELECT FILE#, FIRST_NONLOGGED_SCN FROM V$DATAFILE WHERE FIRST_NONLOGGED_SCN > 0;

12. Recreate the Standby Controlfile following:

Note 459411.1  Steps to recreate a Physical Standby Controlfile

13. Remove the incremental backups from the standby system:

RMAN> DELETE BACKUP TAG 'FOR STANDBY';

14. Manually remove the incremental backups from the primary system. For example, the following example uses the Linux rm command:

% rm /tmp/ForStandby_*

15. Start Redo Apply on the standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

Note: Starting from 12c we can use RECOVER DATABASE...FROM SERVICE clause in RMAN to generate, transfer and apply the incremental backup in a single step. Please refer below document for examples: 

Note 1987763.1  ROLLING FORWARD A PHYSICAL STANDBY USING RECOVER FROM SERVICE COMMAND IN 12C 

 

2. Follow this step-by-step procedure to roll forward a physical standby database for which nologging changes have been applied to a large portion of the database:

1. Query the V$DATAFILE view on the standby database to record the lowest FIRST_NONLOGGED_SCN:

SQL> SELECT MIN(FIRST_NONLOGGED_SCN) FROM V$DATAFILE WHERE FIRST_NONLOGGED_SCN>0;

MIN(FIRST_NONLOGGED_SCN) 
------------------------ 
                  223948

2.Stop Redo Apply on the standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

3.While connected to the primary database as the RMAN target, create an incremental backup from the lowest FIRST_NONLOGGED_SCN (recorded in step 0)

RMAN> BACKUP INCREMENTAL FROM SCN 223948 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FOR STANDBY';

4.Transfer all backup sets created on the primary system to the standby system. (Note that more than one backup file may have been created.) The following example uses the scp command to copy the files:

% scp /tmp/ForStandby_* standby:/tmp

5.While connected to the standby database as the RMAN target, catalog all incremental backup piece(s)

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

6.While connected to the standby database as the RMAN target, apply the incremental backups:

RMAN> RECOVER DATABASE NOREDO;

7.Query the V$DATAFILE view to verify there are no datafiles with nologged changes. The following query on the standby database should return zero rows:

SQL> SELECT FILE#, FIRST_NONLOGGED_SCN FROM V$DATAFILE WHERE FIRST_NONLOGGED_SCN > 0;

8. Recreate the Standby Controlfile following:

Note 459411.1  Steps to recreate a Physical Standby Controlfile

9.Remove the incremental backups from the standby system:

RMAN> DELETE BACKUP TAG 'FOR STANDBY';

10.Manually remove the incremental backups from the primary system. For example, the following removes the backups using the Linux rm command:

% rm /tmp/ForStandby_*

11.Start Redo Apply on the standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

 

Note:

If the affected files belong to a READ ONLY tablespace, those files will be ignored during backup. To bypass the issue, at Primary Database, switch the tablespace from read only to read write and back to read only again : 

SQL> alter tablespace <tablespace_name> read write ; 
SQL> alter tablespace <tablespace_name> read only ;

 

REFERENCES

NOTE:794505.1  - ORA-1578 / ORA-26040 Corrupt blocks by NOLOGGING - Error explanation and solution





Rolling Forward a Physical Standby Using Recover From Service Command in 12c (文档 ID 1987763.1)



In this Document 


Goal

Solution

References


APPLIES TO:

Oracle Database - Enterprise Edition - Version 12.1.0.1 and later 
Information in this document applies to any platform. 

GOAL

  Rolling Forward a Physical Standby Database Using the RECOVER FROM SERVICE Command

A standby database is a transactionally-consistent copy of the production database. It enables production Oracle database to survive disasters and data corruption. If the production database becomes unavailable because of a planned or an unplanned outage, Data Guard can switch a standby database to the production role, minimizing the downtime associated with the outage. Moreover, performance of production database can be improved by offloading resource-intensive backup and reporting operations to standby systems. As you can see, it’s always desirable to have standby database synchronized with the primary database.

Prior to 12c, in order to roll forward the standby database using incremental backups you would need to:

  • Create a control file for the standby database on the primary database.

  • Take an incremental backup on the primary starting from the SCN# of the standby database.

  • Copy the incremental backup to the standby host and catalog it with RMAN.

  • Mount the standby database with newly created standby control file.

  • Cancel managed recovery of the standby database and apply incremental backup to the standby database.

  • Start managed recovery of standby database.

In 12c, this procedure has been dramatically simplified. Now you can use the RECOVER … FROM SERVICE command to synchronize the physical standby database with the primary database.  This command does the following:

  • Creates an incremental backup containing the changes to the primary database. All changes to data files on the primary database, beginning with the SCN in the standby data file header, are included in the incremental backup.

  • Transfers the incremental backup over the network to the physical standby database.

  • Applies the incremental backup to the physical standby database.

This results in rolling forward the standby data files to the same point-in-time as the primary. However, the standby control file still contains old SCN values which are lower than the SCN values in the standby data files. Therefore, to complete the synchronization of the physical standby database, the standby control file needs to be refreshed to update the SCN#.

SOLUTION

Steps to Refresh a Physical Standby Database with Changes Made to the Primary Database 

Environment: 

Primary Database: 
DB_UNIQUE_NAME: prim ( net service name 'PRIM') 

Standby Database: 
DB_UNIQUE_NAME:clone( net service name 'CLONE') 

Use the following steps to refresh the physical standby database with changes made to the primary database: 

Prerequisites 

  • Oracle Net connectivity is established between the physical standby database and the primary database.

  • You can do this by adding an entry corresponding to the primary database in the tnsnames.ora file of the physical standby database.

  • The password files on the primary database and the physical standby database are the same.

  • The COMPATIBLE parameter in the initialization parameter file of the primary database and physical standby database is set to 12.0.

  • Start RMAN and connect as target to the physical standby database.

Check the existing size of the Primary database and compare with the standby existing size as we need at-least the difference in size (free space)  since standby is behind ,if the datafile on primary has autoextended then standby file would be same in size compared to prod,so when you do the incremental rollforward it would apply the blocks and add any new one to match the size of standby file.

1. Place the physical standby database in MOUNT mode.


    SHUTDOWN IMMEDIATE; 
    STARTUP MOUNT;

 2. Stop the managed recovery processes on the physical standby database.

 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

 

NOTE:  If using broker, you will need to stop MRP through DGMGRL.  I.e.: 

DGMGRL> edit database '<Standby db_unique_name>' set STATE='APPLY-OFF' ;

3. Let us identify the datafiles on standby database which are out of sync with respect to primary.


Primary: 

SQL> select HXFIL File_num,substr(HXFNM,1,40),fhscn from x$kcvfh; 

  FILE_NUM SUBSTR(HXFNM,1,40)                       FHSCN 
---------- ---------------------------------------- ---------------- 
         1 /u01/app/oracle/oradata/prim/system01.db 1984501 
         3 /u01/app/oracle/oradata/prim/sysaux01.db 1984501 
         4 /u01/app/oracle/oradata/prim/undotbs01.d 1984501 
         5 /u01/app/oracle/oradata/prim/pdbseed/sys  1733076 
         6 /u01/app/oracle/oradata/prim/users01.dbf 1984501 
         7 /u01/app/oracle/oradata/prim/pdbseed/sys  1733076 
         8 /u01/app/oracle/oradata/prim/pdb1/system 1984501 
         9 /u01/app/oracle/oradata/prim/pdb1/sysaux 1984501 
        10 /u01/app/oracle/oradata/prim/pdb1/pdb1_u 1984501 
        16 /u01/app/oracle/oradata/prim/pdb3/system 1984501 
        17 /u01/app/oracle/oradata/prim/pdb3/sysaux 1984501 
        18 /u01/app/oracle/oradata/prim/pdb3/pdb1_u 1984501 
        19 /u01/app/oracle/oradata/prim/pdb3/test.d 1984501 

13 rows selected. 

STANDBy: 

SQL>  select HXFIL File_num,substr(HXFNM,1,40),fhscn from x$kcvfh; 

  FILE_NUM SUBSTR(HXFNM,1,40)                       FHSCN 
---------- ---------------------------------------- ---------------- 
         1 /u01/app/oracle/oradata/clone/system01.d 1980995 
         3 /u01/app/oracle/oradata/clone/sysaux01.d 1980998 
         4 /u01/app/oracle/oradata/clone/undotbs01. 1981008 
         5 /u01/app/oracle/oradata/clone/pdbseed/sy  1733076 
         6 /u01/app/oracle/oradata/clone/users01.db 1981012 
         7 /u01/app/oracle/oradata/clone/pdbseed/sy  1733076 
         8 /u01/app/oracle/oradata/clone/pdb1/syste 1981015 
         9 /u01/app/oracle/oradata/clone/pdb1/sysau 1981021 
        10 /u01/app/oracle/oradata/clone/pdb1/pdb1_ 1981028 
        16 /u01/app/oracle/oradata/clone/pdb3/syste 1981030 
        17 /u01/app/oracle/oradata/clone/pdb3/sysau 1981036 
        18 /u01/app/oracle/oradata/clone/pdb3/pdb1_ 1981043 
        19 /u01/app/oracle/oradata/clone/pdb3/test. 1981044 

13 rows selected. 

On  checking SCN in datafile headers on primary (prim) and standby (clone), we note that whereas SCN 

of datafiles 5,7 match on primary and standby, for rest of the  datafiles (1,3,4,6,8,9,10,16,17) standby is lagging behind  primary.

 

4. Note the current SCN of the physical standby database. This is required to determine, in a later step, if new data files were added to the primary database.

Query the V$DATABASE view to obtain the current SCN using the following command:

SELECT CURRENT_SCN FROM V$DATABASE;

5.  The RECOVER … FROM SERVICE command refreshes the standby data files and rolls them forward to the same point-in-time as the primary. 

[oracle@localhost ~]$ rman target/ 

Recovery Manager: Release 12.1.0.1.0 - Production on Mon Mar 9 18:22:52 2015 

Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved. 

connected to target database: PRIM (DBID=4165840403, not open)

RMAN> recover database from service prim noredo using compressed backupset;

  Log:


Starting recover at 09-MAR-15 
using target database control file instead of recovery catalog 
allocated channel: ORA_DISK_1 
channel ORA_DISK_1: SID=32 device type=DISK 
skipping datafile 5; already restored to SCN 1733076 
skipping datafile 7; already restored to SCN 1733076 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00001: /u01/app/oracle/oradata/clone/system01.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00003: /u01/app/oracle/oradata/clone/sysaux01.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00004: /u01/app/oracle/oradata/clone/undotbs01.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00006: /u01/app/oracle/oradata/clone/users01.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00008: /u01/app/oracle/oradata/clone/pdb1/system01.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00009: /u01/app/oracle/oradata/clone/pdb1/sysaux01.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00010: /u01/app/oracle/oradata/clone/pdb1/pdb1_users01.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00016: /u01/app/oracle/oradata/clone/pdb3/system01.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00017: /u01/app/oracle/oradata/clone/pdb3/sysaux01.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00018: /u01/app/oracle/oradata/clone/pdb3/pdb1_users01.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 
channel ORA_DISK_1: starting incremental datafile backup set restore 
channel ORA_DISK_1: using compressed network backup set from service prim 
destination for restore of datafile 00019: /u01/app/oracle/oradata/clone/pdb3/test.dbf 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 

Finished recover at 09-MAR-15


6. Lets check the SCNs of the datafiles at primary and standby now.

Primary 
-------- 
SQL> select HXFIL File_num,substr(HXFNM,1,40),fhscn from x$kcvfh; 

  FILE_NUM SUBSTR(HXFNM,1,40)                       FHSCN 
---------- ---------------------------------------- ---------------- 
         1 /u01/app/oracle/oradata/prim/system01.db 1985174 
         3 /u01/app/oracle/oradata/prim/sysaux01.db 1985183 
         4 /u01/app/oracle/oradata/prim/undotbs01.d 1985194 
         5 /u01/app/oracle/oradata/prim/pdbseed/sys 1733076 
         6 /u01/app/oracle/oradata/prim/users01.dbf 1985203 
         7 /u01/app/oracle/oradata/prim/pdbseed/sys 1733076 
         8 /u01/app/oracle/oradata/prim/pdb1/system 1985206 
         9 /u01/app/oracle/oradata/prim/pdb1/sysaux 1985212 
        10 /u01/app/oracle/oradata/prim/pdb1/pdb1_u 1985218 
        16 /u01/app/oracle/oradata/prim/pdb3/system 1985221 
        17 /u01/app/oracle/oradata/prim/pdb3/sysaux 1985343 
        18 /u01/app/oracle/oradata/prim/pdb3/pdb1_u 1985350 
        19 /u01/app/oracle/oradata/prim/pdb3/test.d 1985354 

Standby 
-------- 
RMAN> select HXFIL File_num,substr(HXFNM,1,40),fhscn from x$kcvfh; 

  FILE_NUM SUBSTR(HXFNM,1,40)                       FHSCN 
---------- ---------------------------------------- ---------------- 
         1 /u01/app/oracle/oradata/clone/system01.d 1985174 
         3 /u01/app/oracle/oradata/clone/sysaux01.d 1985183 
         4 /u01/app/oracle/oradata/clone/undotbs01. 1985194 
         5 /u01/app/oracle/oradata/clone/pdbseed/sy 1733076 
         6 /u01/app/oracle/oradata/clone/users01.db 1985203 
         7 /u01/app/oracle/oradata/clone/pdbseed/sy 1733076 
         8 /u01/app/oracle/oradata/clone/pdb1/syste 1985206 
         9 /u01/app/oracle/oradata/clone/pdb1/sysau 1985212 
        10 /u01/app/oracle/oradata/clone/pdb1/pdb1_ 1985218 
        16 /u01/app/oracle/oradata/clone/pdb3/syste 1985221 
        17 /u01/app/oracle/oradata/clone/pdb3/sysau 1985343 
        18 /u01/app/oracle/oradata/clone/pdb3/pdb1_ 1985350 
        19 /u01/app/oracle/oradata/clone/pdb3/test. 1985354 

13 rows selected

 

From above,we can see primary and standby SCNs matching now.


However, the standby control file still contains old SCN values which are lower than the SCN values in the standby data files.  
Therefore, to complete the synchronization of the physical standby database, we must refresh the standby control file to update the SCN#. 

7. Use the following commands to shut down the standby database and then start it in NOMOUNT mode.


    SHUTDOWN IMMEDIATE; 
    STARTUP NOMOUNT;


8. Restore the standby control file by using the control file on the primary database using service prim.

The following command restores the control file on the physical standby database by using the primary database control file. 

RESTORE STANDBY CONTROLFILE FROM SERVICE <primary_tns_service>; 

RMAN> restore standby controlfile from service prim; 

Starting restore at 09-MAR-15 
allocated channel: ORA_DISK_1 
channel ORA_DISK_1: SID=20 device type=DISK 

channel ORA_DISK_1: starting datafile backup set restore 
channel ORA_DISK_1: using network backup set from service prim 
channel ORA_DISK_1: restoring control file 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 
output file name=/u01/app/oracle/oradata/clone/control01.ctl 
output file name=/u01/app/oracle/fast_recovery_area/clone/control02.ctl 
Finished restore at 09-MAR-15

 

After this step, the names of files in the standby control file are the names that were used in the primary database.

NOTE:  Depending on the configuration, the path and/or names of the standby datafiles after the standby controlfile refresh may be correct and thus steps #9 and #10 can be skipped.  

 

Mount the standby database using the following command: 

RMAN> alter database mount; 

Statement processed 
released channel: ORA_DISK_1 


RMAN> report schema; 

Starting implicit crosscheck backup at 09-MAR-15 
allocated channel: ORA_DISK_1 
channel ORA_DISK_1: SID=21 device type=DISK 
Crosschecked 9 objects 
Finished implicit crosscheck backup at 09-MAR-15 

Starting implicit crosscheck copy at 09-MAR-15 
using channel ORA_DISK_1 
Crosschecked 2 objects 
Finished implicit crosscheck copy at 09-MAR-15 

searching for all files in the recovery area 
cataloging files... 
cataloging done 

List of Cataloged Files 
======================= 
File Name: /u01/app/oracle/fast_recovery_area/CLONE/archivelog/2015_03_05/o1_mf_1_17_11q13dm8_.arc 
File Name: /u01/app/oracle/fast_recovery_area/CLONE/archivelog/2015_03_05/o1_mf_1_16_10q13dm8_.arc 
File Name: /u01/app/oracle/fast_recovery_area/CLONE/archivelog/2015_03_05/o1_mf_1_2_bhk1ctcz_.arc 
File Name: /u01/app/oracle/fast_recovery_area/CLONE/archivelog/2015_03_05/o1_mf_1_1_bhk17cw8_.arc 

RMAN-06139: WARNING: control file is not current for REPORT SCHEMA 
Report of database schema for database with db_unique_name CLONE 

List of Permanent Datafiles 
=========================== 
File Size(MB) Tablespace           RB segs Datafile Name 
---- -------- -------------------- ------- ------------------------ 
1    780      SYSTEM               ***     /u01/app/oracle/oradata/prim/system01.dbf 
3    730      SYSAUX               ***     /u01/app/oracle/oradata/prim/sysaux01.dbf 
4    90       UNDOTBS1             ***     /u01/app/oracle/oradata/prim/undotbs01.dbf 
5    250      PDB$SEED:SYSTEM      ***     /u01/app/oracle/oradata/prim/pdbseed/system01.dbf
6    5        USERS                ***     /u01/app/oracle/oradata/prim/users01.dbf 
7    590      PDB$SEED:SYSAUX      ***     /u01/app/oracle/oradata/prim/pdbseed/sysaux01.dbf
8    260      PDB1:SYSTEM          ***     /u01/app/oracle/oradata/prim/pdb1/system01.dbf 
9    620      PDB1:SYSAUX          ***     /u01/app/oracle/oradata/prim/pdb1/sysaux01.dbf 
10   5        PDB1:USERS           ***     /u01/app/oracle/oradata/prim/pdb1/pdb1_users01.dbf 
16   260      PDB3:SYSTEM          ***     /u01/app/oracle/oradata/prim/pdb3/system01.dbf 
17   620      PDB3:SYSAUX          ***     /u01/app/oracle/oradata/prim/pdb3/sysaux01.dbf 
18   5        PDB3:USERS           ***     /u01/app/oracle/oradata/prim/pdb3/pdb1_users01.dbf 
19   50       PDB3:TEST            ***     /u01/app/oracle/oradata/prim/pdb3/test.dbf 

List of Temporary Files 
======================= 
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name 
---- -------- -------------------- ----------- -------------------- 
1    60       TEMP                 32767       /u01/app/oracle/oradata/prim/temp01.dbf 
2    20       PDB$SEED:TEMP        32767       /u01/app/oracle/oradata/prim/pdbseed/pdbseed_temp01.dbf 
3    373      PDB1:TEMP            32767       /u01/app/oracle/oradata/prim/pdb1/temp01.dbf 
4    71       PDB3:TEMP            32767       /u01/app/oracle/oradata/prim/pdb3/temp01.dbf


9. Update the names of the data files and the temp files in the standby control file. 

 

   Use the CATALOG command and the SWITCH command to update all the data file names. 

        RMAN> catalog start with '<path where the actual standby datafile existed>'; 

        In this case 

        RMAN> Catalog start with '/u01/app/oracle/oradata/clone/'; 

searching for all files that match the pattern /u01/app/oracle/oradata/clone 

List of Files Unknown to the Database 
===================================== 
File Name: /u01/app/oracle/oradata/clone/pdb1/pdb1_users01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb1/sysaux01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb1/system01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdbseed/sysaux01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdbseed/system01.dbf 
File Name: /u01/app/oracle/oradata/clone/sysaux01.dbf 
File Name: /u01/app/oracle/oradata/clone/system01.dbf 
File Name: /u01/app/oracle/oradata/clone/undotbs01.dbf 
File Name: /u01/app/oracle/oradata/clone/users01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb3/pdb1_users01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb3/sysaux01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb3/system01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb3/test.dbf 

Do you really want to catalog the above files (enter YES or NO)? yes 
cataloging files... 
cataloging done 

List of Cataloged Files 
======================= 
File Name: /u01/app/oracle/oradata/clone/pdb1/pdb1_users01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb1/sysaux01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb1/system01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdbseed/sysaux01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdbseed/system01.dbf 
File Name: /u01/app/oracle/oradata/clone/sysaux01.dbf 
File Name: /u01/app/oracle/oradata/clone/system01.dbf 
File Name: /u01/app/oracle/oradata/clone/undotbs01.dbf 
File Name: /u01/app/oracle/oradata/clone/users01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb3/pdb1_users01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb3/sysaux01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb3/system01.dbf 
File Name: /u01/app/oracle/oradata/clone/pdb3/test.dbf

10. Switch to cataloged copy.

RMAN> SWITCH DATABASE TO COPY; 

datafile 1 switched to datafile copy "/u01/app/oracle/oradata/clone/system01.dbf" 
datafile 3 switched to datafile copy "/u01/app/oracle/oradata/clone/sysaux01.dbf" 
datafile 4 switched to datafile copy "/u01/app/oracle/oradata/clone/undotbs01.dbf" 
datafile 5 switched to datafile copy "/u01/app/oracle/oradata/clone/pdbseed/system01.dbf" 
datafile 6 switched to datafile copy "/u01/app/oracle/oradata/clone/users01.dbf" 
datafile 7 switched to datafile copy "/u01/app/oracle/oradata/clone/pdbseed/sysaux01.dbf" 
datafile 8 switched to datafile copy "/u01/app/oracle/oradata/clone/pdb1/system01.dbf" 
datafile 9 switched to datafile copy "/u01/app/oracle/oradata/clone/pdb1/sysaux01.dbf" 
datafile 10 switched to datafile copy "/u01/app/oracle/oradata/clone/pdb1/pdb1_users01.dbf" 
datafile 16 switched to datafile copy "/u01/app/oracle/oradata/clone/pdb3/system01.dbf" 
datafile 17 switched to datafile copy "/u01/app/oracle/oradata/clone/pdb3/sysaux01.dbf" 
datafile 18 switched to datafile copy "/u01/app/oracle/oradata/clone/pdb3/pdb1_users01.dbf" 
datafile 19 switched to datafile copy "/u01/app/oracle/oradata/clone/pdb3/test.dbf"


Here, /u01/app/oracle/oradata/clone is the location of the data files on the physical standby database. 
All data files must be stored in this location.

11. Use the current SCN returned in Step 4 to determine if new data files were added to the primary database since the standby database was last refreshed. If yes, these data files need to be restored on the standby from the primary database.

The following example assumes that the CURRENT_SCN returned in Step 6 is 1984232 and lists the data files that were created on the primary after the timestamp represented by this SCN:

SELECT file# FROM V$DATAFILE WHERE creation_change# >= 1984232;

If no files are returned in Step 11, then go to Step 13. If one or more files are returned in Step 11, then restore these data files from the primary database as in step 12.

12. If you are not connected to a recovery catalog, then use the following commands to restore data files that were added to the primary after the standby was last refreshed ( assuming datafile 21  added to the primary):

RUN 

SET NEWNAME FOR DATABASE TO '/u01/app/oracle/oradata/clone'; 
RESTORE DATAFILE 21 FROM SERVICE prim; 
}

If you are connected to a recovery catalog, then use the following command to restore data files that were added to the primary after the standby was last refreshed (assuming data file 21 added to the primary):

RESTORE DATAFILE 21 FROM SERVICE prim;



13. Update the names of the online redo logs and standby redo logs in the standby control file using one of the following methods: 

 - Use the ALTER DATABASE CLEAR command to clear the log files in all redo log groups of the standby database. RMAN then recreates all the standby redo logs and the online redo log files.

 Note:

Clearing log files is recommended only if the standby database does not have access to the online redo log files and standby redo log 
 files of the primary database( for ex: standby and primary at same server or using same ASM disk group). If the standby database has access to the redo log files of the primary database and the redo log file 
 names of the primary database are OMF names, then the ALTER DATABASE command will delete log files on the primary database.

 - Use the ALTER DATABASE RENAME FILE command to rename the redo log files. 
   Use a separate command to rename each log file. 

   To rename log files, the STANDBY_FILE_MANAGEMENT initialization parameter must be set to MANUAL.  
   Renaming log files is recommended when the number of online redo logs files and standby redo log files is the same 
   in the primary database and the physical standby database. 

   (Oracle Active Data Guard only) Perform the following steps to open the physical standby database:



On the primary database, switch the archived redo log files using the following command: 

       

ALTER SYSTEM ARCHIVE LOG CURRENT;

  
On the physical standby database, run the following commands:

        RECOVER DATABASE; 
        ALTER DATABASE OPEN READ ONLY;

     Start the managed recovery processes on the physical standby database by using the following command:


     ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;






REFERENCES

NOTE:1646232.1  - ORA-19573 when trying to restore to standby with incremental backup From Primary or During any RMAN restore operation





About Me

........................................................................................................................

● 本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除

● 本文在itpub( http://blog.itpub.net/26736162 )、博客园( http://www.cnblogs.com/lhrbest )和个人微信公众号( xiaomaimiaolhr )上有同步更新

● 本文itpub地址: http://blog.itpub.net/26736162

● 本文博客园地址: http://www.cnblogs.com/lhrbest

● 本文pdf版、个人简介及小麦苗云盘地址: http://blog.itpub.net/26736162/viewspace-1624453/

● 数据库笔试面试题库及解答: http://blog.itpub.net/26736162/viewspace-2134706/

● DBA宝典今日头条号地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826

........................................................................................................................

● QQ群号: 230161599 (满) 、618766405

● 微信群:可加我微信,我拉大家进群,非诚勿扰

● 联系我请加QQ好友 ( 646634621 ) ,注明添加缘由

● 于 2018-07-01 06:00 ~ 2018-07-31 24:00 在魔都完成

● 最新修改时间:2018-07-01 06:00 ~ 2018-07-31 24:00

● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解

● 版权所有,欢迎分享本文,转载请保留出处

........................................................................................................................

● 小麦苗的微店 : https://weidian.com/s/793741433?wfr=c&ifr=shopdetail

● 小麦苗出版的数据库类丛书 : http://blog.itpub.net/26736162/viewspace-2142121/

● 小麦苗OCP、OCM、高可用网络班 : http://blog.itpub.net/26736162/viewspace-2148098/

● 小麦苗腾讯课堂主页 : https://lhr.ke.qq.com/

........................................................................................................................

使用 微信客户端 扫描下面的二维码来关注小麦苗的微信公众号( xiaomaimiaolhr )及QQ群(DBA宝典)、添加小麦苗微信, 学习最实用的数据库技术。

修复由于主库NOLOGGING操作引起的备库ORA-01578和ORA-26040错误

........................................................................................................................

修复由于主库NOLOGGING操作引起的备库ORA-01578和ORA-26040错误修复由于主库NOLOGGING操作引起的备库ORA-01578和ORA-26040错误

 

 


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI