- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
14#
发表于 2012-3-9 20:36:42
有网友提问,若控制文件是 create controlfile 重建得来的 又会如何? 这里我们可以看一下:
我们来看一下:
SQL> alter system switch logfile;
System altered.
SQL> select distinct checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
15169797
SQL> alter system checkpoint;
System altered.
SQL> select distinct checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
15169802 =>E7783A
15169802 =>E7783A 最近的一次FULL CHECKPOINT的SCN
SQL> select name from v$tablespace;
NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
USERS
EXAMPLE
TEMP
SQL> alter tablespace SYSTEM begin backup;
Tablespace altered.
SQL> alter tablespace UNDOTBS1 begin backup;
Tablespace altered.
SQL> alter tablespace SYSAUX begin backup;
Tablespace altered.
SQL> alter tablespace USERS begin backup;
Tablespace altered.
SQL> alter tablespace EXAMPLE begin backup;
Tablespace altered.
SQL> alter tablespace SYSTEM end backup;
Tablespace altered.
SQL> alter tablespace UNDOTBS1 end backup;
Tablespace altered.
SQL> alter tablespace SYSAUX end backup;
Tablespace altered.
SQL> alter tablespace USERS end backup;
Tablespace altered.
SQL> alter tablespace EXAMPLE end backup;
Tablespace altered.
begin /end backup 会引发FILE CHECKPOINT ,造成datafile_header的 checkpoint_change# 更新
SQL> select distinct checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
15169814
15169827
15169842
15169821
15169835
15169814 =>E77916 是最小的一个 datafile header checkpoint_change#
SQL> oradebug setmypid;
Statement processed.
SQL> oradebug dump controlf 3;
Statement processed.
SQL> oradebug tracefile_name;
但是此时去dump controlf 可以发现 控制文件中的database checkpint 仍是 E7783A 15169802 即上一次FULL CHECKPOINT的 SCN
***************************************************************************
DATABASE ENTRY
***************************************************************************
(size = 316, compat size = 316, section max = 1, section in-use = 1,
last-recid= 0, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 1, numrecs = 1)
03/09/2012 23:04:33
DB Name "G10R21"
Database flags = 0x00404001 0x00001000
Controlfile Creation Timestamp 03/09/2012 23:04:33
Incmplt recovery scn: 0x0000.00000000
Resetlogs scn: 0x0000.00e7784f Resetlogs Timestamp 03/09/2012 23:11:46
Prior resetlogs scn: 0x0000.00e77780 Prior resetlogs Timestamp 03/09/2012 22:57:44
Redo Version: compatible=0xa200100
#Data files = 16, #Online files = 16
Database checkpoint: Thread=1 scn: 0x0000.00e7790a ==>15169802
Threads: #Enabled=1, #Open=1, Head=1, Tail=1
***************************************************************************
REDO THREAD RECORDS
***************************************************************************
(size = 256, compat size = 256, section max = 8, section in-use = 1,
last-recid= 0, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 9, numrecs = 8)
THREAD #1 - status:0xf thread links forward:0 back:0
#logs:3 first:1 last:3 current:2 last used seq#:0x2
enabled at scn: 0x0000.00e7784f 03/09/2012 23:11:46
disabled at scn: 0x0000.00000000 01/01/1988 00:00:00
opened at 03/09/2012 23:11:46 by instance G10R21
Checkpointed at scn: 0x0000.00e7790a 03/09/2012 23:12:12
thread:1 rba:(0x2.3.10)
SQL> alter database backup controlfile to trace;
Database altered.
SQL> oradebug setmypid;
Statement processed.
SQL> oradebug tracefile_name;
SQL> shutdown abort;
ORACLE instance shut down.
[oracle@vrh8 ~]$ rm /s01/recreate.ctl
我们以NORESETLOGS重建控制文件:
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 620756992 bytes
Fixed Size 2022760 bytes
Variable Size 234881688 bytes
Database Buffers 377487360 bytes
Redo Buffers 6365184 bytes
SQL> show parameter control
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /s01/recreate.ctl
SQL> CREATE CONTROLFILE REUSE DATABASE "G10R21" NORESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 2921
7 LOGFILE
8 GROUP 1 (
9 '/s01/oradata/G10R21/onlinelog/o1_mf_1_7ch812dg_.log',
10 '/s01/flash_recovery_area/G10R21/onlinelog/o1_mf_1_7ch813h5_.log'
11 ) SIZE 50M,
12 GROUP 2 (
13 '/s01/oradata/G10R21/onlinelog/o1_mf_2_7ch8144q_.log',
14 '/s01/flash_recovery_area/G10R21/onlinelog/o1_mf_2_7ch815cj_.log'
15 ) SIZE 50M,
16 GROUP 3 (
17 '/s01/oradata/G10R21/onlinelog/o1_mf_3_7ch816g2_.log',
18 '/s01/flash_recovery_area/G10R21/onlinelog/o1_mf_3_7ch817gp_.log'
19 ) SIZE 50M
20 -- STANDBY LOGFILE
DATAFILE
21 22 '/s01/oradata/G10R21/datafile/o1_mf_system_7ch8004t_.dbf',
23 '/s01/oradata/G10R21/datafile/o1_mf_undotbs1_7ch80081_.dbf',
24 '/s01/oradata/G10R21/datafile/o1_mf_sysaux_7ch8004x_.dbf',
25 '/s01/oradata/G10R21/datafile/o1_mf_users_7ch80085_.dbf',
26 '/s01/oradata/G10R21/datafile/o1_mf_example_7ch81ch3_.dbf',
27 '/s01/oradata/G10R21/datafile/o1_mf_users_7gvd5pwh_.dbf',
28 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6fdt_.dbf',
29 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6nxy_.dbf',
30 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6qc2_.dbf',
31 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6stt_.dbf',
32 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6w5w_.dbf',
33 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6yo0_.dbf',
34 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t717x_.dbf',
35 '/s01/oradata/G10R21/datafile/o1_mf_undotbs1_7h6ttkkx_.dbf',
36 '/s01/oradata/G10R21/datafile/o1_mf_undotbs1_7h6ttpn1_.dbf',
37 '/s01/oradata/G10R21/datafile/o1_mf_undotbs1_7h6ttsbd_.dbf'
38 CHARACTER SET AL32UTF8;
Control file created.
SQL> oradebug setmypid;
Statement processed.
SQL> oradebug dump controlf 3;
Statement processed.
***************************************************************************
DATABASE ENTRY
***************************************************************************
(size = 316, compat size = 316, section max = 1, section in-use = 1,
last-recid= 0, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 1, numrecs = 1)
03/09/2012 23:16:57
DB Name "G10R21"
Database flags = 0x00400103 0x00001000
Controlfile Creation Timestamp 03/09/2012 23:16:58
Incmplt recovery scn: 0x0000.00000000
Resetlogs scn: 0x0000.00e7784f Resetlogs Timestamp 03/09/2012 23:11:46
Prior resetlogs scn: 0x0000.00e77780 Prior resetlogs Timestamp 03/09/2012 22:57:44
Redo Version: compatible=0xa200100
#Data files = 16, #Online files = 16
Database checkpoint: Thread=1 scn: 0x0000.00e77902 15169794
Threads: #Enabled=1, #Open=1, Head=1, Tail=1
Database checkpoint: 变成了 00e77902 =》 15169794,比上次FULL CHECKPOINT的15169802 还要小
这个
00e77902 =》 15169794从哪里来?
***************************************************************************
REDO THREAD RECORDS
***************************************************************************
(size = 256, compat size = 256, section max = 8, section in-use = 1,
last-recid= 0, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 9, numrecs = 8)
THREAD #1 - status:0x7 thread links forward:0 back:0
#logs:3 first:1 last:3 current:2 last used seq#:0x2
enabled at scn: 0x0000.00e7784f 03/09/2012 23:11:46
disabled at scn: 0x0000.00000000 01/01/1988 00:00:00
opened at 01/01/1988 00:00:00 by instance
Checkpointed at scn: 0x0000.00e77902 03/09/2012 23:11:54
thread:1 rba:(0x2.2.0)
***************************************************************************
LOG FILE RECORDS
***************************************************************************
(size = 72, compat size = 72, section max = 16, section in-use = 3,
last-recid= 0, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 10, numrecs = 16)
LOG FILE #1:
(name #3) /s01/oradata/G10R21/onlinelog/o1_mf_1_7ch812dg_.log
(name #4) /s01/flash_recovery_area/G10R21/onlinelog/o1_mf_1_7ch813h5_.log
Thread 1 redo log links: forward: 2 backward: 0
siz: 0x19000 seq: 0x00000001 hws: 0x4 bsz: 512 nab: 0xb6 flg: 0x0 dup: 2
Archive links: fwrd: 2 back: 0 Prev scn: 0x0000.00000000
Low scn: 0x0000.00e7784f 03/09/2012 23:11:46
Next scn: 0x0000.00e77902 03/09/2012 23:11:54
LOG FILE #2:
(name #1) /s01/oradata/G10R21/onlinelog/o1_mf_2_7ch8144q_.log
(name #2) /s01/flash_recovery_area/G10R21/onlinelog/o1_mf_2_7ch815cj_.log
Thread 1 redo log links: forward: 3 backward: 1
siz: 0x19000 seq: 0x00000002 hws: 0x1 bsz: 512 nab: 0xffffffff flg: 0xa dup: 2
Archive links: fwrd: 0 back: 1 Prev scn: 0x0000.00e7784f
Low scn: 0x0000.00e77902 03/09/2012 23:11:54
Next scn: 0xffff.ffffffff 01/01/1988 00:00:00
LOG FILE #3:
(name #5) /s01/oradata/G10R21/onlinelog/o1_mf_3_7ch816g2_.log
(name #6) /s01/flash_recovery_area/G10R21/onlinelog/o1_mf_3_7ch817gp_.log
Thread 1 redo log links: forward: 0 backward: 2
siz: 0x19000 seq: 0x00000000 hws: 0x2 bsz: 512 nab: 0x2 flg: 0x1 dup: 2
Archive links: fwrd: 0 back: 0 Prev scn: 0x0000.00000000
Low scn: 0x0000.00000000 01/01/1988 00:00:00
Next scn: 0x0000.00000000 01/01/1988 00:00:00
原来这个
00e77902 =》 15169794 来源于 current online redo logfile中最小的LOW SCN
***************************************************************************
DATA FILE RECORDS
***************************************************************************
(size = 428, compat size = 428, section max = 100, section in-use = 19,
last-recid= 0, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 11, numrecs = 100)
DATA FILE #1:
(name #22) /s01/oradata/G10R21/datafile/o1_mf_system_7ch8004t_.dbf
creation size=0 block size=8192 status=0x12 head=22 tail=22 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:2314 scn: 0x0000.00e77916 03/09/2012 23:12:46
Stop scn: 0xffff.ffffffff 03/09/2012 23:16:58
Creation Checkpointed at scn: 0x0000.00000008 10/22/2005 21:44:31
thread:0 rba:(0x0.0.0)
DATAFILE 1 的checkpoint scn最小为 00e77916 =》15169814
SQL> recover database using backup controlfile;
ORA-00279: change 15169814 generated at 03/09/2012 23:12:46 needed for thread 1
ORA-00289: suggestion :
/s01/flash_recovery_area/G10R21/archivelog/2012_03_09/o1_mf_1_2_%u_.arc
ORA-00280: change 15169814 for thread 1 is in sequence #2
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 15169814 generated at 03/09/2012 23:12:46 needed for thread 1
可以看到 recover database using backup controlfile 的起点是 15169814 即 最小的一个 datafile header 的CHECKPOINT CHANGE#,
也就是说 丢失控制文件 并(create controlfile)重建后的recover 从 最小的datafile header CHECKPOINT_CHANGE#开始 ,直到NEXT SCN 无穷大的 current logfile的 end 为止!
我们在看一下 RESETLOGS的情况:
SQL>
SQL> CREATE CONTROLFILE REUSE DATABASE "G10R21" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
2 3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 2921
7 LOGFILE
8 GROUP 1 (
9 '/s01/oradata/G10R21/onlinelog/o1_mf_1_7ch812dg_.log',
10 '/s01/flash_recovery_area/G10R21/onlinelog/o1_mf_1_7ch813h5_.log'
11 ) SIZE 50M,
12 GROUP 2 (
13 '/s01/oradata/G10R21/onlinelog/o1_mf_2_7ch8144q_.log',
14 '/s01/flash_recovery_area/G10R21/onlinelog/o1_mf_2_7ch815cj_.log'
15 ) SIZE 50M,
16 GROUP 3 (
17 '/s01/oradata/G10R21/onlinelog/o1_mf_3_7ch816g2_.log',
18 '/s01/flash_recovery_area/G10R21/onlinelog/o1_mf_3_7ch817gp_.log'
19 ) SIZE 50M
20 -- STANDBY LOGFILE
21 DATAFILE
22 '/s01/oradata/G10R21/datafile/o1_mf_system_7ch8004t_.dbf',
23 '/s01/oradata/G10R21/datafile/o1_mf_undotbs1_7ch80081_.dbf',
'/s01/oradata/G10R21/datafile/o1_mf_sysaux_7ch8004x_.dbf',
24 25 '/s01/oradata/G10R21/datafile/o1_mf_users_7ch80085_.dbf',
26 '/s01/oradata/G10R21/datafile/o1_mf_example_7ch81ch3_.dbf',
27 '/s01/oradata/G10R21/datafile/o1_mf_users_7gvd5pwh_.dbf',
28 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6fdt_.dbf',
29 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6nxy_.dbf',
30 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6qc2_.dbf',
31 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6stt_.dbf',
32 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6w5w_.dbf',
33 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t6yo0_.dbf',
34 '/s01/oradata/G10R21/datafile/o1_mf_users_7h6t717x_.dbf',
35 '/s01/oradata/G10R21/datafile/o1_mf_undotbs1_7h6ttkkx_.dbf',
36 '/s01/oradata/G10R21/datafile/o1_mf_undotbs1_7h6ttpn1_.dbf',
37 '/s01/oradata/G10R21/datafile/o1_mf_undotbs1_7h6ttsbd_.dbf'
CHARACTER SET AL32UTF8; 38
Control file created.
SQL> oradebug setmypid;
Statement processed.
SQL> oradebug dump controlf 3;
Statement processed.
SQL> oradebug tracefile_name;
***************************************************************************
DATABASE ENTRY
***************************************************************************
(size = 316, compat size = 316, section max = 1, section in-use = 1,
last-recid= 0, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 1, numrecs = 1)
03/09/2012 23:20:03
DB Name "G10R21"
Database flags = 0x00400147 0x00001000
Controlfile Creation Timestamp 03/09/2012 23:20:03
Incmplt recovery scn: 0x0000.00e77932
Resetlogs scn: 0x0000.00e7784f Resetlogs Timestamp 03/09/2012 23:11:46
Prior resetlogs scn: 0x0000.00e77780 Prior resetlogs Timestamp 03/09/2012 22:57:44
Redo Version: compatible=0xa200100
#Data files = 16, #Online files = 16
Database checkpoint: Thread=0 scn: 0x0000.00000000
Threads: #Enabled=1, #Open=0, Head=0, Tail=0
***************************************************************************
REDO THREAD RECORDS
***************************************************************************
(size = 256, compat size = 256, section max = 8, section in-use = 1,
last-recid= 0, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 9, numrecs = 8)
THREAD #1 - status:0x6 thread links forward:0 back:0
#logs:3 first:1 last:3 current:3 last used seq#:0x0
enabled at scn: 0x0000.00000000 01/01/1988 00:00:00
disabled at scn: 0x0000.00000000 01/01/1988 00:00:00
opened at 01/01/1988 00:00:00 by instance
Checkpointed at scn: 0x0000.00000000
thread:0 rba:(0x0.0.0)
***************************************************************************
LOG FILE RECORDS
***************************************************************************
(size = 72, compat size = 72, section max = 16, section in-use = 3,
last-recid= 0, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 10, numrecs = 16)
LOG FILE #1:
(name #5) /s01/oradata/G10R21/onlinelog/o1_mf_1_7ch812dg_.log
(name #6) /s01/flash_recovery_area/G10R21/onlinelog/o1_mf_1_7ch813h5_.log
Thread 1 redo log links: forward: 2 backward: 0
siz: 0x19000 seq: 0x00000000 hws: 0x0 bsz: 512 nab: 0x0 flg: 0x1 dup: 2
Archive links: fwrd: 0 back: 0 Prev scn: 0x0000.00000000
Low scn: 0x0000.00000000 01/01/1988 00:00:00
Next scn: 0x0000.00000000 01/01/1988 00:00:00
LOG FILE #2:
(name #3) /s01/oradata/G10R21/onlinelog/o1_mf_2_7ch8144q_.log
(name #4) /s01/flash_recovery_area/G10R21/onlinelog/o1_mf_2_7ch815cj_.log
Thread 1 redo log links: forward: 3 backward: 1
siz: 0x19000 seq: 0x00000000 hws: 0x0 bsz: 512 nab: 0x0 flg: 0x1 dup: 2
Archive links: fwrd: 0 back: 0 Prev scn: 0x0000.00000000
Low scn: 0x0000.00000000 01/01/1988 00:00:00
Next scn: 0x0000.00000000 01/01/1988 00:00:00
LOG FILE #3:
(name #1) /s01/oradata/G10R21/onlinelog/o1_mf_3_7ch816g2_.log
(name #2) /s01/flash_recovery_area/G10R21/onlinelog/o1_mf_3_7ch817gp_.log
Thread 1 redo log links: forward: 0 backward: 2
siz: 0x19000 seq: 0x00000000 hws: 0x0 bsz: 512 nab: 0x2 flg: 0xb dup: 2
Archive links: fwrd: 0 back: 0 Prev scn: 0x0000.00000000
Low scn: 0x0000.00000000 01/01/1988 00:00:00
Next scn: 0x0000.00000000 01/01/1988 00:00:00
虽然database checkpoint scn 等都是0 ,但是不影响 从 最小的datafile header checkpoint change 开始recover的 结论。
SQL> recover database using backup controlfile;
ORA-00279: change 15169814 generated at 03/09/2012 23:12:46 needed for thread 1
ORA-00289: suggestion :
/s01/flash_recovery_area/G10R21/archivelog/2012_03_09/o1_mf_1_2_%u_.arc
ORA-00280: change 15169814 for thread 1 is in sequence #2
Specify log: {<RET>=suggested | filename | AUTO | CANCEL} |
|