创建TimesTen 数据库

定义Data Source Name (DSN)

TimesTen是通过DSN来访问的,DSN是TimesTen数据库的逻辑名,在Linux系统中,DSN文件位于/info/sys.odbc.ini
我们以自带的sampldb_1122 DSN定义为例:

[ODBC Data Sources]
sampledb_1122=TimesTen 11.2.2 Driver
# Driver有两种,TimesTen 11.2.2 Driver为direct driver,表示数据库在本地
# TimesTen 11.2.2 Client Driver是client driver,表示数据库位于其它主机

[sampledb_1122]
# 下面是具体的属性,象DataStore,DatabaseCharacterSet都属于DataStore属性
# 在数据库建立时必须指定,后续如果想修改必须重建数据库
Driver=/home/oracle/TimesTen/tt1122/lib/libtten.so
DataStore=/home/oracle/TimesTen/tt1122/info/DemoDataStore/sampledb_1122
# 确保/home/oracle/TimesTen/tt1122/info/DemoDataStore目录存在
# 建库时会在此目录生成以sampledb_1122为前缀的文件
PermSize=40
TempSize=32
DatabaseCharacterSet=US7ASCII

确保数据和日志目录存在及具备相应权限

DSN文件中属性部分,DataStore定义了数据文件和日志文件的目录,你也可以用LogDir属性单独指定日志文件的目录,通常将数据文件和日志文件分别放置在不同的磁盘上,以保证I/O性能。
例如:

DataStore=/home/oracle/TimesTen/tt1122/info/DemoDataStore/sampledb_1122
LogDir=/u02/TimesTen/log

注意LogDir表示的是目录,而DataStore的前面部分/home/oracle/TimesTen/tt1122/info/DemoDataStore/表示目录,最后一部分sampledb_1122表示的是数据库名以及文件前缀。

$ ls /home/oracle/TimesTen/tt1122/info/DemoDataStore/sampledb_1122*
ls: /home/oracle/TimesTen/tt1122/info/DemoDataStore/sampledb_1122*: No such file or directory

没有文件存在,可以开始建库了

创建TimesTen数据库

如果数据库不存在,可使用ttisql 建立并自动连接,如果存在,则直接连接到数据库

$ ttisql sampledb_1122

[oracle@timesten-hol ~]$ tttail sampledb_1122
18:54:16.405       1 TRACE    1L    1C   3997P Database sampledb_1122 loaded into memory
18:54:16.405       2 TRACE    1L    1C   3997P TimesTen Release 11.2.2.6.2

18:43:17.90 Info:    :  2603: maind got #21.203, hello: pid=3935 type=library payload=%00%00%00%00 protocolID=TimesTen 11.2.2.6.2.tt1122 ident=%00%00%00%00
18:43:17.90 Info:    :  2603: Got hello from pid 3935, type library (/home/oracle/TimesTen/tt1122/bin/ttIsqlCmd sampledb_1122 )
18:43:17.90 Info:    :  2603: maind: done with request #21.203
18:43:17.91 Info:    :  2603: maind got #21.204 from 3935, connect: name=/home/oracle/TimesTen/tt1122/info/DemoDataStore/sampledb_1122 context=         129c790 user=oracle pass= dbdev= logdev= logdir= grpname= access=%00%00%00%00 persist=%00%00%00%00 flags=@%00%00%01 newpermsz=%00%00%80%02%00%00%00%00 newtempsz=%00%00%00%02%00%00%00%00 newpermthresh=Z%00%00%00 newtempthresh=Z%00%00%00 newlogbufsz=%00%00%00%00%00%00%00%00 newsgasize=%00%00%00%02%00%00%00%00 newsgaaddr=%00%00%00%a0%7f%00%00%00 autorefreshType=%ff%ff%ff%ff logbufparallelism=%00%00%00%00 logflushmethod=%00%00%00%00 logmarkerinterval=%00%00%00%00 connections=%00%00%00%00 preallocatedExecEnvs=%00%00%00%00 commitBufferSizeMax=%00%00%00%00 control1=%00%00%00%00 control2=%00%00%00%00 control3=%00%00%00%00 ckptrate=%ff%ff%ff%ff connflags=%00%00%00%00 newlogfilesz=%00%00%00%00%00%00%00%00 skiprestorecheck=%00%00%00%00 realuser=oracle conn_name=sampledb_1122 ckptfrequency=%ff%ff%ff%ff ckptlogvolume=%ff%ff%ff%ff recoverythreads=%00%00%00%00 reqid=* plsql=%01%00%00%00 receiverThreads=
18:43:17.91 Info:    :  2603: 3935 0x129c790: Connect /home/oracle/TimesTen/tt1122/info/DemoDataStore/sampledb_1122 a=0x0 f=0x1000040
18:43:17.91 Info:    :  2603:                          permsize=41943040 tempsize=33554432
18:43:17.91 Info:    :  2603:                          logbuffersize=0 logfilesize=0
18:43:17.91 Info:    :  2603:                          permwarnthresh=90 tempwarnthresh=90 logflushmethod=0 connections=0
18:43:17.91 Info:    :  2603:                          preallocatedExecEnvs=0 commitBufferSizeMax=0 ckptfrequency=-1 ckptlogvolume=-1 conn_name=sampledb_1122
18:43:17.91 Info:    :  2603:                          recoverythreads=0 logbufparallelism=0
18:43:17.91 Info:    :  2603:                          plsql=1 sgasize=33554432 sgaaddr=0x7fa0000000
18:43:17.91 Info:    :  2603:                          control1=0 control2=0 control3=0
18:43:17.91 Info:    :  2603:                          ckptrate=-1 receiverThreads=0
18:43:17.91 Info:    :  2603:                          cacheAwtMethod=1
18:43:17.91 Info:    :  2603:                          ReplicationParallelismBufferMB=64 ReplicationParallelismLatches = 128
18:43:17.91 Info:    :  2603: 3935 0x129c790: No such data store
18:43:17.91 Info:    :  2603: daDbConnect failed
18:43:17.91 Info:    :  2603: return 1 833 'no such data store!' arg1='/home/oracle/TimesTen/tt1122/info/DemoDataStore/sampledb_1122' arg1type='S' arg2='' arg2type='S'
18:43:17.91 Info:    :  2603: maind: done with request #21.204

TimesTen数据库的组成

[oracle@timesten-hol DemoDataStore]$ cd /home/oracle/TimesTen/tt1122/info/DemoDataStore/
[oracle@timesten-hol DemoDataStore]$ ll sampledb_1122*
-rw-rw---- 1 oracle oracle 22964768 Apr 7 18:43 sampledb_1122.ds0 -rw-rw---- 1 oracle oracle 28798976 Apr 7 18:43 sampledb_1122.ds1 -rw-rw---- 1 oracle oracle 15872000 Apr 7 18:43 sampledb_1122.log0 -rw-rw---- 1 oracle oracle 67108864 Apr 7 18:43 sampledb_1122.res0 -rw-rw---- 1 oracle oracle 67108864 Apr 7 18:43 sampledb_1122.res1 -rw-rw---- 1 oracle oracle 67108864 Apr 7 18:43 sampledb_1122.res2

数据库建立后,我们可以看到目录中包含三类文件:
1. checkpoint文件
即数据文件,TimesTen保留两个checkpoint文件,在checkpoint时,TimesTen确定哪一个是最新的checkpoint文件,然后将数据写入另一个文件
checkpoint有两个作用,一个是加速恢复,因其保存了最新的状态;二是删除不必要的日志文件,以释放空间。
2. 日志文件
日志文件存放所有的更新动作,和checkpoint文件结合在一起,就可以实现恢复。
格式为log0, log1, … log#n
3. res文件
res0-3是为日志文件预留的空间,在空间不够时保证日志还可以继续写

你可能感兴趣的:(建库,timesten)