Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1278227
  • 博文数量: 1211
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 14340
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-09 11:20
文章分类

全部博文(1211)

文章存档

2011年(1)

2008年(1210)

我的朋友

分类: 服务器与存储

2008-06-16 19:13:08

################################                                                                     
# [1.5] 有trace,活动在线日志损坏   
################################
################################                                                             
# [1.5.1] 有trace,活动在线日志损坏,正常shutdown或是当前的数据文件  
################################
SQL> create table arch (status varchar(2));

表已创建。

SQL> alter system switch logfile;

系统已更改。

SQL> insert into arch select 'ok' from dba_objects;

已创建6166行。

SQL> commit;

提交完成。

SQL> insert into arch select 'ok' from dba_objects;

已创建6166行。

SQL> commit;

提交完成。

SQL> alter system switch logfile;

系统已更改。

SQL> insert into arch select 'no' from dba_objects;

已创建6166行。

SQL> commit;

提交完成。

SQL> select GROUP#,SEQUENCE#,archived, STATUS from v$log;

    GROUP#  SEQUENCE# ARC STATUS
---------- ---------- --- ----------------
         1          2 YES ACTIVE
         2          1 YES ACTIVE
         3          3 NO  CURRENT
    
SQL> shutdown  --正常关闭数据库
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。


此时模拟删除当前在线日志组3
SQL>
SQL>
SQL> startup nomount
ORACLE 例程已经启动。

Total System Global Area  101784276 bytes
Fixed Size                   453332 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "testdb" RESETLOGS  ARCHIVELOG
  2  --  SET STANDBY TO MAXIMIZE PERFORMANCE
  3      MAXLOGFILES 5
  4      MAXLOGMEMBERS 3
  5      MAXDATAFILES 100
  6      MAXINSTANCES 1
  7      MAXLOGHISTORY 226
  8  LOGFILE
  9    GROUP 1 'C:\ORACLE\ORADATA\testdb\REDO01.LOG'  SIZE 100M,
10    GROUP 2 'C:\ORACLE\ORADATA\testdb\REDO02.LOG'  SIZE 100M,
11    GROUP 3 'C:\ORACLE\ORADATA\testdb\REDO03.LOG'  SIZE 100M
12  -- STANDBY LOGFILE
13  DATAFILE
14    'C:\ORACLE\ORADATA\testdb\SYSTEM01.DBF',
15    'C:\ORACLE\ORADATA\testdb\UNDOTBS01.DBF',
16    'C:\ORACLE\ORADATA\testdb\INDX01.DBF',
17    'C:\ORACLE\ORADATA\testdb\TOOLS01.DBF',
18    'C:\ORACLE\ORADATA\testdb\USERS01.DBF'
19  CHARACTER SET ZHS16GBK
20  ;

控制文件已创建

SQL> alter database open resetlogs;

数据库已更改。
   
SQL> select count(*),status from arch group by status;

  COUNT(*) ST
---------- --
      6166 no
     12332 ok

-->>没有丢失任何数据,因为你的数据都已经写到数据文件里了    

#########################################                                                  
# [1.5.2] 有trace,活动在线日志损坏,shutdown abort 或是非当前的数据文件
          ,当前在线日志文件损坏         
#########################################

####################################################
[测试1] shutdown abort,备份控制文件或者resetlog的trace,
没有数据文件备份,采用强制打开数据库的方法
####################################################
SQL> create table arch (status varchar(2));           
                                                          
表已创建。                                                    

SQL> alter system switch logfile;

系统已更改。

SQL> insert into arch select 'ok' from dba_objects;

已创建6166行。

SQL> commit;

提交完成。

SQL> insert into arch select 'ok' from dba_objects;

已创建6166行。

SQL> commit;

提交完成。

SQL> alter system switch logfile;
SQL> insert into arch select 'no' from dba_objects;

已创建6166行。

SQL> commit;

提交完成。
SQL>  select GROUP#,SEQUENCE#,archived, STATUS from v$log;

GROUP#  SEQUENCE# ARC STATUS
---------- ---------- --- ----------------
         1          2 YES ACTIVE
         2          3 NO  CURRENT
         3          1 YES INACTIVE

SQL> insert into arch select 'no' from dba_objects;

已创建6166行。

SQL> shutdown abort
ORACLE 例程已经关闭。

SQL> startup
ORACLE 例程已经启动。

Total System Global Area  101784276 bytes
Fixed Size                   453332 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
数据库装载完毕。
ORA-00313: 无法打开日志组 1 (线程 1) 的成员
ORA-00312: 联机日志 1 线程 1: 'C:\ORACLE\ORADATA\TESTDB\REDO01.LOG'
ORA-27047: 无法读取文件的标题块
OSD-04006: ReadFile() 失败, 无法读取文件
O/S-Error: (OS 38) 到达文件结尾。


SQL> alter database clear logfile group 1;
alter database clear logfile group 1
*
ERROR 位于第 1 行:
ORA-01624: 线程1的紧急恢复需要日志1
ORA-00312: 联机日志 1 线程 1: 'C:\ORACLE\ORADATA\TESTDB\REDO01.LOG'

SQL> startup nomount
ORACLE 例程已经启动。

Total System Global Area  101784276 bytes
Fixed Size                   453332 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "testdb" RESETLOGS  ARCHIVELOG
  2  --  SET STANDBY TO MAXIMIZE PERFORMANCE
  3      MAXLOGFILES 5
  4      MAXLOGMEMBERS 3
  5      MAXDATAFILES 100
  6      MAXINSTANCES 1
  7      MAXLOGHISTORY 226
  8  LOGFILE
  9    GROUP 1 'C:\ORACLE\ORADATA\testdb\REDO01.LOG'  SIZE 100M,
10    GROUP 2 'C:\ORACLE\ORADATA\testdb\REDO02.LOG'  SIZE 100M,
11    GROUP 3 'C:\ORACLE\ORADATA\testdb\REDO03.LOG'  SIZE 100M
12  -- STANDBY LOGFILE
13  DATAFILE
14    'C:\ORACLE\ORADATA\testdb\SYSTEM01.DBF',
15    'C:\ORACLE\ORADATA\testdb\UNDOTBS01.DBF',
16    'C:\ORACLE\ORADATA\testdb\INDX01.DBF',
17    'C:\ORACLE\ORADATA\testdb\TOOLS01.DBF',
18    'C:\ORACLE\ORADATA\testdb\USERS01.DBF'
19  CHARACTER SET ZHS16GBK
20  ;

控制文件已创建

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR 位于第 1 行:
ORA-01194: ??1?????????????
ORA-01110: ???? 1: 'C:\ORACLE\ORADATA\TESTDB\SYSTEM01.DBF'

SQL> recover database using backup controlfile until cancel;
ORA-00279: ?? 70123 (? 02/28/2005 15:22:05 ??) ???? 1 ????
ORA-00289: ??: C:\ORACLE\ORADATA\TESTDB\ARCHIVE\1_3.DBF
ORA-00280: ?? 70123 ???? 1 ???? # 3 ???


指定日志: {=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: ??: RECOVER ??? OPEN RESETLOGS ???????
ORA-01194: ??1?????????????
ORA-01110: ???? 1: 'C:\ORACLE\ORADATA\TESTDB\SYSTEM01.DBF'


ORA-01112: ???????

我们看到如果是abort DOWN机的话,打开数据库都需要应用在线活动日志

这时必须加隐含参数强制打开数据库,并进行导出,重建数据库,导入业务数据

SQL> show parameter spfile                                                                               
                                                                                                         
NAME                                 TYPE        VALUE                                                   
------------------------------------ ----------- -----------------------------                           
spfile                               string      %ORACLE_HOME%\DATABASE\SPFILE                           
                                                 ORACLE_SID%.ORA                                         
                                                                                                         
                                                                                                         
SQL> create pfile='pfiletest.ora' from spfile;                                                           
                                                                                                         
文件已创建。                                                                                             
                                                                                                         
SQL> create pfile='c:\pfiletest.ora' from spfile;                                                        
                                                                                                         
文件已创建。                                                                                             
编辑c:\pfiletest.ora                                                                                     
增加三个参数                                                                                             
                                                                                                         
_allow_resetlogs_corruption=true                                                                         
_corrupted_rollback_segments=true                                                                        
_offline_rollback_segments=true                                                                          
                                                                                                         
SQL> shutdown immediate                                                                                  
ORA-01109: 数据库未打开                                                                                  
                                                                                                         
                                                                                                         
已经卸载数据库。                                                                                         
ORACLE 例程已经关闭。                                                                                    
SQL>                                                                                                     
SQL>                                                                                                     
SQL>                                                                                                     
SQL> startup pfile='c:\pfiletest.ora'                                                                    
ORACLE 例程已经启动。                                                                                    
                                                                                                         
Total System Global Area  135338868 bytes                                                                
Fixed Size                   453492 bytes                                                                
Variable Size             109051904 bytes                                                                
Database Buffers           25165824 bytes                                                                
Redo Buffers                 667648 bytes                                                                
数据库装载完毕。                                                                                         
ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项                                          
                                                                                                         
                                                                                                         
SQL> alter database open resetlogs;                                                                      
alter database open resetlogs                                                                            
*                                                                                                        
ERROR 位于第 1 行:                                                                                       
ORA-01092: ORACLE 例程终止。强行断开连接                                                                 
                                                                                                         
                                                                                                         
SQL>                                                                                                     
SQL>                                                                                                     
SQL> exit                                                                                                
从Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production                                             
With the Partitioning, OLAP and Oracle Data Mining options                                               
JServer Release 9.2.0.1.0 - Production中断开                                                             
                                                                                                         
C:\>sqlplus "/as sysdba"                                                                                 
                                                                                                         
SQL*Plus: Release 9.2.0.1.0 - Production on 星期五 12月 31 14:03:09 2004                                 
                                                                                                         
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.                                      
                                                                                                         
已连接到空闲例程。                                                                                       
                                                                                                         
SQL> startup pfile='c:\pfiletest.ora'                                                                    
ORACLE 例程已经启动。                                                                                    
                                                                                                         
Total System Global Area  135338868 bytes                                                                
Fixed Size                   453492 bytes                                                                
Variable Size             109051904 bytes                                                                
Database Buffers           25165824 bytes                                                                
Redo Buffers                 667648 bytes                                                                
数据库装载完毕。                                                                                         
数据库已经打开。                                                                                         
SQL>                      

阅读(520) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~