1.poke推进scn修复(针对2662)(ORA-600 [2662] [a] [b] [c] [d] [e])(12.2以下可以使用)
1.查看当前数据库的Current SCN
SYS@orcl> select current_scn||‘’ from v$database;
CURRENT_SCN||‘’
————————
4563483988
可以看到当前SCN是4563483988,我现在想推进SCN,在10w级别,也就是4563483988标红数字修改为指定值。
2.重新启动数据库到mount阶段
SYS@orcl> shutdown abort
ORACLE instance shut down.
SYS@orcl> startup mount
ORACLE instance started.
Total System Global Area 1235959808 bytes
Fixed Size 2252784 bytes
Variable Size 788529168 bytes
Database Buffers 436207616 bytes
Redo Buffers 8970240 bytes
Database mounted.
3.使用oradebug poke推进SCN
我这里直接把十万位的"4"改为"9"了,相当于推进了50w左右: 说明:实验发现oradebug poke 推进的SCN值,既可以指定十六进制的0x11008DE74,也可以直接指定十进制的4563983988。
1.指定进程
SYS@orcl> oradebug setmypid
Statement processed.
查看kcsgscn_
SYS@orcl> oradebug dumpvar sga kcsgscn_
kcslf kcsgscn_ [06001AE70, 06001AEA0) = 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 6001AB50 00000000
这步没用
SYS@orcl> select to_char(checkpoint_change#, ‘XXXXXXXXXXXXXXXX’) from v$database;
TO_CHAR(CHECKPOINT_CHANGE#,'XXXXXX
——————————————————————
110013C41
修改,poke
这里的0x06001AE70见oradebug dumpvar sga kcsgscn_出来的部分,8是固定的,4563983988是自己想要到的scn位置
SYS@orcl> oradebug poke 0x06001AE70 8 4563983988
BEFORE: [06001AE70, 06001AE78) = 00000000 00000000
AFTER: [06001AE70, 06001AE78) = 1008DE74 00000001
查看kcsgscn_
SYS@orcl> oradebug dumpvar sga kcsgscn_
kcslf kcsgscn_ [06001AE70, 06001AEA0) = 1008DE74 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 6001AB50 00000000
SYS@orcl> alter database open;
Database altered.
SYS@orcl> select current_scn||‘’ from v$database;
CURRENT_SCN||‘’
————————
4563984271
可以看到已经成功将SCN推进到4563983988,SCN不断增长,所以这里查到的值略大一些。
4.补充实际计算推进SCN的方法
ORA-600 [2662] [a] [b] [c] [d] [e]
本文在 2018-12-16 进一步补充说明: 在实际这类工作中,我们实际应该是要认真计算好需要推进SCN的值,而不应图省事直接给一个很大的值。后者不但是技术水平不成熟的表现,而且是不负责任的行为。
ora-600 [2662]参数说明:
ORA-00600: internal error code, arguments: [2662], [a], [b], [c], [d], [e], [], []
a–CRUUENT SCN WRAP
b–CURRENT SCN BASE
c–DEPENDENT SCN WRAP
d–DEPENDENT SCN BASE
e–where present this is the dba where the dependent scn came from.
例子1:
–ORA-00600: internal error code, arguments: [2662], [2], [1424107441], [2], [1424142235], [8388617], [], []
select 2*power(2,32)+1424142235 from dual;
10014076827
例子2:
–ORA-00600: internal error code, arguments: [2662], [2], [1424142249], [2], [1424142302], [8388649], [], []
select 2*power(2,32)+1424143000 from dual;
10014077592
总结公式:c * power(2,32) + d {+ 可适当加一点,但不要太大!}
c代表:Arg [c] dependent SCN WRAP
d代表:Arg [d] dependent SCN BASE
SCN组成:
SCN占6字节,由SCN_WRAP和SCN_BASE组成
SCN =(SCN_WRAP << 32)+ SCN_BASE
SCN是一个6字节(6*8=48bit)的数字,其值最大为281,474,976,710,656(2^48),SCN分为2个部分:
SCN_BASE是一个4字节(4 * 8=32bit)的数字
SCN_WRAP是一个2字节(2 * 8=16bit)的数字
每当SCN_BASE达到其最大值(2^32 = 4294967296)时,SCN_WRAP增加1,SCN_BASE将被重置为0,一直持续到SCN_WRAP达到其最大值,即2^16 = 65536
整个流程
oradebug setmypid
oradebug dumpvar sga kcsgscn_
oradebug poke 0x060012658 8 10014077592
oradebug dumpvar sga kcsgscn_
alter database open;
2.12c event 21307096推进scn修复 (12.2之后)
计算方式
Lowest_scn+event level * 1000000
查看当前数据库SCN:
SQL> select to_char(current_scn) from v$database;
TO_CHAR(CURRENT_SCN)
——————————————
12796139551520
2.添加event以及参数
alter system set “_allow_resetlogs_corruption”=true scope=spfile;
alter system set event=‘21307096 trace name context forever,level 3’ scope=spfile;
3.启动数据库
SQL> shutdown immediate;
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1660944384 bytes
Fixed Size 8793448 bytes
Variable Size 889193112 bytes
Database Buffers 754974720 bytes
Redo Buffers 7983104 bytes
Database mounted.
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 12796139551734 generated at 04/20/2022 11:13:44 needed for
thread 1
ORA-00289: suggestion :
/app/oracle/product/12.2.0/db_1/dbs/arch1_1_1102504135.dbf
ORA-00280: change 12796139551734 for thread 1 is in sequence #1
Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL>
SQL>
SQL> alter database open resetlogs;
Database altered.
SQL> select to_char(current_scn) from v$database;
TO_CHAR(CURRENT_SCN)
——————————————
12796142552279
SCN成功推进300w
3.gdb推进scn修复(12.2以下能用)
Session 1:
查询当前scn:
SQL> select current_scn from v$database;
CURRENT_SCN
————————
2910718245
查询当前SCN转成16进制后的值:
SQL> select to_char(2910718245,‘xxxxxxxxxxxx’) from dual;
TO_CHAR(29107
————————
ad7e0925
查询预修改的SCN转换成16进制后的值,本次将最高位增加一位数
SQL> select to_char(3910718245,‘xxxxxxxxxxxx’) from dual;
TO_CHAR(39107
————————
e918d325
SQL> oradebug setmypid
Statement processed.
SQL> oradebug dumpvar sga kcsgscn_
kscn8 kcsgscn_ [060017E98, 060017EA0) = AD7E093B 00000000
需要注意的是,060017E98是SCN BASE值,AD7E093B是当前的SCN值,可以理解为060017E98是一个代号x,当前的x等于AD7E093B,待会儿我们修改SCN值的时候,就会需要指定060017E98这个值等于多少。
Session 2:
[oracle@redhat19c11 ~]$ ps -ef|grep LOCAL=YES
oracle 9824 9730 0 Feb22 ? 00:00:01 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 18621 8636 0 01:18 pts/1 00:00:00 grep --color=auto LOCAL=YES
oracle 20109 20105 0 Feb15 ? 00:00:13 oracletestdb19c (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
本次测试库是orcl,因此选9824
[oracle@redhat19c11 ~]$ gdb $ORACLE_HOME/bin/oracle 9824
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright © 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type “show copying”
and “show warranty” for details.
This GDB was configured as “x86_64-redhat-linux-gnu”.
For bug reporting instructions, please see:
(gdb) set *((int *) 0x060017E98) = 0xe918d32—>将SCN BASE修改为刚才查出来的值
(gdb) quit
A debugging session is active.
Inferior 1 [process 9824] will be detached.
Quit anyway? (y or n) y
Detaching from program: /oracle/app/product/19.3.0/db_1/bin/oracle, process 9824
返回session1查询,修改成功:
SQL> select current_scn from v$database;
CURRENT_SCN
————————
3910718287
重启数据库,也可正常打开数据库
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 2466250400 bytes
Fixed Size 9137824 bytes
Variable Size 603979776 bytes
Database Buffers 1845493760 bytes
Redo Buffers 7639040 bytes
Database mounted.
Database opened.
SQL> select current_scn from v$database;
CURRENT_SCN
————————
3910719415
4.bbed修改
修改484和500信息即可
部分参考:
Nathan-wang