TimesTen中配置只讀Cache Group to Oracle的基本步驟

lishiran發表於2007-03-14
一、準備工作
1)軟體安裝
安裝TimesTen
安裝Oracle client
[@more@]

一、準備工作
1)軟體安裝
安裝TimesTen
安裝Oracle client
2)在Oracle中建立一個讓TimesTen訪問的帳戶
 SQL> conn /as sysdba;
 已連線。
 SQL> create user tt_toms identified by tt_toms;
 使用者已建立。
 SQL> grant connect,resource,create any trigger ,create session to tt_toms;
 授權成功。
 SQL>

3)create 一個dsn
 我在這裡建立了一個system dsn,命名為tt_study

4)create 一個帳戶在dsn上
 E:>ttisql tt_study
 Copyright (c) 1996-2006, Oracle. All rights reserved.
 Type or "help" for help, type "exit" to quit ttIsql.
 All commands must end with a semicolon character.

 connect "DSN=tt_study";
 Connection successful: DSN=tt_study;UID=46192;DataStore=E:tt_dbdatatt_study;
 DRIVER=C:WINDOWSsystem32ttdv60.dll;LogDir=e:tt_dbdatalog;PermSize=20;
 (Default setting AutoCommit=1)
 Command> create user tt_toms identified by 'tt_toms'; 

Command> grant ddl,admin to tt_toms; 

Command> exit
 Disconnecting...
 Done.

5)修改DSN tt_study增加
 User ID:tt_toms
Oracle ID:ora10
Oracle Password: tt_toms

儲存退出,重新用ttisql 訪問tt_study,你會發現:
E:>ttisql tt_study
 Copyright (c) 1996-2006, Oracle. All rights reserved.
 Type ? or "help" for help, type "exit" to quit ttIsql.
 All commands must end with a semicolon character.

 connect "DSN=tt_study";
 Enter password for 'tt_toms':
 Connection successful: DSN=tt_study;UID=tt_toms;DataStore=E:tt_dbdatatt_study
 ;DRIVER=C:WINDOWSsystem32ttdv60.dll;OracleId=ora10;LogDir=e:tt_dbdatalog;
 PermSize=20;
 (Default setting AutoCommit=1)
 Command> 

二、建立一個read only cache group

1)在Oracle上用tt_toms使用者建立一個測試用的表
 SQL> conn

  已連線。
  SQL> create table tt_test (a int primary key);
  表已建立。

  SQL> insert into tt_test values(1);
  已建立 1 行。

  SQL> insert into tt_test values(2);
  已建立 1 行。

  SQL> commit;
  提交完成。

  SQL> select * from tt_test;

  NO
  ----------
  1
  2
  SQL>

2)建立一個cache group
 E:>ttisql tt_study
 Copyright (c) 1996-2006, Oracle. All rights reserved.
 Type ? or "help" for help, type "exit" to quit ttIsql.
 All commands must end with a semicolon character.

 connect "DSN=tt_study";
 Enter password for 'tt_toms':
 Connection successful: DSN=tt_study;UID=tt_toms;DataStore=E:tt_dbdatatt_study
 ;DRIVER=C:WINDOWSsystem32ttdv60.dll;OracleId=ora10;LogDir=e:tt_dbdatalog;
 PermSize=20;
 (Default setting AutoCommit=1)
 Command> call ttcacheuidpwdset('tt_toms','tt_toms');
 Command> call ttcachestart();
 Command> create readonly cache group tt_cache autorefresh interval 2 seconds from tt_test(a int primary key);
 Command>


 3)Load Cache Group
Command> load cache group tt_cache commit every 2 rows;

2 rows affected.
Command> select *from tt_test;
< 1 >
< 2 >
2 rows found.
Command> cachegroups;

Cache Group TT_TOMS.TT_CACHE:

Cache Group Type: Read Only
Autorefresh: Yes
Autorefresh Mode: Incremental
Autorefresh State: On
Autorefresh Interval: 2 Seconds
Autorefresh Limit: 10000

Root Table: TT_TOMS.TT_TEST
Table Type: Read Only

1 cache group found.
Command>


4)測試
 在oracle上在插入一行資料
  SQL> insert into tt_test values(3);
  已建立 1 行。

  SQL> commit;
  提交完成。
  SQL>
 
  到TimesTen上驗證一下
  Command> select *from tt_test;
 < 1 >
 < 2 >
 < 3 >
 3 rows found.

5)刪除Cache Group

drop cache group tt_cache;

6)stop cache group agent
call ttcachestop();

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9099175/viewspace-905063/,如需轉載,請註明出處,否則將追究法律責任。

相關文章