TimesTen c/s模式配置

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:TimesTen c/s模式配置

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

一、linux/unix环境配置
1.相关IP配置
客户端:192.168.1.105
服务端:192.168.1.10

2.服务端ODBC配置

$ more sys.odbc.ini
[ODBC Data Sources]
TT_1122=TimesTen 11.2.2 Driver
[TT_1122]
Driver=/u01/TimesTen/tt1122/lib/libtten.so
DataStore=/u01/TimesTen/tt1122/info/TT_1122
DatabaseCharacterSet=ZHS16GBK
PermSize=64
OracleNetServiceName=XFF

3.服务端timesten监听端口

$ ttstatus|grep "TimesTen server"
TimesTen server pid 3792 started on port 53393

4.客户端配置

$ more sys.ttconnect.ini
[tt_xifenfei_c_s]
Network_Address=192.168.1.10
TCP_PORT=53393
$ more sys.odbc.ini
[ODBC Data Sources]
tt_xifenfei_c=TimesTen 11.2.2 Client Driver
[tt_xifenfei_c]
TTC_SERVER=tt_xifenfei_c_s
TTC_SERVER_DSN=tt_1122
UID=chf
PWD=xifenfei

参考:在另一节点配置TT客户端的简明方法

二、win环境配置
1.在odbc中选择增加timesten client

2.点击services,增加ip和端口配置

3.配置关闭services,配置其他选项

三、补充说明
这里的配置,基本上都是最基础配置,在实际生产环境中,需要考虑其他相关环境变量

Multiple-table cache group配置

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:Multiple-table cache group配置

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

1.准备测试表和数据

SQL> CREATE TABLE customer
  2  (cust_num NUMBER(6) NOT NULL PRIMARY KEY,
  3   name     VARCHAR2(50)
  4  );
Table created.
SQL> CREATE TABLE orders
  2  (ord_num      NUMBER(10) NOT NULL PRIMARY KEY,
  3   cust_num     NUMBER(6) NOT NULL
  4  );
Table created.
SQL> insert into customer values(1,'wwww.xifenfei.com1');
1 row created.
SQL> insert into customer values(2,'wwww.xifenfei.com2');
1 row created.
SQL> insert into customer values(3,'wwww.xifenfei.com3');
1 row created.
SQL> insert into customer values(4,'wwww.xifenfei.com4');
1 row created.
SQL> insert into orders(cust_num,ord_num) values(1,1);
1 row created.
SQL> insert into orders (cust_num,ord_num) values(1,2);
1 row created.
SQL> insert into orders (cust_num,ord_num) values(3,5);
1 row created.
SQL> insert into orders (cust_num,ord_num) values(3,6);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from customer;
  CUST_NUM NAME
---------- --------------------------------------------------
         1 wwww.xifenfei.com1
         2 wwww.xifenfei.com2
         3 wwww.xifenfei.com3
         4 wwww.xifenfei.com4
SQL> select * from orders;
   ORD_NUM   CUST_NUM
---------- ----------
         1          1
         2          1
         5          3
         6          3
SQL> grant select on oratt.customer to cacheuser;
Grant succeeded.
SQL> grant select on oratt.orders to cacheuser;
Grant succeeded.

2.创建cache group

[oracle@xifenfei ~]$ ttIsql "DSN=tt_1122;UID=cacheuser;PWD=timesten;OraclePWD=oracle"
Command>  drop cache group cacheuser.customer_orders;
Command> CREATE READONLY CACHE GROUP customer_orders
       > AUTOREFRESH INTERVAL 5 SECONDS
       > STATE ON
       > FROM oratt.customer
       >  (cust_num NUMBER(6) NOT NULL,
       >   name     VARCHAR2(50),
       >   PRIMARY KEY(cust_num)),
       > oratt.orders
       >  (ord_num      NUMBER(10) NOT NULL,
       >   cust_num     NUMBER(6) NOT NULL,
       >   PRIMARY KEY(ord_num),
       >   FOREIGN KEY(cust_num) REFERENCES oratt.customer(cust_num));
Command> cachegroups;
Cache Group CACHEUSER.CUSTOMER_ORDERS:
  Cache Group Type: Read Only
  Autorefresh: Yes
  Autorefresh Mode: Incremental
  Autorefresh State: On
  Autorefresh Interval: 5 Seconds
  Autorefresh Status: ok
  Aging: No aging defined
  Root Table: ORATT.CUSTOMER
  Table Type: Read Only
  Child Table: ORATT.ORDERS
  Table Type: Read Only
1 cache groups found.

3.TT中表访问授权

[oracle@xifenfei ~]$ ttisql tt_1122
Command> grant select on oratt.customer to cacheuser;
Command> grant select on oratt.orders to cacheuser;

4.测试数据初始化

[oracle@xifenfei ~]$ ttIsql "DSN=tt_1122;UID=cacheuser;PWD=timesten;OraclePWD=oracle"
Command> select * from oratt.customer;
< 1, wwww.xifenfei.com1 >
< 2, wwww.xifenfei.com2 >
< 3, wwww.xifenfei.com3 >
< 4, wwww.xifenfei.com4 >
4 rows found.
Command> select * from oratt.orders;
< 1, 1 >
< 2, 1 >
< 5, 3 >
< 6, 3 >
4 rows found.

5.ORACLE修改数据

SQL> update customer set name='xifenfei' where cust_num=2;
1 row updated.
SQL> insert into customer values(5,'wwww.xifenfei.com5');
1 row created.
SQL> delete from customer where cust_num=1;
1 row deleted.
SQL> commit;
Commit complete.

6.TT中验证数据

Command> select * from oratt.customer;
< 2, xifenfei >
< 3, wwww.xifenfei.com3 >
< 4, wwww.xifenfei.com4 >
< 5, wwww.xifenfei.com5 >
4 rows found.
Command> select * from oratt.orders;
< 5, 3 >
< 6, 3 >
2 rows found.

7.补充说明
7.1)在oracle中需要授权cacheuser有访问oratt中相关表权限,不然创建cache group失败
7.2)自动刷新数据需要设置AUTOREFRESH STATE ON,其他方法初始化关联表的数据暂未知
7.3)在TT中,关联表删除是级联的

Configuring an active standby pair with one subscriber

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:Configuring an active standby pair with one subscriber

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

Step 1: Create the DSNs for the master and the subscriber databases

[master1]
DRIVER=/u01/TimesTen/tt1122/lib/libtten.so
DataStore=/u01/TimesTen/replicate//master1
DatabaseCharacterSet=ZHS16GBK
ConnectionCharacterSet=ZHS16GBK
PermSize=64
[master2]
DRIVER=/u01/TimesTen/tt1122/lib/libtten.so
DataStore=/u01/TimesTen/replicate//master2
DatabaseCharacterSet=ZHS16GBK
ConnectionCharacterSet=ZHS16GBK
PermSize=64
[subscriber1]
DRIVER=/u01/TimesTen/tt1122/lib/libtten.so
DataStore=/u01/TimesTen/replicate/subscriber1
DatabaseCharacterSet=ZHS16GBK
ConnectionCharacterSet=ZHS16GBK
PermSize=64

Step 2: Create a table in one of the master databases

[oracle@xifenfei info]$ ttIsql master1
Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=master1";
Connection successful: DSN=master1;UID=oracle;DataStore=/u01/TimesTen/replicate//master1;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=ZHS16GBK;DRIVER=/u01/TimesTen/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command>  CREATE TABLE tab (a NUMBER NOT NULL,
       >    b CHAR(18),
       >    PRIMARY KEY (a));

Step 3: Define the active standby pair

Command>  CREATE ACTIVE STANDBY PAIR master1, master2
       >    SUBSCRIBER subscriber1;

Step 4: Start the replication agent on a master database

Command>  CALL ttRepStart;

Step 5: Set the state of a master database to ‘ACTIVE’

Command>  CALL ttRepStateSet('ACTIVE');

Step 6. Create a user on the active database

Command> CREATE USER terry IDENTIFIED BY terry;
User created.
Command>  GRANT admin TO terry;

Step 7: Duplicate the active database to the standby database

[oracle@xifenfei info]$ ttRepAdmin -duplicate -from master1 -host xifenfei -uid terry -pwd terry  "dsn=master2"

Step 8: Start the replication agent on the standby database

[oracle@xifenfei info]$ ttIsql master2
Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=master2";
Connection successful: DSN=master2;UID=oracle;DataStore=/u01/TimesTen/replicate//master2;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=ZHS16GBK;DRIVER=/u01/TimesTen/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command>  CALL ttRepStart;

Step 9. Duplicate the standby database to the subscriber

[oracle@xifenfei info]$ ttRepAdmin -duplicate -from master2 -host xifenfei -uid terry -pwd terry  "dsn=subscriber1"

Step 10: Start the replication agent on the subscriber

[oracle@xifenfei info]$ ttIsql subscriber1
Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=subscriber1";
Connection successful: DSN=subscriber1;UID=oracle;DataStore=/u01/TimesTen/replicate/subscriber1;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=ZHS16GBK;DRIVER=/u01/TimesTen/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command>  CALL ttRepStart;

Step 11: Insert data into the table on the active database

[oracle@xifenfei info]$ ttIsql master1
Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=master1";
Connection successful: DSN=master1;UID=oracle;DataStore=/u01/TimesTen/replicate//master1;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=ZHS16GBK;DRIVER=/u01/TimesTen/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> INSERT INTO tab VALUES (1,'Hello');
1 row inserted.
Command> commit;

Setp 12:Verify that the insert is replicated to master2 and subscriber1

[oracle@xifenfei info]$ ttIsql master2
Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=master2";
Connection successful: DSN=master2;UID=oracle;DataStore=/u01/TimesTen/replicate//master2;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=ZHS16GBK;DRIVER=/u01/TimesTen/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> select * from tab;
< 1, Hello              >
1 row found.
Command> exit
Disconnecting...
Done.
[oracle@xifenfei info]$ ttIsql subscriber1
Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=subscriber1";
Connection successful: DSN=subscriber1;UID=oracle;DataStore=/u01/TimesTen/replicate/subscriber1;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=ZHS16GBK;DRIVER=/u01/TimesTen/tt1122/lib/libtten.so;PermSize=64;TypeMode=0;
(Default setting AutoCommit=1)
Command> select * from tab;
< 1, Hello              >
1 row found.

Configuring an active standby pair with one subscriber

In-Memory Database Cache 入门配置

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:In-Memory Database Cache 入门配置

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

一、Oracle数据库创建相关用户和权限
1.创建timesten用户
store information about cache grids

SQL> CREATE TABLESPACE cachetblsp DATAFILE
  2  'E:\ORACLE\ORADATA\XFF\datfttuser.dbf'
  3  SIZE 10M autoextend on next 10m maxsize 30g;
表空间已创建。
SQL> @E:\oracle\timesten\oraclescripts\initCacheGlobalSchema "cachetblsp"
Please enter the tablespace where TIMESTEN user is to be created
The value chosen for tablespace is cachetblsp
******* 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 过程已成功完成。

2.创建测试用户
the Oracle tables to be cached in a TimesTen database

SQL> create user xff identified by xifenfei;
用户已创建。
SQL> grant create session,resource to xff;
授权成功。

3.创建cache管理用户
creates and maintains Oracle objects that store information used to manage cache grids and enforce predefined behaviors of particular cache group types.

SQL> CREATE USER cacheuser IDENTIFIED BY oracle
  2  DEFAULT TABLESPACE cachetblsp QUOTA UNLIMITED ON cachetblsp;
用户已创建。
SQL>  @grantCacheAdminPrivileges "cacheuser"
Please enter the administrator user id
The value chosen for administrator user id is cacheuser
***************** Initialization for cache admin begins ******************
0. Granting the CREATE SESSION privilege to CACHEUSER
1. Granting the TT_CACHE_ADMIN_ROLE to CACHEUSER
2. Granting the DBMS_LOCK package privilege to CACHEUSER
3. Granting the RESOURCE  privilege to CACHEUSER
4. Granting the CREATE PROCEDURE  privilege to CACHEUSER
5. Granting the CREATE ANY TRIGGER  privilege to CACHEUSER
6. Granting the DBMS_LOB package privilege to CACHEUSER
7. Granting the SELECT on SYS.ALL_OBJECTS privilege to CACHEUSER
8. Granting the SELECT on SYS.ALL_SYNONYMS privilege to CACHEUSER
9. Checking if the cache administrator user has permissions on the default
tablespace
     Permission exists
11. Granting the CREATE ANY TYPE privilege to CACHEUSER
********* Initialization for cache admin user done successfully *********

二、TimesTen创建相关用户
1.cache管理用户
A cache manager user performs cache grid and cache group operations. The TimesTen cache manager user must have the same name as an Oracle user that can access the cached Oracle tables.

Command>  CREATE USER cacheuser IDENTIFIED BY timesten;
User created.
Command> GRANT CREATE SESSION, CACHE_MANAGER, CREATE ANY TABLE TO cacheuser;

2.cache对应用户
You must create a TimesTen cache table user with the same name as an Oracle schema user for each schema user who owns or will own Oracle tables to be cached in the TimesTen database

Command> create user xff identified by timesten;
User created.

三、配置DSN

Data Store Path + Name: E:\oracle\timesten\mytt_db\data
Permanent Data Size: 64
Oracle Net Service Name: XFF
Database Character Set: ZHS16GBK

四、在TT中设置cache管理用户名和密码

ttIsql "DSN=my_ttdb;UID=cacheuser;PWD=timesten;OraclePWD=oracle"
Command> call ttCacheUidPwdSet('cacheuser','oracle');
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.
--第一次调用相关函数因为没有编译出错,再次调用即可
Command> call ttCacheUidPwdSet('cacheuser','oracle');

五、创建测试表(Oracle db中)

SQL>  CREATE TABLE readtab (keyval NUMBER NOT NULL PRIMARY KEY, str VARCHAR2(32));
表已创建。
SQL> CREATE TABLE writetab (pk NUMBER NOT NULL PRIMARY KEY, attr VARCHAR2(40));
表已创建。
SQL> INSERT INTO readtab VALUES (1, 'Hello');
已创建 1 行。
SQL> INSERT INTO readtab VALUES (2, 'World');
已创建 1 行。
SQL> INSERT INTO writetab VALUES (100, 'XIFENFEI');
已创建 1 行。
SQL> INSERT INTO writetab VALUES (101, 'WWW.XIFENFEI.COM');
已创建 1 行。
SQL> COMMIT;
提交完成。
SQL> GRANT SELECT ON readtab TO cacheuser;
授权成功。
SQL> GRANT SELECT ON writetab TO cacheuser;
授权成功。
SQL> GRANT INSERT ON writetab TO cacheuser;
授权成功。
SQL> GRANT UPDATE ON writetab TO cacheuser;
授权成功。
SQL>  GRANT DELETE ON writetab TO cacheuser;
授权成功。

六、TimesTen相关配置
1.创建cache grid

Command> call ttGridCreate('myGrid');
Command>  call ttGridNameSet('myGrid');

2.Start the cache agent

Command> call ttCacheStart;

3.创建cache group

Command> call ttCacheStart;
Command> CREATE READONLY CACHE GROUP readcache
       > AUTOREFRESH INTERVAL 5 SECONDS
       > FROM XFF.readtab
       > (keyval NUMBER NOT NULL PRIMARY KEY, str VARCHAR2(32));
Command> CREATE DYNAMIC ASYNCHRONOUS WRITETHROUGH  CACHE GROUP writecache
       > FROM XFF.writetab
       > (pk NUMBER NOT NULL PRIMARY KEY, attr VARCHAR2(40));
Command> cachegroups;
Cache Group CACHEUSER.READCACHE:
  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: XFF.READTAB
  Table Type: Read Only
Cache Group CACHEUSER.WRITECACHE:
  Cache Group Type: Asynchronous Writethrough (Dynamic)
  Autorefresh: No
  Aging: LRU on
  Root Table: XFF.WRITETAB
  Table Type: Propagate
2 cache groups found.

4.Start the replication agent for the AWT cache group

Command> call ttRepStart;

5.Manually load the cache group

Command>  LOAD CACHE GROUP readcache COMMIT EVERY 256 ROWS;
2 cache instances affected.
Command> LOAD CACHE GROUP writecache COMMIT EVERY 256 ROWS;
2 cache instances affected.

七、TT授权
主要是为了直接在cacheuser中操作方便,无其他应意义

ttisql my_ttdb
Command> GRANT SELECT ON xff.readtab TO cacheuser;
Command> GRANT SELECT ON xff.writetab TO cacheuser;
Command> GRANT UPDATE ON xff.writetab TO cacheuser;
Command> GRANT DELETE ON xff.writetab TO cacheuser;
Command> GRANT INSERT ON xff.writetab TO cacheuser;

八、相关测试
1.测试READTAB表

Command> SELECT * FROM XFF.READTAB;
< 1, Hello >
< 2, World >
2 rows found.
SQL> INSERT INTO readtab VALUES (3, 'Welcome');
已创建 1 行。
SQL> commit;
提交完成。
Command> SELECT * FROM XFF.READTAB;
< 1, Hello >
< 2, World >
< 3, Welcome >
3 rows found.
SQL> update readtab set str='www.xifenfei';
已更新3行。
SQL> commit;
提交完成。
Command> SELECT * FROM XFF.READTAB;
< 1, www.xifenfei >
< 2, www.xifenfei >
< 3, www.xifenfei >
3 rows found.
SQL> delete from readtab where keyval=3;
已删除 1 行。
SQL> commit;
提交完成。
Command> SELECT * FROM XFF.READTAB;
< 1, www.xifenfei >
< 2, www.xifenfei >
2 rows found.

2.测试WRITETAB表

Command> SELECT * FROM XFF.writeTAB;
< 100, XIFENFEI >
< 101, WWW.XIFENFEI.COM >
2 rows found.
Command> update xff.writetab set attr='www.xifenfei.com' where pk=100;
1 row updated.
Command> commit;
SQL> select * from writetab;
        PK ATTR
---------- ----------------------------------------
       100 www.xifenfei.com
       101 WWW.XIFENFEI.COM
Command> insert into xff.writetab values(102,'xifenfei');
1 row inserted.
Command> commit;
SQL> select * from writetab;
        PK ATTR
---------- --------------------------------
       102 xifenfei
       100 www.xifenfei.com
       101 WWW.XIFENFEI.COM

相关文档

TimesTen命令—ttrestore

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:TimesTen命令—ttrestore

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

ttrestore使用说明

E:\>ttrestore -h
Usage:
  ttrestore [-h | -help | -?]
  ttrestore [-V | -version]
  ttrestore [-fname <filePrefix>] [-noconn] -dir <directory>
                 {<DSN> | [-connstr] <connStr>}
  ttrestore -i [-noconn] {<DSN> | [-connstr] <connStr>}
options:
  -h | -help | -?      Prints this message and exits.
  -V | -version        Prints the release number and exits.
  -fname <filePrefix>  The file prefix for the backup files in the backup
                       directory. Default is the base filename portion of the
                       DataStore parameter of the data store to be restored.
  -dir <directory>     The directory in which the backup files are stored.
  -noconn              Do not test-connect after restoring the data store.
  -i                   Read from standard input for stream data.
  <DSN>, <connStr>     The DSN or ODBC connection string of the data store
                       to be restored.

查看库中当前情况

Command> tables;
  XIFENFEI.REP_TABLE
  XIFENFEI.T1
  XIFENFEI.T2
  XIFENFEI.T3
  XIFENFEI.T4
  XIFENFEI.V4
  XIFENFEI.XFF
7 tables found.
Command> select * from t2;
< 3 >
< 5 >
< 3 >
< 5 >
< 3 >
< 5 >
< 3 >
< 5 >
< 3 >
< 5 >
< 3 >
< 5 >
12 rows found.

删除数据文件和日志文件

E:\oracle\timesten\mytt_db>dir
 驱动器 E 中的卷没有标签。
 卷的序列号是 38D0-2A35
 E:\oracle\timesten\mytt_db 的目录
2012/02/23  22:58    <DIR>          .
2012/02/23  22:58    <DIR>          ..
2012/02/11  19:06    <DIR>          data
2012/02/23  22:57    <DIR>          log
               0 个文件              0 字节
               4 个目录  9,478,365,184 可用字节
E:\>ttisql my_ttdb
Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=my_ttdb";
  821: No readable checkpoint files.  OS error: '系统找不到指定的文件。'.  Consi
der connecting with Overwrite=1 to create new data store
The command failed.
Done.

还原数据库

E:\>ttrestore -dir E:\oracle\timesten\tt_back\full   -fname xifenfei01_ my_ttdb
Restore started ...
Restore complete
E:\oracle\timesten\mytt_db>dir
 驱动器 E 中的卷没有标签。
 卷的序列号是 38D0-2A35
 E:\oracle\timesten\mytt_db 的目录
2012/02/23  23:01    <DIR>          .
2012/02/23  23:01    <DIR>          ..
2012/02/11  19:06    <DIR>          data
2012/02/23  23:01        21,119,936 data.ds0
2012/02/23  23:01        21,119,936 data.ds1
2012/02/23  23:01    <DIR>          log
               2 个文件     42,239,872 字节
               4 个目录  9,222,610,944 可用字节

测试还原结果

E:\>ttisql my_ttdb
Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=my_ttdb";
Connection successful: DSN=my_ttdb;UID=XIFENFEI;DataStore=E:\oracle\timesten\myt
t_db\data;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=ZHS16GBK;DRIVER=E
:\oracle\timesten\bin\ttdv1122.dll;LogDir=E:\oracle\timesten\mytt_db\log;PermSiz
e=64;TempSize=32;RACCallback=0;TypeMode=0;OracleNetServiceName=XFF;
(Default setting AutoCommit=1)
Command> tables;
  XIFENFEI.REP_TABLE
  XIFENFEI.T1
  XIFENFEI.T2
  XIFENFEI.T3
  XIFENFEI.T4
  XIFENFEI.V4
  XIFENFEI.XFF
7 tables found.
Command> select * FROM T2;
< 3 >
< 5 >
< 3 >
< 5 >
< 3 >
< 5 >
< 3 >
< 5 >
< 3 >
< 5 >
< 3 >
< 5 >
12 rows found.

补充说明
1)ttRestore 除了可以作为数据库还原操作外,还可以用来做数据库复制

ttBackup -dir /users/rob/tmp -fname restored "dsn=origDSN"
ttRestore -dir /users/rob/tmp -fname restored "dsn=restoredDSN"

2)对于在Linux或者unix系统使用streamFull备份恢复方式

dd bs=64k if=/dev/rmt0 | ttRestore -i DSN=FastIns

3)该命令是用来数据库还原,那么对于备份之后到数据库异常这段时间的数据该如何处理,是否会丢失暂时还未知。

TimesTen命令—ttBackup

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:TimesTen命令—ttBackup

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

ttBackup使用说明

c:\>ttBackup  -h
Usage:
  ttBackup [-h | -help | -?]
  ttBackup [-V | -version]
  ttBackup -dir <directory> [-type <backupType>] [-fname <fileprefix>]
           [-force] {<DSN> | [-connstr] <connStr>}
options:
  -h | -help | -?      Prints this message and exits.
  -V | -version        Prints the release number and exits.
  -type  <backupType>  The type of backup to be performed.  Supported backup
                       types are given below.  Default is "fileFull".
  -dir   <directory>   The directory in which to store the backup files.
  -fname <fileprefix>  The file prefix for the backup files in the backup
                       directory.  Default is the base filename portion of the
                       DataStore parameter of the data store to be backed up.
  -force               Destroy existing backup files before performing backup
                       (full file-based backups only).
  <DSN>, <connStr>     The DSN or ODBC connection string of the data store to
                       be backed up.
Backup types are:
  fileFull         Full backup to the specified backup directory.  The
                   resulting backup is not enabled for incremental backup.
                   This is the default backup type.
  fileFullEnable   Full backup to the specified backup directory.  The
                   resulting backup is enabled for incremental backup.
  fileIncremental  Incremental backup.  Augments pre-existing backup given
                   by '-dir' and optionally '-fname'.
  fileIncrOrFull   If incremental backup is possible, then behaves like
                   "fileIncremental"; else behaves like "fileFullEnable".
NOTE: For above types, '-dir' is required; '-fname' and '-force' are optional.
  streamFull       Full backup to the standard output.  '-dir', '-fname' and
                   '-force' are ignored.
  incrementalStop  Does not perform a backup. Disables an incremental-enabled
                   backup.  '-dir' is required; '-fname' is optional; '-force'
                   is ignored.

ttBackupStatus函数说

全备和增量备份

--全备并启动增量备份功能
c:\>ttbackup -dir E:\oracle\timesten\tt_back\full  -type fileFullEnable    -fname xifenfei01_ -force my_ttdb
Backup started ...
Backup complete
Command> call ttBackupStatus ();
< 2, 0, 1, 2012-02-22 23:13:18.125000, 2012-02-22 23:13:18.505000, 0, 11821056,0, 5896 >
1 row found.
--增量备份
c:\>ttbackup -dir E:\oracle\timesten\tt_back\full  -type fileIncremental  -fname xifenfei01_  -force my_ttdb
Backup started ...
Backup complete
Command> call ttBackupStatus ();
< 2, 0, 0, 2012-02-22 23:19:24.453000, 2012-02-22 23:19:24.702000, 0, 11825152,0, 3960 >
1 row found.
--执行结果
E:\oracle\timesten\tt_back\full>dir
 驱动器 E 中的卷没有标签。
 卷的序列号是 38D0-2A35
 E:\oracle\timesten\tt_back\full 的目录
2012/02/22  23:19    <DIR>          .
2012/02/22  23:19    <DIR>          ..
2012/02/22  23:13        21,119,936 xifenfei01_.0.bac
2012/02/22  23:19        11,943,936 xifenfei01_.0.bac0
2012/02/22  23:19               696 xifenfei01_.sta
               3 个文件     33,064,568 字节
               2 个目录  9,432,420,352 可用字节
--补充说明
1.需要使用fileFullEnable启动增量备份
2.增量备份需要指定dir和fname和全备时一致

fileIncrOrFull测试

c:\>ttbackup -dir E:\oracle\timesten\tt_back\full  -type fileIncrOrFull    -force  -fname xifenfei01_  my_ttdb
Backup started ...
Backup complete
Command> call ttBackupStatus ();
< 2, 0, 0, 2012-02-22 23:47:57.997000, 2012-02-22 23:47:58.174000, 0, 11880448,0, 5740 >
1 row found.
c:\>ttbackup -dir E:\oracle\timesten\tt_back\full  -type fileIncrOrFull    -force  -fname xifenfei00_  my_ttdb
Backup started ...
Backup complete
Command> call ttBackupStatus ();
< 2, 0, 1, 2012-02-22 23:53:37.364000, 2012-02-22 23:53:37.753000, 0, 11886592,0, 5076 >
1 row found.
--补充说明
在有启用增量备份(启用增量的全备或者增量备份本身)的基础上,会自动进行增量备份;
在无启用增量备份(没有备份或者备份没有启用增量备份)的基础上,如果无则会进行全备

streamFull测试

c:\>ttBackup -type streamFull my_ttdb>E:\oracle\timesten\tt_back\full\xifenfei.tream
Backup started ...
Backup complete
Command> call ttBackupStatus ();
< 2, 1, 1, 2012-02-22 23:38:52.480000, 2012-02-22 23:38:52.606000, 0, 11874304,0, 4384 >
1 row found.
c:\>dir E:\oracle\timesten\tt_back\full\xifenfei.*
 驱动器 E 中的卷没有标签。
 卷的序列号是 38D0-2A35
 E:\oracle\timesten\tt_back\full 的目录
2012/02/22  23:38        33,064,596 xifenfei.tream
               1 个文件     33,064,596 字节
               0 个目录  9,399,287,808 可用字节
--补充说明
在linux/unix环境中,执行流备份可以结合dd命令
如:ttBackup -type streamFull FastIns | dd bs=64k of=/dev/rmt0

Timesten安装与试用

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:Timesten安装与试用

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

1.安装timesten

[oracle@bas linux8664]$ ./setup.sh
NOTE: Each TimesTen installation is identified by a unique instance name.
      The instance name must be a non-null alphanumeric string, not longer
      than 255 characters.
Please choose an instance name for this installation? [ tt1122 ] xifenfei
Instance name will be 'xifenfei'.
Is this correct? [ yes ] yes
Of the three components:
  [1] Client/Server and Data Manager
  [2] Data Manager Only
  [3] Client Only
Which would you like to install? [ 1 ] 1
Of the following options :
  [1] /home/oracle
  [2] /home/oracle/timesten
  [3] Specify a location
  [q] Quit the installation
Where would you like to install the xifenfei instance of TimesTen? [ 1 ] 2
Where would you like to create the daemon home directory? [ /home/oracle/timesten/TimesTen/xifenfei/info ]
The daemon logs will be located in /home/oracle/timesten/TimesTen/xifenfei/info
Would you like to specify a different location for the daemon logs? [ no ]
Installing into /home/oracle/timesten/TimesTen/xifenfei ...
Uncompressing ...
NOTE: If you are configuring TimesTen for use with Oracle Clusterware, the
      daemon port number must be the same across all TimesTen installations
      managed within the same Oracle Clusterware cluster.
NOTE: All installations that replicate to each other must use the same daemon
      port number that is set at installation time. The daemon port number can
      be verified by running 'ttVersion'.
The default port number is 53396.
Do you want to use the default port number for the TimesTen daemon? [ yes ]
The daemon will run on the default port number (53396).
NOTE: For security, we recommend that you restrict access to the
      TimesTen installation to members of a single OS group. Only members of
      that OS group will be allowed to perform direct mode connections to
      TimesTen, and only members of that OS group will be allowed to perform
      operations that access TimesTen data stores, TimesTen files and shared
      memory. The OS group defaults to the primary group of the instance
      administrator. You can default to this group, choose another OS group
      or you can make this instance world-accessible. If you choose to make
      this instance world-accessible, all database files and shared memory
      are readable and writable by all users.
Restrict access to the the TimesTen installation to the group 'oinstall'? [ yes ] yes
NOTE: Enabling PL/SQL will increase the size of some TimesTen libraries.
Would you like to enable PL/SQL for this instance? [ yes ] yes
      TNS_ADMIN was not set in your environment but there is a tnsnames.ora
      file in /opt/app/oracle/product/10.2.0/db_1/network/admin.
Would you like to use this TNS_ADMIN setting for the In-Memory Database Cache? [ yes ] yes
TNS_ADMIN will be set to /opt/app/oracle/product/10.2.0/db_1/network/admin
You can change TNS_ADMIN later by running <install_dir>/bin/ttmodinstall.
NOTE: It appears that you are running version 3.4 or higher of the g++
      compiler. TimesTen ships with multiple sets of client libraries and server
      binaries : one built for compatibility with g++ 3.4.6 and one with
      g++ 4.1.0. The installer has created links to the 3.4.6 library in the
      <install_dir>/lib directory and to the 3.4.6 server binary in the
      <install_dir>/bin directory. If you want to use a different compiler,
      please modify the links to point to the desired library and server binary.
Installing server components ...
What is the TCP/IP port number that you want the TimesTen Server to listen on? [ 53397 ]
Do you want to install QuickStart and the TimesTen Documentation? [ no ] no
Would you like to install the documentation (without QuickStart)? [ yes ]
Where would you like to create the doc directory (s=skip)? [ /home/oracle/timesten/TimesTen/xifenfei/doc ] s
Installing client components ...
Would you like to use TimesTen Replication with Oracle Clusterware? [ no ] no
NOTE: The TimesTen daemon startup/shutdown scripts have not been installed.
Run the 'setuproot' script :
        cd /home/oracle/timesten/TimesTen/xifenfei/bin
        ./setuproot -install
This will move the TimesTen startup script into its appropriate location.
The startup script is currently located here :
  '/home/oracle/timesten/TimesTen/xifenfei/startup/tt_xifenfei'.
The documentation was not installed.
To manually install the documentation, run the command 'setup.sh -installDoc'
The 11.2.2.2 Release Notes are located here :
  '/home/oracle/timesten/TimesTen/xifenfei/README.html'
Starting the daemon ...
TimesTen Daemon startup OK.
End of TimesTen installation.
--设置开机启动
[root@bas linux8664]# cd /home/oracle/timesten/TimesTen/xifenfei/bin/
[root@bas bin]# ./setuproot -install
Would you like to install the TimesTen daemon startup scripts into /etc/init.d? [ yes ] yes
Copying /home/oracle/timesten/TimesTen/xifenfei/startup/tt_xifenfei to /etc/init.d
Successfully installed the following scripts :
/etc/init.d/tt_xifenfei
/etc/rc.d/rc0.d/K45tt_xifenfei
/etc/rc.d/rc1.d/K45tt_xifenfei
/etc/rc.d/rc2.d/S90tt_xifenfei
/etc/rc.d/rc3.d/S90tt_xifenfei
/etc/rc.d/rc5.d/S90tt_xifenfei
/etc/rc.d/rc6.d/K45tt_xifenfei

2.配置DSN

[root@bas info]# pwd
/home/oracle/timesten/TimesTen/xifenfei/info
[root@bas info]# more sys.odbc.ini
[ODBC Data Sources]
TT_1122=TimesTen 11.2.2 Driver
[TT_1122]
Driver=/home/oracle/timesten/TimesTen/xifenfei/lib/libtten.so
DataStore=/home/oracle/timesten/TimesTen/xifenfei/info/TT_1122
DatabaseCharacterSet=ZHS16GBK
PermSize=300
TempSize=64
OracleNetServiceName=orcl_tt

Driver = the TimesTen Direct Linked ODBC Driver
DataStore = the location and the name of the database files
LogDir = the directory for the transaction logs
PermSize = the size of the permanent region of the database. In the above example, this is configured for 40MB
TempSize = the size of the temporary region of the database. In the above example, this is configured for 32MB
DatabaseCharacterSet = the character set used by the database
OracleNetServiceName = the TNS service name to the Oracle database. This attribute is required for In-Memory Database Cache only.

3.查看相关文件和进程

[root@bas info]# ps -ef|grep timesten|grep -v grep
oracle   30391     1  0 00:01 ?        00:00:00 /home/oracle/timesten/TimesTen/xifenfei/bin/timestend -initfd 13
oracle   30395 30391  0 00:01 ?        00:00:00 /home/oracle/timesten/TimesTen/xifenfei/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000000 -facility user
oracle   30396 30391  0 00:01 ?        00:00:00 /home/oracle/timesten/TimesTen/xifenfei/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000001 -facility user
oracle   30397 30391  0 00:01 ?        00:00:00 /home/oracle/timesten/TimesTen/xifenfei/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000002 -facility user
oracle   30398 30391  0 00:01 ?        00:00:00 /home/oracle/timesten/TimesTen/xifenfei/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000003 -facility user
oracle   30400 30391  0 00:01 ?        00:00:00 /home/oracle/timesten/TimesTen/xifenfei/bin/ttcserver -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000004 -p 53397 -facility user -group oinstall
[root@bas TimesTen]# pwd
/home/oracle/timesten/TimesTen
[root@bas TimesTen]# ls -l
total 4
drwxr-x---  17 oracle oinstall 4096 Feb 12 00:01 xifenfei
[root@bas TimesTen]# cd xifenfei
[root@bas xifenfei]# ls -l
total 140
drwxr-x---  4 oracle oinstall  4096 Feb 12 00:01 3rdparty
drwxr-x---  2 oracle oinstall  4096 Feb 12 00:43 bin
drwxr-x---  3 oracle oinstall  4096 Dec 24 00:23 include
drwxr-x---  2 oracle oinstall  4096 Feb 12 00:18 info
drwxr-x---  2 oracle oinstall  4096 Feb 12 00:00 lib
drwxr-x---  2 oracle oinstall  4096 Dec 24 00:23 mibs
drwxr-x---  3 oracle oinstall  4096 Dec 24 00:23 network
drwxr-x---  3 oracle oinstall  4096 Dec 24 00:23 nls
drwxr-x---  2 oracle oinstall  4096 Dec 24 00:23 oraclescripts
drwxr-x---  4 oracle oinstall  4096 Feb 11 23:59 PERL
drwxr-x---  8 oracle oinstall  4096 Dec 24 00:23 plsql
-r--r-----  1 oracle oinstall 74764 Feb 12 00:00 README.html
drwxr-x---  2 oracle oinstall  4096 Feb 11 23:59 startup
drwxr-x---  2 oracle oinstall  4096 Dec 24 00:23 support
drwxrw----  5 oracle oinstall  4096 Feb 12 00:00 ttclasses
drwxr-x---  3 oracle oinstall  4096 Feb 11 23:59 ttoracle_home

4.试用Timesten

[oracle@bas bin]$ ttisql -version
TimesTen Release 11.2.2.2.0
[oracle@bas info]$ ttisql TT_1122
Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=TT_1122";
Warning 01S00: Undefined connection attribute "ConnectionCharacte" on line 144 of file /home/oracle/timesten/TimesTen/xifenfei/info/sys.odbc.ini
Connection successful: DSN=TT_1122;UID=oracle;DataStore=/home/oracle/timesten/TimesTen/xifenfei/info/TT_1122;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/timesten/TimesTen/xifenfei/lib/libtten.so;PermSize=300;TempSize=64;TypeMode=0;OracleNetServiceName=orcl_tt;
(Default setting AutoCommit=1)
Command> tables;
0 tables found.
Command> create table t_xff(id number,name varchar2(100));
Command> tables;
  ORACLE.T_XFF
1 table found.
Command> desc t_xff;
Table ORACLE.T_XFF:
  Columns:
    ID                              NUMBER
    NAME                            VARCHAR2 (100) INLINE
1 table found.
Command> insert into t_xff values(1,'xifenfei');
1 row inserted.
Command> insert into t_xff values(2,'www.xifenfei.com');
1 row inserted.
Command> commit;
Command> select * from t_xff;
< 1, xifenfei >
< 2, www.xifenfei.com >
2 rows found.
Command> update t_xff set name='xff' where id=1;
1 row updated.
Command> select * from t_xff;
< 1, xff >
< 2, www.xifenfei.com >
2 rows found.
Command> delete from t_xff where id=1;
1 row deleted.
Command> commit;
Command> select * from t_xff;
< 2, www.xifenfei.com >
1 row found.
Command> help
Use "help all" to get a description of all commands or use "help <cmd>" to
limit it to that command.
?                         free                      sqlcolumns
!                         functions                 sqlgetinfo
@@                        globalprocessing          sqlquerytimeout
accept                    help                      sqlstatistics
allfunctions              history                   sqltables
allindexes                host                      statsclear
allpackages               if                        statsestimate
allprocedures             indexes                   statsupdate
allsequences              isolation                 synonyms
allsynonyms               monitor                   tables
alltables                 tblsize                   timing
allviews                  multipleconnections       tryglobalprocessing
autocommit                ncharencoding             tryhash
builtins                  optfirstrow               trymaterialize
cachegroups               optprofile                trymergejoin
cachesqlget               packages                  trynestedloopjoin
clearhistory              passthrough               tryrowid
clienttimeout             prefetchcount             tryrowlocks
close                     prepare                   tryserial
closeall                  print                     trytbllocks
cmdcache                  procedures                trytmphash
columnlabels              quantify                  trytmptable
commit                    prompt                    trytmprange
commitdurable             remark                    tryrange
compact                   repschemes                undefine
compare                   retryconnect              unsetjoinorder
connect                   rollback                  unsetuseindex
define                    run                       use
describe                  savehistory               variable
disconnect                sequences                 verbosity
dssize                    set                       version
e:                        setjoinorder              vertical
exec                      setuseindex               views
execandfetch              setvariable               waitfor
exit                      show                      whenever
explain                   showjoinorder             xlabookmarkdelete
fetchall                  showplan                  <sql_statement>
fetchone                  sleep
Command> exit
Disconnecting...
Done.