The NoteBook of EricKong

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  610 Posts :: 1 Stories :: 190 Comments :: 0 Trackbacks
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; 
 
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; 
posted on 2014-11-18 12:17 Eric_jiang 阅读(142) 评论(0)  编辑  收藏 所属分类: DB2

只有注册用户登录后才能发表评论。


网站导航: