본문 바로가기
컴퓨터 활용(한글, 오피스 등)/기타

oracle DB Link 대신 EAI 권장

by 3604 2024. 4. 9.
728x90
  •  

출처: https://blog.naver.com/lirensi/220034851216

작년 부터 화두가 되는 Issue다.

SCN은 Oracle내부에서 운용되는 중요한 Key로서 System Change Number의 약자이다.

 

아래는 MOS에서 참조한 내용이다(ID. 1376995.1)

The system change number (SCN) is a logical, internal timestamp used by the Oracle Database.
SCNs order events that occur within the database, which is necessary to satisfy the ACID

properties of a transaction.

The database uses SCNs to query and track changes.
For example, if a transaction updates a row, then the database records the SCN at which

this update occurred.
Other modifications in this transaction typically have the same SCN.
When a transaction commits, the database records an SCN for this commit.
Multiple transactions that commit at the same time may share the same SCN.

SCNs occur in a monotonically increasing sequence, and there is a very large upper

limit to how many SCNs an Oracle Database can use - that limit is currently 281 trillion,

or specifically 281,474,976,710,656 (is 2^48) SCN values.

 

위의 내용 중 마지막을 보면 SCN에는 Limit이 있는데 약 281조까지 가능하다.

 

SCN = SCN Wrap(2 byte) + SCN Base(4 Byte) 로 구성되어 있으며, 아래와 같은 범위를 갖는다.

SCN Wrap : 0x0000 ~ 0xFFFF

SCN Base : 0x00000000 ~ 0xFFFFFFFF

 

즉, SCN은 0xFFFF FFFFFFFF = 281,474,976,710,655 까지 가능하다는 것이다.

Oracle에 따르면 초당 16K씩 증가한다고 위의 제한을 두었기에 약 544년동안 사용할 수 있다는

것으로 어마어마하게 큰 숫자임에는 틀림없다.

 

더 자세한 사항은 일단 생략하기로 하고,

이 처럼 꽤 큰 값이지만, 최근 국내 일부 Site에서 이것에 근접하게 SCN이 증가되어 Issue가

되었었다. 이유는 "SCN Propagation"에 기인한다.

즉, DB Link로 연결된 각 DB간에는 서로의 SCN중 가장 큰 값으로 동기화 한 후 Transaction을 처리

하는데 DB Link시 Undo Segment를 할당한다는 것을 안다면 이해하기가 쉬울것이다.

 

따라서 잘못 Recovery된 DB의 경우 SCN이 Bump-up이 되게되고(어떤 이유인지 모르지만) 이를 DB

Link로 사용하는 다른 DB또한 SCN이 Boom-up되는 것이 아닌가 한다는 것이 Oracle의 입장인 듯

하다.

 

이를 막기(?) 위해 Oracle에서는 CPUJan2012를 적용하라고 한다.

CPUJan2012에서는 SCN이 허용된 범위(Max Resonable SCN) 이상에서 증가되면 Error를 통해

사전에 알 수 있다는 것이다.

하지만 이 또한 Alert일뿐... 추후 어떻게 대응할지 지켜봐야 할 듯 하다.

 

### SCN 확인 SQL ###

1) Oracle 10g이상의 경우

col CURRENT_SCN format 999,999,999,999,999,990
select CURRENT_SCN from v$database;

set linesize 200
WITH limits AS (
  SELECT
      current_scn
  --, dbms_flashback.get_system_change_number as current_scn -- Oracle 9i
    , (SYSDATE - TO_DATE('1988-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) * 24*60*60 * 16384
        AS SCN_soft_limit
    , 281474976710656 AS SCN_hard_limit
  FROM V$DATABASE
)
SELECT
    current_scn
  , current_scn/scn_soft_limit*100 AS pct_soft_limit_exhausted
  , scn_soft_limit
  , current_scn/scn_hard_limit*100 AS pct_hard_limit_exhausted
  , scn_hard_limit
FROM limits;


SELECT NAME, 
   (current_scn/281474976710656)*100 as PCT_OF_SCN_KEYSPACE_USED, 
   ROUND(SYSDATE-CREATED) as DAYS_SINCE_DB_CREATION,
   ROUND(1/(current_scn/281474976710656)*(SYSDATE-CREATED)) AS EST_DAYS_BEFORE_SCN_EXHAUSTED,
   ROUND(1/(current_scn/281474976710656)*(SYSDATE-CREATED)/365) AS EST_YEARS_BEFORE_SCN_EXHAUSTED

FROM v$database;

 

2) Oracle 9i 이하의 경우

col CURRENT_SCN format 999,999,999,999,999,990
SELECT dbms_flashback.get_system_change_number as current_scn
FROM DUAL;

 

### 참조 ###

Master Note: Overview for SCN issues (Doc ID 1503937.1) 
System Change Number (SCN), Headroom, Security and Patch Information (Doc ID 1376995.1) 
Installing, Executing and Interpreting output from the "scnhealthcheck.sql" script (Doc ID 1393363.1) 
Evidence to collect when reporting "high SCN rate" issues to Oracle Support (Doc ID 1388639.1) 
PDIT : How to debug SCN growth on a Oracle Database (Doc ID 1554534.1)

http://orainternals.wordpress.com/2012/01/19/scn-what-why-and-how/

 

참고 자료

High Growth SCN Rate Issues - Oracle 가이드 및 권고안(2014 07).pdf
1.91MB

728x90