|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
能够以较低的成本向客户提供IT所有权,当节约成本成为客户最高优先级时,解决方案提供商可以向更多的客户同时提供服务。虽然有许多来自RDBMS固有的局限性。oracle|工具|数据|数据库
主题:本文申明在数据库启动的时分,怎样主动猎取SharedPool里最经常使用的历程和包等工具。
注释:上面用实例来演示Startup以后和Shutdown之前,怎样用Triger来完成主动办理的义务。
1.创立一个供Triger挪用的Procedure
a.创立一个用来保留Procedure和Package的称号的Table(list_tab)
SQL>createtablesys.list_tab(ownervarchar2(64),NAMEVARCHAR2(100));
Tablecreated.
b.创立一个Procedure(proc_pkgs_list)来保留SharedPool内里的工具名
SQL>createorreplacePROCEDUREproc_pkgs_listAS
2ownvarchar2(64);
3namvarchar2(100);
4cursorpkgsis
5selectowner,name
6fromSYS.v_$db_object_cache
7wheretypein(PACKAGE,PROCEDURE)
8and(loads>1orKEPT=YES);
9BEGIN
10deletefromsys.list_tab;
11commit;
12openpkgs;
13loop
14fetchpkgsintoown,nam;
15exitwhenpkgs%notfound;
16insertintosys.list_tabvalues(own,nam);
17commit;
18endloop;
19end;
20/
Procedurecreated.
c.创立Procedure(proc_pkgs_keep)用来保留挪用dbms_shared_pool包的了局(注:假如没有dbms_shared_pool包,能够用dbmspool.sql剧本天生)
SQL>CREATEORREPLACEPROCEDUREsys.proc_pkgs_keepAS
2ownvarchar2(64);
3namvarchar2(100);
4cursorpkgsis
5selectowner,name
6fromsys.list_tab;
7BEGIN
8openpkgs;
9loop
10fetchpkgsintoown,nam;
11exitwhenpkgs%notfound;
12SYS.dbms_shared_pool.keep(||own||.||nam||);
13endloop;
14sys.dbms_shared_pool.keep(SYS.STANDARD);
15sys.dbms_shared_pool.keep(SYS.DIUTIL);
16END;
17/
Procedurecreated.
2.编译、测试Procedure
SQL>executesys.proc_pkgs_list;
PL/SQLproceduresuccessfullycompleted.
SQL>executesys.proc_pkgs_keep;
PL/SQLproceduresuccessfullycompleted.
3.创立Triger
a.在Instanceshutdown之前的triger
SQL>CREATEORREPLACETRIGGERdb_shutdown_list
2BEFORESHUTDOWNONDATABASE
3BEGIN
4sys.proc_pkgs_list;
5END;
6/
Triggercreated.
b.在Instancestartup以后的triger
SQL>CREATEORREPLACETRIGGERdb_startup_keep
2AFTERSTARTUPONDATABASE
3BEGIN
4sys.proc_pkgs_keep;
5END;
6/
Triggercreated.
反省alter.log文件,检察Triger是不是乐成。假如不乐成,则在数据库封闭大概启动的时分会看到以下提醒***SHUTDOWN
Shuttingdowninstance(immediate)
Licensehighwatermark=2
MonMay2212:31:452000
ALTERDATABASECLOSENORMAL
MonMay2212:31:452000
SMON:disablingtxrecovery
MonMay2212:31:462000
Errorsinfile/8i/ora815/admin/hp11_815/udump/ora_12624.trc:
ORA-04098:triggerDB_SHUTDOWN_LISTisinvalidandfailedre-validation
SMON:disablingcacherecovery
MonMay2212:31:472000
Thread1closedatlogsequence16579
MonMay2212:31:472000
Completed:ALTERDATABASECLOSENORMAL
MonMay2212:31:472000
ALTERDATABASEDISMOUNT
Completed:ALTERDATABASEDISMOUNT
***STARTUP
Example1:
StartingORACLEinstance(normal)
LICENSE_MAX_SESSION=0
...
SMON:enablingtxrecovery
TueApr1810:21:382000
Errorsinfile/8i/ora815/admin/hp11_815/udump/ora_7291.trc:
ORA-04098:triggerDB_STARTUP_KEEPisinvalidandfailedre-valid
ation
TueApr1810:21:382000
Completed:alterdatabaseopen
TueApr1810:21:302000
StartingORACLEinstance(normal)
LICENSE_MAX_SESSION=0
Example2:
SMON:enablingtxrecovery
TueApr1811:12:412000
Errorsinfile/8i/ora815/admin/hp11_815/udump/ora_7562.trc:
ORA-00604:erroroccurredatrecursiveSQLlevel1
ORA-00931:missingidentifier
ORA-06512:at"SYS.DBMS_UTILITY",line68
ORA-06512:at"SYS.DBMS_SHARED_POOL",line43
ORA-06512:at"SYS.DBMS_SHARED_POOL",line51
ORA-06512:at"SYS.PROC_PKGS_KEEP",line13
ORA-06512:atline2
TueApr1811:12:412000
Completed:alterdatabaseopen
Inthe/8i/ora815/admin/hp11_815/udump/ora_7562.trcfile:
ErrorinexecutingtriggersonSTARTUP
***2000.04.18.11.12.41.052
ksedmp:internalorfatalerror
ORA-00604:erroroccurredatrecursiveSQLlevel1
ORA-00931:missingidentifier
ORA-06512:at"SYS.DBMS_UTILITY",line68
ORA-06512:at"SYS.DBMS_SHARED_POOL",line43
ORA-06512:at"SYS.DBMS_SHARED_POOL",line51
ORA-06512:at"SYS.PROC_PKGS_KEEP",line13
ORA-06512:atline2
以上Procedure和Triger必需在sys的形式下实行,而且包管表list_tab的存在。
解决方案提供商开始推动DBaaS浪潮之前,他们应该深入了解究竟什么是DBaaS。 |
|