首页 > 数据库 > 数据库开发技术 > 使用表空间备份重建数据库
今天在个人机子上试验了一下,通过部分表空间备份重建数据库
有3个表空间备份
NEWDB.3.db2inst1.DBPART000.20130821204748.001 MYTBS的备份
NEWDB.3.db2inst1.DBPART000.20130821204740.001 SYSTOOLSPACE的备份
NEWDB.3.db2inst1.DBPART000.20130821204722.001 SYSCATSPACE USERSPACE1的备份
只用3个表空间来重建NEWDB(SYSCATSPACE是必须的)
db2 "restore db newdb rebuild with tablespace (SYSCATSPACE,USERSPACE1,mytbs) taken at 20130821204748"
SQL2561W Warning! Rebuilding a database from a table space image or using a
subset of table spaces. The target database will be overwritten. The restore
utility also reports the following sqlcode "2539".
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
此时数据库处于ROLL-FORWARD
db2 connect to newdb
SQL1117N A connection to or activation of database "NEWDB" cannot be made
because of ROLL-FORWARD PENDING. SQLSTATE=57019
rollforward NEWDB
db2 "rollforward db newdb to end of logs and stop "
SQL1271W Database "NEWDB" is recovered but one or more table spaces are
offline on members or nodes "0".
发出警告,表明有一个表空间offline。但是此时数据库已经可以连接并使用。只有没有被恢复的表空间SYSTOOLSPACE处于Restore pending状态。
之后我们可以单独恢复这个表空间
db2 "rollforward db newdb to end of logs and stop tablespace (SYSTOOLSPACE)"
Rollforward Status
Input database alias = newdb
Number of members have returned status = 1
Member ID = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = -
Last committed transaction = 2013-08-21-20.47.28.000000 Local
DB20000I The ROLLFORWARD command completed successfully.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24079837/viewspace-1060868/ ,如需转载,请注明出处,否则将追究法律责任。