DB2在線備份,以及重定向恢復(fù)實(shí)戰(zhàn)演習(xí)!
以下的文章主要向大家描述的是DB2在線備份,以及重定向恢復(fù)的實(shí)際操作步驟,相信如果你掌握了DB2在線備份,以及重定向恢復(fù)的實(shí)際操作步驟,會(huì)在以后的學(xué)習(xí)或是工作中帶來很大的幫助。
目標(biāo):在數(shù)據(jù)庫服務(wù)器上備份,然后將這個(gè)備份重定向恢復(fù)到本機(jī)數(shù)據(jù)庫上。
1.先在數(shù)據(jù)庫服務(wù)器上執(zhí)行如下命令進(jìn)行全盤DB2在線備份(包括日志) (db2 ? backup可以查看backup幫助信息)
- db2 backup db wdcs online to E:\Allan include logs 時(shí)間戳為20100420093345
然后將該備份映像拷貝至本機(jī)的C:\temp路徑下
2.在數(shù)據(jù)庫服務(wù)器上執(zhí)行如下命令查看當(dāng)前數(shù)據(jù)庫表空間情況
- db2 list tablespaces show detail
3.在本地為原數(shù)據(jù)庫創(chuàng)建相應(yīng)的表空間容器。進(jìn)入cmd窗口執(zhí)行一下命令:
- mkdir C:\DB2 \NODE0000\wdcs\syscatspace C:\DB2 \NODE0000\wdcs\indexspace1
- C:\DB2 \NODE0000\wdcs\systoolspace C:\DB2 \NODE0000\wdcs\systoolstmpspace
- C:\DB2 \NODE0000\wdcs\tablespace1 C:\DB2 \NODE0000\wdcs\tempspace1 C:\DB2 \NODE0000\wdcs\userspace1
4.在本地創(chuàng)建一個(gè)跟數(shù)據(jù)庫服務(wù)器上同名的空數(shù)據(jù)庫wdcs: create db wdcs
5.開始本機(jī)上執(zhí)行數(shù)據(jù)庫恢復(fù)命令(將日志指定存放的路徑為:
- C:\db2workspace\wdcs_log)
- db2 restore db wdcs from c:\temp taken at 20100420093345 into wdcs logtarget c:\db2workspace\wdcs_log redirect
此時(shí)會(huì)提示要求指定存儲(chǔ)容器路徑
6.要恢復(fù)的本地?cái)?shù)據(jù)庫表空間指定容器,執(zhí)行下列命令 ( 其中的數(shù)字:0,1,2,3,4,5,6,7,8是源數(shù)據(jù)庫的表空間標(biāo)識,path后面的路徑就是上面第3步建的路徑,標(biāo)識號和路徑一一對應(yīng) ,最后的file "c:\db2workspace\wdcscontainer\dms.dat" 50000;file "c:\db2workspace\wdcscontainer\index.dat" 50000 是重新建立DB2在線備份管理類型的表空間容器)
- db2 set tablespace containers for 0 using (path "c:\DB2\node0000\wdcs\syscatspace")
- db2 set tablespace containers for 1 using (path "c:\DB2\node0000\wdcs\tempspace1")
- db2 set tablespace containers for 2 using (path "c:\DB2\node0000\wdcs\userspace1")
- db2 set tablespace containers for 3 using (path "c:\DB2\node0000\wdcs\systoolspace")
- db2 set tablespace containers for 4 using (path "c:\DB2\node0000\wdcs\tablespace1")
- db2 set tablespace containers for 5 using (path "c:\DB2\node0000\wdcs\indexspace1")
- db2 set tablespace containers for 6 using (path "c:\DB2\node0000\wdcs\systoolstmpspace")
- db2 set tablespace containers for 7 using (file "c:\db2workspace\wdcscontainer\dms.dat" 50000)
- db2 set tablespace containers for 8 using (file "c:\db2workspace\wdcscontainer\index.dat" 50000)
7.然后繼續(xù)執(zhí)行恢復(fù):
- db2 restore db wdcs continue
8. 最后要執(zhí)行前滾命:
- db2 rollforward db wdcs to end of logs and stop overflow log path (C:\db2workspace\wdcs_log)
以上的相關(guān)內(nèi)容就是對DB2在線備份,重定向恢復(fù)的介紹,望你能有所收獲。
【編輯推薦】