1.     Cache Group/Grid的清除
 
在TimesTen 7以上的版本中,如果已经建了Cache Group,而你想直接ttdestroy datastore的话,会报如下的错误:
 
[timesten@rac1 info]$ ttdestroy tt_workshop
Failed to destroy data store: TT10026: Some cache groups that hold triggers and other objects in Oracle may exist in the datastore, drop all the cache groups before destroying the datastore — file "db.c", lineno 22014, procedure "sbDbDestroy"
 
这是因为建立Cache Group的时候会在Oracle那边的创建一些底层的辅助性的objects,所以要求你在ttdestroy之前必须先drop 掉 相关的Cache Group。
 
在我们上面的例子中,在RAC1节点上,有三个Cache Group,分别是AWT、G_AWT、RO。
 
[timesten@rac1 info]$ ttisql tt_workshop
Command> cachegroups;
 
Cache Group CACHEUSER.AWT:
 Cache Group Type: Asynchronous Writethrough
 Autorefresh: No
 Aging: No aging defined
 Root Table: ORATT.BONUS
 Table Type: Propagate
 
Cache Group CACHEUSER.G_AWT:
 Cache Group Type: Asynchronous Writethrough global (Dynamic)
 Autorefresh: No
 Aging: LRU on
 Root Table: ORATT.DEPT
 Table Type: Propagate
 
 Child Table: ORATT.EMP
 Table Type: Propagate
 
Cache Group CACHEUSER.RO:
 Cache Group Type: Read Only
 Autorefresh: Yes
 Autorefresh Mode: Incremental
 Autorefresh State: On
 Autorefresh Interval: 5 Seconds
 Autorefresh Status: unknown
 Aging: No aging defined
 
 Root Table: ORATT.SALGRADE
 Table Type: Read Only
 
3 cache groups found.
Command>
 
那么清除Cache Group有哪几种方式呢?一般有如下三种
 
1)         推荐的命令方式
 
//执行下面命令之前必须保证Oracle是运行的,且replication agent是关闭的,但cache agent是打开的。如果有Cache Grid的话,必须先detach。
 
ttisql tt_workshop
Command> grant drop any table to cacheuser;
 
ttisql "dsn=tt_workshop;uid=cacheuser;pwd=timesten;oraclepwd=oracle"
Command> Call ttGridDetachAll;
Command> call ttrepstop;
Command> drop cache group g_awt;
Command> drop cache group awt;
Command> drop cache group ro;
Command> Call ttcachestop;
Command> exit;
ttdestroy tt_workshop;
 
2)         通过脚本手工删除方式
 
有的时候,Oracle那边的额东东可能是通过手工方式创建,虽然这种情形比较少,那么随后的清除Cache Group也必须通过手工的方式去做。
 
ttisql "dsn=tt_workshop;uid=cacheuser;pwd=timesten;oraclepwd=oracle"
Command> cachesqlget INCREMENTAL_AUTOREFRESH RO UNINSTALL /tmp/obj.sql;
Command> exit
% sqlplus / as sysdba
SQL> @/tmp/obj
SQL> exit
 
这种方式虽然比较少见,不过可以通过这种方式看看到底TimesTen在oracle那边做了些什么。
 
3)         暴力方式
 
还有一种情形,可能TimesTen突然宕机了,导致datastore或者磁盘无法访问,或者整个datastore都不见了,这样也就无从说起通过命令行或者手工删除的方式去oracle那边清除了。这时候就只能到oracle那边把所有的相关object找出来,直接清除,不过这样做的风险就是,如果你还有其他的TimesTen也连在这个Oracle上,就都失效了。所以一般只是在特殊的情形下,且只有宕机的TimesTen连到这个Oracle。
 
% sqlplus / as sysdba
SQL> select ‘drop ‘||object_type ||’ ‘||owner||’.'||object_name|| ‘;’ from all_objects where object_name like ‘TT\_%’ escape ‘\’;
 
‘DROP’||OBJECT_TYPE||”||OWNER||’.'||OBJECT_NAME||’;’
——————————————————————————–
drop TABLE CACHEUSER.TT_05_USER_COUNT;
drop TABLE CACHEUSER.TT_05_SYNC_OBJS;
drop TABLE CACHEUSER.TT_05_MYGRID_1CGNODEINFO;
drop TABLE CACHEUSER.TT_05_MYGRID_1CGNODEID;
drop INDEX CACHEUSER.TT_05_MYGRID_1CGIXIPPORT2;
drop INDEX CACHEUSER.TT_05_MYGRID_1CGIXIPPORT;
drop TABLE CACHEUSER.TT_05_MYGRID_1CGGROUPDEFS;
drop TABLE CACHEUSER.TT_05_DDL_TRACKING;
drop TABLE CACHEUSER.TT_05_DDL_L;
drop TABLE CACHEUSER.TT_05_DB_PARAMS;
drop TABLE CACHEUSER.TT_05_DATABASES;
 
‘DROP’||OBJECT_TYPE||”||OWNER||’.'||OBJECT_NAME||’;’
——————————————————————————–
drop INDEX CACHEUSER.TT_05_CACHE_STATS_S_U;
drop TABLE CACHEUSER.TT_05_CACHE_STATS;
drop TABLE CACHEUSER.TT_05_AR_PARAMS;
drop TABLE CACHEUSER.TT_05_AGENT_STATUS;
drop TABLE TIMESTEN.TT_GRIDINFO;
drop TABLE TIMESTEN.TT_GRIDID;
 
17 rows selected.
 
SQL>
 
然后直接在sqlplus中执行上面生成的drop语句即可。
 
一般来说,最好是通过第一种方式,即正常的命令行方式执行清除。如果Cache Grid涉及到多个TimesTen节点,在每个节点上也都要完成同样的清除工作。

留言已经关闭