(1)逻辑坏块分析
数据库开启foce logging的重要性,可以避免由于直接路径加载 和 no logging导致RMAN恢复出现大量逻辑坏块。
ORA-26040: 数据块是使用 NOLOGGING 选项加载的+
SQL> show user 表已创建。 SQL> create table t2 as select * from dba_objects; 表已创建。 SQL> connect / as sysdba 表已创建。 SQL> connect nmos/123 表已更改。 SQL> insert /*+append*/ into t1 select * from dba_objects; 已创建 72933 行。 SQL> commit; 提交完成。 SQL> insert into t2 select * from dba_objects; 已创建 72933 行。 SQL> commit; 提交完成。 SQL> connect / as sysdba 表已创建。 SQL> alter table t3 nologging; 表已更改。 SQL> alter table t4 nologging; 表已更改。 SQL> insert /*+append*/ into t3 select * from dba_objects; 已创建 72934 行。 SQL> commit; 提交完成。 SQL> insert into t4 select * from dba_objects; 已创建 72934 行。 SQL> commit; 提交完成。 SQL> select UNRECOVERABLE_CHANGE# from v$datafile; UNRECOVERABLE_CHANGE# 已选择 9 行。 SQL> SQL> startup force mount; Total System Global Area 5066719232 bytes C:\Users\Administrator>rman target / 恢复管理器: Release 12.2.0.1.0 - Production on 星期一 12月 17 10:37:24 2018 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. 已连接到目标数据库: ORCL (DBID=1514004854, 未打开) RMAN> restore database; 从位于 17-12月-18 的 restore 开始 通道 ORA_DISK_1: 正在开始还原数据文件备份集
RMAN> recover database; 从位于 17-12月-18 的 recover 开始 正在开始介质的恢复 在 17-12月-18 完成了 recover RMAN> ALTER DATABASE open; 已处理语句 RMAN> exit
C:\Users\Administrator>sqlplus / as sysdba SQL*Plus: Release 12.2.0.1.0 Production on 星期一 12月 17 10:38:18 2018 Copyright (c) 1982, 2016, Oracle. All rights reserved.
SQL> select count(1) from t3; COUNT(1) SQL> select count(1) from t4; COUNT(1) SQL> connect nmos/123
COUNT(1) SQL> |
解决手段:开启force logging模式。
SQL> alter database force logging;
数据库已更改。
SQL> create table forcelogging nologging as select * from dba_objects;
表已创建。
SQL> insert /*+append*/ into forcelogging select * from dba_objects;
已创建 72871 行。
SQL> commit;
提交完成。 C:\Users\Administrator>sqlplus nmos/123
SQL*Plus: Release 12.2.0.1.0 Production on 星期一 12月 24 15:56:38 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
上次成功登录时间: 星期一 12月 24 2018 15:52:28 +08:00
连接到: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> SQL> SQL> SQL> select count(1) from forcelogging;
COUNT(1) ---------- 145741
SQL> select count(1) from t1; select count(1) from t1 * 第 1 行出现错误: ORA-01578: ORACLE 数据块损坏 (文件号 11, 块号 4014) ORA-01110: 数据文件 11: 'F:\APP\ADMINISTRATOR\VIRTUAL\ORADATA\ORCL\USERS00221.DBF' ORA-26040: 数据块是使用 NOLOGGING 选项加载的
SQL>
|
- 结论
1 开始force logging模式可以避免一些nologging+直接路径加载等不可恢复的操作导致的逻辑坏块问题。
2 对于sys用户的对象事务操作强制日志。
3 普通用户对象事务没有强制日志。