Chinaunix首页 | 论坛 | 博客
  • 博客访问: 508048
  • 博文数量: 101
  • 博客积分: 1635
  • 博客等级: 上尉
  • 技术积分: 1282
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-05 01:51
文章分类

全部博文(101)

文章存档

2019年(2)

2018年(16)

2013年(14)

2012年(69)

我的朋友

分类: Oracle

2018-10-23 11:29:47

++++++++++session1++++++++++++
SQL> oradebug setmypid
Statement processed.
SQL> oradebug event 10046 trace name context forever,level 12;
Statement processed.
SQL> alter database open;


Database altered.


SQL> oradebug close_trace
Statement processed.
SQL> oradebug tracefile_name
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_31151.trc


+++++++++++++session2+++++++++++++
[oracle@localhost trace]$ strace -fr -o /tmp/31134.log -p 31134


31134      0.000018 times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 851450350
31134      0.000040 gettimeofday({1539744436, 640254}, NULL) = 0
31134      0.000032 statfs("/u01/app/oracle/oradata/orcl/system01.dbf", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=205339306, f_bfree=200304667, f_bavail=189872360, f_files=52166656, f_ffree=52015910, f_fsid={833983380, 166413555}, f_namelen=255, f_frsize=4096}) = 0
31134      0.000026 open("/u01/app/oracle/oradata/orcl/system01.dbf", O_RDWR|O_DSYNC) = 11
31134      0.000022 getrlimit(RLIMIT_NOFILE, {rlim_cur=64*1024, rlim_max=64*1024}) = 0
31134      0.000016 fcntl(11, F_DUPFD, 256) = 256
31134      0.000026 close(11)           = 0
31134      0.000015 fcntl(256, F_SETFD, FD_CLOEXEC) = 0


31134      0.000015 fstatfs(259, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=205339306, f_bfree=200304665, f_bavail=189872358, f_files=52166656, f_ffree=52015910, f_fsid={833983380, 166413555}, f_namelen=255, f_frsize=4096}) = 0
31134      0.000017 gettimeofday({1539744436, 640962}, NULL) = 0
31134      0.000023 gettimeofday({1539744436, 640985}, NULL) = 0
31134      0.000017 statfs("/u01/app/oracle/oradata/orcl/temp01.dbf", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=205339306, f_bfree=200304665, f_bavail=189872358, f_files=52166656, f_ffree=52015910, f_fsid={833983380, 166413555}, f_namelen=255, f_frsize=4096}) = 0
31134      0.000019 open("/u01/app/oracle/oradata/orcl/temp01.dbf", O_RDWR|O_DSYNC) = 11
31134      0.000023 getrlimit(RLIMIT_NOFILE, {rlim_cur=64*1024, rlim_max=64*1024}) = 0


oracle 的open过程smon进程,读取了system文件和tempfile文件。


strace -fr -o /tmp/580.log -p 580
[oracle@localhost trace]$ cat  /tmp/580.log |grep read
580        0.000017 pread(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4\270!\0\0\0\0\0\0\0\4 \v\346\350FZ"..., 16384, 16384) = 16384
580        0.000016 pread(257, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4\270!\0\0\0\0\0\0\0\4 \v\346\350FZ"..., 16384, 16384) = 16384
580        0.000015 pread(256, "\25\302\0\0\17\0\0\0rG\0\0\377\377\1\4\347\247\0\0\0@\0\0\0\0\0\0\0\0\0\1"..., 16384, 245760) = 16384
580        0.000016 pread(256, "\25\302\0\0\21\0\0\0rG\0\0\377\377\1\4\356>\0\0\0\0\0\0\0\0\0\0f\235\321:"..., 16384, 278528) = 16384
580        0.000015 pread(256, "\25\302\0\0\27\0\0\0kG\0\0\377\377\1\4\323\332\0\0\0\0\0\0\0 \0\0\16\0\0\0"..., 16384, 376832) = 16384
580        0.000014 pread(256, "\25\302\0\0 \0\0\0hG\0\0\377\377\1\4\2667\0\0\3\0\3\0\0\0\0\0\0\0/u"..., 16384, 524288) = 16384
580        0.000017 read(11, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0g{\0\0\0 \0\0\0\201\1\0}|{z"..., 8192) = 8192
580        0.000019 pread(258, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0g{\0\0\0 \0\0\0\201\1\0}|{z"..., 8192, 0) = 8192
580        0.000017 pread(258, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0g{\0\0\0 \0\0\0\201\1\0}|{z"..., 8192, 0) = 8192
580        0.000022 read(11, "Character devices:\n  1 mem\n  4 /"..., 1024) = 463
580        0.000015 read(11, "253:0\n", 4096) = 6
580        0.000014 read(11, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0g\37\0\0\0 \0\0\0\345\1\0}|{z"..., 8192) = 8192
580        0.000016 pread(259, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0g\37\0\0\0 \0\0\0\345\1\0}|{z"..., 8192, 0) = 8192
580        0.000017 pread(259, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0g\37\0\0\0 \0\0\0\345\1\0}|{z"..., 8192, 0) = 8192
580        0.000017 read(11, "Character devices:\n  1 mem\n  4 /"..., 1024) = 463
580        0.000016 read(11, "253:0\n", 4096) = 6
580        0.000026 read(11, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0\346\370\0\0\0 \0\0\200\2\0\0}|{z"..., 8192) = 8192
580        0.000017 pread(260, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0\346\370\0\0\0 \0\0\200\2\0\0}|{z"..., 8192, 0) = 8192
580        0.000027 pread(260, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0\346\370\0\0\0 \0\0\200\2\0\0}|{z"..., 8192, 0) = 8192
580        0.000017 read(11, "Character devices:\n  1 mem\n  4 /"..., 1024) = 463
580        0.000016 read(11, "253:0\n", 4096) = 6
580        0.000015 read(11, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0f\310\0\0\0 \0\0\0002\0\0}|{z"..., 8192) = 8192
580        0.000027 pread(261, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0f\310\0\0\0 \0\0\0002\0\0}|{z"..., 8192, 0) = 8192
580        0.000019 pread(261, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0f\310\0\0\0 \0\0\0002\0\0}|{z"..., 8192, 0) = 8192
580        0.000027 read(11, "Character devices:\n  1 mem\n  4 /"..., 1024) = 463
580        0.000016 read(11, "253:0\n", 4096) = 6
580        0.000016 pread(256, "\25\302\0\0\265\0\0\0|\2\0\0\377\377\1\4=~\0\0\0\n\0\0\0 \0\0\36\0\10\0"..., 16384, 2965504) = 16384
580        0.000013 read(11, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0f\341\0\0\0 \0\0\0\33\0\0}|{z"..., 8192) = 8192
580        0.000017 pread(262, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0f\341\0\0\0 \0\0\0\33\0\0}|{z"..., 8192, 0) = 8192
580        0.000030 pread(262, "\0\242\0\0\0\0\300\377\0\0\0\0\0\0\0\0f\341\0\0\0 \0\0\0\33\0\0}|{z"..., 8192, 0) = 8192
580        0.000017 read(11, "Character devices:\n  1 mem\n  4 /"..., 1024) = 463
580        0.000017 read(11, "253:0\n", 4096) = 6
580        0.000016 pread(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4\276!\0\0\0\0\0\0\0\4 \v\346\350FZ"..., 16384, 16384) = 16384
580        0.000015 pread(257, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4\276!\0\0\0\0\0\0\0\4 \v\346\350FZ"..., 16384, 16384) = 16384
580        0.000027 pread(256, "\25\302\0\0\17\0\0\0tG\0\0\377\377\1\4\347\257\0\0\0@\0\0\0\0\0\0\0\0\0\1"..., 16384, 245760) = 16384
580        0.000045 pread(256, "\25\302\0\0\21\0\0\0tG\0\0\377\377\1\4\356>\0\0\0\0\0\0\0\0\0\0f\235\321:"..., 16384, 278528) = 16384
580        0.000017 pread(256, "\25\302\0\0\27\0\0\0kG\0\0\377\377\1\4\323\332\0\0\0\0\0\0\0 \0\0\16\0\0\0"..., 16384, 376832) = 16384
580        0.000019 pread(258, "\v\242\0\0\1\0@\0\0\0\0\0\0\0\1\4\317\300\0\0\0\0\0\0\0\4 \v\346\350FZ"..., 8192, 8192) = 8192
580        0.000016 pread(259, "\v\242\0\0\1\0\200\0\0\0\0\0\0\0\1\4\10\341\0\0\0\0\0\0\0\4 \v\346\350FZ"..., 8192, 8192) = 8192
580        0.000016 pread(260, "\v\242\0\0\1\0\0\1\0\0\0\0\0\0\1\4Oa\0\0\0\0\0\0\0\4 \v\346\350FZ"..., 8192, 8192) = 8192
580        0.000016 pread(261, "\v\242\0\0\1\0@\1\0\0\0\0\0\0\1\4c\272\0\0\0\0\0\0\0\4 \v\346\350FZ"..., 8192, 8192) = 8192
580        0.000015 pread(256, "\25\302\0\0\265\0\0\0|\2\0\0\377\377\1\4=~\0\0\0\n\0\0\0 \0\0\36\0\10\0"..., 16384, 2965504) = 16384
580        0.000015 pread(262, "\v\242\0\0\1\0@\0\0\0\0\0\0\0\1\4Y\345\0\0\0\0\0\0\0\4 \v\346\350FZ"..., 8192, 8192) = 8192
580        0.000028 read(11, "\25\23\"\1\23\3\t\t\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 256) = 256
580        0.000016 read(11, "f\31\2603gJ>h\265z\342\207C\226]\310m\374\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 512) = 512


strace跟踪smon和dbwr进程,我们可以得到下面的结论:
1)在open过程中smon进程会读取controlfile文件,system,temp文件
2)在open过程中dbwr进程会去读取controlfile,也会对数据文件进行写操作。
3)dbwr进程在读取controlfile的时候,会进行two pass去读取。


继续dump open的过程
WAIT #139878192038872: nam='control file sequential read' ela= 2 file#=0 block#=18 blocks=1 obj#=-1 tim=1442300930471843
WAIT #139878192038872: nam='control file sequential read' ela= 2 file#=0 block#=281 blocks=1 obj#=-1 tim=1442300930471850
WAIT #139878192038872: nam='log file sync' ela= 8324 buffer#=4720 sync scn=1746473 p3=0 obj#=-1 tim=1442300930480225
WAIT #139878192038872: nam='control file sequential read' ela= 7 file#=0 block#=1 blocks=1 obj#=-1 tim=1442300930480303
WAIT #139878192038872: nam='control file sequential read' ela= 3 file#=0 block#=16 blocks=1 obj#=-1 tim=1442300930480321
WAIT #139878192038872: nam='control file sequential read' ela= 3 file#=0 block#=18 blocks=1 obj#=-1 tim=1442300930480331
WAIT #139878192038872: nam='control file sequential read' ela= 4 file#=0 block#=281 blocks=1 obj#=-1 tim=1442300930480342
WAIT #139878192038872: nam='instance state change' ela= 281 layer=2 value=1 waited=1 obj#=-1 tim=1442300930480655
WAIT #139878192038872: nam='db file sequential read' ela= 2281 file#=1 block#=520 blocks=1 obj#=-1 tim=1442300930499074
看见正在同步scn号
从10046trace,我们可以看见在读取controlfile的头部block,然后再读取其它的block。scn=1746473说明在open的时候会去比较scn.
另外最后一行,注意到  file#=1 block#=520,这个地方比较的特殊。
select owner,segment_name,header_file,header_block from dba_segments where segment_name='BOOTSTRAP$'
1 SYS BOOTSTRAP$ 1 520


下面是创建bootstrap$对象的过程
PARSING IN CURSOR #139878192030648 len=188 dep=1 uid=0 oct=1 lid=0 tim=1442300930528717 hv=4006182593 ad='8e8d7558' sqlid='32r4f1brckzq1'
create table bootstrap$ (
END OF STMT
PARSE #139878192030648:c=1999,e=25869,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=1442300930528716
EXEC #139878192030648:c=0,e=503,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,plh=0,tim=1442300930529299
CLOSE #139878192030648:c=0,e=3,dep=1,type=0,tim=1442300930529376
=====================
PARSING IN CURSOR #139878192030648 len=55 dep=1 uid=0 oct=3 lid=0 tim=1442300930529834 hv=2111436465 ad='8e8d5bf8' sqlid='6apq2rjyxmxpj'
select line#, sql_text from bootstrap$ where obj# != :1
END OF STMT
PARSE #139878192030648:c=1000,e=447,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=1442300930529833
BINDS #139878192030648:
 Bind#0
  oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00
  oacflg=08 fl2=0001 frm=00 csi=00 siz=24 off=0
  kxsbbbfp=7f37edf29f70  bln=22  avl=02  flg=05
  value=59




从value=59看出oracle为该对象创建了59个核心的对象。










可以通过bbed进行进一步的观察
BBED> set file 5 block 1
        FILE#           5
        BLOCK#          1


BBED> p kcvfhcpc
ub4 kcvfhcpc                                @140      0x00000010


BBED> p kcvfhccc
ub4 kcvfhccc                                @148      0x0000000f


SQL>  alter session set events 'immediate trace name controlf level 3';


Session altered.


SQL> oradebug tracefile_name
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_30873.trc


DATA FILE #5: 
  name #9: /u01/app/oracle/oradata/orcl/tbs_unvdata01.dbf
creation size=12800 block size=8192 status=0xe head=9 tail=9 dup=1
 tablespace 6, index=6 krfil=5 prev_file=0
 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
 Checkpoint cnt:16 scn: 0x0000.0052dbd0 10/17/2018 13:11:59
 Stop scn: 0xffff.ffffffff 10/17/2018 10:57:49
 Creation Checkpointed at scn:  0x0000.004f62b1 10/16/2018 17:49:00
 thread:1 rba:(0xbc.2c3.10)
 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000
 Offline scn: 0x0000.00000000 prev_range: 0
 Online Checkpointed at scn:  0x0000.00000000 
 thread:0 rba:(0x0.0.0)


datafile header里面的cnt值 和controlfie中记录的datafile的cnt值都是10,一致的。
手工修改datafile header中的cnt值,观察open的启动
BBED>  modify /x 09 offset 140
 File: /u01/app/oracle/oradata/orcl/tbs_unvdata01.dbf (5)
 Block: 1                Offsets:  140 to  651           Dba:0x01400001
------------------------------------------------------------------------
 09000000 357afd3a 0f000000 00000000 00000000 00000000 00000000 00000000 




SQL> startup mount;
ORACLE instance started.


Total System Global Area  313159680 bytes
Fixed Size                  2252824 bytes
Variable Size             188747752 bytes
Database Buffers          117440512 bytes
Redo Buffers                4718592 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01122: database file 5 failed verification check
ORA-01110: data file 5: '/u01/app/oracle/oradata/orcl/tbs_unvdata01.dbf'
ORA-01210: data file header is media corrupt






这种需要重建控制文件


在open的时候,oracle会去比较controlfiel中的datafile checkpoint count值与datafile header中的checkpoint count.
当datafile header中的checkpoint count值小于datafile 中的checkpoint count,提示需要介质恢复
当datafile header中的checkpoint count值大于datafile 中的checkpoint count,数据库能正常的启动。


checkpoint cnt可以理解为增量检查点的次数。




如下是controlfile的dump trace:


SQL> alter session set events 'immediate trace name controlf level 3';


Session altered.


SQL> oradebug close_trace
Statement processed.
SQL> oradebug tracefile_name
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_2974.trc






***************************************************************************
DATA FILE RECORDS
***************************************************************************
 (size = 520, compat size = 520, section max = 100, section in-use = 5,
  last-recid= 70, old-recno = 0, last-recno = 0)
 (extent = 1, blkno = 11, numrecs = 100)
DATA FILE #1: 
  name #7: /u01/app/oracle/oradata/orcl/system01.dbf
creation size=0 block size=8192 status=0xe head=7 tail=7 dup=1
 tablespace 0, index=1 krfil=1 prev_file=0
 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
 Checkpoint cnt:293 scn: 0x0000.00547188 10/18/2018 11:35:13
 Stop scn: 0xffff.ffffffff 10/18/2018 11:34:59
 Creation Checkpointed at scn:  0x0000.00000007 08/24/2013 11:37:33
 thread:0 rba:(0x0.0.0)
 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000
 Offline scn: 0x0000.000e2005 prev_range: 0


此时的scn号00547188 
如下是此时的datafile header dump:


SQL> oradebug setmypid
Statement processed.
SQL>  alter session set events 'immediate trace name file_hdrs level 3';


Session altered.


SQL> oradebug close_trace
Statement processed.
SQL> oradebug tracefile_name
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_2974.trc
DATA FILE #5: 
  name #9: /u01/app/oracle/oradata/orcl/tbs_unvdata01.dbf
creation size=12800 block size=8192 status=0xe head=9 tail=9 dup=1
 tablespace 6, index=6 krfil=5 prev_file=0
 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
 Checkpoint cnt:23 scn: 0x0000.00547188 10/18/2018 11:35:13
 Stop scn: 0xffff.ffffffff 10/18/2018 11:34:59
 Creation Checkpointed at scn:  0x0000.004f62b1 10/16/2018 17:49:00
 thread:1 rba:(0xbc.2c3.10)
 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000
 Offline scn: 0x0000.00000000 prev_range: 0
 Online Checkpointed at scn:  0x0000.00000000 
 thread:0 rba:(0x0.0.0)


测试的scn值 是一致的。




首先模拟datafile checkpoin scn(start scn)小于controlfile 中的stop scn的情况:


BBED> d /v offset 484 count 10
 File: /u01/app/oracle/oradata/orcl/tbs_unvdata01.dbf (5)
 Block: 1       Offsets:  484 to  493  Dba:0x01400001
-------------------------------------------------------
 88715400 00000000 f1c2              l .qT.....                                                  <16 bytes per line>


BBED> modify /x 00 offset 484               
 File: /u01/app/oracle/oradata/orcl/tbs_unvdata01.dbf (5)
 Block: 1                Offsets:  484 to  493           Dba:0x01400001
------------------------------------------------------------------------
 00715400 00000000 f1c2 


 <32 bytes per line>


BBED> sum apply 
Check value for File 5, Block 1:
current = 0xc89c, required = 0xc89c


SQL> startup mount;
ORACLE instance started.


Total System Global Area  313159680 bytes
Fixed Size                  2252824 bytes
Variable Size             188747752 bytes
Database Buffers          117440512 bytes
Redo Buffers                4718592 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '/u01/app/oracle/oradata/orcl/tbs_unvdata01.dbf'


SQL> select file#, CHECKPOINT_CHANGE#  from v$datafile;
SQL> select  file#,to_char(checkpoint_change#) from v$datafile_header order by 1;


需要介质恢复


recover database;




SQL> select file#, CHECKPOINT_CHANGE#  from v$datafile;


     FILE# CHECKPOINT_CHANGE#
---------- ------------------
         1            5565377
         2            5565377
         3            5565377
         4            5565377
         5            5565377


如果scn号比controlfile的scn号大的话可以正常启动。




什么情况下需要实例恢复
当controlfile 中的datafile的stop scn为空是,会提示需要进行实例恢复


SQL> select count(*) from test;


  COUNT(*)
----------
         0


SQL> drop table test;


Table dropped.


SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.


Total System Global Area  313159680 bytes
Fixed Size                  2252824 bytes
Variable Size             188747752 bytes
Database Buffers          117440512 bytes
Redo Buffers                4718592 bytes
Database mounted.
SQL> oradebug setmypid
Statement processed.
SQL> alter session set events 'immediate trace name controlf level 3';      


Session altered.


SQL> oradebug close_trace
Statement processed.
SQL> oradebug tracefile_name
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_15782.trc
DATA FILE #5: 
  name #9: /u01/app/oracle/oradata/orcl/tbs_unvdata01.dbf
creation size=12800 block size=8192 status=0xe head=9 tail=9 dup=1
 tablespace 6, index=6 krfil=5 prev_file=0
 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
 Checkpoint cnt:33 scn: 0x0000.00551584 10/18/2018 13:14:56
 Stop scn: 0xffff.ffffffff 10/18/2018 13:14:42            --------------可以看到此时的datafile scn为空值(无穷大)
 Creation Checkpointed at scn:  0x0000.004f62b1 10/16/2018 17:49:00
 thread:1 rba:(0xbc.2c3.10)
 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000
 Offline scn: 0x0000.00000000 prev_range: 0
 Online Checkpointed at scn:  0x0000.00000000 
 thread:0 rba:(0x0.0.0)




通过10013跟踪数据库启动
SQL> oradebug setmypid
Statement processed.
SQL> alter session set events '10013 trace name context forever,level 1';


Session altered.


SQL> alter database open;


Database altered.


SQL> oradebug tracefile_name
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_16449.trc


*** 2018-10-18 13:22:27.514
Successfully allocated 7 recovery slaves
Using 20 overflow buffers per recovery slave
Thread 1 checkpoint: logseq 197, block 20776, scn 5576068      -
  cache-low rba: logseq 197, block 20777
    on-disk rba: logseq 197, block 21632, scn 5576690          --on disk rba(scn)值
  start recovery at logseq 197, block 20777, scn 0


*** 2018-10-18 13:22:27.524
Started writing zeroblks thread 1 seq 197 blocks 21632-21639


*** 2018-10-18 13:22:27.524
Completed writing zeroblks thread 1 seq 197
==== Redo read statistics for thread 1 ====
Total physical reads (from disk and memory): 4096Kb
-- Redo read_disk statistics --
Read rate (ASYNC): 427Kb in 0.01s => 41.75 Mb/sec
Longest record: 20Kb, moves: 0/684 (0%)
Longest LWN: 41Kb, moves: 0/142 (0%), moved: 0Mb
Last redo scn: 0x0000.005517f1 (5576689)
----------------------------------------------
----- Recovery Hash Table Statistics ---------
Hash table buckets = 262144
Longest hash chain = 1
Average hash chain = 245/245 = 1.0
Max compares per lookup = 1
Avg compares per lookup = 2014/2259 = 0.9


































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