Db2

DB2 9.7 - 如何將未使用的空間釋放回作業系統?

  • August 23, 2016

我正在尋找關於如何將未使用的空間從 Windows 機器上執行的 DB2 9.7 實例釋放回作業系統的明確說明。如果您已經知道並且只需要提醒,IBM 的文件可能會很棒,但對於主要角色不是 DB2 支持的人來說,它們可能是希臘語。

見連結:http ://www.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.admin.dbobj.doc/doc/c0055392.html

如果我正確閱讀了所有內容,理論上這應該可以解決問題:

alter tablespace userspace1 lower high water mark;
alter tablespace userspace1 reduce max;

在實踐中,如果我只是出去喝杯咖啡,我會做得更多,也會更快樂。

這是 DB2 領域的一個常見問題解答,其答案往往很神秘——可能是因為大多數 DB2 DBA 主要或僅僅是 DB2 DBA。

我希望(可能是徒勞的)我錯過了一些我可以右鍵點擊並選擇“縮小數據庫”的地方,在這種情況下我有點尷尬,有人得到了一些簡單的代表。

表空間細節:

Tablespace ID                        = 2
Name                                 = USERSPACE1
Type                                 = Database managed space
Contents                             = All permanent data. Large table     space.
State                                = 0x0000
  Detailed explanation:
    Normal
Total pages                          = 83320832
Useable pages                        = 83320800
Used pages                           = 16096
Free pages                           = 83304704
High water mark (pages)              = 45397248
Page size (bytes)                    = 4096
Extent size (pages)                  = 32
Prefetch size (pages)                = 32
Number of containers                 = 1
Minimum recovery time                = 2016-08-22-15.32.02.000000

db2pd 輸出:

Tablespace Configuration:
Address            Id    Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe  LastConsecPg Name
0x000000003B4B1F60 0     DMS  Regular 4096   4        Yes  4        1     1         Off 1        0          3            SYSCATSPACE
0x000000003B4B36E0 1     SMS  SysTmp  4096   32       Yes  32       1     1         On  1        0          31           TEMPSPACE1
0x000000003B4B6E20 2     DMS  Large   4096   32       Yes  32       1     1         Off 1        0          31           USERSPACE1
0x000000003B4B85A0 3     DMS  Large   4096   4        Yes  4        1     1         Off 1        0          3            SYSTOOLSPACE
0x000000003B4B9D20 4     DMS  Large   32768  16       No   32       2     2         Off 1        0          15           XXXXXXXXEBIG
0x000000003B4BB4A0 5     SMS  SysTmp  32768  16       No   16       2     2         On  1        0          15           XXXXXXXXETEMP

Tablespace Statistics:
Address            Id    TotalPgs   UsablePgs  UsedPgs    PndFreePgs FreePgs    HWM        Max HWM    State      MinRecTime NQuiescers PathsDropped
0x000000003B4B1F60 0     32768      32764      26628      0          6136       26628      26628      0x00000000 0          0          No
0x000000003B4B36E0 1     1          1          1          0          0          0          0          0x00000000 0          0          No
0x000000003B4B6E20 2     45397280   45397248   15680      416        45381152   45397248   83319520   0x00000000 1471879922 0          No
0x000000003B4B85A0 3     8192       8188       160        0          8028       160        160        0x00000000 1462319023 0          No
0x000000003B4B9D20 4     304        288        272        0          16         288        304        0x00000000 1471348087 0          No
0x000000003B4BB4A0 5     1          1          1          0          0          0          0          0x00000000 1462325615 0          No

Tablespace Autoresize Statistics:
Address            Id    AS  AR  InitSize    IncSize     IIP MaxSize     LastResize                 LRF
0x000000003B4B1F60 0     Yes Yes 33554432    -1                   No  None        None                       No
0x000000003B4B36E0 1     Yes No  0           0                    No  0                    None                       No
0x000000003B4B6E20 2     Yes Yes 33554432    -1                   No  None        None                       No
0x000000003B4B85A0 3     Yes Yes 33554432    -1                   No  None        None                       No
0x000000003B4B9D20 4     Yes Yes 33554432    -1                   No  None        None                       No
0x000000003B4BB4A0 5     Yes No  0           0                    No  0                    None                       No

Containers:
Address            TspId ContainNum Type    TotalPgs   UseablePgs PathID     StripeSet  Container
0x000000003B4B34A0 0     0          File    32768      32764      0          0          E:\DB2\NODE0000\XXXXXXXX\T0000000\C0000000.CAT
0x000000003B4B4BC0 1     0          Path    1          1          0          0          E:\DB2\NODE0000\XXXXXXXX\T0000001\C0000000.TMP
0x0000000044D1D8A0 2     0          File    45397280   45397248   0          0          E:\DB2\NODE0000\XXXXXXXX\T0000002\C0000000.LRG
0x000000003B4B9AE0 3     0          File    8192       8188       0          0          E:\DB2\NODE0000\XXXXXXXX\T0000003\C0000000.LRG
0x0000000044D35E40 4     0          File    304        288        0          0          E:\DB2\NODE0000\XXXXXXXX\T0000004\C0000000.LRG
0x000000003B4BC980 5     0          Path    1          1          0          0          E:\DB2\NODE0000\XXXXXXXX\T0000005\C0000000.TMP

高水位線 (HWM) 減少和容器調整大小都是後台操作,因此命令完成後您不會立即看到效果。為了達到更好的效果,您需要先降低 HWM,等到它完成(用於db2pd -tablespaces驗證),然後嘗試減小容器大小。請注意,對於非自動儲存表空間,您將需要稍微不同的語法:ALTER TABLESPACE USERSPACE1 REDUCE (ALL CONTAINERS <whatever size is free>).

引用自:https://dba.stackexchange.com/questions/147521