概要:恢复文件原数据库名:TEST,恢复目标数据库名:TEST123,恢复文件目录:/home/db2inst1下,恢复方式:重定向(REDIRECT)
1.将TEST数据库的备份文件恢复到TEST123库
[root@db2 ~]# su - db2inst1
[db2inst1@db2 ~]$db2 RESTORE DATABASE TEST FROM '/home/db2inst1' TAKEN AT 20140910164553 INTO TEST123 REDIRECT WITHOUT ROLLING FORWARD
SQL1277W A redirected restore operation is being performed. Table space
configuration can now be viewed and table spaces that do not use automatic
storage can have their containers reconfigured.
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@db2 ~]$ db2pd -db TEST123 -tablespaces
Database Partition 0 -- Database TEST123 -- Active -- Up 0 days 00:36:04 -- Date 06/02/2015 05:15:24
Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002AAB2B1D4B20 0 DMS Regular 8192 4 Yes 4 1 1 Off 1 0 3 SYSCATSPACE
0x00002AAB2B1D6220 1 SMS SysTmp 8192 128 Yes 128 1 1 On 1 0 127 TEMPSPACE1
0x00002AAB2B1D9940 2 DMS Large 8192 128 Yes 128 1 1 Off 1 0 127 USERSPACE1
0x00002AAB2B1DB040 3 SMS UsrTmp 8192 128 Yes 128 1 1 On 1 0 127 USER_TMP_TBS
0x00002AAB2B1DE520 4 DMS Large 8192 128 Yes 128 2 2 Off 1 0 127 HIS_TBS_DATA
0x00002AAB2B1DFE60 5 DMS Large 8192 128 Yes 128 2 2 Off 1 0 127 HIS_TBS_INDEX
0x00002AAB2B1E1560 6 SMS SysTmp 16384 128 No 128 3 3 On 1 0 127 TMP_16
0x00002AAB2B1E4A40 7 SMS SysTmp 32768 128 No 128 4 4 On 1 0 127 TMPSYS32
Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped
0x00002AAB2B1D4B20 0 184320 184316 0 0 0 0 0 0x02000100 0 0 No
0x00002AAB2B1D6220 1 1 1 1 0 0 0 0 0x02000100 0 0 No
0x00002AAB2B1D9940 2 606208 606080 0 0 0 0 0 0x02000100 0 0 No
0x00002AAB2B1DB040 3 0 0 0 0 0 0 0 0x02001100 0 0 No
0x00002AAB2B1DE520 4 2097152 2097024 0 0 0 0 0 0x02000100 0 0 No
0x00002AAB2B1DFE60 5 1310720 1310592 0 0 0 0 0 0x02000100 0 0 No
0x00002AAB2B1E1560 6 1 1 1 0 0 0 0 0x02001100 0 0 No
0x00002AAB2B1E4A40 7 0 0 0 0 0 0 0 0x02001100 0 0 No
Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002AAB2B1D4B20 0 Yes Yes 33554432 -1 No None None No
0x00002AAB2B1D6220 1 Yes No 0 0 No 0 None No
0x00002AAB2B1D9940 2 Yes Yes 33554432 -1 No None None No
0x00002AAB2B1DB040 3 No No 0 0 No 0 None No
0x00002AAB2B1DE520 4 Yes Yes -2147483648 2147483648 No None None No
0x00002AAB2B1DFE60 5 Yes Yes 1073741824 1073741824 No None None No
0x00002AAB2B1E1560 6 No No 0 0 No 0 None No
0x00002AAB2B1E4A40 7 No No 0 0 No 0 None No
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002AAB2B1D5FE0 0 0 File 184320 184316 0 0 /home/db2inst1/db2inst1/NODE0000/TEST123/T0000000/C0000000.CAT
0x00002AAB2B1D9700 1 0 Path 1 1 0 0 /home/db2inst1/db2inst1/NODE0000/TEST123/T0000001/C0000000.TMP
0x00002AAB2B1DAE00 2 0 File 606208 606080 0 0 /home/db2inst1/db2inst1/NODE0000/TEST123/T0000002/C0000000.LRG
0x00002AAB2B0E8BC0 3 0 Path 0 0 - 0 /home/db2inst1/db2inst1/NODE0000/SQL00003/USER_TMP_TBS
0x00002AAB2B1DFC20 4 0 File 2097152 2097024 0 0 /home/db2inst1/db2inst1/NODE0000/TEST123/T0000004/C0000000.LRG
0x00002AAB2B1E1320 5 0 File 1310720 1310592 0 0 /home/db2inst1/db2inst1/NODE0000/TEST123/T0000005/C0000000.LRG
0x00002AAB2B1DF9E0 6 0 Path 1 1 - 0 /home/db2inst1/db2inst1/NODE0000/TEST/T0000001/TMP_16
0x00002AAB2B1E5F00 7 0 Path 0 0 - 0 /home/db2inst1/db2inst1/NODE0000/SQL00003/TMPSYS32
--注意这里ContainNum为容器标识,Type为容器类型,在重定向容器时要用到这2个参数,可以看出ContainNum为0,1,2,4,5指向为TEST123目录,其余3,6,7产生到其他目录,可能会造成冲突导致无法创建表空间问题,故重建容器位置,如下:
[db2inst1@db2 ~]$ db2 "set tablespace containers for 3 USING (PATH '/home/db2inst1/db2inst1/NODE0000/TEST123/T0000003/USER_TMP_TBS')"
DB20000I The SET TABLESPACE CONTAINERS command completed successfully.
[db2inst1@db2 ~]$ db2 "set tablespace containers for 6 USING (PATH '/home/db2inst1/db2inst1/NODE0000/TEST123/T0000006/TMP_16')"
DB20000I The SET TABLESPACE CONTAINERS command completed successfully.
[db2inst1@db2 ~]$ db2 "set tablespace containers for 7 USING (PATH '/home/db2inst1/db2inst1/NODE0000/TEST123/T0000007/TMPSYS32')"
DB20000I The SET TABLESPACE CONTAINERS command completed successfully.
[db2inst1@db2 ~]$ db2 RESTORE DATABASE TEST CONTINUE;
--注意这里是TEST而不是TEST123,否则会报 DB21080E No previous RESTORE DATABASE command with REDIRECT option was issued for this database alias, or the information about that command is lost.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29812844/viewspace-1988783/
,如需转载,请注明出处,否则将追究法律责任。