db2数据库还原命令
db2数据库还原命令.
如需帮助,请发邮件到 lyc557@163.com
1.备份的数据库(olddb) 与要还原的数据(newdb)名不相同:
db2 restore db olddb into newdb;
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;
如需帮助,请发邮件到 lyc557@163.com