我是靠谱客的博主 成就便当,最近开发中收集的这篇文章主要介绍CUR_SCN_COMPAT 2019年6月23日自动从1直接跳级到3,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

[oracle@zyjxnew ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 3 09:39:59 2019

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> conn /as sysdba
Connected.
SQL> !vi scn_chk.sql

set serveroutput on
 declare
 rsl number;
 headroom_in_scn number;
 headroom_in_sec number;
 CUR_SCN_COMPAT number;
 MAX_SCN_COMPAT number;
 auto_rollover_ts date;
 target_compat number ;
 is_enabled boolean;
 VERSION varchar2(100);
 is_rolloverd boolean;
 db_role varchar2(100);
 started_ts date;
 begin
 select banner into VERSION from v$version where rownum=1;
 select DATABASE_ROLE into db_role from v$database;
 select startup_time into started_ts from v$instance;
 dbms_scn.GETCURRENTSCNPARAMS(rsl,headroom_in_scn,HEADROOM_IN_SEC,CUR_SCN_COMPAT,MAX_SCN_COMPAT);
 dbms_output.put_line('Current datatime:'||to_char(sysdate,'RRRRmmdd hh24:mi:ss'));
 dbms_output.put_line('Oracle Version:'||VERSION);
 dbms_output.put_line('Database role:' ||db_role);
 dbms_output.put_line('Instance starttime: '||to_char(started_ts,'RRRRmmdd hh24:mi:ss'));
 dbms_output.put_line('RSL=' ||rsl);
 dbms_output.put_line('headroom_in_scn=' || headroom_in_scn);
 dbms_output.put_line('headroom_in_sec=' || headroom_in_sec);
 dbms_output.put_line('CUR_SCN_COMPAT=' ||CUR_SCN_COMPAT);
 dbms_output.put_line('MAX_SCN_COMPAT=' ||MAX_SCN_COMPAT);
 
 dbms_scn.getscnautorolloverparams (auto_rollover_ts, target_compat, is_enabled);
 dbms_output.put_line( 'auto_rollover_ts='|| to_char(auto_rollover_ts, 'YYYY-MM-DD' ));
 dbms_output.put_line( 'target_compat='||target_compat);
 if(is_enabled) then
 dbms_output.put_line(' Auto_rollover is enabled!' );
 if CUR_SCN_COMPAT = target_compat then
 dbms_output.put_line('SCN compat had Auto rollover !' );
 end if;
 if CUR_SCN_COMPAT < target_compat and sysdate > auto_rollover_ts then
 dbms_output.put_line('SCN compat No Auto_rollover !' );
 -- standby or read-only database
 if started_ts<auto_rollover_ts and db_role='PHYSICAL STANDBY' then
 dbms_output.put_line('Tip: Restart Instance SCN compat will rollover automatic.' );
 end if;
 end if ;
 else
 dbms_output.put_line( ' Auto_rollover is disabled!');
 end if;
 end;
 /
"scn_chk.sql" [New] 49L, 1950C written

SQL> @scn_chk.sql
Current datatime:20190703 09:40:24
Oracle Version:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit
Production
Database role:PRIMARY
Instance starttime: 20190527 18:48:28
RSL=35577937002496
headroom_in_scn=19759203047497
headroom_in_sec=201001007
CUR_SCN_COMPAT=3
MAX_SCN_COMPAT=3
auto_rollover_ts=2019-06-23
target_compat=3
Auto_rollover is enabled!
SCN compat had Auto rollover !

PL/SQL procedure successfully completed.
SQL> col CURRENT_SCN for 999999999999999999999999999999
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
15818733980592

SQL> @scn_chk.sql
Current datatime:20190703 09:45:50
Oracle Version:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit
Production
Database role:PRIMARY
Instance starttime: 20190527 18:48:28
RSL=35577969049600
headroom_in_scn=19759235066349
headroom_in_sec=201001333
CUR_SCN_COMPAT=3
MAX_SCN_COMPAT=3
auto_rollover_ts=2019-06-23
target_compat=3
Auto_rollover is enabled!
SCN compat had Auto rollover !

PL/SQL procedure successfully completed.

SQL> set time on
09:46:18 SQL> @scn_chk.sql
Current datatime:20190703 09:46:22
Oracle Version:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit
Production
Database role:PRIMARY
Instance starttime: 20190527 18:48:28
RSL=35577972195328
headroom_in_scn=19759238207241
headroom_in_sec=201001365
CUR_SCN_COMPAT=3
MAX_SCN_COMPAT=3
auto_rollover_ts=2019-06-23
target_compat=3
Auto_rollover is enabled!
SCN compat had Auto rollover !

PL/SQL procedure successfully completed.

09:46:22 SQL> /
Current datatime:20190703 09:46:35
Oracle Version:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit
Production
Database role:PRIMARY
Instance starttime: 20190527 18:48:28
RSL=35577973473280
headroom_in_scn=19759239482976
headroom_in_sec=201001378
CUR_SCN_COMPAT=3
MAX_SCN_COMPAT=3
auto_rollover_ts=2019-06-23
target_compat=3
Auto_rollover is enabled!
SCN compat had Auto rollover !

PL/SQL procedure successfully completed.

09:46:35 SQL> /
Current datatime:20190703 09:46:48
Oracle Version:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit
Production
Database role:PRIMARY
Instance starttime: 20190527 18:48:28
RSL=35577974751232
headroom_in_scn=19759240759625
headroom_in_sec=201001391
CUR_SCN_COMPAT=3
MAX_SCN_COMPAT=3
auto_rollover_ts=2019-06-23
target_compat=3
Auto_rollover is enabled!
SCN compat had Auto rollover !

PL/SQL procedure successfully completed.

09:46:48 SQL> select current_scn from v$database
09:49:44   2  ;   

                    CURRENT_SCN
-------------------------------
                 15818733992061

09:49:50 SQL> /

                    CURRENT_SCN
-------------------------------
                 15818733992066

09:49:53 SQL> @scn_chk.sql
Current datatime:20190703 09:50:05
Oracle Version:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit
Production
Database role:PRIMARY
Instance starttime: 20190527 18:48:28
RSL=35577994117120
headroom_in_scn=19759260125033
headroom_in_sec=201001588
CUR_SCN_COMPAT=3
MAX_SCN_COMPAT=3
auto_rollover_ts=2019-06-23
target_compat=3
Auto_rollover is enabled!
SCN compat had Auto rollover !

PL/SQL procedure successfully completed.

https://www.cnblogs.com/dc-chen/p/7245290.html

脚本检查:

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    --day
from v$instance;

注:根据scnhealthcheck.sql定义:

  • 当SCN Headroom > 62天则健康状态为A,系统无SCN问题;
  • 当10 < SCN Headroom <= 62天则健康状态为B,系统存在SCN问题,尚不致命;
  • 当SCN Headroom <=10天则健康状态为C,系统存在致命的SCN问题,需立即处理。

正常状态如下:

SQL> select
  2    version,
  3    to_char(SYSDATE,'YYYY/MM/DD HH24:MI:SS') DATE_TIME,
  4    ((((
  5     ((to_number(to_char(sysdate,'YYYY'))-1988)*12*31*24*60*60) +
  6     ((to_number(to_char(sysdate,'MM'))-1)*31*24*60*60) +
  7     (((to_number(to_char(sysdate,'DD'))-1))*24*60*60) +
  8     (to_number(to_char(sysdate,'HH24'))*60*60) +
  9     (to_number(to_char(sysdate,'MI'))*60) +
 10     (to_number(to_char(sysdate,'SS')))
 11     ) * (16*1024)) - dbms_flashback.get_system_change_number)
 12    / (16*1024*60*60*24) 
 13    ) indicator    --day
 14  from v$instance;

VERSION           DATE_TIME            INDICATOR
----------------- ------------------- ----------
11.2.0.4.0        2019/07/03 09:54:52 545.656147

 

SQL> /

VERSION           DATE_TIME            INDICATOR
----------------- ------------------- ----------
11.2.0.4.0        2019/07/03 09:57:25 545.657831

最后

以上就是成就便当为你收集整理的CUR_SCN_COMPAT 2019年6月23日自动从1直接跳级到3的全部内容,希望文章能够帮你解决CUR_SCN_COMPAT 2019年6月23日自动从1直接跳级到3所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部