[DB2]db2重定向恢復

梓沐發表於2016-02-15
概要:恢復檔案原資料庫名: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部落格 ” ,連結:http://blog.itpub.net/29812844/viewspace-1988783/,如需轉載,請註明出處,否則將追究法律責任。

相關文章