環境:RHEL 6.5(x86-64) + Oracle 11.2.0.4
聲明:推進SCN屬於非常規恢復范疇,不建議非專業人員操作,否則后果自負。
需求:我這里演示下推進SCN 10W數量級,實際需求推進多少可以根據ORA-600 [2662] [a] [b] [c] [d] [e]具體值來確認。
ARGUMENTS:
Arg [a] Current SCN WRAP
Arg [b] Current SCN BASE
Arg [c] dependent SCN WRAP
Arg [d] dependent SCN BASE
Arg [e] Where present this is the DBA where the dependent SCN came from.
更多詳情可參考: ORA-600 [2662] "Block SCN is ahead of Current SCN" (文檔 ID 28929.1)
1.查看當前數據庫的Current SCN
SYS@orcl> select current_scn||'' from v$database;
CURRENT_SCN||''
--------------------------------------------------------------------------------
4563483988
可以看到當前SCN是4563483988,我現在想推進SCN,在10w級別,也就是4563483988標紅數字修改為指定值。
2.重新啟動數據庫到mount階段
重新啟動數據庫到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。SYS@orcl> oradebug setmypid
Statement processed.
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
SYS@orcl> oradebug poke 0x06001AE70 8 4563983988
BEFORE: [06001AE70, 06001AE78) = 00000000 00000000
AFTER: [06001AE70, 06001AE78) = 1008DE74 00000001
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的方法
本文在 2018-12-16 進一步補充說明: 在實際這類工作中,我們實際應該是要認真計算好需要推進SCN的值,而不應圖省事直接給一個很大的值。后者不但是技術水平不成熟的表現,而且是不負責任的行為。--ORA-00600: internal error code, arguments: [2662], [2], [1424107441], [2], [1424142235], [8388617], [], []
select 2*power(2,32)+1424142235 from dual;
10014076827
--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
oradebug setmypid
oradebug dumpvar sga kcsgscn_
oradebug poke 0x060012658 8 10014077592
oradebug dumpvar sga kcsgscn_
alter database open;
最后要說的是,做事情還是多考慮些,在非常規恢復中也能溫柔的去推進SCN,高級DBA的價值從細節上體現。