Nologging操作对standby的影响

一、实验环境
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE    9.2.0.1.0       Production
TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production

SQL> select force_logging from v$database;

FOR
---
NO

二、Nologging操作

1.在primary上执行
SQL> create table test nologging tablespace test as select * from all_objects where rownum<1001;

Table created.

2.归档当前日志
SQL> alter system archive log current;

System altered.

3.在备库,等刚才传过来的日志应用后,启动到read only
SQL> alter database recover managed standby database finish;

Database altered.

SQL> alter database open read only;

Database altered.

4.执行查询
SQL> select * from test;
select * from test
              *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 8, block # 10)
ORA-01110: data file 8: 'D:/ORACLE/ORADATA/TEST/TEST01.DBF'
ORA-26040: Data block was loaded using the NOLOGGING option

可以看到,主库的nologging操作不会无法传递到备库来,这样就会造成主备库的数据不一致,丢失了数据。

三、处理方法
在主库上,将受nologging操作影响的datafile做个热备,然后copy到备库覆盖原来的,再重新应用日志

1.查找受nologging操作影响的datafile
SQL> select a.file_name,a.tablespace_name,b.unrecoverable_change# from dba_data_
files a,v$datafile b where a.file_id=b.file#;

FILE_NAME                                TABLESPACE UNRECOVERABLE_CHANGE#
---------------------------------------- ---------- ---------------------
D:/ORACLE/ORADATA/NING/SYSTEM01.DBF      SYSTEM                         0
D:/ORACLE/ORADATA/NING/UNDOTBS01.DBF     UNDOTBS1                       0
D:/ORACLE/ORADATA/NING/CWMLITE01.DBF     CWMLITE                        0
D:/ORACLE/ORADATA/NING/EXAMPLE01.DBF     EXAMPLE                        0
D:/ORACLE/ORADATA/NING/INDX01.DBF        INDX                                    0
D:/ORACLE/ORADATA/NING/TOOLS01.DBF       TOOLS                          0
D:/ORACLE/ORADATA/NING/USERS01.DBF       USERS                          0
D:/ORACLE/ORADATA/NING/TEST01.DBF        TEST                      738934

8 rows selected.

2.关闭备库
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

3.从主库备份受影响的test01.dbf到备库
SQL> alter tablespace test begin backup;

Tablespace altered.

在操作系统中复制文件

SQL> alter tablespace test end backup;

Tablespace altered.

4.归档当前日志
SQL> alter system archive log current;

System altered.

5.启动备库并恢复
注意将上一不归档的日志全部copy到备库的归档目的地,需要end backup操作的日志才能将数据库恢复到一致状态
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  135338868 bytes
Fixed Size                   453492 bytes
Variable Size             109051904 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
SQL> alter database mount standby database;

Database altered.

SQL> alter database open read only;
alter database open read only
*
ERROR at line 1:
ORA-16004: backup database requires recovery
ORA-01195: online backup of file 8 needs more recovery to be consistent
ORA-01110: data file 8: 'D:/ORACLE/ORADATA/TEST/TEST01.DBF'

SQL> recover standby database;
ORA-00279: change 738991 generated at 11/22/2006 10:46:44 needed for thread 1
ORA-00289: suggestion : D:/ORACLE/ARCH/TEST/ARC00100.001
ORA-00280: change 738991 for thread 1 is in sequence #100


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 739327 generated at 11/22/2006 10:53:30 needed for thread 1
ORA-00289: suggestion : D:/ORACLE/ARCH/TEST/ARC00101.001
ORA-00280: change 739327 for thread 1 is in sequence #101
ORA-00278: log file 'D:/ORACLE/ARCH/TEST/ARC00100.001' no longer needed for
this recovery


ORA-00308: cannot open archived log 'D:/ORACLE/ARCH/TEST/ARC00101.001'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.

SQL> alter database open read only;

Database altered.

6.再在备库执行查询
SQL> select count(1) from test;

  COUNT(1)
----------
      1000

四、将主库置于force logging模式
SQL> alter database force logging;

Database altered.

SQL> select force_logging from v$database;

FOR
---
YES 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值