标签:删除oracle manager 文件 err error: finish close shutdown stack
删除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 manager 文件 err error: finish close shutdown stack
原文地址:https://www.cnblogs.com/plluoye/p/8979477.html