Skip to content

谈谈adjust_scn的计算方法

遭遇2662错误时候(关于2662的介绍参考我以前写的2262的介绍),经验丰富的dba首先考虑到的就是设置adjust_scn的方式来打开数据库,但是有个问题就是如何计算djust_scn level的合适的值?这方面的资料目前也比较少,关于这个方面的技术内容可以参考MT id:[​3​0​6​8​1​.​1​],但是升级后的OTN没这个文章了…所以这里最后面会贴出这个文章.

一:Adjust_scn算法规则

这个报错参数的含义在metalink中如此描述的:
Arg [a] Current SCN WRAP
Arg [b] Current SCN BASE
Arg dependent SCN WRAP
为了存储更大的SCN值,当SCN BASE到足够大并开始重置的时候,SCN WRAP将加1。

Arg [d] dependent SCN BASE
Arg [e] Where present this is the DBA where the dependent SCN came from.
也就是Arg [d] 的值是从哪个block中找到的,通常是一个datablock address。

通过这几个参数根据一定的规则可以计算出我们需要的level。计算规则如下:
1.Arg *4得出一个数值,假设为V_Wrap
2.如果Arg [d]=0,则V_Wrap值为需要的level
Arg [d] < 1073741824,V_Wrap+1为需要的level Arg [d] < 2147483648,V_Wrap+2为需要的level Arg [d] < 3221225472,V_Wrap+3为需要的level 二.计算案例 举个例子来计算: ORA-00600: internal error code, arguments: [2662], [0], [378942], [7777], [22222222], [111089032], [], [] 在这上面的报错根据算法计算如下: 1.Arg c *4 = 7777 * 4 = 31108 2.Arg [d] = 22222222 < 1073741824 所以这里adjust_scn=31108+1=31109 因此在这个例子中我们应该执行>
alter session set events ‘IMMEDIATE trace name ADJUST_SCN level 31109‘;

三.MOS文档信息

接下来提上相关的mos 文档资料:

DocID: Note:30681.1
Subject: EVENT: ADJUST_SCN - Quick Reference
Type: REFERENCE
Status: PUBLISHED
Content Type:TEXT/PLAIN
CreationDate: 20-OCT-1997
LastRevision Date: 04-AUG-2000
Language: USAENG

ADJUST_SCNEvent
~~~~~~~~~~~~~~~~
***WARNING ***
This event should only ever be used underthe guidance
of an experienced Oracle analyst.
If an SCN is ahead of the current databaseSCN, this indicates
some form of database corruption. Thedatabase should be rebuilt
after bumping the SCN.
****************

The ADJUST_SCN event is useful in somerecovery situations where the
current SCN needs to be incremented by alarge value to ensure it
isahead of the highest SCN in the database. This is typically
required if either:
a. An ORA-600 [2662] error is signalledagainst database blocks
or
b. ORA-1555 errors keep occuring afterforcing the database open
or ORA-604 / ORA-1555 errors occurduring database open.
(Note: If startup reports ORA-704& ORA-1555 errors together
then the ADJUST_SCN eventcannot be used to bump the
SCN as the error is occuringduring bootstrap.
Repeated startup/shutdown attemptsmay help if the SCN
mismatch is small)
or
c. If a database has been forced openused _ALLOW_RESETLOGS_CORRUPTION
(See<Parameter:Allow_Resetlogs_Corruption> )

The ADJUST_SCN event acts as describedbelow.

**NOTE: You can check that the ADJUST_SCNevent has fired as it
should write a message to the alert log inthe form
"Debugging event used to advance scn to %s".
If this message is NOT present in the alert log the event
has probably not fired.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the database will NOT open:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Take a backup.
You can use event 10015 to trigger anADJUST_SCN on database open:

startup mount;

alter session set events '10015 tracename adjust_scn level 1';

(NB: You can only use IMMEDIATE here onan OPEN database. If the
database is only mounted use the 10015 trigger to adjust SCN,
otherwise you get ORA 600 [2251], [65535], [4294967295] )

alter database open;

If you get an ORA 600:2256 shutdown, usea higher level and reopen.

Do *NOT* set this event in init.ora or theinstance will crash as soon
as SMON or PMON try to do any clean up.Always use it with the
"alter session" command.

~~~~~~~~~~~~~~~~~~~~~~~~~~
If the database *IS* OPEN:
~~~~~~~~~~~~~~~~~~~~~~~~~~
You can increase the SCN thus:

alter session set events 'IMMEDIATEtrace name ADJUST_SCN level 1';

LEVEL:Level 1 is usually sufficient - it raises the SCN to 1 billion
(1024*1024*1024)
Level 2 raises it to 2 billion etc...

If you try to raise the SCN to a level LESS THAN or EQUAL to its
current setting you will get <OERI:2256> - See below.
Ie: The event steps the SCN to known levels. You cannot use
the same level twice.

Calculating a Level from 600 errors:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get a LEVEL for ADJUST_SCN:

a) Determine the TARGET scn:
ora-600 [2662] See <OERI:2662> Use TARGET >= blocks SCN
ora-600 [2256] See<OERI:2256> Use TARGET >=Current SCN

b)Multiply the TARGET wrap number by 4. This will give you the level
to use in the adjust_scn to get the correct wrap number.
c) Next, add the following value to thelevel to get the desired base
value as well :

Add to Level Base
~~~~~~~~~~~~ ~~~~~~~~~~~~
0 0
1 1073741824
2 2147483648
3 3221225472

-------------------------------------------------------------------------------------------------------
数据库群: 66809572 欢迎从事it行业的朋友加入。2000人超级大群。