1、在相同平台相同版本下,可以使用ttBackup/ttRestore进行迁移。
2、在不同版本不同平台下,就要使用ttMigrate工具了。
3、环境说明:
目前我这边两台主机10.45.11.93后面简称服务端,上面安装了tt客户端、服务端以及管理端。
另一台主机10.45.11.94,后面简称客户端,上面只安装了tt客户端。版本都是11.2.2.8。
服务端有TT1122_new这个DSN库,并且里面有一个表:
[TT1122_new]
Driver=/home/timesten/TimesTen/tt1122/lib/libtten.so
DataStore=/tmp/tt1122_new/TT1122_new
DatabaseCharacterSet=US7ASCII
[timesten@trgxtts info]$ ttisql TT1122_new
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=TT1122_new";
Connection successful: DSN=TT1122_new;UID=timesten;DataStore=/tmp/tt1122_new/TT1122_new;DatabaseCharacterSet=US7ASCII;ConnectionCharacterSet=US7ASCII;DRIVER=/home/timesten/TimesTen/tt1122/lib/libtten.so;TypeMode=0;
(Default setting AutoCommit=1)
Command> select * from timesten.newtab ;
< 10 >
1 row found.
Command>
我们的目标就是把这个DSN对应的库迁移到新的库下面去,简单来做,我们迁移到服务端一个新配置的DSN,我们定义这个DSN为如下,下面为服务端sys.odbc.ini配置:
vi sys.odbc.ini
[TTMigrate_test]
Driver=/home/timesten/TimesTen/tt1122/lib/libtten.so
DataStore=/tmp/tt1122migrate_test/TTMigrate_test
DatabaseCharacterSet=US7ASCII
4、我们要在客户端用ttMigrateCS把服务端源库导出来。做如下工作:
以下均为客户端配置:
[timesten@trgxtts info]$ vi sys.odbc.ini
[ODBC Data Sources]
mydb_CS=TimesTen 11.2.2 Client Driver
[mydb_CS]
TTC_SERVER=mydb_test
TTC_SERVER_DSN=TT1122_new
UID=scott
[timesten@srcxtts info]$ vi sys.ttconnect.ini
[mydb_test]
Description=TimesTen Server
Network_Address=10.45.11.93
TCP_PORT=53397
以上配置详解可以参见:
https://blog.csdn.net/kadwf123/article/details/80319614
5、配置好客户端后,就可以使用ttMigrateCS进行导出了。
在客户端上执行:
[timesten@srcxtts test]$ ttMigrateCS -c mydb_CS mydb_cs.dat
Enter password for 'scott':
Saving user PUBLIC
User successfully saved.
Saving user SCOTT
User successfully saved.
Saving table TIMESTEN.NEWTAB
Saving rows...
1/1 row saved.
Table successfully saved.
会导出一个文件在当前执行命令的目录:
[timesten@srcxtts test]$ ll
总用量 4
-rw-r--r--. 1 timesten ttadmin 2399 5月 15 13:59 mydb_cs.dat
6、在目标库建一个DSN,并且使用ttisql进行初始化。
目标DSN我们已经建好,名为:
TTMigrate_test
见步骤3中列的。
初始化这个DSN,在目标库(本例服务端)执行:
[timesten@trgxtts info]$ ttIsql -connstr "dsn=TTMigrate_test;AutoCreate=1" -e "quit"
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "dsn=TTMigrate_test;AutoCreate=1";
Connection successful: DSN=TTMigrate_test;UID=timesten;DataStore=/tmp/tt1122migrate_test/TTMigrate_test;DatabaseCharacterSet=US7ASCII;ConnectionCharacterSet=US7ASCII;DRIVER=/home/timesten/TimesTen/tt1122/lib/libtten.so;TypeMode=0;
(Default setting AutoCommit=1)
quit;
Disconnecting...
Done.
此时这个目标库已经存在了,但是里面是空的。
文件已存在:
[timesten@trgxtts tt1122migrate_test]$ ll
总用量 268868
-rw-rw----. 1 timesten ttadmin 28829752 5月 15 14:02 TTMigrate_test.ds0
-rw-rw----. 1 timesten ttadmin 28831744 5月 15 14:02 TTMigrate_test.ds1
-rw-rw----. 1 timesten ttadmin 16328704 5月 15 14:02 TTMigrate_test.log0
-rw-rw----. 1 timesten ttadmin 67108864 5月 15 14:02 TTMigrate_test.res0
-rw-rw----. 1 timesten ttadmin 67108864 5月 15 14:02 TTMigrate_test.res1
-rw-rw----. 1 timesten ttadmin 67108864 5月 15 14:02 TTMigrate_test.res2
但是空的
[timesten@trgxtts info]$ ttisql TTMigrate_test
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=TTMigrate_test";
Connection successful: DSN=TTMigrate_test;UID=timesten;DataStore=/tmp/tt1122migrate_test/TTMigrate_test;DatabaseCharacterSet=US7ASCII;ConnectionCharacterSet=US7ASCII;DRIVER=/home/timesten/TimesTen/tt1122/lib/libtten.so;TypeMode=0;
(Default setting AutoCommit=1)
Command> select * from timesten.newtab ;
2206: Table TIMESTEN.NEWTAB not found
The command failed.
7、确定新的库DS位置配置无误,就可以通过ttMigrate来导入数据了。
在目标端(本例服务端)执行:
[timesten@trgxtts test]$ ttMigrate -r -relaxedUpgrade TTMigrate_test mydb_cs.dat
Restoring user SCOTT
Restoring privileges...
Privileges restored.
User successfully restored.
Restoring table TIMESTEN.NEWTAB
Restoring rows...
1/1 row restored.
Table successfully restored.
[timesten@trgxtts test]$
然后查验数据是否已经有了:
[timesten@trgxtts info]$ ttisql TTMigrate_test
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=TTMigrate_test";
Connection successful: DSN=TTMigrate_test;UID=timesten;DataStore=/tmp/tt1122migrate_test/TTMigrate_test;DatabaseCharacterSet=US7ASCII;ConnectionCharacterSet=US7ASCII;DRIVER=/home/timesten/TimesTen/tt1122/lib/libtten.so;TypeMode=0;
(Default setting AutoCommit=1)
Command> select * from timesten.newtab ;
< 10 >
1 row found.
Command>
此时发现数据已经导入进来了。