1.TimesTen-Isntall-Linux
省略,详细步骤链接http://blog.sina.com.cn/s/blog_b6a665450102v3cw.html
2. Cache to oracle
2.1 Create a DSN for the TimesTen database
Before you can use Oracle In-Memory Database Cache, you must create
some Oracle users:
A user timesten owns Oracle tables that store information about
cache grids.
One or more schema users own the Oracle tables to be cached in a
TimesTen database. These may be existing users or new users.
A cache administration user creates and maintains Oracle objects
that store information used to manage cache grids and enforce
predefined behaviors of particular cache group types.
Start SQL*Plus on the Oracle system from an operating system shell
or command prompt, and connect to the Oracle database instance as
the sys user.
Use SQL*Plus to create a default tablespace that will be used by
both the timesten user and the cache administration user. This
tablespace should only be used to store objects for Oracle
In-Memory Database Cache and should not be shared with other
/applications. Then run the SQL*Plus script
TimesTen_install_dir/oraclescripts/initCacheGlobalSchema.sql to
create the following elements:
The timesten user
The Oracle tables owned by the timesten user to store information
about cache grids
The TT_CACHE_ADMIN_ROLE role that defines privileges on these
Oracle tables
Pass the default tablespace as an argument to the
initCacheGlobalSchema.sql script. In the following example, the
name of the default tablespace is cachetblsp:
SQL> CREATE TABLESPACE cachetblsp DATAFILE 'datfttuser.dbf' SIZE
100M;
SQL> @initCacheGlobalSchema "cachetblsp" SQL> CREATE USER test IDENTIFIED BY test;
SQL> GRANT dba to test; 2.2 Create a DSN for the TimesTen database
Vi sys.odbc.ini
[test]
Driver=/tt/TimesTen/tt1122/lib/libtten.so
DataStore=/tt/TimesTen/tt1122/info/DemoDataStore/test
PermSize=40
TempSize=32
PLSQL=1
DatabaseCharacterSet=ZHS16GBK
uid=test
pwd=test
oracleid=tnseproe
oraclepwd=test 2.3 配置tns
[timesten@wlsttnode1 admin]$ more tnsnames.ora
tnseproe =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)(HOST = 192.168.25.10)(PORT=1521))
(CONNECT_DATA =
(SERVICE_NAME = eproe)
)
)
2.4 Create users in the TimesTen database
[timesten@wlsttnode1 info]$ ttisql test
Copyright (c) 1996-2011, Oracle. All rights
reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=test";
Connection successful:
DSN=test;UID=test;DataStore=/tt/TimesTen/tt1122/info/DemoDataStore/test;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=US7ASCII;DRIVER=/tt/TimesTen/tt1122/lib/libtten.so;OracleId=tnseproe;PermSize=40;TempSize=32;TypeMode=0;OracleNetServiceName=tnseproe;
(Default setting AutoCommit=1)
Command> call
ttCacheUidPwdSet('test','test');
Command> call ttGridCreate('myGrid');
Command> call ttGridNameSet('myGrid');
Command> CREATE DYNAMIC ASYNCHRONOUS WRITETHROUGH GLOBAL CACHE
GROUP writecache FROM test.writetb (id NUMBER NOT NULL PRIMARY
KEY,name VARCHAR2(50));
Command> CREATE READONLY CACHE GROUP readcache AUTOREFRESH
INTERVAL 5 SECONDS FROM test.tt_test (id NUMBER NOT NULL PRIMARY
KEY,name VARCHAR2(50));
Warning 5002: Unable to connect to the cache
agent for /tt/TimesTen/tt1122/info/DemoDataStore/test; check agent
status
Warning 5051: Commit message to cache agent
failed. Cache agent must be restarted
Command> call ttcachestart;
Command> CREATE READONLY CACHE GROUP readcache AUTOREFRESH
INTERVAL 5 SECONDS FROM test.tt_test (id NUMBER NOT NULL PRIMARY
KEY,name VARCHAR2(50));
8224: Cache group READCACHE already exists
The command failed.
Command> cachegroups
Cache Group TEST.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: TEST.TT_TEST
Table Type: Read Only
Cache Group TEST.WRITECACHE:
Cache Group Type: Asynchronous Writethrough
global (Dynamic)
Autorefresh: No
Aging: LRU on
Root Table: TEST.WRITETB
Table Type: Propagate
2 cache groups found.
Command>
Command>
Command> select * from test.tt_test;
0 rows found.
Command> select * from TEST.WRITETB;
0 rows found.
Command> LOAD CACHE GROUP readcache COMMIT EVERY 256 ROWS;
4 cache instances affected.
Command> LOAD CACHE GROUP WRITECACHE COMMIT EVERY 256
ROWS;
3319: This operation needs the database to attach
to the grid first
The command failed.
Command> call
ttGridAttach(1,'WRITECACHE','wlsttnode1',5001);
Command> LOAD CACHE GROUP WRITECACHE COMMIT EVERY 256
ROWS;
3 cache instances affected.
Command>
Command> select * from test.tt_test;
< 1, Hello >
< 2, World >
< 3, tsttt >
< 4, sddf >
4 rows found.
Command> select * from test.radcache;
2206: Table TEST.RADCACHE not found
The command failed.
Command> select * from TEST.WRITETB;
< 1, sss >
< 2, dfdsaf >
< 3, sddf >
3 rows found.
Command>
SQL> insert into tt_test values(5,'mema');
Command> select * from test.tt_test;
< 1, Hello >
< 2, World >
< 3, tsttt >
< 4, sddf >
< 5, mema >
5 rows found.
3 Timesten to Timesten
3.1 Setting up an Active Master Database
ttisql repdb1_1122 3.1.1Create a Database User to Administer the Replication
Operations
create user adm identified by adm;
grant admin to adm;
create table customers (
cust_number number,
first_name varchar2(12) not
null,
last_name varchar2(12) not
null,
address varchar2(100) not
null,
primary key (cust_number));
insert into customers values (3700,'Peter','Burchard','882
Osborne Avenue, Boston, MA 02122');
insert into customers values (1121,'Saul','Mendoza','721 Stardust
Street, Mountain View, CA 94043');
create table orders (
order_number number not
null,
cust_number number not
null,
prod_number char(10) not
null,
order_date date not
null,
primary key (order_number),
foreign key (cust_number) references customers
(cust_number));
insert into ORDERS values
(6853036,3700,'0028616731',to_date('2008-04-05','yyyy-mm-dd'));
insert into ORDERS values
(6853041,3700,'0198612710',to_date('2009-01-12','yyyy-mm-dd'));
insert into ORDERS values
(6853169,1121,'0003750299',to_date('2008-08-01','yyyy-mm-dd'));
insert into ORDERS values
(6853174,1121,'0789428741',to_date('2008-10-25','yyyy-mm-dd'));
insert into ORDERS values
(6853179,1121,'0198612583',to_date('2009-02-02','yyyy-mm-dd'));
Define the active standby pair
connect "dsn=repdb1_1122;uid=adm;pwd=adm";
create active standby pair repdb1_1122 on "tthost1", repdb2_1122 on
"tthost2";
3.1.2Set the replication state to Active
call ttrepstateset ('active');
call ttrepstateget;
3.1.3Start the replication agent
call ttrepstart;
3.2Creating a Standby Database
3.2.1Duplicate the active database to the standby
ttrepadmin -duplicate -from repdb1_1122 -host "tthost1" -uid adm
-pwd adm "dsn=repdb2_1122"
3.2.2Start the replication agent
connect "dsn=repdb2_1122;uid=adm;pwd=adm";
call ttrepstart;
call ttrepstateget;
3.3Verify the data is being replicated between the active and the
standby
connect "dsn=repdb1_1122;uid=adm;pwd=adm";
insert into orders values (6853180,1121,'9999999999',
sysdate);
select * from orders where order_number=6853180;