此时该表被导出到了/backup/a。
注意如果要导出Cachegroup中的表,必须指定为CG导出,否则会报错:
[root@test ~]# ttMigrate -c TT_1122 /backup/a TEST_USER.TBL_PRODUCTS
ttMigrate: Error received while processing table TEST_USER.TBL_PRODUCTS -- table can only be saved by saving cache group TEST_USER.GC_TBL_PRODUCTS.
[root@test ~]# ttMigrate -c TT_1122 /backup/a TEST_USER.GC_TBL_PRODUCTS
Saving cache group TEST_USER.GC_TBL_PRODUCTS
Saving cached table TEST_USER.TBL_PRODUCTS
Cache group successfully saved.
导出文件可以使用ttMigrate -l/-L/-d/-D查看内容。
ttMigrate也可以用于执行恢复,具体格式为:
ttMigrate -r DSN filename
例如将刚才导出的文件进行恢复:
[root@test ~]# ttMigrate -r TT_1122 /backup/a
Restoring cache group TEST_USER.GC_TBL_PRODUCTS
Restoring cached table TEST_USER.TBL_PRODUCTS
ttMigrate: Error received while restoring cache group TEST_USER.GC_TBL_PRODUCTS -- 37000: [TimesTen][TimesTen 11.2.2.8.0 ODBC Driver][TimesTen]TT8224: Cache group GC_TBL_PRODUCTS already exists -- file "plittddl.c", lineno 737, procedure "plittCreate" (TimesTen
error code = 8224).
*** Cache group TEST_USER.GC_TBL_PRODUCTS was not restored.
There were errors restoring the following objects:
cache group TEST_USER.GC_TBL_PRODUCTS
此时提示TT中已经存在该CG,于是我们将CG删除之后再恢复:
Command> select count(*) from tbl_products; ---删除前查看数据量
< 10150 >
1 row found.
Command>
Command> drop cache group TEST_USER.GC_TBL_PRODUCTS;
[root@test ~]# ttMigrate -r "dsn=TT_1122;uid=TEST_USER;oraclepwd=TEST_USER" /backup/a
Enter password for ‘TEST_USER‘:
Restoring cache group TEST_USER.GC_TBL_PRODUCTS
Restoring cached table TEST_USER.TBL_PRODUCTS
1/1 cached table restored.
Cache group successfully restored.
已经导入成功了。
但此时我们查看表,发现还没有从数据库中load数据。
1 row found.
Command> alter cache group GC_TBL_PRODUCTS set AUTOREFRESH interval 5 seconds;
Command> select count(*) from tbl_products;
< 0 >
1 row found.
Command> alter cache group GC_TBL_PRODUCTS set AUTOREFRESH state paused;
Command> load cache group GC_TBL_PRODUCTS commit every 500 rows ;
10154 cache instances affected.
Command> load cache group GC_TBL_PRODUCTS commit every 500 rows;
以上是导出单个对象的例子。
全备执行完了,此时在/backup生产了备份文件。
下面执行恢复.
systax:
ttRestore -fname ttbak -dir /backup TT_1122
[root@test ~]# ttRestore -fname fileprefix -dir path TT_1122
Restore started ...
Restore failed:
Error 12133: TT12133: Data store file already exists -- file "restore.c", lineno 1006, procedure "doRestore" ---报错
[root@test TimesTen]# rm -rf /var/TimesTen/tt1122/TT_1122.ds* ---删除掉ds文件
[root@test TimesTen]# ttRestore -fname ttbak -dir /backup TT_1122
Restore started ...
Restore failed:
Error 12134: TT12134: Log file(s) already exist -- file "restore.c", lineno 1040, procedure "doRestore" ---报错logfile存在
You have new mail in /var/spool/mail/root
[root@test TimesTen]#
[root@test TimesTen]# rm -rf /var/TimesTen/tt1122/TT_1122.log13* ---删除掉log文件
[root@test TimesTen]# ttRestore -fname ttbak -dir /backup TT_1122
Restore started ...
Restore failed:
Error 12116: TT12116: Cannot create database for restore -- file "restore.c", lineno 1808, procedure "dsCreate"
Error 839: TT0839: Cannot access data store because it is in use. A data store may be considered to be in use due to its RAM Policy setting, even though there are no active connections to it. -- file "db.c", lineno 20680, procedure "sbDbDestroy"
Error 830: TT0830: Cannot create data store file. OS-detected error: Could not destroy previous data store -- file "db.c", lineno 7788, procedure "sbDbCreate"
---此时有连接存在未释放,不允许创建DS
[root@test TimesTen]#
[root@test TimesTen]# ttDaemonAdmin -stop
TimesTen Daemon stopped.
[root@test TimesTen]# ttstatus
ttStatus: Could not connect to the TimesTen daemon.
If the TimesTen daemon is not running, please start it
by running "ttDaemonAdmin -start".
[root@test TimesTen]# ttRestore -fname ttbak -dir /backup TT_1122
ttRestore: TimesTen daemon is not running
[root@test TimesTen]# ttDaemonAdmin -start ----重启Daemon
TimesTen Daemon startup OK.
[root@test TimesTen]# ttRestore -fname ttbak -dir /backup TT_1122
Restore started ...
Restore complete
[root@test TimesTen]# ---完成restore
Command> select count(*) from x;
< 22000 >
1 row found.
Command> ----验证数据未丢失