TimesTen 演示文档


一、安装 timesten 系列二:如何安装 timesten 安装目录 /u02/timesten timesten instance 名字为 tt70 1.修改内核参数 修改/etc/sysctl.conf 文件,加上如下列 kernel.core_uses_pid = 1 kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_max=4194304 net.core.wmem_max=4194304 net.ipv4.tcp_rmem=4096 4194304 4194304 net.ipv4.tcp_wmem=98304 4194304 4194304 net.ipv4.tcp_mem=98304 4194304 4194304 然后执行 sysctl -p ,使修改生效 2.为了能够连接到 oracle 做同步,请安装 oracle 10.2 的客户端 oracle 以 oracle 用户,dba 组安装 3.添加用户 useradd -g dba -u 505 timesten 4.用 root 用户登陆 os 然后执行下面的操作,为 timesten 保存安装信息用 mkdir /etc/TimesTen chmod 775 /etc/TimesTen chgrp dba /etc/TimesTen 5.设置用户.bash_profile export CLASSPATH=/oracle/timesten/TimesTen/tt70/lib/ttjdbc14.jar:$CLASSPATH export PATH=/oracle/timesten/TimesTen/tt70/bin:$PATH export ORACLE_HOME=/oracle/product/10.2.0/db_1 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib:/oracle/timesten/TimesTe n/tt70/lib:$LD_LIBRARY_PATH IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com 注意:LD_LIBRARY_PATH 一定要包含上面的几个目录,否则 cache 会出问题 下载地址 : http://download.oracle.com/otn/t ... 0500.linux86.tar.gz 然后 解开 timesten 安装包 tar xvzf timesten70500.linux86.tar.tar cd linux86/ ./setup.sh 后面会提示输入路径,名称,端口等,一路回车,就 ok 了,具体的安装提示,请看下面: 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? [ tt70 ] Instance name will be 'tt70'. Is this correct? [ yes ] Please select a product : [1] Oracle TimesTen In-Memory Database [2] Oracle In-Memory Database Cache Which product would you like to install? [ 1 ] Of the three components: [1] Client/Server and Data Manager [2] Data Manager Only [3] Client Only Which would you like to install? [ 1 ] Where would you like to install the tt70 instance of TimesTen? [ /home/timesten ] /u02 The directory /oracle/timesten does not exist. Do you want to create it? [ yes ] Where would you like to create the daemon home directory? [ /u02/TimesTen/tt70/ ] The directory /oracle/timesten/TimesTen/tt70/info does not exist. Do you want to create it? [ yes ] Installing into /oracle/timesten/TimesTen/tt70 ... Uncompressing ... The TimesTen Demo applications can take up to 64 Mbytes of disk space. IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com Depending on how your system is configured, you may not want to create the DemoDataStore directory in the default location, /u02/TimesTen/tt70/DemoDataStore Where would you like to create the DemoDataStore directory? [ /u02/TimesTen/tt70/ ] Creating /u02/TimesTen/tt70/DemoDataStore ... 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 17000. Do you want to use the default port number for the TimesTen daemon? [ yes ] The daemon will run on the default port number (17000). Processing /oracle/timesten/TimesTen/tt70/PERL/perl.tar ... Would you like to enable datastore access control? [ no ] The daemon logs will be located in /oracle/timesten/TimesTen/tt70/info Would you like to specify a different location for the daemon logs? [ no ] NOTE: It appears that you are running version 4.1 of the g++ compiler. TimesTen ships with multiple sets of client libraries and server binaries : one built with g++ 3.2.3, one with g++ 3.4.6, and one with g++ 4.1.0. The installer has created links to the 4.1.0 library in the /lib directory and to the 4.1.0 server binary in the /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 ... Would you like to log all server Connects/Disconnects? [ yes ] What is the TCP/IP port number that you want the TimesTen Server to listen on? [ 17002 ] Starting the daemon ... TimesTen Daemon startup OK. Installing client components ... What is the name of the host running the TimesTen server? [ TT ] What is the TCP/IP port number that the TimesTen server is listening on? [ 17002 ] What is the name of the instance running the TimesTen server? [ tt70 ] Creating new /u02/TimesTen/tt70/sys.ttconnect.ini Extracting 3rd party tools ... Would you like to install the documentation? [ yes ] no Documentation not installed. IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com To manually install the documentation, run the command 'setup.sh -installDoc' NOTE: The TimesTen daemon startup/shutdown scripts have not been installed. Run the script ' /u02/TimesTen/tt70/bin/setuproot' as root. This will move the TimesTen startup script into its appropriate location. The startup script is currently located here : ' /u02/TimesTen/tt70/startup/tt_tt70'. End of TimesTen installation. 为了添加随着 OS 启动而启动 timesten daemon 的脚本,需要按照提示,用 root 用户执行下 面的脚本: cd /u02/TimesTen/tt70/bin/ ./setuproot 很简单,就完成了安装了,看看 timesten 启动之后的进程情况: ps -ef |grep timesten timesten 2200 1 0 18:45 ? 00:00:00 /oracle/timesten/TimesTen/tt70/bin/timestend -initfd 13 timesten 2203 2200 0 18:45 ? 00:00:00 /oracle/timesten/TimesTen/tt70/bin/timestensubd timesten 2204 2200 0 18:45 ? 00:00:00 /oracle/timesten/TimesTen/tt70/bin/timestensubd timesten 2205 2200 0 18:45 ? 00:00:00 /oracle/timesten/TimesTen/tt70/bin/timestensubd timesten 2206 2200 0 18:45 ? 00:00:00 /oracle/timesten/TimesTen/tt70/bin/timestensubd timesten 2208 2200 0 18:45 ? 00:00:00 /oracle/timesten/TimesTen/tt70/bin/ttcserver 系统安装完成之后,会有一个缺省的 data store(这个概念和 oracle 的数据库概念差不多), 叫 TpcbData_tt70 我们现在就连接到这个 data store 来看看,看看 timesten 工作是否正常。 因为是 root 安装的用之前需要改权限 [root@cuug95 linux86]# chown oracle:dba -R /u01/app/oracle/TimesTen/ [root@cuug95 linux86]# chown oracle:dba -R /var/TimesTen ttIsql TpcbData_tt70 (注释:ttIsql 是一个和 oracle sqlplus 差不多的命令行交互控制工 具) IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com ttIsqlCS cs_tt70 (基于 c/s 方式连接的命令,需要配置 sys.odbc.ini 和 sys.ttconect.ini 文件) [timesten@rac01 info]$ ttIsql TpcbData_tt70 Copyright (c) 1996-2008, Oracle. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. All commands must end with a semicolon character. connect "DSN=TpcbData_tt70"; Connection successful: DSN=TpcbData_tt70;UID=timesten;DataStore=/oracle/timesten/TimesTen/tt70/info/DemoDataSt ore/TpcbData;DatabaseCharacterSet=US7ASCII;ConnectionCharacterSet=US7ASCII;WaitForConne ct=0;DRIVER=/oracle/timesten/TimesTen/tt70/lib/libtten.so;Authenticate=0;PermSize=16;TypeM ode=0; (Default setting AutoCommit=1) Command> tables; SYS.CACHE_GROUP SYS.COLUMNS SYS.COLUMN_HISTORY SYS.COL_STATS ....... 在来做一个创建表的测试 Command> create table test(id number(2)); Command> insert into test values(1); 1 row inserted. Command> commit; Command> select * from test; < 1 > 1 row found. TT 的语法和 oracle 几乎是一样的. 如何启动停止 timesten 呢?(以后就简称 timesten 为 TT) 启动 TT ttDaemonAdmin -start IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com 停止 TT ttDaemonAdmin -stop 或者: /etc/init.d/tt_tt70 start 2、Stoping TimesTen Daemon /etc/init.d/tt_tt70 stop ================================== 二、安装 TT cache 1、安装执行安装命令: ./setup.sh -installCache ,然后安装提示,一路 next 下去,就 ok 了,详细信息请看下面的 log [timesten@rac01 linux86]$ ./setup.sh -installCache There is 1 TimesTen instance installed locally : 1) tt70 (TimesTen7.0.5.0.0) NOTE: There is only one instance which can be upgraded. Instance Name : tt70 Product Installed : TimesTen7.0.5.0.0 Installation Directory : /oracle/timesten/TimesTen/tt70 BitLevel : 32 Component Installed : Client/Server and DataManager Daemon Port : 17000 Would you like to upgrade this instance? [ yes ] Extracting Cache Connect to Oracle ... The following variables have been set in the file : /oracle/timesten/TimesTen/tt70/bin/ttThunk ORACLE_HOME=/oracle/product/10.2.0/db_1 IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com LD_LIBRARY_PATH=/oracle/timesten/TimesTen/tt70/lib:/oracle/product/10.2.0/db_1/lib32:/oracl e/product/10.2.0/db_1/network/lib32:/oracle/product/10.2.0/db_1/lib:/oracle/product/10.2.0/ db_1/network/lib Would you like to enable the Cache Connect to Oracle Administrator? [ yes ] What TCP/IP port number would you like Cache Connect to Oracle Administrator to listen on? [ 17004 ] NOTE: To access the TimesTen Cache Connect to Oracle Administrator go to the url: http://localhost:17004/cache Restarting the daemon ... TimesTen Daemon stopped. TimesTen Daemon startup OK. End of TimesTen installation. 然后检查 timesten 用户的.bash_profile 文件,确认 ORACLE_HOME 是否设置为正确的 oracle client 的安装目录, 确认 LD_LIBRARY_PATH ,一定要包含 $ORACLE_HOME/lib:$ORACLE_HOME/network/lib 2、然后在 oracle 数据库上面创建 用户,以便 TT 用来连接到 oracle sqlplus '/as sysdba' create user tt identified by tt; grant connect,resource to tt; 3 、 然 后 修 改 我 们 创 建 的 cuugdata_tt70 data store 的系统级 DSN(/var/TimesTen/sys.odbc.ini),加上如下信息 系统级添加: [ODBC Data Sources] ....... cuugdata_tt70=TimesTen 7.0 Driver cuugdata_tt70=TimesTen 7.0 Client Driver 修改后的完整 DSN 如下(注意:DatabaseCharacterSet 必须和 oracle 的一致): [cuugdata_tt70] Driver=/oracle/timesten/TimesTen/tt70/lib/libtten.so DataStore=/oracle/timesten/TimesTen/tt70/cuugdata/cuugdata DatabaseCharacterSet=zhs16gbk IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com Authenticate=0 PermSize=64 TempSize=16 UID=tt OracleId=prod OraclePwd=tt 4、在 oracle client 端的tnsnames.ora 里面添加一个名字叫prod(对应上面定义的OracleId) 的别名,如下 prod = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = TT)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prod) ) ) 5、开始创建 cache group ttIsql cuugdata_tt70 Command>call ttCacheUidPwdSet('tt','tt'); #设置连接到 oracle 的用户名和密码 Command>call ttCacheStart; #启动 cache, 每次重启 TT,都要启动该进 程。否则没有 agent 进程。 6、创建一个 read only 的语法如下(Oracle 数据库中更新的数据通过非同步模式反映到 TimesTen 中): CREATE READONLY CACHE GROUP readcache AUTOREFRESH INTERVAL 1 SECONDS FROM t1 (id number(2) not null primary key); 注意:from t1 后面是跟 oracle 里面需要同步的表的名字,一定要有同样的列和字段类 型,而且一定要有 pk 或者非空的唯一性索引字段 一个只读的 cache group 创建好了,然后从 oracle 里面 load 一次数据,用如下语法: LOAD CACHE GROUP readcache COMMIT EVERY 256 ROWS; 然后在 oracle 里面 insert 数据,看看是否能在 TT 里面出现。 如果要删除 cache group,则执行如下命令: drop CACHE GROUP readcache; 7、创建一个同步的 cache group 语法如下,(TimesTen 中更新的数据通过同步模式写入 IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com Oracle 数据库): CREATE SYNCHRONOUS WRITETHROUGH CACHE GROUP CG_2 FROM t2 (id number(2) not null primary key); LOAD CACHE GROUP CG_2 COMMIT EVERY 256 ROWS; 在 timsten 中插入表 t1,查看 oracle 中是否能够更新。 8、创建一个用户管理的 cache group: CREATE USERMANAGED CACHE GROUP CG_3 AUTOREFRESH MODE INCREMENTAL INTERVAL 5 SECONDS FROM t3(id number(2) primary key,PROPAGATE); LOAD CACHE GROUP CG_3 COMMIT EVERY 200 ROWS; 其他的操作和 read only 一样,比如创建完成之后,需要第一次 load 数据 。 9、可以修改 cache group 的属性: ALTER CACHE GROUP update_anywhere_t1 SET AUTOREFRESH MODE FULL ALTER CACHE GROUP update_anywhere_t1 SET AUTOREFRESH INTERVAL 30 SECONDS ALTER CACHE GROUP update_anywhere_t1 SET AUTOREFRESH STATE ON 10、查看 TT 状态: ttStatus 11、使用 ttIsql cachegroups 命令来检查 READCACHE 缓存集合的定义: Command> cachegroups; =========================== 三、配置双向复制: 1、两台主机添加 DSN: IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com [ODBC Data Sources] rep_tt70=TimesTen 7.0 Driver rep_tt70=TimesTen 7.0 Client Driver [rep_tt70] Driver=/u01/app/oracle/TimesTen/tt70/TimesTen/tt70/lib/libtten.so DataStore=/u01/app/oracle/TimesTen/tt70/TimesTen/tt70/repStore/rep DatabaseCharacterSet=ZHS16GBK PermSize=64 TempSize=16 WaitForConnect=0 Authenticate=0 2、两个主机都要同时创建表: create table test_r(id number(2) primary key); 3、两个主机都要创建 replication: CREATE REPLICATION reptest1 ELEMENT e_2 TABLE test_r MASTER rep on "tt" SUBSCRIBER rep on "db" ELEMENT e_3 TABLE test_r MASTER rep on "db" SUBSCRIBER rep on "tt"; 注意:MASTER 和 SUBSCRIBER 后面跟的都是 data store 对应的文件名的前缀! 比如 datastore 的配置是/u02/Timesten/tt70/repStore/rep,那么就应该是 rep . 4、两个主机启动启动 replication agent : ttAdmin -repStart rep2_tt70 5、查看状态: ttRepAdmin -showStatus rep_tt70 正常的状态总共有 4 个部分: DSN : rep_tt70 Process ID : 8652 (Started) ...... Replication Peers: IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com Name : REP Host : TT Port : 34707 (AUTO) (Connected) Replication State : STARTED Communication Protocol : 24 TRANSMITTER thread(s): For : REP Start/Restart count : 1 Send LSN : 0.691800 Transactions sent : 1 ..... RECEIVER thread(s): For : REP Start/Restart count : 1 Transactions received : 1 ...... 6、在两个主机上操作,都能够复制。 7、删除 replication Command> drop REPLICATION oracle.REPTEST1; (如果没有 call ttCacheUidPwdSet('tt','tt'), 则创建的 replication 属于前缀是 oracle 的,删除是需要加上前缀,而且只能添加一条 replication 到另外一个主机上) 如果用户登入时使用 call ttCacheUidPwdSet('tt','tt'); 则创建的表都是以 tt 做为前缀,否 则默认都是以 oracle 做为前缀,如果同步时,会有问题。 还有同步时两边的环境都要一样,特别是CLASSPATH 和LD_LIBRARY_PATH 等变量的值, 否则会不同步。 ======================================= ============ java 连接测试: 1、java 程序源代码如下,往表插入 99999 行数据,统计所需要的时间: import java.sql.*; import javax.sql.*; public class Bench{ public static void main(String args[]) { String URL = "jdbc:timesten:client:dsn=cuugdata_tt70"; IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com Connection con = null; try { Class.forName("com.timesten.jdbc.TimesTenDriver"); } catch (ClassNotFoundException ex) {ex.printStackTrace(); } try { con = DriverManager.getConnection(URL); System.out.println("connected"); java.sql.Statement st=con.createStatement(); java.sql.PreparedStatement prest=con.prepareStatement("insert into test values(?)"); long begin_date=java.util.Calendar.getInstance().getTimeInMillis(); for (int i=1;i<100000;i++) { prest.setInt(1,i); prest.executeUpdate(); } con.commit(); long end_date=java.util.Calendar.getInstance().getTimeInMillis(); long con_time=end_date-begin_date; System.out.println("totaol time="+con_time); con.close(); } catch (SQLException ex) { ex.printStackTrace();} } } 一、通过直接内存访问方式连接,无 log,无 checkpoint 1.1 在 sys.odbc.ini 中的 cuugdata_tt70 配置如下: [cuugdata_tt70] Driver=/u01/app/oracle/TimesTen/tt70/TimesTen/tt70/lib/libtten.so DataStore=/u01/app/oracle/TimesTen/tt70/TimesTen/tt70/cuugdataStore/cuugdata DatabaseCharacterSet=ZHS16GBK PermSize=64 TempSize=16 Logging=0 DurableCommits=0 IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com CkptFrequency=0 CkptLogVolume=0 LockLevel=1 TTC_SERVER=LocalHost_tt70 TTC_SERVER_DSN=cuugdata_tt70 1.2、在 sys.ttconnect.ini 的配置如下: [cuugdata_tt70] Description=TimesTen Server Network_Address=ttLocalHost TCP_PORT=17002 ttendaemon.options -serverShmIpc -serverShmSize 128M =============================== 二、通过 tcp/ip 方式连接,无 log,无 checkpoint 2.1 在 sys.odbc.ini 中的 cuugdata_tt70 配置如下: [cuugdata_tt70] Driver=/u01/app/oracle/TimesTen/tt70/TimesTen/tt70/lib/libtten.so DataStore=/u01/app/oracle/TimesTen/tt70/TimesTen/tt70/cuugdataStore/cuugdata DatabaseCharacterSet=ZHS16GBK PermSize=64 TempSize=16 Logging=0 DurableCommits=0 CkptFrequency=0 CkptLogVolume=0 LockLevel=1 TTC_SERVER=LocalHost_tt70 TTC_SERVER_DSN=cuugdata_tt70 2.2、在 sys.ttconnect.ini 的配置如下; [cuugdata_tt70] Description=TimesTen Server Network_Address=192.168.18.93 IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com TCP_PORT=17002 ttendaemon.options -serverShmIpc -serverShmSize 128M ================================================ 三、通过直接内存访问方式连接,有 log,有 checkpoint 3.1 在 sys.odbc.ini 中的 cuugdata_tt70 配置如下: PermSize=64 TempSize=16 #Logging=0 #DurableCommits=0 #CkptFrequency=0 #CkptLogVolume=0 #LockLevel=1 2.2、在 sys.ttconnect.ini 的配置如下; [cuugdata_tt70] Description=TimesTen Server Network_Address=ttLocalHost TCP_PORT=17002 ttendaemon.options -serverShmIpc -serverShmSize 128M ================== IT高端实训 企业人才基地 CUUG 中国UNIX用户协会培训中心 Tel:010-88589826 Fax:010-88587026 网址: http://www.cuug.com
还剩13页未读

继续阅读

下载pdf到电脑,查找使用更方便

pdf的实际排版效果,会与网站的显示效果略有不同!!

需要 6 金币 [ 分享pdf获得金币 ] 0 人已下载

下载pdf

pdf贡献者

l845598032

贡献于2013-10-20

下载需要 6 金币 [金币充值 ]
亲,您也可以通过 分享原创pdf 来获得金币奖励!
下载pdf