恢复重做日志

 关闭情况下,非活动日志组成员全部损坏。此时DBA可以增加新日志组,删除原有日志组,然后打开数据库。

1)查看当前的日志状态。
SQL> select group#,thread#,sequence#,status from v$log;
    GROUP#    THREAD#  SEQUENCE# STATUS                                        
---------- ---------- ---------- ----------------                              
         1          1          7 CURRENT                                       
         2          1          5 INACTIVE                                      
         3          1          6 INACTIVE                                      

SQL> select group#,members,sequence#,status from v$log;
    GROUP#    MEMBERS  SEQUENCE# STATUS                                        
---------- ---------- ---------- ----------------                              
         1          1          7 CURRENT                                       
         2          1          5 INACTIVE                                      
         3          1          6 INACTIVE                                      

SQL> col member for a50
SQL> select group#,member,status from v$logfile;
    GROUP# MEMBER                                             STATUS           
---------- -------------------------------------------------- -------          
         3 F:\APP\YANG\ORADATA\ORACL\REDO03.LOG                                
         2 F:\APP\YANG\ORADATA\ORACL\REDO02.LOG                                
         1 F:\APP\YANG\ORADATA\ORACL\REDO01.LOG
                                

2)关闭数据库,并删除非活动的日志 模拟日志组损坏。                  

SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。

-----用os命令 删除日志组2 ,3两组
SQL> startup
ORACLE 例程已经启动。
Total System Global Area  535662592 bytes                                      
Fixed Size                  1334380 bytes                                      
Variable Size             142607252 bytes                                      
Database Buffers          385875968 bytes                                      
Redo Buffers                5844992 bytes                                      
数据库装载完毕。
ORA-00313: 无法打开日志组 2 (用于线程 1) 的成员
ORA-00312: 联机日志 2 线程 1: 'F:\APP\YANG\ORADATA\ORACL\REDO02.LOG'

3)在为数据库添加日志时 如果和以前的一样 要先将以前的删除,之后再添加日志。否则会报错。。

SQL> alter database add logfile ('f:\app\yang\oradata\oracl\redo02.log') size 50m;
alter database add logfile ('f:\app\yang\oradata\oracl\redo02.log') size 50m
*
第 1 行出现错误:
ORA-01577: 无法添加日志文件 'f:\app\yang\oradata\oracl\redo02.log' -
文件已是数据库的一部分
SQL> alter database drop logfile group 2;
----删除后,再添加
数据库已更改。
SQL> alter database add logfile ('f:\app\yang\oradata\oracl\redo02.log') size 50m;
数据库已更改。
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-00313: 无法打开日志组 3 (用于线程 1) 的成员
ORA-00312: 联机日志 3 线程 1: 'F:\APP\YANG\ORADATA\ORACL\REDO03.LOG'
SQL> alter database drop logfile group 3;
数据库已更改。
SQL> alter database add logfile ('f:\app\yang\oradata\oracl\redo03.log') size 50m;
数据库已更改。

3)打开数据库
SQL> alter database open;
数据库已更改。
SQL> select group#,member,type from v$logfile;
    GROUP# MEMBER                                   TYPE                       
---------- ---------------------------------------- -------                    
         3 F:\APP\YANG\ORADATA\ORACL\REDO03.LOG     ONLINE                     
         2 F:\APP\YANG\ORADATA\ORACL\REDO02.LOG     ONLINE                     
         1 F:\APP\YANG\ORADATA\ORACL\REDO01.LOG     ONLINE                     
SQL> select group#,members,sequence#,status from v$log;

    GROUP#    MEMBERS  SEQUENCE# STATUS                                        
---------- ---------- ---------- ----------------                              
         1          1          7 CURRENT                                       
         2          1          0 UNUSED                                        
         3          1          0 UNUSED                                        
SQL> alter system switch logfile;
系统已更改。
SQL> select group#,members,sequence#,status from v$log;
    GROUP#    MEMBERS  SEQUENCE# STATUS                                        
---------- ---------- ---------- ----------------                              
         1          1          7 ACTIVE                                        
         2          1          8 CURRENT                                       
         3          1          0 UNUSED                                        
SQL> alter system switch logfile;
系统已更改。
SQL> select group#,members,sequence#,status from v$log;
    GROUP#    MEMBERS  SEQUENCE# STATUS                                        
---------- ---------- ---------- ----------------                              
         1          1          7 ACTIVE                                        
         2          1          8 ACTIVE                                        
         3          1          9 CURRENT
                                       


 

上一篇:Arista思科网络专利案,Arista又赢一回合


下一篇:OpenStack踩坑记录