• 【原创】TimeSten安装与配置


    1.安装TimeSten
    2.安装时要指定TNS_ADMIN_LOCATION,即tnsnames.ora的路径,因为tt会根据这个连接Oracle。C:TimesTen t1122_32 etworkadmin,要具体到目录而非文件。
    配置过程:
    注意事项:
    1.Oracle和TimeSten之间同步的用户名必须一致,也就是Cache Manager用户名必须相同。
    2.Oracle和TimeSten的数据库编码方式必须一致,否则会关联失败。
    3.Oracle版本和TimeSten版本必须一致,否则有可能出现数据类型影射失败的情况。
    4.在定义CacheGroup时,TimeSten会根据CacheGroup中的Cache Table去Oracle的Cache Table中寻找、对比,因此,如果要将某个表加入Cache Group,必须在Oracle和TimeSten中都定义才可以,而且定义必须一致,而且这两个用户必须一致。
    5.对于Blob类型的定义,blob会影射为varbinary:
     在Oracle创建表:
    CREATE TABLE t (
      i INT NOT NULL PRIMARY KEY
      , c CLOB
      , b BLOB
      , nc NCLOB);
    然后在TimeSten中定义CacheGroup:
    CREATE DYNAMIC ASYNCHRONOUS WRITETHROUGH CACHE GROUP cg1 
      FROM t
     (i INT NOT NULL PRIMARY KEY
      , c VARCHAR2(4194304 BYTE)
      , b VARBINARY(4194304)
      , nc NVARCHAR2(2097152)
      );
    
    -----------------------------------------------------------------------------------------------------------------
    3.先新建一个Cache Manager用户:
    --------------------------------------------------------------------------------------------------------------------------------------
    C:Documents and Settingszhangxsh.ETHER>ttisql
     
    Copyright (c) 1996-2011, Oracle. All rights reserved.
    Type ? or "help" for help, type "exit" to quit ttIsql.
     
     
    Command> connect cache_session;
    Connection successful: DSN=cache_session;UID=zhangxsh;
    (Default setting AutoCommit=1)
    Command> create user cacheadmin identified by cacheadm in;
     
    User created.
     
    Command> grant admin to cacheadm;
    15151: GRANT failed: User CACHEADM does not exist
    The command failed.
    Command> grant admin to cacheadmin;
    Command>
    ------------------------------------------------------------------
    4.再新建一个Cache Table User
    -------------------------------------------------------------------------------
    Command> create user cache identified by cache;
     
    User created.
     
    Command> grant create session to cache;
    Command>
    ---------------------------------------------------------------------------------
    5.Associate the Oracle Cache Administration user with the Cache Database(互相关联)
    Command> connect "dsn=session_cache;uid=cacheadmin;oraclepwd=cacheadmin";
    Enter password for 'cacheadmin':
    Connection successful: DSN=session_cache;UID=cacheadmin;DataStore=C:Times
    (Default setting AutoCommit=1)
    con1: Command> call ttcacheuidpwdset ('cacheadmin','cacheadmin');
    con1: Command>
    ---------------------------------------------------------------------------------
    6.Create a Cache Grid
    con1: Command> call ttcacheuidpwdset ('cacheadmin','cacheadmin');
    con1: Command> call ttcacheuidget;
    < CACHEADMIN >
    1 row found.
    con1: Command> call ttgridcreate ('samplegrid');
    con1: Command> call ttgridinfo;
    < SAMPLEGRID, CACHEADMIN, NT, 32-bit, 11, 2, 2 >
    1 row found.
    con1: Command>
    ----------------------------------------------------------------------------------
    7.Associate the Cache Database with the Cache Grid
    call ttgridnameset ('samplegrid');
    ======================================================================
    将CacheGroup加入CacheDatabase
    connect "dsn=cachedb1_1122;uid=cacheadm;pwd=cacheadm;oraclepwd=cacheadm";
    call ttcachestart;
    在Oracle中创建表:
    -----------------------------------------------------------------------------------
    -- Create table
    create table T_SESSION
    (
      C_SID VARCHAR2(200) primary key ,
      C_SESSION BLOB
    )
    tablespace USERS
      pctfree 10
      initrans 1
      maxtrans 255
      storage
      (
        initial 64
        minextents 1
        maxextents unlimited
      );
    -- Grant/Revoke object privileges
    grant select, insert, update, delete on T_SESSION to CACHEADMIN;
    -----------------------------------------------------------------------------------
    然后建立以下CacheGroup:
    create [dynamic] asynchronous writethrough cache group g_awt from zhangxsh.t_session ( c_sid varchar(200) not null , c_session varbinary(262144),primary key(c_sid));
    create dynamic asynchronous writethrough cache group g_awt from uss.t_session ( c_sid varchar(200) not null , c_session varbinary(262144),primary key(c_sid));
    create dynamic asynchronous writethrough cache group g_awt from uss.t_session ( c_sid varchar(200) not null , c_session varbinary(262144),d_create timestamp,primary key(c_sid)) AGING USE  timestamp LIFETIME 15 minutes CYCLE 5 seconds ON;
    --------------------------------------------------------------------------------------
    要启用自动回写:
    call ttRepStart;--启用回写Agent
    ------------------------------------------
    启用时间失效机制(Defining Cache Groups一节中有介绍):
    每隔60秒检查when_placed截止现在超过45天的记录并删除。
    CREATE ASYNCHRONOUS WRITETHROUGH CACHE GROUP ordered_items
    FROM oratt.orders
     (ord_num      NUMBER(10) NOT NULL,
      cust_num     NUMBER(6) NOT NULL,
      when_placed  DATE NOT NULL,
      when_shipped DATE NOT NULL,
      PRIMARY KEY(ord_num))
    AGING USE when_placed LIFETIME 45 DAYS CYCLE 60 MINUTES ON,
    oratt.order_item
     (orditem_id NUMBER(12) NOT NULL,
      ord_num    NUMBER(10),
      prod_num   VARCHAR2(6),
      quantity   NUMBER(3),
      PRIMARY KEY(orditem_id),
      FOREIGN KEY(ord_num) REFERENCES oratt.orders(ord_num));
  • 相关阅读:
    以一道CTF题目看无参数RCE
    浅谈php序列化字符串逃逸问题
    [XCTF 4th] ics-05 复现
    关于Sharp俩打印机AR-1808S和AR-2348SV的共享问题
    关于使用AdventureWorks2008示例数据库之初碰到的问题
    明日科技的SQL Server---6
    ado.net 4 step by step随书数据库
    手欠,大半个下午加一晚上就报销了。
    程序员的SQL金典
    c#读写文件
  • 原文地址:https://www.cnblogs.com/zhangxsh/p/3494521.html
Copyright © 2020-2023  润新知