TimesTen-ODBC--应用开发PPT

上传人:每**** 文档编号:133164737 上传时间:2022-08-09 格式:PPT 页数:109 大小:534KB
收藏 版权申诉 举报 下载
TimesTen-ODBC--应用开发PPT_第1页
第1页 / 共109页
TimesTen-ODBC--应用开发PPT_第2页
第2页 / 共109页
TimesTen-ODBC--应用开发PPT_第3页
第3页 / 共109页
资源描述:

《TimesTen-ODBC--应用开发PPT》由会员分享,可在线阅读,更多相关《TimesTen-ODBC--应用开发PPT(109页珍藏版)》请在装配图网上搜索。

1、 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-Sensitive TimesTen ODBC 应用开发应用开发zhaojunfeng 2008-03-14 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveAgenda ODBC 程序结构 如何使用ODBC句柄 实现 SQL Statements 异常捕捉 性能方面考虑 其他建议2

2、3 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveODBC 程序流程程序流程SQLFreeStmtSQLDisconnectSQLFreeConnectSQLFreeEnvSQLAllocEnvSQLAllocConnectSQLConnectSQLAllocStmtProcess SQL StatementsReceive ResultsCLOSE optionDROP option4 2007-Proprietary and Confidentia

3、l Information of Amdocs.Security Level Classification-SensitiveODBC 应用的句柄应用的句柄Environment 句柄句柄 初始化 ODBC 调用接口 ODBC 方法:SQLAllocEnv()和 SQLFreeEnv()Connection 句柄句柄 存储数据源连接信息 ODBC 方法:SQLAllocConnect()和 SQLFreeConnect()隐式分配一个特定的 Environment 句柄Statement 句柄句柄 存储SQL statement 信息 ODBC 方法:SQLAllocStmt()和 SQLFr

4、eeStmt()隐式分配一个特定的 Connection 句柄5 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-Sensitive使用使用 ODBC 应用句柄应用句柄statement 句柄只能在初始阶段分配一次,并在结束阶段释放.在使用多线程编程中,statement 和 connection 句柄 应该属于线程结构体内.句柄不能用于多线程并发运行,如果想实现在多个线程在不同的时间访问同一个句柄,那么应用必须通过一些信号量等方式的机制来实现。6 2007-Propri

5、etary and Confidential Information of Amdocs.Security Level Classification-SensitiveSQL Statement 执行流程执行流程SQLPrepareSQLBindParameterSQLExecuteYesInitializeTerminateIf more processingSQLFreeStmtIf repeatNoSQLTransactRepeatable Execution?SQLBindParameterSQLExecDirect7 2007-Proprietary and Confidential

6、 Information of Amdocs.Security Level Classification-Sensitive绑定参数缓存绑定参数缓存只需要Prepare 或者编译 SQL statements 及内建procedures一次,然后执行或者调用多次。尽量使用参数化statements,在运行期使用变量方式来应用SQL statements和内建 procedure。一旦statement被prepared,尽快绑定参数和列变量。在程序开始的时候申明/分配一次需要用到的变量。变量属于全局范围的。如果使用到多线程,变量申明在线程内部。8 2007-Proprietary and Co

7、nfidential Information of Amdocs.Security Level Classification-Sensitive绑定参数缓存示例绑定参数缓存示例#define CHARLEN 20SQLINTEGER intBuf,nullData=SQL_NULL_DATA;SQLCHAR charBufCHARLEN;SQLFLOAT floatBuf;rc=SQLPrepare(hStmt,(SQLCHAR*)“insert into student.tab values(?,?,?)”,SQL_NTS);rc=SQLBindParameter(hStmt,1,SQL_P

8、ARAM_INPUT,SQL_C_SLONG,SQL_INTEGER,0,0,&intBuf,sizeof(intBuf),NULL);rc=SQLBindParameter(hStmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,CHARLEN,0,charBuf,CHARLEN,SQL_NTS);rc=SQLBindParameter(hStmt,3,SQL_PARAM_INPUT,SQL_C_DOUBLE,SQL_FLOAT,0,0,&floatBuf,sizeof(floatBuf),&nullData);.rc=SQLExecute(hStmt);9

9、2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveC 和和 SQL 数据类型的绑定映射数据类型的绑定映射SQL_CHARSQL_INTEGER(unsigned)SQL_C_CHARSQL_C_TIMESQL_C_DATESQL_C_BINARYSQL_C_BINARYSQL_C_BINARYSQL_C_DOUBLESQL_C_DOUBLESQL_C_FLOATSQL_C_CHARSQL_C_ULONGSQL_VARCHARSQL_LONGVARCHARS

10、QL_DECIMALSQL_NUMERICSQL_BITSQL_TINYINT(signed)SQL_TINYINT(unsigned)SQL_SMALLINT(signed)SQL_SMALLINT(unsigned)SQL_INTEGER(signed)SQL_BIGINTSQL_REALSQL_FLOATSQL_DOUBLESQL_BINARYSQL_VARBINARYSQL_LONGVARBINARYSQL_DATESQL_TIMESQL_TIMESTAMPSQL_C_CHARSQL_C_CHARSQL_C_CHARSQL_C_CHARSQL_C_BITSQL_C_STINYINTSQ

11、L_C_UTINYINTSQL_C_SSHORTSQL_C_USHORTSQL_C_SLONGSQL_C_TIMESTAMP10 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveODBC 异常捕捉异常捕捉所有 ODBC 方法都会有一个返回代码 确保程序中已经捕捉!如果返回代码是SQL_ERROR 或者SQL_SUCCESS_WITH_INFO,那么调用ODBC方法 SQLError()获取详细信息获取(TimesTen)本地错误代码和错误信息获取 SQL

12、STATE(ODBC 错误代码)#define ERRMSGLEN 255SQLUCHAR sqlstate6;SQLINTEGER native_error=0;SQLUCHAR ErrorMsgERRMSGLEN;SQLSMALLINT cbErrorMsg;rc=SQLError(hEnv,hDbc,hStmt,sqlstate,&native_error,ErrorMsg,ERRMSGLEN,&cbErrorMsg);11 2007-Proprietary and Confidential Information of Amdocs.Security Level Classificat

13、ion-Sensitive应用性能方面考虑应用性能方面考虑(1/3)使用TimesTen ODBC直连方式会获得最佳性能尽量多次执行Prepare statements可以避免没有必要的参数重复绑定可使用 SQLBindCol()来代替 SQLGetData()这样可以减少运行期系统表锁的占用时间尽量避免数据转换尽量使用定长数据类型12 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-Sensitive应用性能方面考虑应用性能方面考虑(2/3)尽量避免ALTER TABL

14、E 操作 更新优化统计表尽量利用你创建的索引尽量使用短交易来减少锁冲突有规则的进行checkpoint操作有规则的进行backups操作(如果使用增量备份,那么这个操作尤为重要)13 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-Sensitive其他建议其他建议检查连接属性配置文件(sys.odbc.ini/.odbc.ini 文件).检查表的所属者owners.方法调用顺序或者游标状态不正确往往是应用程序不正确的信号。游标都和特定的statement句柄关联,(隐式

15、和connection句柄关联)Transactions和特定的 connection 句柄关联 如果statements 或者 connections 是跨线程共享的,那么需要应用来避免方法调用顺序和游标状态错误。14 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-Sensitive检查点和日志文件检查点和日志文件 Oracle TimesTen定期将数据存储区和事务日志的更改写入磁盘 如果需要恢复数据存储区,Oracle TimesTen将把磁盘上的数据存储区检查点

16、与仍位于日志文件中的已完成事务合并在一起 检查点和日志文件使用普通的磁盘文件系统 15 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveReplication TimesTen to TimesTen Replication TimesTen to TimesTen是 Oracle TimesTen In-Memory Database的一个选项,它支持服务器间的实时数据复制,以获得高可用性和负载共享。数据复制可以是双机热备份(active-standb

17、y)或负载均衡(active-active)数据复制可以使用异步或同步传输,数据复制可以包含冲突检测和冲突解决以及在故障服务器恢复后自动重新同步。16 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-Sensitive复制代理复制代理17 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveReplication 配置复制后,将为每个数

18、据存储区启动复制代理进程。如果为复制而配置了同一服务器上的多个数据存储区,则每个数据存储区将有一个单独的复制代理 每个复制代理能够向一个或多个用户服务器发送更新,并从一个或多个主服务器那里接收更新 复制代理通过 TCP/IP流套接字进行通信 18 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveCache Connect to Oracle Cache Connect to Oracle 是 Oracle TimesTen In-Memory Datab

19、ase的一个选项,它为位于应用程序层中的 Oracle 磁盘数据创建实时、可更新的高速缓存 Cache Connect to Oracle 能够将 Oracle 磁盘数据的子集加载到 TimesTen中,能够双向传播更新 Cache Connect to Oracle 能够使对非高速缓存数据的 SQL请求的透传自动化 Cache Connect to Oracle 能够在故障之后自动重新同步数据19 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveCac

20、he Connect to Oracle 高速缓存组是由一个或多个通过主键/外键关系以逻辑层次结构排列的表的集合。高速缓存组中的每个表都与 Oracle 数据库表相关 一个高速缓存组表可以包含相关 Oracle 表中的所有行和列或行和列的一个子集 可以通过 SQL 语句创建和修改高速缓存组 20 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveCache Connect to Oracle 高速缓存组支持以下特性:应用程序可以对高速缓存组执行读取和写入操

21、作 可以自动或手动刷新高速缓存组(将 Oracle 数据库数据置于高速缓存组中)可以自动或手动清理高速缓存组(将高速缓存更新传播到 Oracle 表)可以自动跟踪对 Oracle 表或高速缓存组的更改 21 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-Sensitive多种灵活的多种灵活的cache group A.只读的cache group,定时把Oracle数据刷新到TimesTen里面,TimesTen里面的数据是只读的.可以通过改变PassThrough的属

22、性,把对TimesTen的数据变更到Oracle里面,然后再通过Oracle刷新到TimesTen里面 B.同步的cahe group,写TimesTen的数据会先同步更新完Oracle数据库然后再更新到TimesTen C.异步的cache group,直接更新到TimesTen里面,TimesTen定时通过replication agent把数据批量更新到Oracle里面。如果Oracle当了,等Oracle起来后,TimesTen会自动同步到Oracle上面。D.用户管理的cahe group,用户自定义刷新,加载,卸载等。22 2007-Proprietary and Confiden

23、tial Information of Amdocs.Security Level Classification-SensitiveTimesTen对行业标准的支持对行业标准的支持 支持多种操作系统,比如Linux,AIX,Solaris,Windows,HP-Unix等32位或者64位操作系统 支持用户的权限和认证管理,支持create user,grant,revoke操作 没有tablespace的概念,使用的DSN的概念,没有存储过程,函数,嵌入式c 支持多种常用的字符集,如ZHS16GBK,UTF8,US7ASCII等23 2007-Proprietary and Confident

24、ial Information of Amdocs.Security Level Classification-SensitiveTimesTen对行业标准的支持对行业标准的支持 支持常用的数据对象,比如table,index,view,materialized view,sequence 支持常用的数据类型,比如number,char,varchar2,date等 支持sql92标准来进行DDL操作,比如create table,drop table,或者是改变对象属性比如alter table 等 支持标准DML语法,如select,insert,update,delete,truncat

25、e24 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesten安装安装(hp平台)平台)1.内核参数调整 semmns 是系统内系统用户可用的IPC信号总数,设置为大于或者等于4096(或8192等,推荐公式SEMMNS=SEMMNU=(SEMMNI*SEMMSL)shmmax 最大的共享内存段,以字节为单位,一般设置为内存的实际大小 64位机上检测目录是否支持大文件系统(如果要设置DataStore大于2G,就必须设置大文件系统):#fsad

26、m-F vxfs/dir_name设置大文件系统#/usr/sbin/fsadm-F xvfs -o largefiles/dir_name 25 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesten安装安装 2.目录,用户及组 增加组TimesTen(也可通过sam):#groupadd g 600 TimesTen 增加用户timesten并加入到sys,TimesTen组中:#useradd-u 600 -g TimesTen-G sy

27、s d /ttinstall/TimesTen timesten 如果有Oracle安装组的话,也可以现在把timesten用户加入到Oracle安装组dba中,因为Cache Group需要对Oracle目录有访问的权限 26 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesten安装安装 相关目录:#mkdir /etc/TimesTen#chmod 775/etc/TimesTen#chgrp R TimesTen/etc/TimesTe

28、n#chown R timesten:TimesTen/etc/TimesTen/etc/TimesTen目录用于TimesTen实例的注册 27 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesten安装安装 3.FTP到需要安装TimesTen的主机上的一个目录,要求可用空间在500M以上,然后解包:tar xvf timesten604.hp64ipf.tar4.解包后会在当前目录下生成hp64ipf/目录,执行该目录下面的setup.s

29、h命令 5.输入Instance name6.选择产品类型 Oracle TimesTen In-Memory Database:完全的内存数据库,和oracle数据库没有关系Cache Connect to Oracle:从oracle数据库cache数据到TimesTen内存数据库;也支持直接在内存数据库中建立实体表。28 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesten安装安装 7.选择组件 1 Client/Server and

30、Data Manager 2 Data Manager Only 3 Client Only Client/Server 模式下的三个选择:客户端、服务器端、客户端+服务器端 8.选择安装路径 9.选择TimesTen Daemon 监听端口,默认为 17000 29 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesten安装安装 10.设置Access Control Access Control 提供了一个对TimesTen的初级的权限保护

31、功能,它只是对谁能通过正常的途径(比如ttisql、JDBC及ODBC)访问到相应的Data Store做了初级的限制;并不是说,它对在操作系统级别上对Data Store的文件 以及 Log 文件的访问做除了安全保障。比如 root 用户,即使它不是TimesTen的用户,root用户可以做他想做的任何事情,比如删除Data Store文件等。所以安装的时候一定要注意,一般建议设置为 yes,Yes时才允许TimesTen创建新的用户 30 2007-Proprietary and Confidential Information of Amdocs.Security Level Class

32、ification-SensitiveTimesten安装安装 11.设置Cache Connect to Oracle 12.后面按照提示默认安装 31 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 系统变量系统变量 下列为TimesTen安装之后,可能需要设置的系统变量:1.LIB、LIBPATH、LD_LIBRARY_PATH、SHLIB_PATH:指向TimesTen所用到的共享库,即$INSTALL_DIR/LIB 目录;如

33、用到Cache Group,还需包含$ORACLE_HOME/LIB,不同的平台该变量的名字各有差异:SOLARIS LD_LIBRARY_PATH AIX LIBPATH HP-UX 32Bit SHLIB_PATH HP-UX 64Bit LD_LIBRARY_PAT($INSTALL_DIR/LIB)SHLIB_PATH($ORACLE_HOME/LIB)Tru64 UNIX LD_LIBRARY_PATH32 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-Sen

34、sitiveTimesTen 系统变量系统变量 2.CLASSPATH :如用到JDK,则需要设置该变量指向相应的Jar文件 目前支持的JDK有 JDK1.4、JDK5.0、BEA Weblogic Jrockit 5.0 3.ODBCINI:指向.odbc.ini 配置文件。当用户连接TimesTen的时候,TimesTen会按照下面的顺序查找相关的配置文件:1.环境变量ODBCINI所指向的.odbc.ini文件 2.运行TimesTen的用户主目录下的.odbc.ini 文件 3.环境变量SYSODBCINI所指向的 sys.odbc.ini文件 4./var/TimesTen/sys.

35、odbc.ini 5.install_dir/info/sys.odbc.ini(非root用户才会执行该步)33 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 系统变量系统变量 ORACLE_HOME 指向Oracle 数据库的安装目录,如果要用到Cache Group,该变量必须设置 PATH 指向TimesTen的bin 目录,即$INSTALL_DIR/bin;如果用到Cache Group的话,还要包含Oracle的bin目

36、录 SYSODBCINI 指向 SYS.ODBC.INI 配置文件,具体说明见 ODBCINI34 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 系统变量系统变量 SYSTTCONNECTINI:当用Client/Server 模式访问TimesTen的时候,该变量指向客户端的 sys.ttconnect.ini 配置文件。客户端查找配置文件的顺序是:1.环境变量SYSTTCONNECTINI所指向的 sys.ttconnect.in

37、i 配置文件。2./var/TimesTen/sys.ttconnect.ini 3.$INSTALL_DIR/info/sys.ttconnect.ini(非root用户安装)TMP/TMPDIR:指向TimesTen的临时目录。TimesTen的某些操作,比如ttRepAdmin duplicate、大的删除等会用到临时目录。该参数缺省设置为:HP-UX 和AIX 是/var/tmp;而Solaris、Linux、Tru64 UNIX 则是/tmp35 2007-Proprietary and Confidential Information of Amdocs.Security Leve

38、l Classification-SensitiveTimesTen 使用使用(1)-启动和关闭启动和关闭 TimesTen 安装完之后,缺省是已经起来了的 启动TimesTen:ttdaemonadmin-start 关闭TimesTen:ttdaemonadmin stop 关闭TimesTen前,建议先断开所有连接TimesTen的应用,如果启动了Cache Agent和Replication Agent,建议也都先停掉 36 2007-Proprietary and Confidential Information of Amdocs.Security Level Classifica

39、tion-SensitiveTimesTen 使用使用(1)-启动和关闭启动和关闭 ps-ef|grep timesten/tstenv/timeten/TimesTen/tt70/bin/timestend/tstenv/timeten/TimesTen/tt70/bin/timestenws/tstenv/timeten/TimesTen/tt70/bin/timestensubd/tstenv/timeten/TimesTen/tt70/bin/timestensubd /tstenv/timeten/TimesTen/tt70/bin/timestensubd /tstenv/time

40、ten/TimesTen/tt70/bin/timestensubd37 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 使用使用(1)-启动和关闭启动和关闭 ttstatus TimesTen status report as of Wed Dec 5 11:12:54 2007 Daemon pid 24468 port 18001 instance tt70 TimesTen server pid 24474 started on

41、 port 18003 TimesTen webserver pid 24473 started on port 18005-Data store/tstenv/timeten/TimesTen/tt70/info/IOMS There are no connections to the data store Replication policy :Manual Cache agent policy :Manual-Access control enabled.End of report38 2007-Proprietary and Confidential Information of Am

42、docs.Security Level Classification-SensitiveTimesTen 使用使用(1)-启动和关闭启动和关闭 缺省的有:TimesTen的后台守护进程(timestensubd)TimesTen的主守护进程(Daemon)Client/Server中的Server守护进程 TimesTen的一个WebServer 进程39 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 使用使用(2)-增加数据库用户增

43、加数据库用户 安装好系统后,系统有个自带的DSN,和access control结合起来用,一般创建用户,变更密码,授予权限等相关权限、用户控制在这个DSN来做 对于需要权限控制,创建用户等,安装的时候要把access control 安装上,如果安装的时候没有安装上,那么可以等安装后执行:ttmodinstall enableAccessControl ttmodinstall也可以重新指定监控的port端口,重新设置环境变量ORACLE_HOME 可以使用 ttmodinstall h 来查看该功能的使用40 2007-Proprietary and Confidential Inform

44、ation of Amdocs.Security Level Classification-SensitiveTimesTen 使用使用(2)-增加数据库用户增加数据库用户 TimesTen支持的创建后用户的权限有下面几种 1.Admin 2.Connect 3.create datastore 4.ddl 5.write 6.select41 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 使用使用(2)-增加数据库用户增加数据库用户

45、$ttisql TT_tt70_train Command create user tt_train identified by tt_train;Command grant ddl,admin to tt_train;Command grant write to tt_train;Command grant SELECT to tt_train;Command quit 42 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 使用使用(

46、3)-DataStore 介绍介绍 DataStore 是指TimesTen中的表、索引等放在内存段中的一个集合,类似与Oracle中库的概念 一个TimesTen Data Manager可以管理多个DataStore DataStore由放在相应ODBC配置文件中的一个DSN(Data Source Name)所定义,该DSN由一个名字和相关的属性组成,如下:名为TT_tt70_train的 DataStore的定义43 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification

47、-SensitiveDataStore 介绍介绍 ODBC Data Sources TT_tt70_train=TimesTen 7.0 Driver TT_tt70_train Driver=/tstenv/timeten/zjf/TimesTen/tt70_train/lib/libtten.so DataStore=/tstenv/timeten/zjf/TimesTen/tt70_train/info/TT_tt70_train DatabaseCharacterSet=US7ASCII PermSize=50 TempSize=1044 2007-Proprietary and C

48、onfidential Information of Amdocs.Security Level Classification-SensitiveDataStore 介绍介绍 ODBC配置文件分为两种:系统级ODBC文件(可通过环境变量SYSODBCINI另行设置)和用户级ODBC配置文件(可通过环境变量ODBCINI另行设置)。系统级的ODBC可以被任何用户所引用,而用户级的只能被该用户所引用。系统级的ODBC文件在Windows平台下可以通过控制面板-ODBC数据源管理-系统DSN 定义;而UNIX平台下,则一般是通过定义文件$INSTALL_DIR/sys.odbc.ini完成45 20

49、07-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveDataStore 介绍介绍 当用户连接一个DataStore的时候,TimesTen会按照下面的顺序查找配置文件:1.环境变量ODBCINI所指的.odbc.ini文件 2.运行TimesTen的用户主目录下的.odbc.ini 文件 3.环境变量SYSODBCINI所指的 sys.odbc.ini文件 4./var/TimesTen/sys.odbc.ini 5.$INSTALL_DIR/info/sys.

50、odbc.ini(非root用户才会执行该步)$INSTALL_DIR为TimesTen的安装目录46 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveDataStore 介绍介绍 在上面的 TT_tt70_train 定义里面,有两个重要的属性:Driver=/tstenv/timeten/zjf/TimesTen/tt70_train/lib/libtten.so 指操作该数据源所需要的驱动 DataStore=/tstenv/timeten/zjf

51、/TimesTen/tt70_train/info/TT_tt70_train 指的是放置Checkpoint文件的磁盘地址 TimesTen虽然运行的时候将所有的数据都预先装载在内存中,但它也有自己的数据文件、日志文件等47 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveDataStore 介绍介绍 数据文件叫checkpoint 文件,是TimesTen内存中数据在磁盘上的一个镜像,相当于Oracle数据库中的数据文件DBF TimesTen会在一

52、定条件下自动做Check point,它会将内存中的脏数据和磁盘上的数据文件做增量同步。当首次登陆到该DSN,或者TimesTen异常中止/失败时,TimesTen需要这些读取这些文件做恢复48 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveDataStore 介绍介绍下面是DataStore TT_tt70_train 在磁盘上的相应文件:$pwd/tstenv/timeten/zjf/TimesTen/tt70_train/info$ls-al|g

53、rep TT_tt70_train-rw-rw-rw-1 timeten users 14785240 Dec 5 18:46 TT_tt70_train.ds0-rw-rw-rw-1 timeten users 14785240 Dec 5 18:38 TT_tt70_train.ds1-rw-rw-rw-1 timeten users 753664 Dec 5 18:46 TT_tt70_train.log0-rw-rw-rw-1 timeten users 67108864 Dec 5 18:28 TT_tt70_train.res0-rw-rw-rw-1 timeten users 6

54、7108864 Dec 5 18:28 TT_tt70_train.res1-rw-rw-rw-1 timeten users 67108864 Dec 5 18:28 TT_tt70_train.res249 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveDataStore 介绍介绍 针对TT_tt70_train这个DataStore,磁盘上对应由两个checkpoint 文件,TT_tt70_train.ds0,TT_tt70_train.ds1

55、 一个日志文件,TT_tt70_train.log0 三个保留文件(reservation)TT_tt70_train.res0,TT_tt70_train.res1,TT_tt70_train.res250 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveCheckpoint文件文件 针对Checkpoint文件,TimesTen会以DataStore属性的最后一节为文件名,创建相应的Checkpoint文件 TimesTen每次做Checkpoint

56、的时候,会轮换着写这两个文件,每次都写较旧的那个,所以在某些时间段内,这两个文件不是完全一致的。每次做Checkpoint的时候,TimesTen先在这两个文件之间做一个同步,然后把最新的更新,写到旧的Checkpoint文件中。为什么不同时写入两个文件呢?如果同时往两个文件写入,而写入过程发生异常,会导致两个文件同时被损坏,带来灾难性的后果51 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen如何创建日志文件和保留文件呢如何创建日志文件

57、和保留文件呢?在ODBC配置文件里面,通过属性 LogDir 来定义日志文件,没有显式设置LogDir时,日志文件将和Checkpoint文件位于同一目录下,且以DataStore属性中定义的目录的最后一节为文件名,后缀中按数字序列递增命名,例如TT_tt70_train.log0,TT_tt70_train.log1。等。具体定义了LogDir后,日志文件将位于该目录下,且以该属性值所指向的目录的最后一节为文件名,例如:52 2007-Proprietary and Confidential Information of Amdocs.Security Level Classificatio

58、n-SensitiveCheckpoint文件文件 LogDir=/tstenv/timeten/zjf/TimesTen/tt70_train/log 此时,TimesTen将在目录/tstenv/timeten/zjf/TimesTen/tt70_train/log 下创建名为TT_tt70_traincache的日志和保留文件 日志文件会和保留文件始终位于同一个目录下 强烈建议将日志文件和Checkpoint文件分开放在不同磁盘上,且处于不同的磁盘控制器下,以尽量减少磁盘IO的影响53 2007-Proprietary and Confidential Information of Am

59、docs.Security Level Classification-Sensitive保留文件保留文件 保留文件始终和日志文件位于同一目录下,它的大小由属性LogFileSize定义。缺省的LogFileSize是64M 当由于某些原因导致文件系统没有空余的磁盘空间时,如果没有保留文件,TimesTen将无法运行下去,因为事务的提交不可避免地导致日志文件的增长,但此时已没有任何可用于增长的磁盘空间,从而导致TimesTen处于静止状态,在此状态下,只允许读操作而不允许写操作54 2007-Proprietary and Confidential Information of Amdocs.S

60、ecurity Level Classification-Sensitive保留文件保留文件 保留文件是作为溢出缓冲空间使用的,它们被预先创建,当磁盘空间都被用光时,TimesTen会利用这些保留文件作为一个缓冲,从而完成最终的一些事务,避免TimesTen进入静止状态 创建三个保留文件的原因是因为在绝大多数情况下,三个保留文件被证明是最优的选择55 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 使用使用(4)-DataStore配置

61、配置 非root用户安装时,TimesTen的配置文件为$TimesTen_Home/info/sys.odbc.ini 文件中。下面是安装后的这个文件缺省内容,这一段是TimesTen的所有属性值,是我们配置的一个很好参考#Authenticate=1 (client/server only)只用于Client/Server模式,当Server端该值设置为1时,只有提供了UID和Password的客户端连接才能访问该DSN,如果Access如果Access Control已经设置,则Authenticate必须设置为1。本地访问,即直连方式则忽略该参数#AutoCreate=1 当连接一个不

62、存在的DataStore时,是否自动创建它#CkptFrequency (if Logging=1 then 600 else 0)#CkptLogVolume=0 CkptFrequency/CkptLogVolume为Checkpoint的触发条件,当任何一个被触发时,TimesTen 将做Checkpoint操作56 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 使用使用(4)-DataStore配置配置#CkptRate=0

63、(0=rate not limited)#ConnectionCharacterSet (if DatabaseCharacterSet=TIMESTEN8 then TIMESTEN8 else US7ASCII)#ConnectionName (process argv0)#Connections=64#DatabaseCharacterSet(no default)57 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 使用使用(4

64、)-DataStore配置配置#Diagnostics=1 定义诊断信息的记录粒度0为关闭诊断信息。1为基本诊断信息#DurableCommits=0 日志是否被实时同步到磁盘上。0为异步方式,1为实时同步#ForceConnect=0#GroupRestrict (none by default)#Isolation=1 (1=read-committed,0=serializabl)#LockLevel=0 (0=row-level locking)#LockWait=10 (seconds)#Logging=1 (1=write log to disk)#LogAutoTruncate=

65、158 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 使用使用(4)-DataStore配置配置#LogBuffSize=65536(measured in KB)#LogDir (same as checkpoint directory by default)#LogFileSize=64 (measured in MB)#LogFlushMethod=0 控制TimesTen同步或者写日志到日志文件的方式。0为使用前一次的设置值;

66、1为批同步的方式(缺省);2为实时同步的方式#LogPurge=1 是否自动清除不用的日志文件#MatchLogOpts=0 是否使用第一次连接DataStore时logging/logpurge的值,0为使用;1为忽略第一次连接时的值,而是使用当前连接的特有的值#MemoryLock=0 (HP-UX,Linux,and Solaris platforms only)#NLS_LENGTH_SEMANTICS=BYTE#NLS_NCHAR_CONV_EXCP=0#NLS_SORT=BINARY#OverWrite=059 2007-Proprietary and Confidential Information of Amdocs.Security Level Classification-SensitiveTimesTen 使用使用(4)-DataStore配置配置#PermSize=2 (measured in MB;default is 2 on 32-bit,4 on 64-bit)永久内存区域的大小,即DataStore的大小#PermWarnThreshold=90#Pr

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!