删除Oracle Online Redo 测试

删除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
[[email protected] 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
?
因为日志文件丢失,启动三次失败后终止实例。
可见,删除在线日志后数据库可以正常关闭,但却不能正常启动,
下面进行恢复
[[email protected] 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.
?
[[email protected] 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
[[email protected] 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并没有真正删除它,关掉使用它的进程后,才会真正删除。

下面验证:
删除在线日志
[[email protected] ~]$ rm -rf /u01/app/oracle/oradata/orcl11g/redo0*
[[email protected] ~]$ ll /u01/app/oracle/oradata/orcl11g/redo*
ls: cannot access /u01/app/oracle/oradata/orcl11g/redo*: No such file or directory
[[email protected] ~]$ 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 检查
[[email protected] ~]$ 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,下面查看日志文件在操作系统上的真正位置:
[[email protected] ~]$ cd /proc/76779/fd
[[email protected] 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
[[email protected] 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
[[email protected] fd]$ ls
[[email protected] fd]$ ll
total 0
[[email protected] fd]$ cd ..
-bash: cd: ..: No such file or directory
[[email protected] fd]$ ps -ef | grep 76779
oracle    77010  76395  0 05:39 pts/0    00:00:00 grep 76779
[[email protected] fd]$ lsof -n | grep -i deleted
随着数据库实例的关闭,Oracle 进程76779消失,所有被Oracle占用的资源全部释放。导致Online Redolog彻底被删除,数据库也就不能启动了。

原文地址:https://www.cnblogs.com/plluoye/p/8979477.html

时间: 2024-10-15 08:18:30

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

Oracle在线 redo log文件丢失后的恢复

今天一个开发库启动不了了,发过来报错一看是日志文件损坏了(见下图),接着说了一下前因后果.说是年前服务器掉电了,然后就再没有启动起来过.今天有人用才想到要处理. 先说一下大体的思路,如果损坏的redo log是INACTIVE状态的,也就是实例崩溃恢复用不到的redo log,那处理起来比较容易,直接alter database clear logfile group #;或alter database clear unarchived logfile group #;重建日志组就行了.建议重建

Oracle Net Manager 测试监听服务

前几天因为工作需要,安装了Oracle 11g,但怎么都监听不了本机.打开 PL/SQL Devloper 也登陆不了.随删除之. 今天有时间,又把Oracle 安装上了,想着怎么才能监听.经过操作,现在成功,下面是 过程: 1. 安装完ORACLE 后,进入 配置与移植工具,选择 Net Manager 2. 配置监听程序和服务命名. 我使用的协议为 TCP/IP. 主机 :127.0.0.1 .端口 : 1521. 3. 打开 CMD,输入 sqlplus.exe sys/manager a

删除oracle数据库用户

手工删除ORACLE数据库用户时常会出现会话进程仍在使用导致删除失败的情况.需要查询会话并将会话删除才能成功将数据库用户删除,比较不方便. 适用场景 自动删除oracle数据库用户 脚本代码 脚本名称:drop_user.sh #!/bin/bash function isExist_dbuser() { [ $# -ne 1 ] && { printf "Call the function isExist_dbuser error.\n";return 1;} loc

linux删除ORACLE【weber出品必属精品】

关闭数据库 sqlplus / as sysdba shutdown abort 清除oracle软件 su - oracle cd $ORACLE_BASE rm -rf * rm -rf /etc/ora* 删除之前的设置的配置文件的内容 如果之前改过版本,编辑文件 /etc/redhat-release 把Red Hat Enterprise Linux Server release 4 (Tikanga) 改成版本5 vi /etc/pam.d/login 行末删除以下内容 sessio

linux操作系统下完全删除oracle数据库

1.关掉oracle server 和 background processes ps -ef | grep ora 关掉数据库 shutdown immediate 2.关掉监听 lsnrctl  status 如果开启的话就执行lsnrctl stop 关掉 3.把$ORACLE_HOME下面的文件删掉 用dbca图形界面把数据库删掉 4.把/usr/local/bin 下的三个文件夹 dbhome oraenv coraenv删掉 rm -f dbhome  rm -f oraenv  r

Linux下完全删除Oracle

一.停止Oracle数据库服务 shutdown immediate; 二.停止监听服务 lsnrctl stop 三.用dbca命令卸载数据库实例 四.删除/usr/local/bin下的三个文件 rm –rf /usr/local/bin/coraenv rm –rf /usr/local/bin/dbhome rm –rf /usr/local/bin/oraenv 五.删除/etc下的两个文件 ls –lt|grep ora rm –rf /etc/oraInst.loc rm –rf

oracle exchange partition 测试

Exchange partition提供了一种方式,让你在表与表或分区与分区之间迁移数据,注意不是将表转换成分区或非分区的形式,而仅只是迁移表中数 据(互相迁移),由于其号称是采用了更改数据字典的方式,因此效率最高( 几乎不涉及io操作).Exchange partition适用于所有分区格式,你可以将数据从分区表迁移到非分区表,也可以从非分区表迁移至分区表. 这就给批量更新分区表的数据提供了一个很不错的思路,这里我便做一次普通表与分区表数据交换的实验. 注意:分区表不能直接与分区表交换所以 如

关于手动删除Oracle数据数据,导致Oracle无法连接处理过程

首先使用是使用: sysdba登录   sqlplus / as sysdba 在sql命令行中输入alter database open; 这个时候会报类似"ORA-01157: 无法标识/锁定数据文件 12 - 请参阅 DBWR 跟踪文件ORA-01110: 数据文件 12: 'E:\DBF\A.DBF'"的错误. 这是因为物理上删除了A.DBF文件,但是在oracle系统中关联记录并没有删除.所以我们接下来做的就是使用"alter database datafile '

删除ORACLE目录OCI.dll文件无法删除 (转)

删除ORACLE目录OCI.dll文件无法删除 今天准备把虚拟机里的10g卸载安装11g来研究一些新特性 卸载没有用自带的UnInstall工具之前看warehouse的讲课视频凭记忆手动卸载了下删除注册表,包括HKEY_LOCAL_MACHINE\SOFTWARE和HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services下的oracle目录和服务删除c:\program file\oracle目录重启系统,删除oracle文件所在的目录报错