问题描述

接到某局点客户报障,在进行表重组时,出现错误,无法使表恢复到正常使用情况。

smbdb2:/smbrptdb/db2inst2$db2 reorg table als7.t_fact_loan;

SQL2216N SQL error "-289" occurred while reorganizing a database table or its

indexes.

故障处理过程

在处理有具体报错的问题时,通常都有迹可循。

1) 首先查看报错信息查看报错信息:db2 “? SQL289”

SQL0289N Unable to allocate new pages in table space

从报错代码中,我们先得到一个初步思路:数据库在进行reorg时,无法分配新的页,表空间方面可能存在问题。

2) db2数据库在进行操作时,会在db2diag.log文件中,记录较多的消息。检查报错时间段的数据库消息日志:db2diag -t 2017-01-05-21|more

2017-01-05-21.09.33.869329+480 E977654141A688 LEVEL: Warning

PID : 6881600 TID : 106290 PROC : db2sysc 0

INSTANCE: db2inst2 NODE : 000 DB : RPTDB

APPHDL : 0-45870 APPID: *LOCAL.db2inst2.170105124937

AUTHID : DB2INST2

EDUID : 106290 EDUNAME: db2agent (RPTDB) 0

FUNCTION: DB2 UDB, buffer pool services, sqlbIsSpaceOnPathForConts, probe:20

MESSAGE : ADM6101W While attempting to extend table space "RPTDB_TABLE" (ID

"6"), there were less than "67108864" bytes free on

"/smbrptdb/db2inst2/NODE0000/SQL00001/". This space is reserved for

use by DB2 and/or the operating system.

2017-01-05-21.09.33.869845+480 I977654830A651 LEVEL: Severe (Origin)

PID : 6881600 TID : 106290 PROC : db2sysc 0

INSTANCE: db2inst2 NODE : 000 DB : RPTDB

APPHDL : 0-45870 APPID: *LOCAL.db2inst2.170105124937

AUTHID : DB2INST2

EDUID : 106290 EDUNAME: db2agent (RPTDB) 0

FUNCTION: DB2 UDB, buffer pool services, sqlbGrowNewStripeSet, probe:20

MESSAGE : ZRC=0x850F000C=-2062614516=SQLO_DISK "Disk full."

DIA8312C Disk was full.

从消息日志中,表空间RPTDB_TABLE在进行扩展时,出现报错,明确给出文件系统满的提示。

3) 顺藤摸瓜,对文件系统进行检查:df –h

发现/smbrptdb文件系统使用率100%。与问题吻合。但是作为技术的严谨性,不能只是进行猜测,需要近一步做确认。

4) 检查RPTDB_TABLE表空间所属的文件系统: db2pd -tablespaces -db rptdb

smbdb2:/smbrptdb/db2inst2/sqllib/db2dump$db2pd -tablespaces -db rptdb

Database Partition 0 -- Database RPTDB -- Active -- Up 17 days 01:44:47 -- Date 2017-01-05-21.21.15.509708

Tablespace Configuration:

Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name

0x07000001DE08E1A0 0 DMS Regular 16384 4 Yes 24 1 1 Off 1 0 3 SYSCATSPACE

0x07000001DE08F920 1 SMS SysTmp 16384 32 Yes 192 1 1 On 1 0 31 TEMPSPACE1

0x07000001DE093080 2 DMS Large 16384 32 Yes 192 1 1 Off 1 0 31 USERSPACE1

0x07000001DE094800 3 DMS Large 16384 4 Yes 24 1 1 Off 1 0 3 SYSTOOLSPACE

0x07000001DE095F80 4 DMS Regular 16384 32 Yes 192 1 1 Off 1 0 31 RPTDB_INDEX

0x07000001DE097700 5 SMS SysTmp 32768 32 Yes 192 2 2 On 1 0 31 TEMPSPACE32

0x07000001DE09AE60 6 DMS Large 16384 32 Yes 192 1 1 Off 1 0 31 RPTDB_TABLE

Tablespace Statistics:

Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped

0x07000001DE08E1A0 0 14336 14332 12320 0 2012 12320 12320 0x00000000 0 0 No

0x07000001DE08F920 1 1 1 1 0 0 0 0 0x00000000 0 0 No

0x07000001DE093080 2 2048 2016 1312 0 704 1312 1312 0x00000000 1444822621 0 No

0x07000001DE094800 3 2048 2044 232 0 1812 232 232 0x00000000 0 0 No

0x07000001DE095F80 4 8597504 8597472 8596320 0 1152 8596320 8596320 0x00000000 1483426811 0 No

0x07000001DE097700 5 1 1 1 0 0 0 0 0x00000000 1463713993 0 No

0x07000001DE09AE60 6 20125696 20125664 12368224 7757440 0 20125664 20125664 0x00000000 1483618634 0 No

Tablespace Autoresize Statistics:

Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF

0x07000001DE08E1A0 0 Yes Yes 0 -1 No None None No

0x07000001DE08F920 1 Yes No 0 0 No 0 None No

0x07000001DE093080 2 Yes Yes 0 -1 No None None No

0x07000001DE094800 3 Yes Yes 0 -1 No None None No

0x07000001DE095F80 4 Yes Yes 0 -1 No None 01/05/2017 08:02:07.291110 No

0x07000001DE097700 5 Yes No 0 0 No 0 None No

0x07000001DE09AE60 6 Yes Yes 0 -1 No None 01/05/2017 20:40:33.559794 Yes

Containers:

Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container

0x07000001DE08F6E0 0 0 File 14336 14332 0 0 /smbrptdb/db2inst2/NODE0000/RPTDB/T0000000/C0000000.CAT

0x07000001DE090E00 1 0 Path 1 1 0 0 /smbrptdb/db2inst2/NODE0000/RPTDB/T0000001/C0000000.TMP

0x07000001DE0945C0 2 0 File 2048 2016 0 0 /smbrptdb/db2inst2/NODE0000/RPTDB/T0000002/C0000000.LRG

0x07000001DE095D40 3 0 File 2048 2044 0 0 /smbrptdb/db2inst2/NODE0000/RPTDB/T0000003/C0000000.LRG

0x07000001DE0974C0 4 0 File 8597504 8597472 0 0 /smbrptdb/db2inst2/NODE0000/RPTDB/T0000004/C0000000.USR

0x07000001DE098BE0 5 0 Path 1 1 0 0 /smbrptdb/db2inst2/NODE0000/RPTDB/T0000005/C0000000.TMP

0x07000001DE09C3A0 6 0 File 20125696 20125664 0 0 /smbrptdb/db2inst2/NODE0000/RPTDB/T0000006/C0000000.LRG

从输出文件中,RPTDB_TABLE的表空间采用的是DMS管理方式,自动扩展,数据文件为:

/smbrptdb/db2inst2/NODE0000/RPTDB/T0000006/C0000000.LRG

5) 通过上面几步的排查,问题的处理方法也呼之欲出。对文件系统进行在线扩容。问题得到解决。

故障结论与优化建议

随着业务量的增长,数据库对象越来越庞大,日常的例行工作都有可能导致表无法正常访问。需要确保数据库服务器的系统资源充足,特别是存储空间。

本次操作时,遇到在进行文件系统扩容时,首次扩容20GB,立即被数据库占用,使用率又变为100%。客户当时比较紧张,担心数据库遇到了BUG,会无限的增长空间。此时,就需要了解一下reorg的过程:reorg主要分为:

1 排序

2 构建

3 替换

4 重建索引 前当执行第1,2,3步时,使用目标表所在的数据表空间,将在数据表空间中建立目标表的影子副本,使用的表空间相当于表的实际大小。在执行完1,2,3步后,表所在的表空间会重新收缩。在进行第4步时,占用的又是临时表空间,大小为:nleaf*索引表空间页大小:db2 "select substr(tabname,1,20),substr(indname,1,18),nleaf,indcard from

syscat.indexes"