删除Oracle Online Redo 测试
SQL> select * from v$log;

  GROUP#   THREAD# SEQUENCE#     BYTES BLOCKSIZE   MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- ---------- --- --------
        1          1          4   52428800        512          1 NO CURRENT
        2          1          2   52428800        512          1 NO INACTIVE
        3          1          3   52428800        512          1 NO INACTIVE
删除在线日志
SQL> !rm -rf /u01/app/oracle/oradata/orcl11g/redo0*

SQL> !ls -l /u01/app/oracle/oradata/orcl11g/redo0*
ls: cannot access /u01/app/oracle/oradata/orcl11g/redo0*: No such file or directory

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@cym1 trace]$ ll /u01/app/oracle/oradata/orcl11g/redo*
ls: cannot access /u01/app/oracle/oradata/orcl11g/redo*: No such file or directory
查看删除日志后对数据库操作的影响:
SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

....
SQL> select * from v$log;

  GROUP#   THREAD# SEQUENCE#     BYTES BLOCKSIZE   MEMBERS ARC STATUS          
---------- ---------- ---------- ---------- ---------- ---------- --- ----------------
        1          1         10   52428800        512          1 NO INACTIVE        
        2          1         11   52428800        512          1 NO INACTIVE        
        3          1         12   52428800        512          1 NO CURRENT        

SQL> select * from v$logfile;

  GROUP# STATUS TYPE   MEMBER                                             IS_
---------- ------- ------- -------------------------------------------------- ---
        2         ONLINE /u01/app/oracle/oradata/orcl11g/redo02.log         NO
        3         ONLINE /u01/app/oracle/oradata/orcl11g/redo03.log         NO
        1         ONLINE /u01/app/oracle/oradata/orcl11g/redo01.log         NO


SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> select * from v$log;

  GROUP#   THREAD# SEQUENCE#     BYTES BLOCKSIZE   MEMBERS ARC STATUS        
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------
        1          1         13   52428800        512          1 NO INACTIVE      
        2          1         14   52428800        512          1 NO CURRENT        
        3          1         12   52428800        512          1 NO INACTIVE      

可见删除在线日志不影响数据库正常操作。 对数据库启动关闭的影响:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  409194496 bytes
Fixed Size                  2253744 bytes
Variable Size             310381648 bytes
Database Buffers           92274688 bytes
Redo Buffers                4284416 bytes
SQL> alter database mount;

Database altered.

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 76747
Session ID: 1 Serial number: 3

--查看日志
alter database open
Errors in file /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/trace/orcl11g_lgwr_76732.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/orcl11g/redo01.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/trace/orcl11g_lgwr_76732.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/orcl11g/redo01.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/trace/orcl11g_ora_76747.trc:
ORA-00313: open failed for members of log group 1 of thread
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/orcl11g/redo01.log'
USER (ospid: 76747): terminating the instance due to error 313

因为日志文件丢失,启动三次失败后终止实例。
可见,删除在线日志后数据库可以正常关闭,但却不能正常启动,
下面进行恢复
[oracle@cym1 trace]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Feb 26 04:57:55 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL11G (DBID=1057360211, not open)

RMAN> alter database open resetlogs;

using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 02/26/2018 04:58:18
ORA-01139: RESETLOGS option only valid after an incomplete database recovery

RMAN> recover database;

Starting recover at 2018-02-26 04:58:48
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 2018-02-26 04:58:49

RMAN> alter database open resetlogs;

database opened

RMAN> quit

Recovery Manager complete.

[oracle@cym1 trace]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Feb 26 04:59:00 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from v$log;

  GROUP#   THREAD# SEQUENCE#     BYTES BLOCKSIZE   MEMBERS ARC STATUS          
---------- ---------- ---------- ---------- ---------- ---------- --- ----------------
        1          1          1   52428800        512          1 NO CURRENT          
        2          1          0   52428800        512          1 YES UNUSED          
        3          1          0   52428800        512          1 YES UNUSED          

SQL> select * from v$logfile;

  GROUP# STATUS TYPE   MEMBER                                             IS_
---------- ------- ------- -------------------------------------------------- ---
        2         ONLINE /u01/app/oracle/oradata/orcl11g/redo02.log         NO
        3         ONLINE /u01/app/oracle/oradata/orcl11g/redo03.log         NO
        1         ONLINE /u01/app/oracle/oradata/orcl11g/redo01.log         NO

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@cym1 trace]$ ll /u01/app/oracle/oradata/orcl11g/redo*
-rw-r----- 1 oracle oinstall 52429312 Feb 26 04:59 /u01/app/oracle/oradata/orcl11g/redo01.log
-rw-r----- 1 oracle oinstall 52429312 Feb 26 04:59 /u01/app/oracle/oradata/orcl11g/redo02.log
-rw-r----- 1 oracle oinstall 52429312 Feb 26 04:59 /u01/app/oracle/oradata/orcl11g/redo03.log
通过RestLogs 方式打开数据库后,恢复完成,在线日志文件已自行创建。 任何数据的变更数据库都会先记录redo,才能写到数据文件。但是redo 日志都丢了,怎么数据库还能正常操作呢?不应该直接宕机吗?
推测是因为Linux删除文件的机制导致,删除一个正在被使用的文件,Linux并没有真正删除它,关掉使用它的进程后,才会真正删除。 下面验证:
删除在线日志
[oracle@cym1 ~]$ rm -rf /u01/app/oracle/oradata/orcl11g/redo0*
[oracle@cym1 ~]$ ll /u01/app/oracle/oradata/orcl11g/redo*
ls: cannot access /u01/app/oracle/oradata/orcl11g/redo*: No such file or directory
[oracle@cym1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Feb 26 05:27:15 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select group#,thread#,sequence#,status from v$log;

  GROUP#   THREAD# SEQUENCE# STATUS
---------- ---------- ---------- ----------------
        1          1          1 ACTIVE
        2          1          2 ACTIVE
        3          1          3 CURRENT

SQL> alter system switch logfile;

System altered.
.....
SQL> select group#,thread#,sequence#,status from v$log;

  GROUP#   THREAD# SEQUENCE# STATUS
---------- ---------- ---------- ----------------
        1          1          7 ACTIVE
        2          1          8 CURRENT
        3          1          6 ACTIVE

SQL>
2. lsof 检查
[oracle@cym1 ~]$ lsof -n | grep -i deleted
oracle    76779   oracle 258u     REG              253,0   52429312 800980 /u01/app/oracle/oradata/orcl11g/redo01.log (deleted)
oracle    76779   oracle 259u     REG              253,0   52429312 800981 /u01/app/oracle/oradata/orcl11g/redo02.log (deleted)
oracle    76779   oracle 260u     REG              253,0   52429312 800982 /u01/app/oracle/oradata/orcl11g/redo03.log (deleted)
lsof 用来查看操作系统上被打开的文件,从以上来看在线日志文件仍然处于打开状态,说明还未被真正删除。
进程ID为 76779,下面查看日志文件在操作系统上的真正位置:
[oracle@cym1 ~]$ cd /proc/76779/fd
[oracle@cym1 fd]$ ls
0  1  10  11  12  13  14  2  256  257  258  259  260  261  262  263  264  265  266  267  268  3  4  5  6  7  8  9
[oracle@cym1 fd]$ ll
total 0
lr-x------ 1 oracle oinstall 64 Feb 26 05:29 0 -> /dev/null
l-wx------ 1 oracle oinstall 64 Feb 26 05:29 1 -> /dev/null
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 10 -> /u01/app/oracle/product/11.2.0/dbhome_1/dbs/lkORCL11G
lr-x------ 1 oracle oinstall 64 Feb 26 05:29 11 -> /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/mesg/oraus.msb
l-wx------ 1 oracle oinstall 64 Feb 26 05:29 12 -> /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/trace/orcl11g_lgwr_76779.trc
l-wx------ 1 oracle oinstall 64 Feb 26 05:29 13 -> /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/trace/orcl11g_lgwr_76779.trm
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 14 -> socket:[748707]
l-wx------ 1 oracle oinstall 64 Feb 26 05:29 2 -> /dev/null
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 256 -> /u01/app/oracle/oradata/orcl11g/control01.ctl
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 257 -> /u01/app/oracle/fast_recovery_area/orcl11g/control02.ctl
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 258 -> /u01/app/oracle/oradata/orcl11g/redo01.log (deleted)
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 259 -> /u01/app/oracle/oradata/orcl11g/redo02.log (deleted)
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 260 -> /u01/app/oracle/oradata/orcl11g/redo03.log (deleted)
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 261 -> /u01/app/oracle/oradata/orcl11g/system01.dbf
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 262 -> /u01/app/oracle/oradata/orcl11g/sysaux01.dbf
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 263 -> /u01/app/oracle/oradata/orcl11g/undotbs01.dbf
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 264 -> /u01/app/oracle/oradata/orcl11g/users01.dbf
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 265 -> /u01/app/oracle/oradata/orcl11g/mgmt_depot.dbf
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 266 -> /u01/app/oracle/oradata/orcl11g/mgmt.dbf
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 267 -> /u01/app/oracle/oradata/orcl11g/mgmt_ad4j.dbf
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 268 -> /u01/app/oracle/oradata/orcl11g/temp01.dbf
lr-x------ 1 oracle oinstall 64 Feb 26 05:29 3 -> /dev/null
lr-x------ 1 oracle oinstall 64 Feb 26 05:29 4 -> /dev/null
lr-x------ 1 oracle oinstall 64 Feb 26 05:29 5 -> /dev/null
lr-x------ 1 oracle oinstall 64 Feb 26 05:29 6 -> /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/mesg/oraus.msb
lr-x------ 1 oracle oinstall 64 Feb 26 05:29 7 -> /proc/76779/fd
lr-x------ 1 oracle oinstall 64 Feb 26 05:29 8 -> /dev/zero
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 9 -> /u01/app/oracle/product/11.2.0/dbhome_1/dbs/hc_orcl11g.dat
可见在线日志对应的文件258/259/260还在,而且在数据库关闭前这3个资源是不会被释放的。这就解释了为什么删除在线日志文件不影响数据库正常操作。
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 258 -> /u01/app/oracle/oradata/orcl11g/redo01.log (deleted)
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 259 -> /u01/app/oracle/oradata/orcl11g/redo02.log (deleted)
lrwx------ 1 oracle oinstall 64 Feb 26 05:29 260 -> /u01/app/oracle/oradata/orcl11g/redo03.log (deleted)
下面关闭数据库,看看文件是不是被删除了
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
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@cym1 fd]$ ls
[oracle@cym1 fd]$ ll
total 0
[oracle@cym1 fd]$ cd ..
-bash: cd: ..: No such file or directory
[oracle@cym1 fd]$ ps -ef | grep 76779
oracle    77010  76395  0 05:39 pts/0    00:00:00 grep 76779
[oracle@cym1 fd]$ lsof -n | grep -i deleted
随着数据库实例的关闭,Oracle 进程76779消失,所有被Oracle占用的资源全部释放。导致Online Redolog彻底被删除,数据库也就不能启动了。

删除Oracle Online Redo 测试的更多相关文章

  1. Oracle Flushback 学习测试

    Oracle Flushback 学习测试:三思笔记 Flashback恢复 从9i开始,利用oracle查询的多版本一致的特点,实现从回滚段中读取一定时间内在表中操作的数据,被称为 flashbac ...

  2. 【转】ORACLE的REDO与UNDO

    一.什么是redo?redo:oracle在在线或者归档重做日志文件中的记录的信息,外以出现失败时可以利用这些数据来"重放"事务.每个oracle数据都至少有二个在线重做日志组,每 ...

  3. 转--Oracle 审计和测试操作

    http://blog.itpub.net/21605631/viewspace-759640/转 Oracle 审计和测试操作 :: 分类: Linux 1.1 相关参数 AUDIT_SYS_OPE ...

  4. 【原创】oracle的tpc-c测试及方法

    大家好,很高兴来到博客园分享自己的所见所得.希望和大家多多交流,共同进步. 本文重点在于简介使用BenchmarkSQL对oracle进行tpcc的测试步骤,只是一个简单入门的过程. 开源测试工具:B ...

  5. 如何使用swingbench进行oracle数据库压力测试

    如何使用swingbench进行oracle数据库压力测试 2014-10-06 08:09:02 标签:oracle 数据库压力测试 swingbench 原创作品,允许转载,转载时请务必以超链接形 ...

  6. 删除ORACLE的步骤

    1.关闭oracle所有的服务.可以在windows的服务管理器中关闭: 2.打开注册表:regedit 打开路径: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlS ...

  7. Linux下如何删除Oracle

    一. 停止Oracle数据库服务 shutdown immediate 二. 停止监听服务 lsnrctl stop 三. 用dbca卸载数据库实例 四. 删除相关文件  -->> 如果只 ...

  8. 彻底删除oracle的方法

    环境:Windows 2000+ORACLE,其他环境类似 假设ORACLE安装路径为:D:\ORACLE ,其他路径操作类似 方法: 1.开始->设置->控制面板->管理工具-&g ...

  9. ORACLE 数据库简单测试

    ORACLE 数据库简单测试 操作系统:Windows 7 – ORACLE:oracle database 10.2.0.4 一.目的 测试 启动监听程序.数据库  非同一个用户的情况,用户是否可以 ...

随机推荐

  1. Transformation functionality for the String class

    String类的转换功能: package com.itheima_05; /* * String类的转换功能: * char[] toCharArray():把字符串转换为字符数组 * String ...

  2. Pig join用法举例

    jnd = join a by f1, b by f2;   join操作默认的是内连接,只有两边都匹配才会保留   需要用null补位的那边需要知道它的模式: 如果是左外连接,需要知道右边的数据集的 ...

  3. Android8.0适配那点事(一)

    最近有小伙伴说,7.0适配整了一波,现在又要来适配8.0,真是一波未平一波又起 但是作为开发者来说,学无止境,不跟上时代的步伐,肯定会被时代所淘汰... 话说Android P已经在路上了,你准备好了 ...

  4. 直到黎明 Until Dawn 后感

    直到黎明 会免游戏.白金神作.近些年的恐怖电影都有游戏化的趋势,韩国的某岩vlog,美国的真心话大冒险,都把观众作为meta代入游戏,几乎模糊了游戏与游戏的边界,直到黎明这部电影,与当年的暴雨和超凡双 ...

  5. 从Azure上构建Linux应用程序映像

    下图描述了总体的虚拟机的VHD映像生成以及发布到 Azure Azure 镜像市场的全过程: 具体步骤如下: 从Azure管理平台上Linux申请虚拟机, 安装和配置您要发布的应用软件产品,制作成映像 ...

  6. 关于解决sql2012编辑器对象名无效问题

    出现以下情况: 解决办法: 选择“编辑”——“Intellisense”——“刷新本地缓存” 或者按Ctrl+Shift+R组合键

  7. 固定UILabel宽度分行显示

    固定UILabel宽度分行显示 这种小伎俩估计都被用烂了,笔者给大家提供一个category文件,供大家简单设置哦. 各种富文本效果哦(普通文本也是可以用的呢): 3行,固定宽度200 2行,固定宽度 ...

  8. The expression of type Integer is unboxed into int

    问题:The expression of type Integer is unboxed into int 原因:java的包装类,方法里面要的是Integer,传入的参数确实int类型 解决方案: ...

  9. jQuery插件实例二:年华时代插件ReturnTop回到首页

    这个插件功能在于当网页内容高度很高时,方便用户快速回到顶部.核心在于对屏幕高度的获取,定时器的使用,在引用代码后,只使用$.nhsd.returnTop();即可实现效果 效果图: 代码: ; fun ...

  10. Springboot+RestTemplate 简单使用

        spring框架提供的RestTemplate类可用于在应用中调用rest服务,它简化了与http服务的通信方式,统一了RESTful的标准,封装了http链接, 我们只需要传入url及返回值 ...