数据库表空间重定向恢复问题

我有2个数据库,在一个instance下,sample和tesdb,testdb有2个表空间是采用裸设备,我现在备份sample表空间 IBMDB2SAMPLEREL,IBMDB2SAMPLEXML,都是file类型db2 " backup database sample tablespace (IBMDB2SAMPLEREL,IBMDB2SAMPLEXML ) to /home/db2inst1/backup"现在我想把s...显示全部
我有2个数据库,在一个instance下,sample和tesdb,testdb有2个表空间是采用裸设备,我现在备份sample表空间 IBMDB2SAMPLEREL,IBMDB2SAMPLEXML,都是file类型
db2 " backup database sample tablespace (IBMDB2SAMPLEREL,IBMDB2SAMPLEXML ) to /home/db2inst1/backup"


现在我想把smaple的这2个表空间的数据重定向恢复到testdb上的裸设备表空间上
db2 "restore db sample tablespace (IBMDB2SAMPLEREL,IBMDB2SAMPLEXML ) from /home/db2inst1/backup to /dbdir  into testdb redirect"
但报错如下:SQL2560N  The target database is not identical to the source database for a
restore from a table space level backup.

我想问下这是不支持表空间重定向恢复啊?收起
参与12

查看其它 10 个回答zhujink的回答

zhujinkzhujink商业智能工程师未知
可以恢复到不同的数据库,跨实例也能恢复。这个是我之前做的一个小例子,数据库版本是V9.7:


-- ***************************************************************************
--
-- 将113上的sample数据库全备份恢复到52机器的test数据库上(成功案例)
--
-- ***************************************************************************

--在113上执行备份
$ db2 backup database sample

--将备份文件SAMPLE.0.fdmdb.DBPART000.20140804111250.001传到52上

--在52上创建数据库
$ db2 create database test using codeset utf-8 territory cn

--生成还原脚本看看有没有表空间需要重定向的
$ db2 "restore database sample taken at 20140804111250 into test redirect generate script newdb.clp without rolling forward"

【注意】此时/fdminst/fdmprd/NODE0000/TEST下只有T0000001下的C0000000.TMP临时文件容器存在,其他的T000000x都被删除

--没有需要重定向的表空间,指定ON选项,直接前滚
$ db2 "restore database sample taken at 20140804111250  on /fdminst into test redirect without rolling forward"

【注意】此时一定要指定on,否则会往sample原来的路径(/home/fdmdb)下面还原,因为52上面没有这个路径,所以报错
提示一个SQL2529W的警告,输入Y,回车

$ db2 get connection state

   Database Connection State

Connection state       = Connectable and Connected
Connection mode        = EXCLUSIVE
Local database alias   = TEST
Database name          = TEST
Hostname               =
Service name           =

--继续还原(注意这里还是对sample做restore哦!)
$ db2 restore database sample continue

--完毕,成功!

--剩下就是对对象权限的处理。因为113上sample库的实例用户是fdmdb,而52上没有这个用户,貌似fdmprd实例用户都不能访问这些表了!
银行 · 2015-04-08
浏览1809

回答者

zhujink
商业智能工程师未知

zhujink 最近回答过的问题

回答状态

  • 发布时间:2015-04-08
  • 关注会员:1 人
  • 回答浏览:1809
  • X社区推广