timesten内存数据库培训笔记

基本环境配置

1.启停tt服务
ttdaemonadmin -stop
ttdaemonadmin -start

2.oracle中创建用户
SQL> CREATE USER tt IDENTIFIED BY tt DEFAULT TABLESPACE users;
SQL> GRANT connect, resource, create any trigger TO tt;

3.TT中创建用户
ttIsql TT_instance_dsn
Command> CREATE USER tt IDENTIFIED BY ‘tt’; –与oracle一致
Command> GRANT ADMIN, DDL TO tt;

4.配置dsn相关属性

[cxtest]
Driver=/tt_chk/TimesTen/tt70/lib/libtten.a
DataStore=/tt_chk/datastore/test
LogDir=/tt_log/log
DatabaseCharacterSet=ZHS16GBK
PermSize=20480
TempSize=2048
LogBuffSize=1024000
LogFileSize=1024
CkptLogVolume=1024
OracleId=tt
OraclePwd=ocsuser123
UID=ocsuser
PWD=ocsuser123

5.通过ttisql 连接tt

ttisql dsn_name

二、cache group connect to oracle

cachegroup是tt与oracle之间的一种同步机制、
cache group分为四种synchronous、Asynchronous、 read only、User-managed

1.synchronous机制
Cache table updates are propagated to andcommitted in Oracle, andthen committed in TimesTen,
New transactions cannot be issued on the cache tables until both the Oracle and TimesTen commits complete.

CREATE SYNCHRONOUS WRITETHROUGH CACHE GROUP RegionalOffices FROM
hr.regions (region_id NUMBER NOT NULL,
region_name VARCHAR2(25),
PRIMARY KEY (region_id)),
hr.countries (country_id CHAR(2) NOT NULL,
country_name VARCHAR2(40),
region_id NUMBER,
PRIMARY KEY (country_id),
FOREIGN KEY (region_id)
REFERENCES hr.regions (region_id))
这样方式效率很低,还不如直接用DB。

2.Asynchronous 通过rep agent同步更新的数据, command > call ttrepstart;
Cache table updates are committed in TimesTen, and then propagated to and committed in Oracle by the replication agent
New transactions can be issued on the cache tables without waiting for the Oracle commit to complete

timesten推荐用Asynchronous实现cache group的同步。

CREATE ASYNCHRONOUS WRITETHROUGH CACHE GROUP NewEmployees FROM
hr.employees (employee_id NUMBER(6) NOT NULL,
first_name VARCHAR2(20),
last_name VARCHAR2(25) NOT NULL,
email VARCHAR2(25) NOT NULL,
hire_date DATE NOT NULL,
job_id VARCHAR2(10) NOT NULL,
PRIMARY KEY (employee_id))

cache object in oracle for Asynchronous Writethrough Cache group

TT_version_REPPEERS
TT_version_REPACTIVESTANDBY
TT_03_RepActiveStandby_T

3.read only
Cache tables cannot be updated directly by applications
Tables in a read-only cache group are automatically refreshed from the corresponding Oracle tables

CREATE READONLY CACHE GROUP RecentLocations FROM
hr.locations (location_id NUMBER(4) NOT NULL PRIMARY KEY,
street_address VARCHAR2(40),
postal_code VARCHAR2(12),
country_id CHAR(2))
WHERE location_id >= 3000

cache object in oracle for Read only Cache group with Autorefresh

TT_version_USER_COUNT
TT_version_AGENT_STATUS
TT_version_SYNC_OBJS
TT_version_number_L log table ,must primary key
TT_version_number_T trigger

Autorefresh Steps:

1. (Oracle Side) Writes are made by the app to a cached user table.
2. (Oracle side) When application commits, autorefresh trigger is fired. Trigger registers primary key value to the change log table.
3. Cache agent assign a valid sequence number to the nerecords in the change log table.
4. Cache Agent periodically (at autorefresh interval) checks for new changes by querying change log table. If there are new changes, cache agent performs select query ( join of user table and log table) to receive new changes. Changes are
applied, bookmark is updated in timesten, and transaction committed in timesten
5. Cache agent updates the bookmark on Oracle
6. Cache agent purges the change log records that has been autorefreshed by all timesten datastores.

4.user-managed
以上三种的组合

5.cache agent

cache group与oracle的同步通过cache agent进程来完成。
To start and stop the cache agent, and set the cache agent policy, use one of the following:
1).The ttAdmin utility
2).The ttCacheStart, ttCacheStop, and ttCachePolicySet built-in procedures, respectively

另外还可通过Passthrough 方式指定,略
6.how connect to cache group

% ttisql “dsn=cachedsn;uid=oratt;oraclepwd=oracle;pwd=timesten”
Command> call ttcacheuidpwdset(’cacheadmin’, ’super’); –or ttadmin utilities : ttadmin –cacheuidpwdset –cacheuid cacheadmin –cachepwd super cachedsn
Command> call ttcachestart; –start cache group agent
command> LOAD CACHE GROUP cachegroup_name COMMIT EVERY 256 ROWS
–flush cache group从tt刷新到oracle,
–load cache group 从oracle刷新到tt
7.about cache group attribute

Command> cachegroups;

Cache Group TTUSER.AWTCG:

Cache Group Type: Asynchronous Writethrough
Autorefresh: No

Root Table: TTUSER.AWT
Table Type: Propagate

Cache Group TTUSER.READCACHE:

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

Root Table: TTUSER.READTAB
Table Type: Read Only

Cache Group TTUSER.SWTCG:

Cache Group Type: Synchronous Writethrough
Autorefresh: No

Root Table: TTUSER.SWT
Table Type: Propagate
8.about command

cachesqlget readcache install
cachesqlget readcache UNINSTALL;

通过以上两个命令可以查看建立或删除一个cachegroup所在oracle端的操作。

三、replication

reapplication是tt与tt之间的同步机制,Transactional data replication between TimesTen data stores

1.introduce Replication Topology
Replication Type : Regular Replication vs. Active Standby Pair(ASP)
Replication Work Mode: Unidirectional vs. Bidirectional
Return Service: Sync(Return Receipt, Return Two-safe) vs. Async
Replication Level: Table vs. Datastore

2.replication分为三种
master<->master
master<->subscriber
active -> standby (比较推荐)

3.Replication Configuration
Configure the master data store:
Create the store and its replicated elements
Create a replication scheme
Start the replication agent
Configure the subscriber data store:
Run the ttRepAdmin –duplicate utility command to create the subscriber store from the master store
Start the replication agent

3.1 Unidirectional Asynchronous Replication Scheme
On: westsys
CREATE REPLICATION UniReplScheme
ELEMENT e TABLE repltable
MASTER westds ON “westsys”
SUBSCRIBER eastds ON “eastsys”
call ttrepstart

On:eastsys
ttrepadmin –duplicate –from westds –host “westsys” eastds
Call ttrepstart

3.2 Bidirectional Asynchronous Replication Scheme
On westsys:
CREATE REPLICATION BiReplScheme
ELEMENT e TABLE repltable
MASTER westds ON “westsys”
SUBSCRIBER eastds ON “eastsys”
ELEMENT e2 TABLE repltable
MASTER eastds ON “eastsys”
SUBSCRIBER westds ON “westsys“
Call ttrepstart

On eastsys:
ttrepadmin –duplicate –from westds –host “westsys” eastds
Call ttrepstart

3.3 Active Standby Pair Replication Scheme
On eastsys
CREATE ACTIVE STANDBY PAIR westds ON “westsys”,
centralds ON “centralsys”
SUBSCRIBER eastds ON “eastsys”,
eastds2 ON “eastsys2″,
eastds3 ON “eastsys3″
call ttrepstateset(’active’)
call ttrepstart

On eastsys2/3
Ttrepadmin –duplicate –from eastds –host “eastsys” east2/3
Call ttrepstart
3.4 Configuring Replication on a Cache Table

On master system:
CREATE REPLICATION CGScheme
ELEMENT e TABLE hr.employees
MASTER westds ON “westsys”
SUBSCRIBER eastds ON “eastsys”
ELEMENT e2 TABLE hr.employees
MASTER eastds ON “eastsys”
SUBSCRIBER westds ON “westsys”
call ttrepstart

On subscriber system:
% ttrepadmin –duplicate –from westds –host “westsys” –keepcg -cacheuid cacheadmin –cachepwd super”dsn=eastdsn;uid=oratt;pwd=timesten;oraclepwd=oracle”
% ttadmin –repstart eastdsn
% ttadmin –cachestart eastdsn

3.5 Utility
1).TimesTen Replication Monitoring: ttRepAdmin Utility Commands
2).Use the ALTER REPLICATION SQL statement
3).ttrepstart
4).ttrepstateset、ttrepstateget;

四、XLA(监控应用的工具)
XLA:Transcation log API ,通过调用API监控应用

$TT_HOME/demo/xla/simple用来做简单的TT监控。make后运行 ./xlsSimple dsn即可

五、diagnostic & Utilities
1.Backup & Restore

2.TTBulkcp
Export data from TimesTen table
Import data into TimesTen table
3.Trace log
User error log (tterrors.log)
Support log (ttmesg.log)
command > ttdaemonlog –print log
tttracemon -e show dsn_name –print log

4.TTtraceMon Utilities

ttTraceMon -e show asp2
call tttrace(’level sql 4′);
call tttrace(’outfile /home/timesten/sql.txt’);

5.built-in process & utilites

ttisql环境里过程的叫built-in process
在命令行方式敲的叫utilites
可见manual里tt_ref.pdf里的built-in process和utilites
6.常用工具

ttsize
ttstatus
command> monitor;

7.error code
Diagnostics through SNMP Traps
$TT_HOME/snmp.ini
snmptrapd -f -Le
about manual :err_ref.pdf

8.metalink

advance seach -> production -> tt

六、Performance Tuning

ttOptUpdateStats 全表统计信息收集
ttOptEstimateStats 抽样统计收集

猜你喜欢

转载自blog.csdn.net/superlmj/article/details/5597818