Windows下配置TimesTen的Cache Group

一. 安装TimesTen

TimesTen的安装很简单,直接执行安装程序,选择默认设置即可。在安装前,需要确认如下两点:

1.       确认安装TimesTen的服务器上已经有jdk,且jdk的版本为1.51.6

2.       确认服务器访问oracle的配置文件tnsnames.ora的路径,该路径是TimesTen安装时,需要指定的TNS_ADMIN的值。如“F:\oracle\product\10.2.0\client_1\NETWORK\ADMIN”。

二. 配置TT数据库(即DSN

TT数据库中,一个DSN即是一个TT实例。

1.      配置过程

在安装TT软件后,可通过如下步骤配置DSN

1.         进入“控制面板 –> 管理工具 -> 数据源(ODBC)”,在“系统DSN”页签,选择“添加”。

2.         选择数据库驱动程序,TimesTen相关的驱动程序有2个,"TimesTen Client 11.2.2"是用于访问非本机数据库用的,由于我们要在本机建立数据库,所以选择"TimesTen Data Manager 11.2.2”

 

3.         配置DSN基本属性。

 

在选择DataSource Path时,要确保该目录已经存在。

且此处Database Character Set必须与Oracle的字符集相同,如果不同,后面还需要重新配置数据源。

4.         配置数据库的大小。只需要设置Permanent Data SizeTemporary Data Size的大小,单位均是M

 

 

5.         配置字符集。这里的字符集也是必须与Oracle保持一致。

 

6.         配置完成后,依次点击“OK”、“确定”,保存设置。

7.         cmd窗口,执行ttisql test_tt,检查DSN是否创建成功。或是在ttisql下,执行connect test_tt

正常情况下应如下图所示:

 

 

2.      查看TT状态

cmd窗口,执行ttstatus检查tt状态:

C:\Documents and Settings\Administrator>ttstatus

TimesTen status report as of Tue Sep 11 11:02:45 2012

 

Daemon pid 696 port 53392 instance tt1122_32

TimesTen server pid 1244 started on port 53393

------------------------------------------------------------------------

Data store e:\mydemo\test_tt

There are 12 connections to the data store

Shared Memory KEY Global\test_tt.e||mydemo.SHM.10 HANDLE 0x288

PL/SQL Memory KEY Global\test_tt.e||mydemo.SHM.11 HANDLE 0x290 Address 0x5B8C000

0

Type            PID     Context     Connection Name              ConnID

Process         3420    0x01030d78  test_tt                           1

Subdaemon       1172    0x00b7c398  Manager                        2047

Subdaemon       1172    0x00bcfb00  Rollback                       2046

Subdaemon       1172    0x01845470  Flusher                        2045

Subdaemon       1172    0x01857170  Monitor                        2044

Subdaemon       1172    0x018e8ef0  Deadlock Detector              2041

Subdaemon       1172    0x0e339768  Checkpoint                     2043

Subdaemon       1172    0x0e38b4a8  Log Marker                     2042

Subdaemon       1172    0x0e3ed1f8  Aging                          2040

Subdaemon       1172    0x0e43ef38  HistGC                         2039

Subdaemon       1172    0x0e490c78  AsyncMV                        2038

Subdaemon       1172    0x0e4ea010  IndexGC                        2037

Replication policy  : Manual

Cache Agent policy  : Manual

PL/SQL enabled.

---------------------------------------------------------------------

Accessible by group WWW-B1818C3ACBB\None

End of report

可以看到 DataStore e:\mydemo\test_tt 已经在运行了,且有一些后台的服务线程也已经启动。且显示了相应的TimesTen监听端口号。比如主守护进程(Daemon)的端口号是17000Server端的监听端口号是17002,这个端口号是当Client/Server配置的时候,远程Client端连接过来时,Server端这边的服务端口号;还有WebServer的端口号 17004TimesTen自身带有一个自用的webserver的。

3.      创建TT用户

command窗口,执行如下命令创建TT用户tt:

C:\Documents and Settings\Administrator>ttisql test_tt

 

Copyright (c) 1996-2011, Oracle.  All rights reserved.

Type ? or "help" for help, type "exit" to quit ttIsql.

 

connect "DSN=test_tt";

Connection successful: DSN=test_tt;UID=Administrator;DataStore=E:\MyDemo\test_tt

;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=ZHS16GBK;DRIVER=C:\TimesTe

n\TT1122~1\bin\ttdv1122.dll;PermSize=64;TempSize=32;TypeMode=0;

(Default setting AutoCommit=1)

Command> create user tt identified by tt;

User created.

Command> grant all to tt;

Command> quit;

三. 设置Cache Connect

1.      创建Oracle用户

由于Cache Connect访问Oracle的时候,必须有一个用户在TimesTenOracle中是一样的,通过这个用户登录TimesTen之后,然后 Cache Connect的底层通过这个用户去和Oracle通讯,来进行数据的两边同步。在前面我们已经创建了用户tt,那么现在在oracle中,我们也创建同样的用户tt,并授予相应的Oracle权限。

Oracle dba用户或系统用户登录Oracle,执行创建操作。

C:\Documents and Settings\Administrator>sqlplus system/test@test

SQL> create user tt identified by tt;

用户已创建。

SQL> grant connect,resource,create any trigger to tt;

授权成功。

SQL> grant dba to tt;

授权成功。

SQL> commit;

提交完成。

2.      更新DSN配置

在“控制面板 –> 管理工具 -> 数据源(ODBC)”的“系统DSN”页签,找到之前配置的数据源test_tt,执行如下步骤更新配置:

1.         在“General Connection”页签,填上新建的TT访问Oracle的用户tt.

 

2.         在“IMDB Cache”页签,填上tt用户的密码,及本地配置的要访问的Oracle的服务名。

 

3.         配置完成后,依次点击“OK”、“确定”,保存设置。

3.      创建测试表

tt用户登录Oracle,创建cache测试表。

SQL> connect tt/tt@orcl

已连接。

SQL> create table test(a int primary key, b char(10));

表已创建。

SQL> insert into test values(1,aaa);

已创建 1 行。

SQL> insert into test values(2,bbb);

已创建 1 行。

SQL> commit;

提交完成。

SQL>

4.      创建cache

C:\Documents and Settings\Administrator>ttisql test_tt

Command> call ttcacheuidpwdset(tt,'tt);

Command> call ttcachestart;

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 dbasystem用户登录:

C:\TimesTen\tt1122_32\oraclescripts>

C:\TimesTen\tt1122_32\oraclescripts>sqlplus system/Younuoda2006@orcl

 

SQL> @initCacheGlobalSchema "timesten";

 

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.      创建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_cgCache 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;  (注:原文有问题read应该为test_cg)

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

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.5jdk1.6版本。

1.         打开SQL Developer。在第一次打开的时候,需要在java的安装路径下选择javaw.exe

2.         新建连接。

选择“+”图标,或是在“连接”上右键选择“新建”。

 

 

3.         设置连接属性。选择“TimesTen”页签,连接类型为“直接驱动程序”,连接字符串的形式为“DSN=test_conn;DATASTORE=E:\MyDemo\test_tt;ORACLENETSERVICENAME=orcl;

其中,dsndatastoreoraclenetservicename均已在系统DSN下配置。

 

4.         配置完成后,点击“测试”,如果状态为成功,则表明连接成功;否则,请根据错误提示进行修改。

5.         测试后,选择“连接”。连接成功后,在数据库的图标上,会有个电源样式的小图标。表明该数据库是当前正在使用的数据库。

 

五. 异常处理

1.      connect test_tt报错

Command> connect test_tt;

  836: Cannot create data store shared-memory segment, error 3

The command failed.

检查之后,发现是在ODBC中设置DataStore的路径时出现错误,MyDemo目录是在E盘下而不是D盘。改了之后就能连接了。

2.      执行call ttcacheuidpwdset(’tt’,'tt’)报错

场景一:

Command> call ttcacheuidpwdset('tt','tt');

 5010: No OracleNetServiceName specified in DSN

The command failed.

testtt数据源中,要在General Connection页,在User Id这一栏填上tt,再点击Cache Connect页,看到Oracle User ID已经填上了tt。在Oracle ID一栏填上OracleService Name,在Oracle Password一栏填上对应的密码。

 

场景二:

Command> call ttcacheuidpwdset('tt','tt');

Warning  5183: Function kollglid2 was not in the library. The function will not

be called.

Warning  5183: Function kollgsnp2 was not in the library. The function will not

be called.

Warning  5186: The OCI client library in use does not contain required routines

to support caching LOBS from Oracle.

该错误是由于tt用户没有dba权限引起的。

需要在Oracle中,执行

SQL> grant dba to tt;

SQL> grant create any table to tt;

3.      create readonly cache group报错

Command> create readonly cache group read

 autorefresh interval 5 seconds

 from test

> (a int primary key, b char(10));

报错:

Warning  5002: Unable to connect to the cache agent for e:\mydemo\testtt; check

agent status

Warning  5051: Commit message to cache agent failed. Cache agent must be restarted

可通过重启cache解决:

Command> call ttcachestop;

Command> call ttcachestart;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值