热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

模拟ORA-26040:DatablockwasloadedusingtheNOLOGGINGoption

我们知道通过设置nologging选项,可以加快oracle的某些操作的执行速度,这在执行某些维护任务时是非常有用的,但是该选项也很危险,如果使用不当,就可能导致数据库发生ORA-26040错误。首先,构造使用环境,SQL>selecttablespace_name,logging,force_logging

我们知道通过设置nologging选项,可以加快oracle的某些操作的执行速度,这在执行某些维护任务时是非常有用的,但是该选项也很危险,如果使用不当,就可能导致数据库发生ORA-26040错误。

首先,构造使用环境,

SQL> select tablespace_name,logging,force_logging from dba_tablespaces;

TABLESPACE_NAME 	       LOGGING	 FOR
------------------------------ --------- ---
SYSTEM			       LOGGING	 NO
UNDOTBS1		       LOGGING	 NO
SYSAUX			       LOGGING	 NO
TEMP			       NOLOGGING NO
USERS			       LOGGING	 NO
LOGGING 		       LOGGING	 NO

6 rows selected.
SQL> show user
USER is "LOGGING"
SQL> select table_name,logging from user_tables;

TABLE_NAME		       LOG
------------------------------ ---
SOURCE			       YES
NOLOG			       NO
NOLOG1			       NO

我们使用create table table_name nologging as select * from user_tables创建了表nolog和nolog1。在创建表之前,先使用rman进行全库的备份,表创建完成后,关闭数据库,并使用备份来恢复,结果如下:

[oraten@yue bdump]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on 星期四 11月 13 17:21:02 2014

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: ORATEN (DBID=3658365464, not open)

RMAN> list backup;

using target database control file instead of recovery catalog

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
97      Full    565.31M    DISK        00:00:41     2014-11-12 09:34:45
        BP Key: 65   Status: AVAILABLE  Compressed: NO  Tag: TAG20141112T093404
        Piece Name: /home/app/oraten/flash_recovery_area/ORATEN/backupset/2014_11_12/o1_mf_nnndf_TAG20141112T093404_b65g8fc3_.bkp
  List of Datafiles in backup set 97
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 1276159    2014-11-12 09:34:04 /home/app/oraten/oradata/oraten/system01.dbf
  2       Full 1276159    2014-11-12 09:34:04 /home/app/oraten/oradata/oraten/undotbs01.dbf
  3       Full 1276159    2014-11-12 09:34:04 /home/app/oraten/oradata/oraten/sysaux01.dbf
  4       Full 1276159    2014-11-12 09:34:04 /home/app/oraten/oradata/oraten/users01.dbf
  5       Full 1276159    2014-11-12 09:34:04 /home/app/oraten/oradata/oraten/logging01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
98      Full    6.86M      DISK        00:00:02     2014-11-12 09:34:52
        BP Key: 66   Status: AVAILABLE  Compressed: NO  Tag: TAG20141112T093404
        Piece Name: /home/app/oraten/flash_recovery_area/ORATEN/backupset/2014_11_12/o1_mf_ncsnf_TAG20141112T093404_b65g9vx2_.bkp
  Control File Included: Ckp SCN: 1276545      Ckp time: 2014-11-12 09:34:50
  SPFILE Included: Modification time: 2014-11-12 09:14:00

RMAN> restore database;

Starting restore at 2014-11-13 17:21:19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /home/app/oraten/oradata/oraten/system01.dbf
restoring datafile 00002 to /home/app/oraten/oradata/oraten/undotbs01.dbf
restoring datafile 00003 to /home/app/oraten/oradata/oraten/sysaux01.dbf
restoring datafile 00004 to /home/app/oraten/oradata/oraten/users01.dbf
restoring datafile 00005 to /home/app/oraten/oradata/oraten/logging01.dbf
channel ORA_DISK_1: reading from backup piece /home/app/oraten/flash_recovery_area/ORATEN/backupset/2014_11_12/o1_mf_nnndf_TAG20141112T093404_b65g8fc3_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/app/oraten/flash_recovery_area/ORATEN/backupset/2014_11_12/o1_mf_nnndf_TAG20141112T093404_b65g8fc3_.bkp tag=TAG20141112T093404
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 2014-11-13 17:21:45

RMAN> recover database;

Starting recover at 2014-11-13 17:21:50
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 53 is already on disk as file /home/app/oraten/flash_recovery_area/ORATEN/archivelog/2014_11_12/o1_mf_1_53_b65gj7m2_.arc
archive log thread 1 sequence 54 is already on disk as file /home/app/oraten/flash_recovery_area/ORATEN/archivelog/2014_11_12/o1_mf_1_54_b65kj77p_.arc
archive log thread 1 sequence 55 is already on disk as file /home/app/oraten/flash_recovery_area/ORATEN/archivelog/2014_11_13/o1_mf_1_55_b68w6tft_.arc
archive log filename=/home/app/oraten/flash_recovery_area/ORATEN/archivelog/2014_11_12/o1_mf_1_53_b65gj7m2_.arc thread=1 sequence=53
media recovery complete, elapsed time: 00:00:14
Finished recover at 2014-11-13 17:22:05

RMAN> alter database open;

database opened

RMAN> 

alert 文件中的内容如下:

Thu Nov 13 17:21:20 CST 2014
Full restore complete of datafile 5 /home/app/oraten/oradata/oraten/logging01.dbf.  Elapsed time: 0:00:00 
  checkpoint is 1276159
Full restore complete of datafile 4 /home/app/oraten/oradata/oraten/users01.dbf.  Elapsed time: 0:00:00 
  checkpoint is 1276159
  last deallocation scn is 672889
Full restore complete of datafile 2 /home/app/oraten/oradata/oraten/undotbs01.dbf.  Elapsed time: 0:00:01 
  checkpoint is 1276159
  last deallocation scn is 1252646
Full restore complete of datafile 3 /home/app/oraten/oradata/oraten/sysaux01.dbf.  Elapsed time: 0:00:03 
  checkpoint is 1276159
  last deallocation scn is 842824
Thu Nov 13 17:21:41 CST 2014
Full restore complete of datafile 1 /home/app/oraten/oradata/oraten/system01.dbf.  Elapsed time: 0:00:10 
  checkpoint is 1276159
  last deallocation scn is 399219
Thu Nov 13 17:21:51 CST 2014
alter database recover datafile list clear
Thu Nov 13 17:21:51 CST 2014
Completed: alter database recover datafile list clear
Thu Nov 13 17:21:51 CST 2014
alter database recover datafile list
 1 , 2 , 3 , 4 , 5
Completed: alter database recover datafile list
 1 , 2 , 3 , 4 , 5
Thu Nov 13 17:21:51 CST 2014
alter database recover if needed
 start
Media Recovery Start
 parallel recovery started with 2 processes
ORA-279 signalled during: alter database recover if needed
 start
...
Thu Nov 13 17:21:51 CST 2014
alter database recover logfile '/home/app/oraten/flash_recovery_area/ORATEN/archivelog/2014_11_12/o1_mf_1_53_b65gj7m2_.arc'
Thu Nov 13 17:21:51 CST 2014
Media Recovery Log /home/app/oraten/flash_recovery_area/ORATEN/archivelog/2014_11_12/o1_mf_1_53_b65gj7m2_.arc
Thu Nov 13 17:21:52 CST 2014
Recovery of Online Redo Log: Thread 1 Group 3 Seq 54 Reading mem 0
  Mem# 0: /home/app/oraten/oradata/oraten/redo03.log
Thu Nov 13 17:21:54 CST 2014
Recovery of Online Redo Log: Thread 1 Group 1 Seq 55 Reading mem 0
  Mem# 0: /home/app/oraten/oradata/oraten/redo01.log
Thu Nov 13 17:21:59 CST 2014
Recovery of Online Redo Log: Thread 1 Group 2 Seq 56 Reading mem 0
  Mem# 0: /home/app/oraten/oradata/oraten/redo02.log
Thu Nov 13 17:22:02 CST 2014
Media Recovery Complete (oraten)
Completed: alter database recover logfile '/home/app/oraten/flash_recovery_area/ORATEN/archivelog/2014_11_12/o1_mf_1_53_b65gj7m2_.arc'
Thu Nov 13 17:22:11 CST 2014
alter database open
Thu Nov 13 17:22:11 CST 2014
LGWR: STARTING ARCH PROCESSES
ARC0 started with pid=21, OS id=6628
Thu Nov 13 17:22:11 CST 2014
ARC0: Archival started
ARC1: Archival started
LGWR: STARTING ARCH PROCESSES COMPLETE
ARC1 started with pid=22, OS id=6630
Thu Nov 13 17:22:12 CST 2014
Thread 1 opened at log sequence 56
  Current log# 2 seq# 56 mem# 0: /home/app/oraten/oradata/oraten/redo02.log
Successful open of redo thread 1
Thu Nov 13 17:22:12 CST 2014
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Thu Nov 13 17:22:12 CST 2014
ARC0: Becoming the 'no FAL' ARCH
ARC0: Becoming the 'no SRL' ARCH
Thu Nov 13 17:22:12 CST 2014
ARC1: Becoming the heartbeat ARCH
Thu Nov 13 17:22:12 CST 2014
SMON: enabling cache recovery
Thu Nov 13 17:22:12 CST 2014
Successfully onlined Undo Tablespace 1.
Thu Nov 13 17:22:12 CST 2014
SMON: enabling tx recovery
Thu Nov 13 17:22:12 CST 2014
Database Characterset is AL32UTF8
Opening with internal Resource Manager plan 
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
QMNC started with pid=23, OS id=6632
Thu Nov 13 17:22:12 CST 2014
db_recovery_file_dest_size of 2048 MB is 28.34% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Thu Nov 13 17:22:13 CST 2014
Completed: alter database open
从上面我们看出,一切正常,数据库成功恢复了,但是:

SQL> conn logging/logging
Connected.
SQL> select * from nolog;
select * from nolog
              *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 5, block # 44)
ORA-01110: data file 5: '/home/app/oraten/oradata/oraten/logging01.dbf'
ORA-26040: Data block was loaded using the NOLOGGING option

数据库报错,看来恢复成功并不一定数据库就是正常的。
再看一下,日志的的dump内容,

[oraten@yue udump]$ strings oraten_ora_10509.trc | grep oad
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
Direct Loader invalidate block range redo entry
看来日志中对nologging是有记录的,在rman恢复时,会根据记录将某些块设置为逻辑损坏。





推荐阅读
  • PHP 5.2.5 安装与配置指南
    本文详细介绍了 PHP 5.2.5 的安装和配置步骤,帮助开发者解决常见的环境配置问题,特别是上传图片时遇到的错误。通过本教程,您可以顺利搭建并优化 PHP 运行环境。 ... [详细]
  • 构建基于BERT的中文NL2SQL模型:一个简明的基准
    本文探讨了将自然语言转换为SQL语句(NL2SQL)的任务,这是人工智能领域中一项非常实用的研究方向。文章介绍了笔者在公司举办的首届中文NL2SQL挑战赛中的实践,该比赛提供了金融和通用领域的表格数据,并标注了对应的自然语言与SQL语句对,旨在训练准确的NL2SQL模型。 ... [详细]
  • Hadoop入门与核心组件详解
    本文详细介绍了Hadoop的基础知识及其核心组件,包括HDFS、MapReduce和YARN。通过本文,读者可以全面了解Hadoop的生态系统及应用场景。 ... [详细]
  • 本文介绍了如何使用 PostgreSQL 的 `UPDATE ... FROM` 语法,通过映射表实现对多行记录进行高效的批量更新。这种方法不仅适用于单列更新,还支持多列的同时更新。 ... [详细]
  • 本文详细分析了Hive在启动过程中遇到的权限拒绝错误,并提供了多种解决方案,包括调整文件权限、用户组设置以及环境变量配置等。 ... [详细]
  • 在即将迎来26岁生日之际,作者的人生陷入了低谷。经过近三年的硕士学习后,最终决定退学,并且面临没有工作经验的困境。尽管如此,作者依然坚定地选择为自己的人生负责。 ... [详细]
  • 使用Python在SAE上开发新浪微博应用的初步探索
    最近重新审视了新浪云平台(SAE)提供的服务,发现其已支持Python开发。本文将详细介绍如何利用Django框架构建一个简单的新浪微博应用,并分享开发过程中的关键步骤。 ... [详细]
  • 本文详细介绍了美国最具影响力的十大财团,包括洛克菲勒、摩根、花旗银行等。这些财团在历史发展过程中逐渐形成,并对美国的经济、政治和社会产生深远影响。 ... [详细]
  • 基于KVM的SRIOV直通配置及性能测试
    SRIOV介绍、VF直通配置,以及包转发率性能测试小慢哥的原创文章,欢迎转载目录?1.SRIOV介绍?2.环境说明?3.开启SRIOV?4.生成VF?5.VF ... [详细]
  • 深入探讨CPU虚拟化与KVM内存管理
    本文详细介绍了现代服务器架构中的CPU虚拟化技术,包括SMP、NUMA和MPP三种多处理器结构,并深入探讨了KVM的内存虚拟化机制。通过对比不同架构的特点和应用场景,帮助读者理解如何选择最适合的架构以优化性能。 ... [详细]
  • 解决JAX-WS动态客户端工厂弃用问题并迁移到XFire
    在处理Java项目中的JAR包冲突时,我们遇到了JaxWsDynamicClientFactory被弃用的问题,并成功将其迁移到org.codehaus.xfire.client。本文详细介绍了这一过程及解决方案。 ... [详细]
  • 本题通过将每个矩形视为一个节点,根据其相对位置构建拓扑图,并利用深度优先搜索(DFS)或状态压缩动态规划(DP)求解最小涂色次数。本文详细解析了该问题的建模思路与算法实现。 ... [详细]
  • 本题探讨如何通过最大流算法解决农场排水系统的设计问题。题目要求计算从水源点到汇合点的最大水流速率,使用经典的EK(Edmonds-Karp)和Dinic算法进行求解。 ... [详细]
  • 在网页开发中,页面加载速度是一个关键的用户体验因素。为了提升加载效率,避免在PageLoad事件中进行大量数据绑定操作,可以采用异步加载和特定控件来优化页面加载过程。 ... [详细]
  • 本文介绍了一种根据用户选择动态切换屏幕界面的方法,通过定义不同的选择块(Selection Block),实现灵活的用户交互体验。 ... [详细]
author-avatar
呼吸的雨儿作_741
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有