欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

[20210224]控制文件序列号满的分析.txt

程序员文章站 2022-03-05 17:02:00
[20210224]控制文件序列号满的分析.txt--//上午看了链接:https://blog.csdn.net/enmotech/article/details/113855641,出现控制文件序列号满的情况,我从来没有遇到.--//下午没事,看看是否能在测试环境演示出来重复故障.--//注意不 ......

[20210224]控制文件序列号满的分析.txt

--//上午看了链接:https://blog.csdn.net/enmotech/article/details/113855641,出现控制文件序列号满的情况,我从来没有遇到.
--//下午没事,看看是否能在测试环境演示出来重复故障.
--//注意不能在生产系统做这样的测试!!!很久没有做这类恢复工作,写的有点乱.

1.环境:
scott@book> @ ver1
port_string                    version        banner
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/linux 2.4.xx            11.2.0.4.0     oracle database 11g enterprise edition release 11.2.0.4.0 - 64bit production

2.测试:
--//首先我仔细看了原始链接,我发现作者通过设置小的闪回区,不断切换归档,看查看控制文件顺序号.
--//我自己也尝试了一下,导致归档满了,挂起,我认为跟这个没关系,实际上只要切换归档或者发出检查点,
--//控制文件顺序号就会增加.我先验证这种情况.

sqlplus -s -l scott/book << eof | grep "[0-9]"
set head off
set feedback off
$(seq 5 | xargs -i{} echo -e 'alter system checkpoint;\nselect  controlfile_sequence# from v$database;\nhost sleep 1')
quit
eof

                36500
                36501
                36502
                36503
                36504
--//你可以发现发出检查点,controlfile_sequence#增加1.

sqlplus -s -l scott/book << eof | grep "[0-9]"
set head off
set feedback off
$(seq 5 | xargs -i{} echo -e 'alter system switch logfile;\nselect  controlfile_sequence# from v$database;\nhost sleep 1')
quit
eof

                36506
                36509
                36513
                36517
                36520
--//执行alter system switch logfile也是一样.
--//我有一种预感可能对方日志可能切换过于频繁,可能导致控制文件序列号增加太快,消耗枯竭.

3.首先定位它在控制文件的什么位置.

sys@book> @ spid
         sid      serial# process                  server    spid       pid    p_serial# c50
------------ ------------ ------------------------ --------- ------ ------- ------------ --------------------------------------------------
          30          261 57742                    dedicated 57743       26          101 alter system kill session '30,261' immediate;

scott@book> select  controlfile_sequence# from v$database;
controlfile_sequence#
---------------------
                36571

$ strace  -f -p 57743 -e pread
process 57743 attached - interrupt to quit
pread(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4\327?\0\0\0\0\0\0\0\4 \vn!\267o"..., 16384, 16384) = 16384
pread(256, "\25\302\0\0\17\0\0\0j\275\0\0\377\377\1\4 c\0\0\0\6\0\0\0\0\0\0\0\0\0\4"..., 16384, 245760) = 16384
pread(256, "\25\302\0\0\21\0\0\0j\275\0\0\377\377\1\4\225z\0\0\0\0\0\0\0\0\0\0\256\36q5"..., 16384, 278528) = 16384
pread(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4\327?\0\0\0\0\0\0\0\4 \vn!\267o"..., 16384, 16384) = 16384
pread(256, "\25\302\0\0\17\0\0\0j\275\0\0\377\377\1\4 c\0\0\0\6\0\0\0\0\0\0\0\0\0\4"..., 16384, 245760) = 16384
pread(256, "\25\302\0\0\21\0\0\0j\275\0\0\377\377\1\4\225z\0\0\0\0\0\0\0\0\0\0\256\36q5"..., 16384, 278528) = 16384
pread(256, "\25\302\0\0\32\1\0\0b\275\0\0\377\377\1\4\3270\0\0\27\2\2\0\345\7\0\0\0\0\0\0"..., 16384, 4620288) = 16384

--//应该读的位置在控制文件偏移16384,245760,278528,4620288.
$ echo 16384,245760,278528,4620288 | tr ',' '\n' | xargs -iq bash -c "echo q/16384| bc "| paste -sd','
1,15,17,282

--//关闭数据库,重新启动数据库到mount状态.这样启动后应该不变.
sys@book> startup mount
oracle instance started.
total system global area  643084288 bytes
fixed size                  2255872 bytes
variable size             205521920 bytes
database buffers          427819008 bytes
redo buffers                7487488 bytes
database mounted.

sys@book> select  controlfile_sequence# from v$database;
controlfile_sequence#
---------------------
                36580

--//36580 = 0x8ee4,颠倒过来就是0xe48e.
$ echo 1,15,17,282 | tr ',' '\n' | xargs -iq echo -e 'set dba 101,q\nfind /x e48e top'  | rlbbed
bbed: release 2.0.0.0.0 - limited production on wed feb 24 15:59:39 2021
copyright (c) 1982, 2011, oracle and/or its affiliates.  all rights reserved.
************* !!! for oracle internal use only !!! ***************

bbed> set count 64
        count           64

bbed> set width 160
        width           160

bbed>   dba             0x19400001 (423624705 101,1)

bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 1                                                    offsets:   40 to  103                                               dba:0x19400001
------------------------------------------------------------------------------------------------------------------------------------------------
 e48e0000 8c020000 00400000 00000100 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 5e89c659 ae1e7135

 <64 bytes per line>

bbed>   dba             0x1940000f (423624719 101,15)
bbed> bbed-00212: search string not found
bbed>   dba             0x19400011 (423624721 101,17)
bbed> bbed-00212: search string not found
bbed>   dba             0x1940011a (423624986 101,282)
bbed> bbed-00212: search string not found
--//注我已经定义101对应控制文件,并且实际上指定101,自动设置blocksize=16384,不需要设定.

$ ls -l /mnt/ramdisk/book/control01.ctl
-rw-r----- 1 oracle oinstall 10698752 2021-02-24 16:03:22 /mnt/ramdisk/book/control01.ctl
--//10698752/16384 = 653,从0开始到652,控制文件的0块也是os头,你可以使用xxd -c 16 /mnt/ramdisk/book/control01.ctl查看.
$ xxd -c 16 /mnt/ramdisk/book/control01.ctl | head -6
0000000: 00c2 0000 0000 c0ff 0000 0000 0000 0000  .?...?........
0000010: eaf8 0000 0040 0000 8c02 0000 7d7c 7b7a  犋...@......}||z
                                       ~~~~~~~~~=>奇幻数,数据文件以及日志文件都有类似标识.
0000020: a081 0000 0000 0000 0000 0000 0000 0000  ................
0000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................

$ seq 652 | tr ',' '\n' | xargs -iq echo -e 'set dba 101,q\nfind /x e48e top'  | rlbbed | grep -c2 "\-\-\--"
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 1                                                    offsets:   40 to  103                                               dba:0x19400001
------------------------------------------------------------------------------------------------------------------------------------------------
 e48e0000 8c020000 00400000 00000100 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 5e89c659 ae1e7135
--//很明显位置在控制文件块1,偏移40的位置,应该占32位,4个字节.最大0xffffffff = 4294967295.

4.先做一些功课,看看数据文件以及日志是否存在这个信息.
--//我看一些文件头资料,在数据文件头kcvfh.kcvfhhdr.kccfhcsq也是记录控制文件的seq.
$ seq 6 | xargs -iq echo "p dba q,1  kcvfh.kcvfhhdr.kccfhcsq" | rlbbed| grep kccfhcsq
bbed> ub4 kccfhcsq                                @40       0x00008edc
bbed> ub4 kccfhcsq                                @40       0x00008edc
bbed> ub4 kccfhcsq                                @40       0x00008edc
bbed> ub4 kccfhcsq                                @40       0x00008edc
bbed> ub4 kccfhcsq                                @40       0x00008edc
bbed> ub4 kccfhcsq                                @40       0x00008edc
--//也是在文件头偏移40的位置,但是数值0x8edc = 36572.感觉是我关闭数据库记录的值写入的,比前面+1(对比前面).

--//看看日志文件的情况:
$ seq 501 503 | xargs -iq echo "dump /v dba q,1 offset 36 count 8" | rlbbed | grep 00900100
 d68e0000 00900100                                                       l ........
 dc8e0000 00900100                                                       l ........
 d28e0000 00900100                                                       l ........
--//注我已经定义501,502,503对应日志文件redo01.log,redo02.log,redo03.log.
--//我估计在切换日志时写入当时的控制文件seq.

sys@book> @ log
show redo log layout from v$log and v$logfile...
         group#         thread#       sequence#           bytes       blocksize         members arc status             first_change# first_time             next_change# next_time
--------------- --------------- --------------- --------------- --------------- --------------- --- ---------------- --------------- ------------------- --------------- -------------------
              1               1             716        52428800             512               1 yes inactive             13276955579 2021-02-24 15:48:54     13276955587 2021-02-24 15:48:57
              2               1             717        52428800             512               1 no  current              13276955587 2021-02-24 15:48:57 281474976710655
              3               1             715        52428800             512               1 yes inactive             13276955571 2021-02-24 15:48:51     13276955579 2021-02-24 15:48:54
--//可以确定日志文件也有对应信息.位于块1的偏移36字节处.当前日志是第2组.

5.尝试修改控制文件顺序号:
--//注意修改前备份控制文件.关闭数据库
$ cp  /mnt/ramdisk/book/control0* /home/oracle/tmp/

bbed> set dba 101,1
        dba             0x19400001 (423624705 101,1)

bbed> dump /v dba 101,1 offset 40 count 8
 file: /mnt/ramdisk/book/control01.ctl (101)
 block: 1                                 offsets:   40 to   47                            dba:0x19400001
-----------------------------------------------------------------------------------------------------------
 e68e0000 8c020000                                                       l ........
 <32 bytes per line>
--//关闭数据库后增加+2.

$ seq 652 | tr ',' '\n' | xargs -iq echo -e 'set dba 101,q\nfind /x e68e top'  | rlbbed | grep -c2 "\-\-\--"
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 1                                                    offsets:   40 to  103                                               dba:0x19400001
------------------------------------------------------------------------------------------------------------------------------------------------
 e68e0000 8c020000 00400000 00000100 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 5e89c659 ae1e7135

$ seq 652 | tr ',' '\n' | xargs -iq echo -e 'set dba 101,q\nfind /x e48e top'  | rlbbed | grep -c2 "\-\-\--"
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 15                                                   offsets:    8 to   71                                               dba:0x1940000f
------------------------------------------------------------------------------------------------------------------------------------------------
 e48e0000 ffff0104 2ce80000 00040000 00000000 00000004 06440008 000400e3 00000000 00000002 00000000 00000000 008ddae0 15000000 00000000 00000000
--
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 17                                                   offsets:    8 to   71                                               dba:0x19400011
------------------------------------------------------------------------------------------------------------------------------------------------
 e48e0000 ffff0104 10de0000 00000000 00000000 ae1e7135 424f4f4b 00000000 00000000 08024000 01404010 00000000 00000000 06200e00 00000000 b01e7135
--
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 281                                                  offsets:    8 to   71                                               dba:0x19400119
------------------------------------------------------------------------------------------------------------------------------------------------
 e48e0000 ffff0104 9adc0000 0dff0200 e1070000 00000000 00000000 02000000 02000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
--//视乎在别的位置备份原来的控制文件seq信息.仅仅是猜测.因为前面查询没找到.
--//我尝试再次mount查询该位置.

sys@book> select  controlfile_sequence# from v$database;
controlfile_sequence#
---------------------
                36587

--//36587 = 0x8eeb
$ seq 652 | tr ',' '\n' | xargs -iq echo -e 'set dba 101,q\nfind /x eb8e top'  | rlbbed | grep -c2 "\-\-\--"
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 1                                                    offsets:   40 to  103                                               dba:0x19400001
------------------------------------------------------------------------------------------------------------------------------------------------
 eb8e0000 8c020000 00400000 00000100 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 12d1c659 ae1e7135

$ seq 652 | tr ',' '\n' | xargs -iq echo -e 'set dba 101,q\nfind /x ea8e top'  | rlbbed | grep -c2 "\-\-\--"
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 15                                                   offsets:    8 to   71                                               dba:0x1940000f
------------------------------------------------------------------------------------------------------------------------------------------------
 ea8e0000 ffff0104 2ca00000 00040000 00000000 00000004 06440008 000c00a3 04000000 00000002 00000000 04000000 008ddae0 15000000 00000000 00000000

--
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 17                                                   offsets:    8 to   71                                               dba:0x19400011
------------------------------------------------------------------------------------------------------------------------------------------------
 ea8e0000 ffff0104 10de0000 00000000 00000000 ae1e7135 424f4f4b 00000000 00000000 08024000 01404010 00000000 00000000 06200e00 00000000 b01e7135

--
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 319                                                  offsets:    8 to   71                                               dba:0x1940013f
------------------------------------------------------------------------------------------------------------------------------------------------
 ea8e0000 ffff0104 e60b0000 626f6f6b 000060ff ffffffff 03b66b2a ff7f0000 38aeef7e 00000000 48000000 00000000 48000000 fd7f0000 10000000 00000000
--//应该可以肯定我的分析大致正确.开始修改看看.注意最好在关闭数据库下进行.

bbed> dump /v   dba 101,1 offset 40 count 16
 file: /mnt/ramdisk/book/control01.ctl (101)
 block: 1                                 offsets:   40 to   55                            dba:0x19400001
-----------------------------------------------------------------------------------------------------------
 ed8e0000 8c020000 00400000 00000100                                     l .........@......
<32 bytes per line>

--//修改命令如下:
modify /x ff8e dba 101,1 offset 40
sum apply dba 101,1
modify /x ff8e dba 102,1 offset 40
sum apply dba 102,1
--//注意另外的控制文件也要修改:

bbed> modify /x ff8e dba 101,1 offset 40
warning: contents of previous bifile will be lost. proceed? (y/n) y
 file: /mnt/ramdisk/book/control01.ctl (101)
 block: 1                                                    offsets:   40 to   55                                               dba:0x19400001
------------------------------------------------------------------------------------------------------------------------------------------------
 ff8e0000 8c020000 00400000 00000100
<64 bytes per line>

bbed> sum apply dba 101,1
check value for file 101, block 1:
current = 0x8883, required = 0x8883

bbed> modify /x ff8e dba 102,1 offset 40
 file: /mnt/ramdisk/book/control02.ctl (102)
 block: 1                                                    offsets:   40 to   55                                               dba:0x19800001
------------------------------------------------------------------------------------------------------------------------------------------------
 ff8e0000 8c020000 00400000 00000100

 <64 bytes per line>

bbed> sum apply dba 102,1
check value for file 102, block 1:
current = 0x8883, required = 0x8883
--//0x8eff = 36607,验证看看:

sys@book> startup mount
oracle instance started.

total system global area  643084288 bytes
fixed size                  2255872 bytes
variable size             205521920 bytes
database buffers          427819008 bytes
redo buffers                7487488 bytes
database mounted.

sys@book> select  controlfile_sequence# from v$database;
controlfile_sequence#
---------------------
                36612
--//36612 = 0x8f04,即使在mount状态也增加一点点.

bbed> dump /v   dba 101,1 offset 40 count 16
 file: /mnt/ramdisk/book/control01.ctl (101)
 block: 1                                 offsets:   40 to   55                            dba:0x19400001
-----------------------------------------------------------------------------------------------------------
 048f0000 8c020000 00400000 00000100                                     l .........@......

 <32 bytes per line>
--//说明修改位置正确.

6.继续增大步幅:
--//注意修改前最好关闭数据库进行.
bbed> modify /x 8affffff dba 101,1 offset 40
bbed-00209: invalid number (8affffff)

--//有一个小技巧就是如果修改4个字节的话,第一个字符要小于0x8,,不然报错.
--//修改命令如下:
modify /x 7fffffff dba 101,1 offset 40
sum apply dba 101,1
modify /x 7fffffff dba 102,1 offset 40
sum apply dba 102,1

--//相当于控制文件seq = 0xffffff7f  = 4294967167.
--//0xff-0x7f = 128

sys@book> startup mount
oracle instance started.
total system global area  643084288 bytes
fixed size                  2255872 bytes
variable size             205521920 bytes
database buffers          427819008 bytes
redo buffers                7487488 bytes
database mounted.

sys@book> select  controlfile_sequence# from v$database;
controlfile_sequence#
---------------------
           4294967172

--//4294967172= 0xffffff84,^_^现在已经逼近消耗枯竭状态了.看看是否可以打开,该是见证奇迹的时刻...

sys@book> alter database open ;
database altered.

sys@book> alter system checkpoint ;
system altered.

sys@book> select  controlfile_sequence# from v$database;
controlfile_sequence#
---------------------
           4294967181

sys@book> alter system checkpoint ;
system altered.

sys@book> select  controlfile_sequence# from v$database;
controlfile_sequence#
---------------------
           4294967182

--//每次checkpoint仅仅增加1. 0xffffffff = 4294967295
sys@book> alter system switch logfile;
system altered.

--//执行多次,加快增加....省略....

sys@book> alter system switch logfile;
system altered.

..

sys@book> alter system checkpoint ;
system altered.

sys@book> select  controlfile_sequence# from v$database;
controlfile_sequence#
---------------------
           4294967295
--//4294967295= 0xffffffff,在往前呢?

sys@book> alter system checkpoint ;
system altered.

sys@book> select  controlfile_sequence# from v$database;
--//挂起..

--//alert.log报如下错误.
wed feb 24 17:14:01 2021
errors in file /u01/app/oracle/diag/rdbms/book/book/trace/book_arc1_29847.trc:
ora-00202: control file: '/mnt/ramdisk/book/control01.ctl'
errors in file /u01/app/oracle/diag/rdbms/book/book/trace/book_arc1_29847.trc  (incident=3792203):
ora-00227: corrupt block detected in control file: (block 1, # blocks 1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ora-00202: control file: '/mnt/ramdisk/book/control01.ctl'
incident details in: /u01/app/oracle/diag/rdbms/book/book/incident/incdir_3792203/book_arc1_29847_i3792203.trc
wed feb 24 17:14:02 2021
sweep [inc][3792203]: completed
sweep [inc][3792195]: completed
sweep [inc2][3792203]: completed
sweep [inc2][3792195]: completed
dumping diagnostic data in directory=[cdmp_20210224171402], requested by (instance=1, osid=29847 (arc1)), summary=[incident=3792203].

bbed> dump /v   dba 101,1 offset 40 count 16
 file: /mnt/ramdisk/book/control01.ctl (101)
 block: 1                                 offsets:   40 to   55                            dba:0x19400001
-----------------------------------------------------------------------------------------------------------
 00000000 8c020000 00400000 00000100                                     l .........@......
 <32 bytes per line>
--//全部为0.补充说明我做了多次,如果seq跳跃很快,数据库直接crash,我上面的测试到4294967295时换成了alter system checkpoint ;.

$ echo 15,17,281,319 | tr ',' '\n' | xargs -iq echo -e 'set dba 101,q\ndump /v offset 8 count 8'  | rlbbed | grep -c2 "\-\-"
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 15                                offsets:    8 to   15                            dba:0x1940000f
-----------------------------------------------------------------------------------------------------------
 ffffffff ffff0104                                                       l ........

--
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 17                                offsets:    8 to   15                            dba:0x19400011
-----------------------------------------------------------------------------------------------------------
 ffffffff ffff0104                                                       l ........

--
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 281                               offsets:    8 to   15                            dba:0x19400119
-----------------------------------------------------------------------------------------------------------
 85ffffff ffff0104                                                       l ........

--
bbed>  file: /mnt/ramdisk/book/control01.ctl (101)
 block: 319                               offsets:    8 to   15                            dba:0x1940013f
-----------------------------------------------------------------------------------------------------------
 83ffffff ffff0104                                                       l ........
--//验证我的推测.这里也记录seq信息.

$ seq 501 503 | xargs -iq echo "dump /v dba q,1 offset 36 count 8" | rlbbed | grep 00900100
f8ffffff 00900100                                                       l ........
fcffffff 00900100                                                       l ........
fcffffff 00900100                                                       l ........

--//现在数据库依旧可以登录,但是一些查询会hang住,比如查询v$database视图.

sys@book> shutdown immediate;
ora-00227: corrupt block detected in control file: (block 1, # blocks 1)
ora-00202: control file: '/mnt/ramdisk/book/control01.ctl'

sys@book> alter system checkpoint ;
alter system checkpoint
      *
error at line 1:
ora-03113: end-of-file on communication channel
process id: 30040
session id: 114 serial number: 3

--//alert.log记录如下:
wed feb 24 17:27:02 2021
errors in file /u01/app/oracle/diag/rdbms/book/book/trace/book_ckpt_29816.trc:
ora-00202: control file: '/mnt/ramdisk/book/control01.ctl'
errors in file /u01/app/oracle/diag/rdbms/book/book/trace/book_ckpt_29816.trc  (incident=3792131):
ora-00227: corrupt block detected in control file: (block 1, # blocks 1)
ora-00202: control file: '/mnt/ramdisk/book/control01.ctl'
errors in file /u01/app/oracle/diag/rdbms/book/book/trace/book_ckpt_29816.trc:
ora-00227: corrupt block detected in control file: (block 1, # blocks 1)
ora-00202: control file: '/mnt/ramdisk/book/control01.ctl'
ckpt (ospid: 29816): terminating the instance due to error 227
wed feb 24 17:27:03 2021
system state dump requested by (instance=1, osid=29816 (ckpt)), summary=[abnormal instance termination].
system state dumped to trace file /u01/app/oracle/diag/rdbms/book/book/trace/book_diag_29800_20210224172703.trc
dumping diagnostic data in directory=[cdmp_20210224172703], requested by (instance=1, osid=29816 (ckpt)), summary=[abnormal instance termination].
instance terminated by ckpt, pid = 29816

7.尝试恢复:

sys@book> startup mount
oracle instance started.

total system global area  643084288 bytes
fixed size                  2255872 bytes
variable size             205521920 bytes
database buffers          427819008 bytes
redo buffers                7487488 bytes
ora-00227: corrupt block detected in control file: (block 1, # blocks 1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ora-00202: control file: '/mnt/ramdisk/book/control01.ctl'

sys@book> select  controlfile_sequence# from v$database;
select  controlfile_sequence# from v$database
                                   *
error at line 1:
ora-01507: database not mounted

--//alert.log
alter database   mount
errors in file /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_30094.trc:
ora-00202: control file: '/mnt/ramdisk/book/control01.ctl'
wed feb 24 17:29:02 2021
sweep [inc][3792131]: completed
errors in file /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_30094.trc  (incident=3793788):
ora-00227: corrupt block detected in control file: (block 1, # blocks 1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-// 我没有遇到原链接的提示,这个提示有点昏.
ora-00202: control file: '/mnt/ramdisk/book/control01.ctl'
incident details in: /u01/app/oracle/diag/rdbms/book/book/incident/incdir_3793788/book_ora_30094_i3793788.trc
dumping diagnostic data in directory=[cdmp_20210224172902], requested by (instance=1, osid=30094), summary=[incident=3793788].
ora-227 signalled during: alter database   mount...

$ dbv file=/mnt/ramdisk/book/control01.ctl  blocksize=16384
dbverify: release 11.2.0.4.0 - production on wed feb 24 17:29:52 2021
copyright (c) 1982, 2011, oracle and/or its affiliates.  all rights reserved.
dbverify - verification starting : file = /mnt/ramdisk/book/control01.ctl
dbverify - verification complete

total pages examined         : 652
total pages processed (data) : 0
total pages failing   (data) : 0
total pages processed (index): 0
total pages failing   (index): 0
total pages processed (other): 147
total pages processed (seg)  : 0
total pages failing   (seg)  : 0
total pages empty            : 505
total pages marked corrupt   : 0
total pages influx           : 0
total pages encrypted        : 0
highest block scn            : 4294967295 (65535.4294967295)
--//ok,但是注意后面那行.highest block scn : 4294967295 (65535.4294967295)
--//感觉这个可以称为控制文件的scn号. 4294967295 = 0xffffffff ,65535 = 0xffff

$ seq 6 | xargs -iq echo "p dba q,1  kcvfh.kcvfhhdr.kccfhcsq" | rlbbed| grep kccfhcsq
bbed> ub4 kccfhcsq                                @40       0xffffffff
bbed> ub4 kccfhcsq                                @40       0xffffffff
bbed> ub4 kccfhcsq                                @40       0xffffffff
bbed> ub4 kccfhcsq                                @40       0xffffffff
bbed> ub4 kccfhcsq                                @40       0xffffffff
bbed> ub4 kccfhcsq                                @40       0xffffffff
--//数据文件的kccfhcsq全部是0xffffffff.

bbed> dump /v dba 101,1 offset 40 count 4
 file: /mnt/ramdisk/book/control01.ctl (101)
 block: 1                                 offsets:   40 to   43                            dba:0x19400001
-----------------------------------------------------------------------------------------------------------
 00000000                                                                l ....
 <32 bytes per line>

--//执行如下:
modify /x 7fffffff dba 101,1 offset 40
modify /x 7fffffff dba 102,1 offset 40
modify /x ff dba 101,1 offset 40
modify /x ff dba 102,1 offset 40
sum apply dba 101,1
sum apply dba 102,1
--//重启不行.

modify /x 7fffffff dba 101,1 offset 40
modify /x 7fffffff dba 102,1 offset 40
sum apply dba 101,1
sum apply dba 102,1

sys@book> startup mount
oracle instance started.
total system global area  643084288 bytes
fixed size                  2255872 bytes
variable size             205521920 bytes
database buffers          427819008 bytes
redo buffers                7487488 bytes
ora-00600: internal error code, arguments: [2131], [9], [8], [], [], [], [], [], [], [], [], []
--//不行.

7.如何恢复呢?
--//链接介绍一种方式就是重建控制文件,使用resetlogs重建.
--//原始链接的测试使用resetlogs重建的控制文件,我做了ok,不再贴出,方法比较简单.
--//我想给自己增加一点点难度,就是使用noresetlogs打开,因为这样重建的控制文件要读取redo,数据文件重新
--//回填一些信息,实际上resetlogs也类似,但是noresetlogs回填的控制文件seq很大,一样打不开数据库.
--//也就是必须提到我前面要修改的数据文件以及redo文件的几个偏移位置.太长了,另外写一篇blog.

8.补充说明:
--//前面我提到的rlbbed我建立的bash shell函数,你可以使用别名代替,效果一样的.
$ export rlwrap=$(which rlwrap)
$ type rlbbed
rlbbed is a function
rlbbed ()
{
    cd /home/oracle/bbed;
    $rlwrap -s 9999 -c -r -i -f /usr/local/share/rlwrap/bbed $oracle_home/bin/bbed parfile=bbed.par cmdfile=cmd.par
}

--//关于bbed配置看相关文档.
$ cat cmd.par
set count 64
set width 160

$ cat bbed.par
blocksize=8192
listfile=$home/bbed/filelist.txt
mode=edit
password=blockedit
spool=y

--//filelist.txt文件通过select file#||' '||name c100 from v$dbfile order by file#;生成.我增加了控制文件以及redo文件.
--//还有临时文件.
$ cat filelist.txt  | grep -v "#"
4 /mnt/ramdisk/book/users01.dbf
1 /mnt/ramdisk/book/system01.dbf
2 /mnt/ramdisk/book/sysaux01.dbf
3 /mnt/ramdisk/book/undotbs01.dbf
5 /mnt/ramdisk/book/example01.dbf
6 /mnt/ramdisk/book/tea01.dbf

101 /mnt/ramdisk/book/control01.ctl
102 /mnt/ramdisk/book/control02.ctl

201 /mnt/ramdisk/book/temp01.dbf

501 /mnt/ramdisk/book/redo01.log
502 /mnt/ramdisk/book/redo02.log
503 /mnt/ramdisk/book/redo03.log
504 /mnt/ramdisk/book/redostb01.log

[20210224]控制文件序列号满的分析.txt