Oracle数据恢复情景2-模拟redo log丢失(2)

oracle redo log(当前或非当前日志)损坏之后的db恢复(2)
(2)数据库异常关闭
1.查看当前日志情况
SQL> col GROUP# format 9;
SQL> col TYPE format a8;
SQL> col MEMBER format a40;
SQL> col STATUS format a8;
SQL> select t1.GROUP#,t1.MEMBER,t1.TYPE,t2.STATUS,t2.bytes from v$logfile t1,v$log t2 where t1.GROUP#=t2.GROUP#;
GROUP# MEMBER                                   TYPE     STATUS        BYTES
------ ---------------------------------------- -------- -------- ----------
     3 /opt/oracle/oradata/ora/redo03.log   ONLINE   CURRENT    52428800
     2 /opt/oracle/oradata/ora/redo02.log   ONLINE   INACTIVE   52428800
     1 /opt/oracle/oradata/ora/redo01.log   ONLINE   INACTIVE   52428800
2.模拟数据库活动--删除数据
$ cat del.sql 
delete from DBA_temp1 where rownum<100;
commit;
SQL> @del.sql
SQL> select count(1) from uas.dba_temp1;

  COUNT(1)
----------
     72188

3.删除当前redo log
$ mv redo03.log ..

4.在删除当前redo log以后,继续删除数据
SQL> @del.sql
SQL> select count(1) from uas.dba_temp1;

  COUNT(1)
----------
     71297

SQL> 

5.切换日志
SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile; 
hanging...

6.DB粗暴关闭
SQL> shutdown abort
ORACLE instance shut down.

7.启动DB
SQL> startup
ORACLE instance started.

Total System Global Area 6647513088 bytes
Fixed Size                  2239032 bytes
Variable Size            5049943496 bytes
Database Buffers         1577058304 bytes
Redo Buffers               18272256 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 24253
Session ID: 125 Serial number: 5

SQL> 

SQL> alter database clear unarchived logfile group 3;
alter database clear unarchived logfile group 3
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

SQL>
8.此时数据库已经不能正常工作,需进行修复
SQL> alter database mount;

Database altered.

SQL> alter database clear unarchived logfile group 3;

Database altered.

SQL> alter database open;

Database altered.

SQL> 

SQL> select t1.GROUP#,t1.MEMBER,t1.TYPE,t2.STATUS,t2.bytes from v$logfile t1,v$log t2 where t1.GROUP#=t2.GROUP#;

GROUP# MEMBER                                   TYPE     STATUS        BYTES
------ ---------------------------------------- -------- -------- ----------
     3 /opt/oracle/oradata/ora/redo03.log   ONLINE   CURRENT   52428800
     2 /opt/oracle/oradata/ora/redo02.log   ONLINE   INACTIVE   52428800
     1 /opt/oracle/oradata/ora/redo01.log   ONLINE   INACTIVE   52428800
9.检查数据
SQL> select count(1) from UAS.DBA_TEMP1;

  COUNT(1)
----------
     71297

SQL> 



你可能感兴趣的:(oracle)