oracle-scn資源控制
-------一個資料庫當前最大的可能SCN被稱為"最大合理SCN",該值可以透過如下方式計算:
ora1a-> date
Tue Jun 24 12:15:19 GMT+08:00 2014
SQL> select
2 (
3 (
4 (
5 (
6 (
7 (
8 to_char(sysdate,'YYYY')-1988
9 )*12+
10 to_char(sysdate,'mm')-1
11 )*31+to_char(sysdate,'dd')-1
12 )*24+to_char(sysdate,'hh24')
13 )*60+to_char(sysdate,'mi')
14 )*60+to_char(sysdate,'ss')
15 ) * to_number('ffff','XXXXXXXX')/4 scn
16 from dual
17 /
SCN
----------
1.3944E+13
SQL> select to_char(1.3944E+13) from dual;
TO_CHAR(1.3944
--------------
13944000000000
-------------總共scn資源
SQL> select power(2,48) scn from dual;
SCN
----------
2.8147E+14
SQL> select to_char(2.8147E+14) from dual;
TO_CHAR(2.8147E
---------------
281470000000000
--------------當前資料庫scn
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
1.3944E+13
SQL> select to_char(current_scn) from v$database;
TO_CHAR(CURRENT_SCN)
--------------------------------------------------------------------------------
13943693945867
-----------剩餘資料庫資源
SQL> select 281470000000000-13943693945867 from dual;
281470000000000-13943693945867
------------------------------
2.6753E+14
-------------Oracle在內部控制每秒增減的SCN不超過 16K,按照這樣計算,當前資料庫剩餘517年
SQL> select 2.6753E+14 / 16 / 1024 / 3600 / 24 / 365 from dual;
2.6753E+14/16/1024/3600/24/365
------------------------------
517.780801
############################
在CPU補丁中,Oracle提供了一個指令碼 scnhealthcheck.sql 用於檢查資料庫當前SCN的剩餘情況。
該指令碼的演算法和以上描述相同,最終將最大合理SCN 減去當前資料庫SCN,計算得出一個指標:HeadRoom。也就是SCN尚餘的頂部空間,這個頂部空間最後摺合成天數:
Rem
Rem $Header: rdbms/admin/scnhealthcheck.sql st_server_tbhukya_bug-13498243/8 2012/01/17 03:37:18 tbhukya Exp $
Rem
Rem scnhealthcheck.sql
Rem
Rem Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
Rem
Rem NAME
Rem scnhealthcheck.sql - Scn Health check
Rem
Rem DESCRIPTION
Rem Checks scn health of a DB
Rem
Rem NOTES
Rem .
Rem
Rem MODIFIED (MM/DD/YY)
Rem tbhukya 01/11/12 - Created
Rem
Rem
define LOWTHRESHOLD=10
define MIDTHRESHOLD=62
define VERBOSE=FALSE
set veri off;
set feedback off;
set serverout on
DECLARE
verbose boolean:=&&VERBOSE;
BEGIN
For C in (
select
version,
date_time,
dbms_flashback.get_system_change_number current_scn,
indicator
from
(
select
version,
to_char(SYSDATE,'YYYY/MM/DD HH24:MI:SS') DATE_TIME,
((((
((to_number(to_char(sysdate,'YYYY'))-1988)*12*31*24*60*60) +
((to_number(to_char(sysdate,'MM'))-1)*31*24*60*60) +
(((to_number(to_char(sysdate,'DD'))-1))*24*60*60) +
(to_number(to_char(sysdate,'HH24'))*60*60) +
(to_number(to_char(sysdate,'MI'))*60) +
(to_number(to_char(sysdate,'SS')))
) * (16*1024)) - dbms_flashback.get_system_change_number)
/ (16*1024*60*60*24)
) indicator
from v$instance
)
) LOOP
dbms_output.put_line( '-----------------------------------------------------'
|| '---------' );
dbms_output.put_line( 'ScnHealthCheck' );
dbms_output.put_line( '-----------------------------------------------------'
|| '---------' );
dbms_output.put_line( 'Current Date: '||C.date_time );
dbms_output.put_line( 'Current SCN: '||C.current_scn );
if (verbose) then
dbms_output.put_line( 'SCN Headroom: '||round(C.indicator,2) );
end if;
dbms_output.put_line( 'Version: '||C.version );
dbms_output.put_line( '-----------------------------------------------------'
|| '---------' );
IF C.version > '10.2.0.5.0' and
C.version NOT LIKE '9.2%' THEN
IF C.indicator>&MIDTHRESHOLD THEN
dbms_output.put_line('Result: A - SCN Headroom is good');
dbms_output.put_line('Apply the latest recommended patches');
dbms_output.put_line('based on your maintenance schedule');
IF (C.version < '11.2.0.2') THEN
dbms_output.put_line('AND set _external_scn_rejection_threshold_hours='
|| '24 after apply.');
END IF;
ELSIF C.indicator<=&LOWTHRESHOLD THEN
dbms_output.put_line('Result: C - SCN Headroom is low');
dbms_output.put_line('If you have not already done so apply' );
dbms_output.put_line('the latest recommended patches right now' );
IF (C.version < '11.2.0.2') THEN
dbms_output.put_line('set _external_scn_rejection_threshold_hours=24 '
|| 'after apply');
END IF;
dbms_output.put_line('AND contact Oracle support immediately.' );
ELSE
dbms_output.put_line('Result: B - SCN Headroom is low');
dbms_output.put_line('If you have not already done so apply' );
dbms_output.put_line('the latest recommended patches right now');
IF (C.version < '11.2.0.2') THEN
dbms_output.put_line('AND set _external_scn_rejection_threshold_hours='
||'24 after apply.');
END IF;
END IF;
ELSE
IF C.indicator<=&MIDTHRESHOLD THEN
dbms_output.put_line('Result: C - SCN Headroom is low');
dbms_output.put_line('If you have not already done so apply' );
dbms_output.put_line('the latest recommended patches right now' );
IF (C.version >= '10.1.0.5.0' and
C.version <= '10.2.0.5.0' and
C.version NOT LIKE '9.2%') THEN
dbms_output.put_line(', set _external_scn_rejection_threshold_hours=24'
|| ' after apply');
END IF;
dbms_output.put_line('AND contact Oracle support immediately.' );
ELSE
dbms_output.put_line('Result: A - SCN Headroom is good');
dbms_output.put_line('Apply the latest recommended patches');
dbms_output.put_line('based on your maintenance schedule ');
IF (C.version >= '10.1.0.5.0' and
C.version <= '10.2.0.5.0' and
C.version NOT LIKE '9.2%') THEN
dbms_output.put_line('AND set _external_scn_rejection_threshold_hours=24'
|| ' after apply.');
END IF;
END IF;
END IF;
dbms_output.put_line(
'For further information review MOS document id 1393363.1');
dbms_output.put_line( '-----------------------------------------------------'
|| '---------' );
END LOOP;
end;
/
--------------------------------------------------------------
ScnHealthCheck
--------------------------------------------------------------
Current Date: 2014/06/24 13:43:04
Current SCN: 973822
Version: 11.2.0.1.0
--------------------------------------------------------------
Result: A - SCN Headroom is good
Apply the latest recommended patches
based on your maintenance schedule
AND set _external_scn_rejection_threshold_hours=24 after apply.
For further information review MOS document id 1393363.1
--------------------------------------------------------------
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29108064/viewspace-1192525/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Docker執行資源控制Docker
- 控制器 巢狀資源巢狀
- Thread 控制資源例項thread
- docker的資源控制(CPU、記憶體、IO)Docker記憶體
- wpf自定義控制元件新增引用資源控制元件
- C語言系統資源控制(getrlimit && setrlimit)C語言MIT
- 安全測試---資源控制怎麼實現?
- 資源供給:併發性控制和mutex之一Mutex
- 資源供給:併發性控制和mutex之二Mutex
- 資源供給:併發性控制和mutex之三Mutex
- GridView用資料來源控制元件和用DataTable作為資料來源的不同View控制元件
- 從零搭建一個IdentityServer——資源與訪問控制IDEServer
- 採用linux cgroup控制redis主從多例項資源LinuxRedis
- k8s--資源控制器限制配置詳解K8S
- AIX命令集錦七(系統資源控制器命令)AI
- ECS控制檯雲資源分組管理新姿勢—全域性標籤
- 《非生物因素》解析:用資源規劃控制玩家體驗曲線
- 使用 Admission Webhook 機制實現多叢集資源配額控制WebHook
- 【資源管理器】資源使用者組、資源計劃、資源計劃指令
- PMP資源最佳化技術:資源平衡、資源平滑
- EMC儲存 硬碟 電源 控制器硬碟
- 解密JBoss和Weblogic資料來源連線字串和控制檯密碼解密Web字串密碼
- Identity Server 4資源擁有者密碼認證控制訪問APIIDEServer密碼API
- 減少失誤提高策略性,ACT遊戲中的戰鬥資源控制遊戲
- 在K8S中,Pod 如何實現對節點的資源控制?K8S
- 透過STS來對AWS資源進行更靈活的許可權控制
- 資源下載類網站-如何判定該資源是否是最新資源網站
- 機器學習資源機器學習
- 資源分享
- 資源管理
- 程式碼缺陷解讀——不受控制的資源消耗及表示式永假永真
- 【新炬網路名師大講堂】WAS控制檯資料來源資訊無故丟失
- 利用域控制器和NFS建立統一儲存和資訊資源管理平臺NFS
- 在Docker中,如何控制容器佔用系統資源(CPU,記憶體)的份額?Docker記憶體
- c# 多執行緒環境下控制對共享資源訪問的辦法C#執行緒
- 專案:IT資源共享資源(登入前端)<1>前端
- 開源一個ReactNative日曆控制元件React控制元件
- Go運算子、控制語句-DateWhale開源學習Go