db2數據庫還原命令 1.備份的數據庫(olddb) 與要還原的數據(newdb)名不相同: db2 restore db olddb into newdb; www.2cto.com 2.當前目錄下存在多個備份文件.需要指定時間 db2 restore db olddb taken at 20120819175932 into newdb; 3.需要指定備份文件的目錄 db2 RESTORE DATABASE olddb FROM "/media/olddb.0.db2inst1.NODE0000.CATN0000.20120819175932.001" TAKEN AT 20120819175932 INTO newdb; 4.需要指定newdb NEWLOGPATH路徑 db2 RESTORE DATABASE olddb FROM "/media/olddb.0.db2inst1.NODE0000.CATN0000.20120819175932.001" TAKEN AT 20120819175932 NEWLOGPATH "/opt/log" WITH 2 BUFFERS BUFFER 1024 INTO newdb; www.2cto.com 5.需要指定表空間的 1).創建文件夾 mkdir /home/db2inst1/db2space/newdb_sp0; mkdir /home/db2inst1/db2space/newdb_sp1; mkdir /home/db2inst1/db2space/newdb_sp2; mkdir /home/db2inst1/db2space/newdb_sp3; mkdir /home/db2inst1/db2space/newdb_sp4; mkdir /home/db2inst1/db2space/newdb_sp5; mkdir /home/db2inst1/db2space/newdb_sp6; 2).還原命令加入 redirect without rolling forward db2 RESTORE DATABASE olddb FROM "/media/olddb.0.db2inst1.NODE0000.CATN0000.20120819175932.001" TAKEN AT 20120819175932 NEWLOGPATH "/opt/log" WITH 2 BUFFERS BUFFER 1024 INTO newdb redirect without rolling forward; 3).設置表空間目錄 SET TABLESPACE CONTAINERS FOR 0 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp0"); SET TABLESPACE CONTAINERS FOR 1 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp1"); SET TABLESPACE CONTAINERS FOR 2 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp2"); SET TABLESPACE CONTAINERS FOR 3 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp3"); SET TABLESPACE CONTAINERS FOR 4 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp4"); SET TABLESPACE CONTAINERS FOR 5 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp5"); SET TABLESPACE CONTAINERS FOR 6 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp6"); 3).還原繼續.注意為olddb RESTORE DATABASE olddb CONTINUE; 6.數據庫還原退回 db2 restore db 注意為olddb abort 7.還原後如果NEWLOGPATH 需要變更的 db2 UPDATE DB CFG FOR newdb USING NEWLOGPATH /db2/db2inst1/db2logpath db2 UPDATE DB CFG FOR newdb USING LOGFILSIZ 10001 db2 force applications all; db2stop; db2start; 如需幫助,請發郵件到 [email protected]