5. 创建TimesTen表空间
在此之后要创建一个cache grid,只cache grid的第一个数据库成员需要执行这个操作。注意,只有cache manager user能创建和管理cache grid,一个cache database只能属于一个cache grid,然后可以使用过程ttgridinfo来检查是否创建成功。
在创建cache grid前,要先创建表空间,然后建timesten用户,操作创建grid才不会报错。 创建一个单独的表空间来管理缓存到timesten 的对象 SQL>create tablespace timesten datafile
'D:\\oracle\\product\\10.2.0\\oradata\\orcl\\timesten.dbf' size 50m;
6. 创建timesten 用户
运行initCacheGlobalSchema.sql脚本来创建用户,这用户拥有存储cache grid 和grid member信息的表。这个脚本在%TimesTen_install_dir%/oraclescripts 目录下。 在创建之前,请切换到脚本所在目录,再以oracle dba或system用户登录: C:\\TimesTen\\tt1122_32\\oraclescripts>
C:\\TimesTen\\tt1122_32\\oraclescripts>sqlplus system/Younuoda2006@orcl
SQL> @initCacheGlobalSchema \
Please enter the tablespace where TIMESTEN user is to be created The value chosen for tablespace is timesten
******* Creation of TIMESTEN schema and TT_CACHE_ADMIN_ROLE starts *******
1. Creating TIMESTEN schema
2. Creating TIMESTEN.TT_GRIDID table 3. Creating TIMESTEN.TT_GRIDINFO table 4. Creating TT_CACHE_ADMIN_ROLE role
5. Granting privileges to TT_CACHE_ADMIN_ROLE
** Creation of TIMESTEN schema and TT_CACHE_ADMIN_ROLE done successfully **
PL/SQL 过程已成功完成。
7. 创建Grid
执行ttisql test_dsn连接内存库,创建Grid。
C:\\Documents and Settings\\Administrator>ttisql test_tt Command> call ttGridCreate('myGrid'); Command> call ttGridNameSet('myGrid');
8
8. 创建Cache Group
1. 创建Cache Group。
Command> create readonly cache group test_cg > autorefresh interval 5 seconds > from test
> (a int primary key,b char(10));
其中,test_cg为Cache Group的名,test为前面在Oracle中创建的测试表。 2. 创建完后,执行cachegroups检查是否创建成功:
Command> cachegroups ; Cache Group TT.TEST_CG:
Cache Group Type: Read Only Autorefresh: Yes
Autorefresh Mode: Incremental Autorefresh State: Paused
Autorefresh Interval: 5 Seconds Autorefresh Status: ok Aging: No aging defined
Root Table: TT.TEST Table Type: Read Only
1 cache group found.
在未装载前,cache group的自动刷新状态是Paused。 3. 装载cache group。
Command> load cache group read commit every 10 rows; 4. 检查cache group是否装载成功。 Command> select * from test;
< 1, aaa > < 2, bbb > 2 rows found.
此后,在Oracle数据库中插入到test表的数据,5秒钟之后都会被刷新到TimesTen中来,Cache Connect正常运转了。
5. 通过ttstatus命令可以看到cache agent已经启动:
C:\\Documents and Settings\\Administrator>ttstatus test_tt
TimesTen status report as of Thu Sep 13 16:18:14 2012
Daemon pid 2812 port 53392 instance tt1122_32 TimesTen server pid 2640 started on port 53393
------------------------------------------------------------------------
Data store e:\\mydemo\\test_tt
There are 16 connections to the data store
9
Shared Memory KEY Global\\test_tt.e||mydemo.SHM.10 HANDLE 0x294
PL/SQL Memory KEY Global\\test_tt.e||mydemo.SHM.11 HANDLE 0x298 Address 0x5B8C0000
Type PID Context Connection Name ConnID Cache Agent 1448 0x00df9ff0 Handler 2 Cache Agent 1448 0x0c60ce30 Timer 3 Cache Agent 1448 0x0d310540 Aging 4 Cache Agent 1448 0x0d3ccd70 BMReporter(1976) 6 Cache Agent 1448 0x0d600d10 Refresher(S,5000) 7 Subdaemon 2924 0x00b7c398 Manager 2047 Subdaemon 2924 0x00bcfb00 Rollback 2046 Subdaemon 2924 0x01804dc0 Flusher 2044 Subdaemon 2924 0x01816ac0 Monitor 2045 Subdaemon 2924 0x018acce0 Deadlock Detector 2043 Subdaemon 2924 0x0da60048 Aging 2042 Subdaemon 2924 0x0dac1038 AsyncMV 2041 Subdaemon 2924 0x0db44260 Checkpoint 2040 Subdaemon 2924 0x0db95fa0 Log Marker 2039 Subdaemon 2924 0x0dbe7ce0 HistGC 2038 Subdaemon 2924 0x0dc6e588 IndexGC 2037 Replication policy : Manual Cache Agent policy : Manual
TimesTen's Cache agent is running for this data store PL/SQL enabled.
------------------------------------------------------------------------
Accessible by group WWW-B1818C3ACBB\\None End of report
四. 用SQL Developer连接TT
在使用SQL Developer前,要确保本机上已经安装jdk。建议安装jdk1.5或jdk1.6版本。 1. 打开SQL Developer。在第一次打开的时候,需要在java的安装路径下选择javaw.exe。 2. 新建连接。
选择“+”图标,或是在“连接”上右键选择“新建”。
10
3. 设置连接属性。选择“TimesTen”页签,连接类型为“直接驱动程序”,连接字符串的
形式为“DSN=test_conn;DATASTORE=E:\\MyDemo\\test_tt;ORACLENETSERVICENAME=orcl;”
其中,dsn、datastore、oraclenetservicename均已在系统DSN下配置。
4. 配置完成后,点击“测试”,如果状态为成功,则表明连接成功;否则,请根据错误提
示进行修改。
5. 测试后,选择“连接”。连接成功后,在数据库的图标上,会有个电源样式的小图标。
表明该数据库是当前正在使用的数据库。
11