135-1821-9792

DB2使用resize命令扩容表空间引起rebalance问题的分析

问题描述:
最近一次表空间扩容,环境是DB2 10.1FP4,Suse 11.3,文件系统使用的是Symantec StorageFoundation,有个表空间共32个容器,每个容器大小都是20G,打算扩容这个表空间,于是使用了resize (all 24G)的命令,db2 "alter tablespace tbs resize (all 24G)",执行完成后发现 tbs开始rebalance了,这个有点奇怪,我是在现有的container增加空间,不会影响表空间的HWM,为什么会触发rebalance呢?


问题分析:
查看表空间的snapshot,发现这个表空间的映射有点奇怪(这个是rebalance完成后的),container大小都是一样,为什么映射是这样的?

创新互联专注于做网站、成都做网站、网页设计、网站制作、网站开发。公司秉持“客户至上,用心服务”的宗旨,从客户的利益和观点出发,让客户在网络营销中找到自己的驻足之地。尊重和关怀每一位客户,用严谨的态度对待客户,用专业的服务创造价值,成为客户值得信赖的朋友,为客户解除后顾之忧。

  Range  Stripe Stripe  Max         Max  Start  End    Adj.   Containers

   Number Set    Offset  Extent      Page Stripe Stripe

   [   0] [   0]      0  163835   5242751      0  40958   0    4 (0,1,2,3)

   [   1] [   0]      0  237563   7602047  40959  49150   0    9 (0,1,2,3,4,5,6,7,8)

   [   2] [   0]      0  401398  12844767  49151  81917   0    5 (4,5,6,7,8)

   [   3] [   0]      0  499702  15990495  81918  90109   0    12 (4,5,6,7,8,9,10,11,12,13,14,15)

   [   4] [   0]      0  600054  19201759  90110 104445   0    7 (9,10,11,12,13,14,15)

   [   5] [   0]      0 1212383  38796287 104446 131068   0    23 (9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31)

   [   6] [   0]      0 1572831  50330623 131069 153596   0    16 (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31)


查了信息中心,有一些关于tablespace map的说明,但没有很确切说明问什么会引起rebalance,我坚信本次问题是和表空间分布有关,于是做了一些表空间扩容的测试,最终重现了该现象。

实验测试:
===测试1:增加数据库文件,新增数据文件大于原有的数据文件===
最初表空间分布
db2 get snapshot for tablespaces on sampledb >> ts1.out


  Table space map:


   Range  Stripe Stripe  Max         Max  Start  End    Adj.   Containers
   Number Set    Offset  Extent      Page Stripe Stripe
   [   0] [   0]      0      77      2495      0     38   0    2 (0,1)


执行
db2 "alter tablespace USERSP4 add (file '/db2data/db2inst1/sampledb/data/usersp4_c03' 20M, file '/db2data/db2inst1/sampledb/data/usersp4_c04' 20M)"


查看表空间分布
db2 get snapshot for tablespaces on sampledb >> ts2.out


Table space map:


   Range  Stripe Stripe  Max         Max  Start  End    Adj.   Containers
   Number Set    Offset  Extent      Page Stripe Stripe
   [   0] [   0]      0     155      4991      0     38   0    4 (0,1,2,3)
   [   1] [   0]      0     235      7551     39     78   0    2 (2,3)


执行
db2 "alter tablespace USERSP4 resize (all 20M)"   


查看表空间分布
db2 get snapshot for tablespaces on sampledb >> ts3.out


 Table space map:


   Range  Stripe Stripe  Max         Max  Start  End    Adj.   Containers
   Number Set    Offset  Extent      Page Stripe Stripe
   [   0] [   0]      0     315     10111      0     78   0    4 (0,1,2,3)
自动降表空间分布规整了。



===测试2:增加数据库文件,新增数据文件小于原有的数据文件===
最初表空间分布
db2 get snapshot for tablespaces on sampledb >> ts1.out


  Table space map:


   Range  Stripe Stripe  Max         Max  Start  End    Adj.   Containers
   Number Set    Offset  Extent      Page Stripe Stripe
   [   0] [   0]      0      77      2495      0     38   0    2 (0,1)


执行
db2 "alter tablespace USERSP4 add (file '/db2data/db2inst1/sampledb/data/usersp4_c03' 5M, file '/db2data/db2inst1/sampledb/data/usersp4_c04' 5M)"


查看表空间分布
db2 get snapshot for tablespaces on sampledb >> ts4.out


  Table space map:


   Range  Stripe Stripe  Max         Max  Start  End    Adj.   Containers
   Number Set    Offset  Extent      Page Stripe Stripe
   [   0] [   0]      0      39      1279      0     19   0    2 (0,1)
   [   1] [   0]      0     115      3711     20     38   0    4 (0,1,2,3)
执行
db2 "alter tablespace USERSP4 resize (all 10M)"   


查看表空间分布
db2 get snapshot for tablespaces on sampledb >> ts5.out


   Range  Stripe Stripe  Max         Max  Start  End    Adj.   Containers
   Number Set    Offset  Extent      Page Stripe Stripe
   [   0] [   0]      0      39      1279      0     19   0    2 (0,1)
   [   1] [   0]      0     115      3711     20     38   0    4 (0,1,2,3)
   [   2] [   0]      0     155      4991     39     58   0    2 (2,3)
resize all命令执行后,表空间分布没有自动规整好!!


db2 "alter tablespace USERSP4 resize (all 20M)"   
db2 get snapshot for tablespaces on sampledb >> ts6.out
  Table space map:


   Range  Stripe Stripe  Max         Max  Start  End    Adj.   Containers
   Number Set    Offset  Extent      Page Stripe Stripe
   [   0] [   0]      0      39      1279      0     19   0    2 (0,1)
   [   1] [   0]      0     275      8831     20     78   0    4 (0,1,2,3)
   [   2] [   0]      0     315     10111     79     98   0    2 (2,3)


再次执行resize (all 20M)进行表空间扩容,表空间分布还是没有自动规整!


db2 "alter tablespace USERSP4 resize (all 30M)"   
db2 get snapshot for tablespaces on sampledb >> ts7.out


  Table space map:


   Range  Stripe Stripe  Max         Max  Start  End    Adj.   Containers
   Number Set    Offset  Extent      Page Stripe Stripe
   [   0] [   0]      0      39      1279      0     19   0    2 (0,1)
   [   1] [   0]      0     435     13951     20    118   0    4 (0,1,2,3)
   [   2] [   0]      0     475     15231    119    138   0    2 (2,3)


再次执行resize (all 30M)进行表空间扩容,表空间分布还是没有自动规整!
如果执行完resize (all 20M)后,表空间使用率很高了,比如使用到了第三个Stripe,即276号extent以后的空间,再执行resize (all 30M)后,276号开始的extent会触发rebalance


结论:通过以上测试可以看到DB2在增加新的数据文件的时候,如果新增数据文件大于原来的数据文件,使用resize命令可以自动规整表空间分布;如果新增数据文件小于原来的数据文件,使用resize命令无法自动规整表空间分布,导致数据分布不整齐,可能在扩容期间会引起表空间rebalance。建议DB2每次增加数据文件,与原来的数据文件大小一致,或者至少比原来的数据文件大。

还有一个疑问:如果出现了这种数据文件不对齐的现象,如何才能让数据文件变为规整?

本文题目:DB2使用resize命令扩容表空间引起rebalance问题的分析
网站链接:http://kswsj.com/article/jcjccs.html

其他资讯



Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号