null内存数据库TT交流 内存数据库TT交流 目录目录3、最佳实践 1、TT总体架构 2、参数配置 TT整体架构TT整体架构nullTT组成TT组成TimesTen products consist of combinations of the following components:
内存数据库产品由如下部分组成:
1、Shared libraries 共享库
2、Memory-resident data structures 基于内存的数据结构
3、Database processes 数据库进程
4、Administrative programs 管理程序
5、Checkpoint and log files 日志文件
TT组成(一)TT组成(一)Shared libraries
The routines that implement the TimesTen functionality are embodied in a set of shared libraries that developers link with their applications and execute as a part of the application's process. This shared library approach is in contrast to a more conventional RDBMS, which is implemented as a collection of executable programs to which applications connect, typically over a client/server network. Applications can also use a client/server connection to access an IMDB Cache or TimesTen database, though in most cases the best performance will be realized with a directly linked application.
TimesTen功能是由一系列共享库来体现。开发者利用共享库来连接应用进程。在关系型数据库中,尤其是基于CS架构的应用程序对共享库使用非常广泛。虽然直连是公认的最好的应用方式,但是应用也可以使用C/S模式连接到timesten数据库。TT组成(二)TT组成(二)Memory-resident data structures
The TimesTen database resides entirely in main memory at runtime. It is
maintained in shared memory segments in the operating system and contains all
user data, indexes, system catalogs, log buffers, lock tables and temp space.
Multiple applications can share one database, and a single application can access
multiple databases on the same system.
Timesten在运行状态下是完全保存在内存中的。它保存在操作系统的共享内存段,包含用户数据、索引、系统日志、日志缓存、锁表、临时表空间等。如果操作系统一致,多个应用可以共享一个数据库,一个应用也可以连接多个内存数据库。
Database processes
TimesTen assigns a separate process to each database to perform operations
including the following :对如下每个数据库执行操作,TimesTen的分配一个单独的进程
• Loading the database into memory from a checkpoint file on disk
• Recovering the database if it needs to be recovered after loading it into
Memory 恢复数据库
• Performing periodic checkpoints in the background against the active
Database 后台定期检查数据库,保证可用性。
• Detecting and handling deadlocks 检测处理死锁
• Performing data aging 数据归档
TT组成(三)TT组成(三)Administrative programs
Utility programs are explicitly invoked by users, scripts, or applications to perform services such as interactive SQL, bulk copy, backup and restore,database migration and system monitoring.
实用程序被用户、脚本应用程序服务等显示调用。如:交互式sql、批量复制、备份、恢复、数据库迁移、系统监控。
Checkpoint and log files
Checkpoint files contain an image of the database on disk. TimesTen uses dual checkpoint files for additional safety, in case the system fails while a checkpoint operation is in progress. Changes to databases are captured in transaction logs that are written to disk periodically. If a database needs to be recovered,TimesTen merges the database checkpoint on disk with the completed transactions that are still in the log files. Normal disk file systems are used for checkpoints and log files.
Checkpoint文件是一个保存在磁盘的数据库镜像。如果,在做checkpoint操作时失败,checkpoint文件时一个有效的安全保障。交互日志里面的所有数据库变更都会定期写入磁盘。如果数据库需要恢复,Timesten能在磁盘文件中找到这个还原点。一般情况下,磁盘文件系统被用来保存checkpoint和log文件。
标题[黑体,28号字]标题[黑体,28号字]Cache group
READONLY CACHE GROUP:READONLY
ASYNCHRONOUS WRITETHROUGH CACHE GROUP
SYNCHRONOUS WRITETHROUGH CACHE GROUP
USER MANAGED CACHE GROUP
Applications can read from and write to cache groups.
Cache groups can be refreshed from Oracle data automatically or manually.
Updates to cache groups can be propagated to Oracle tables automatically or manually.
Changes to either Oracle tables or the cache group can be tracked automatically
目录目录3、最佳实践 1、TT总体架构 2、参数配置 ODBC.INIODBC.INIDSN:设置data source name
DRIVER:设置TimesTen动态驱动库路经,如果是使用静态库,则不用设置
DataStore:设置TimesTen数据文件存放路径,
(eg: /timesten6/var/TimesTen/tt60/DemoDataStore/OCS_DATA)
Connections:设置连接数上限
PermSize:设定TimesTen的固定内存,可以在第一次连接时增加PermSize,不能在有数据库连接时修改,单位为MB。
TempSize:设定TimesTen的临时内存,单位为MB,建议设定值=PermSize / 4
ThreadSafe:0:使用非线程安全访问datastore 1:线程安全
Logging:0:不写文件日志 1:写文件日志 2:只写系统内部日志到文件
OracleID:设置连接oracle的SID
OraclePWD:设置连接oracle的password
PassThrough:0:SQL只在TimesTen中执行 1:SQL不能在TimesTen中解析,TimesTen把SQL PassThrough到oracle中解析执行
ckptFrequency:设置 checkpoint的调用时间间隔,单位为秒
CkptLogVolume:当log文件堆积超过设定值时,TimesTen调用checkpoint
LogFileSize:设置日志文件大小,当日志文件超过指定值时,TimesTen会生成新的日志文件,单位为MB
LogBuffSize:内存日志缓冲区大小,单位为KB,建议设定值=PermSize/8
LogPurge :0表示删除日志,1:不删除日志
ODSC.INIODSC.INI1、Connections=300//连接数,可以在monitor中查看已经的连接数connections和DISConnections
2、PermSize=49152//单位是MB,根据实际的需要进行设定,The permanent data partition can be increased in size, but it cannot be decreased.
可以根据实际的需要进行估算
3、TempSize=6144 //单位是MB,The temporary data partition can be either increased or decreased in size for
一般是1/8*PermSize,但一般不超过1G
TimesTen复制TimesTen复制什么是复制replication?
复制replication怎么工作?
怎么配置复制replication?
目录目录3、最佳实践 1、TT总体架构 2、参数配置 什么是复制什么是复制复制就是在多个Data_Store之间数据的相互拷贝,确保应用或者内存数据库在某一台或者多台主机上出现数据问题之后的高可用性。复制工作原理复制工作原理主备机之间的复制是由replication agent 控制,replication agent 读取transaction log 缓存区中的
记录
混凝土 养护记录下载土方回填监理旁站记录免费下载集备记录下载集备记录下载集备记录下载
,确定主备机之间需要更新的各元素,replication agent 通过TCP/IP STREAM SOCKETS 发送更新请求,对端replication agent 接收请求,应用更新。复制的兼容性复制的兼容性主备机之间的DatabaseCharacterSet和TypeMode必须具备相同的属性
主备机之间TimesTen的版本必须一致
主备机之间Data Store实例名称必须一致复制元素复制元素Data Store
Tables
Sequences复制方式复制方式Default replication
Return receipt replication
Return twosafe replication
Default replication是一种异步方式,是默认方式。
Return receipt replication与Return twosafe replication
是同步方式,两者的区别在于前者是基于网络层,后者是基于应用层。前者确保对端replication agent 接收到更新内容后结束会话,后者确保对端应用提交更新后结束会话。
Default replicationDefault replicationReturn receipt replicationReturn receipt replicationReturn twosafe replicationReturn twosafe replication命令行下的命令操作命令行下的命令操作管理TimesTen:ttAdmin -ramPolicy manual tpabm
启停Timesten主进程:ttdaemonadmin –start|stop
启停Timeten缓存:call ttcachestart();call ttcachestop();
启停Timeten复制:call ttrepstart();call ttrepstop();
ttSize计算表大小
ttSize -tbl tb_prd_prd_inst -rows 1000000 "DSN=iba4“
ttSize -tbl RM_HB.DAT_REALTIME_ACCT_ITEM "DSN=iba4tt1“
ttschema 到处创建table、cache、replication、sequence脚本
ttSchema "DSN=iba4" >script.txt
ttSchema -list tables iba4tt1
操作系统下检查锁表情况
ttxactadmin DSN
锁表后的回滚
ttxactadmin -xactIdRollback 1.49 DSN
ttxactadmin -xactIdRollback
通过这种方式回滚之后,手工执行一下 ttckpt; 内存数据库命令行下:call ttckpt();ttStatusttStatus常见问题-解决
方案
气瓶 现场处置方案 .pdf气瓶 现场处置方案 .doc见习基地管理方案.doc关于群访事件的化解方案建筑工地扬尘治理专项方案下载
常见问题-解决方案TT基本的命令操作(常用)
Oracle<->TimesTen数据不同步怎么办?
锁表了怎么办?
Log文件不段增加,磁盘空间快耗尽了,怎么办?
复制不能正常工作怎么办?
我想重新装载TimesTen中的数据怎么办?
如何监控数据库的运行状态?
数据导入导出数据导入导出拷贝目前的数据到文件中
输出为 -o
ttBulkCp -o DSN=ocs tb_bil_acct_balance acct_balance.dump
//字符串不加引号
ttBulkCp -o -Q 0 DSN=ocs tb_bil_acct_balance acct_balance.txt
输入 -i
ttBulkCp -i -e ratable_history.err DSN=ocs_serv ratable_history ratable_history.dump
The above command will terminate after the first error occurs. To force the copy
to continue until the end of the input file (or a fatal error), use -m 0, as in:
ttBulkCp -i -e ratable_history.err -m 0 DSN=ocs_serv ratable_history ratable_history.dumpTtisql 下的命令Ttisql 下的命令call ttConfiguration 内存数据库配置
call ttAgingScheduleNow(时间窗)
命令行下查看锁表信息
call ttlogholds();
statsupdate balance_reserve
表分析
Call ttoptupdatestats
连接登录数据库
ttIsql -connStr "DSN=MY_DSN" -f create.sql
运行脚本
Command> run "create.sql"; Ttisql 下的命令Ttisql 下的命令dssize;
PERM_ALLOCATED_SIZE: 1048576
PERM_IN_USE_SIZE: 3736
PERM_IN_USE_HIGH_WATER: 3753
TEMP_ALLOCATED_SIZE: 1048576
TEMP_IN_USE_SIZE: 114865
TEMP_IN_USE_HIGH_WATER: 114923数据加载和同步数据加载和同步
加载:
LOAD CACHE GROUP UpdateAnywhereCustomers COMMIT EVERY 10 ROWS
LOAD CACHE GROUP CustomerOrders WHERE customer.cust_num = 20 COMMIT EVERY 25 ROWS
卸载:
UNLOAD CACHE GROUP UpdateAnyWhereCustomers
UNLOAD CACHE GROUP CustomerOrders WHERE customer.cust_num > 100
刷新:
REFRESH CACHE GROUP SQL statement is equivalent to an UNLOAD CACHE GROUP statement followed by a LOAD CACHE GROUP statement
Can be used on any cache group type
alter cache group CG_TB_BIL_ACCT_test1 set autorefresh state paused;
REFRESH CACHE GROUP CG_TB_BIL_ACCT_test1 COMMIT EVERY 40 ROWS;
REFRESH CACHE GROUP CustomerOrders WHERE customer.cust_num <= 50 COMMIT EVERY 40 ROWS
增量变更:
FLUSH CACHE GROUP SQL manually propagates committed updates on TimesTen cache tables to corresponding Oracle tables
Can only be used on USERMANAGED cache groups
Can be used only when commit propagation from TimesTen to Oracle is disabled
Only INSERTs and UPDATEs are propagated
FLUSH CACHE GROUP CG_TB_BIL_ACCT_test1;
FLUSH CACHE GROUP UpdateAnywhereCustomers WHERE customer.cust_num <> 99
FLUSH CACHE GROUP UpdateAnywhereCustomers WITH ID (180)索引设置原则索引设置原则创建正确的索引
Hash indexes(比较快的exact match lookup)
T-tree index(适用于exact match & range lookup)
Primary Key 自动创建 Hash index
Hash index :Pages = Rows expected / 256
1、在创建cache 的脚本中:pages=总的记录数/256 ,如果计算出来的pages=1800,则实际pages=2000比较合适,即要比实际的大一些;
2、如果脚本已经创建,并且pages过小,可以采用下列的语句来修改:
ALTER TABLE tb_prd_prd_inst_551 SET pages=9000;
3、修改了pages值后需要分析表:statsupdate tb_prd_prd_inst内存管理策略内存管理策略1、执行:ttAdmin -ramPolicy always|manual|inuse hb_abm 让数据永远保存在内存中(即使没有应用连接和ttisql 连接,除非把数据库停下来)这样不需要每次进入后都需要从新加载到内存中,
2、另外停止TT数据库也需要在断开所有的连接,否则强行stop后再启动,数据库会查找还原点,数据加载时间会很长。Oracle<->TimesTen数据不同步怎么办?Oracle<->TimesTen数据不同步怎么办?存在多种情况:
Cache agent没有启动,使用ttstatus察看TT所有进程的运行状况,使用call ttcachestart();启动cache agent.
Oracle table中的数据存在问题,如有NULL值,导致同步异常,异常日志在/var/adm/syslog/syslog.log中,从日志文件中分析出现错误表,在Oracle中修改或删除异常数据 。
锁表了怎么办?锁表了怎么办?解决方案一:
6003: Lock request denied because of time-out
Details: Tran 11.74108 (pid 9981) wants W lock on table OCSTEST.PROCESS_STATE. But tran 13.32122 (pid 10003) has it in W (request was W). Holder SQL (update process_state set run_state = '0';)
ps 这个进程,确认后kill
Ttxactadmin dsn=?察看系统所有的锁,找到对应的锁,然后ttxactadmin -xactIdRollback
Log文件不段增加,磁盘空间快耗尽了,怎么办?Log文件不段增加,磁盘空间快耗尽了,怎么办?使用ttstatus命名察看replication agent启动没有?如果没有启动,执行call ttrepstart();
使用cal ttckpt();手工check point;使用call ttbookmark();call ttckpthistory();观察处理情况。
可能存在长事务,使用call ttlogholds()命名察看日志情况,如果存在Long-Running Transaction,则根据事务号查询对应的锁,然后rollback就可以了。日志的自动删除日志的自动删除TimesTen purges the log files if all of these conditions are met:
1、The contents of the log files have been written to both checkpoint files,
2、The log files are not pending incremental backup,
3、If replication is being used, the log files have been replicated to all subscribers
复制不能正常工作怎么办?复制不能正常工作怎么办?Replication agent是否正常工作,用ttstatus命名察看运行状态,如果没有启动,执行call ttrepstart();
日志文件是否有积压,请参考前面介绍的方法处理。
日志参数日志参数如果LOG_BUFFER_WAITS增长,请增加LogBufferSize
如果LOG_FS_READS增长,请增加LogBufferSize执行效率执行效率1、在TTisql中设置如下的参数
Command > timing 1;
Command> verbosity 0; //不计算显示的时间:verbosity
2、执行研发提供的SQL语句在ttisql中执行,看执行时间是否基本满足要求
3、主要目的是检查索引是否有效、是否正确的创建了索引,关于索引的问题请参考文档《TimesTen索引.doc》执行计划执行计划Command> autocommit 0;
Command> showplan 1;
Command> prepare SELECT product.name,
> SUM(order_item.quantity) totalqty
> FROM product, order_item
> WHERE product.prod_num = order_item.prod_num AND
> product.price > 50.00
> GROUP BY product.name;
执行计划执行计划Query Optimizer Plan:
STEP: 1
LEVEL: 3
OPERATION: RowLkSerialScan
TBLNAME: ORDER_ITEM
IXNAME:
PRED:
OTHERPRED:
STEP: 2
LEVEL: 3
OPERATION: RowLkHashScan
TBLNAME: PRODUCT
IXNAME: PRODUCT
PRED: PRODUCT.PROD_NUM = ORDER_ITEM.PROD_NUM
OTHERPRED: PRODUCT.PRICE > 50
STEP: 3
LEVEL: 2
OPERATION: NestedLoop
TBLNAME:
IXNAME:
PRED:
OTHERPRED:
STEP: 4
LEVEL: 1
OPERATION: GroupBy
TBLNAME:
IXNAME:
PRED:
OTHERPRED:
null