我试图对server1中的数据库GS_DB进行在线备份,然后将其还原到server2,最后在server2中前滚GS_DB。
在server1中,在线备份: GS_DB已启用归档日志模式,(LOGARCHMETH1)= DISK:C:\ GS_DB_ARCHIVELOG \
db2 backup db GS_DB online to <path> include logs
将备份映像发送到server2。
在server2中,还原数据库:
db2 create db GS_DB2
db2 restore gs_db taken at <timestamp> into gs_db2
SQL2529W Warning! Restoring to an existing database that is different from the backup image database, and the alias name "GS_DB2" of the existing database does not match the alias name "GS_DB" of the backup image, and the database name "GS_DB2" of the existing database does not match the database name "GS_DB" of the backup image. The target database will be overwritten by the backup version. The Roll-forward recovery logs associated with the target database will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
连接到gs_db2:
db2 connect to gs_db2
SQL1117N A connection to or activation of database "GS_DB2" cannot be made because of ROLL-FORWARD PENDING. SQLSTATE=57019
前滚gs_db2:
db2 rollforward db gs_db2 to end of logs and complete
SQL1273N An operation reading the logs on database "GS_DB2" cannot continue because of a missing log file "S0000266.LOG" on database partition "0" and log stream "0".
我已经搜索了此错误代码,并发现还原命令中的logtarget选项可能有用,但是我仍然不明白logtarget的路径应该是什么?
db2 restore gs_db taken at <timestamp> into gs_db2 logtarget <???>
我在这里错过了什么吗?我是否还应该将归档日志S0000266.LOG从server1压缩到server2?我想backup命令中的include logs选项应该完成了吗?
谢谢。
答案 0 :(得分:0)
从联机存档还原数据库后将数据库前滚到最短时间点(备份结束)所需的日志文件默认包含在此联机中。
从在线归档文件还原后,您至少必须在时间上至少前滚数据库到最小点。
如果指定logtarget
子句,则存档中的日志文件将被提取到指定的目录中。
您可以在ROLLFORWARD DATABASE command的OVERFLOW LOG PATH
子句中使用此目录。
答案 1 :(得分:0)
使用以下命令前滚至备份结束。
db2 rollforward db gs_db2 to end of backup and complete
答案 2 :(得分:0)
将日志记录到已还原数据库的存档日志路径中,然后 db2前滚db mydb到日志末尾,并完成覆盖路径“(/ home / db2 / archivelogs)”