Home
Blog
About
Database administration
Operating systems
Development
Links


Following require login:
ScratchPad



Locations of visitors to this page


DB2 Maintenance Windows

With particular reference to automatic jobs, e.g. collecting runstats.

References:

Sample session changing the maintenance window.

XML must be in sqllib/tmp

57> pwd
/db2/db2ed1
61> ls -l sqllib/tmp
total 12
-rwxr-xr-x 1 db2ed1 dbed1adm 218 Jan 15 09:38 auto-runstats.xml
-rwxr-xr-x 1 db2ed1 dbed1adm 377 Jan 15 09:40 maintenance-window.xml

This defines a 12 hour window running every day from 5p.m. (most of the XML is comments):

62> cat sqllib/tmp/maintenance-window.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--  IBM Corporation  version 1.0   -->

<!-- Configuration file for Maintenance Window Specification  -->

<DB2MaintenanceWindows
xmlns="http://www.ibm.com/xmlns/prod/db2/autonomic/config">

<!-- Online Maintenance Window  -->

<OnlineWindow Occurrence="During" startTime="17:00:00" duration="12">
   <DaysOfWeek>All</DaysOfWeek>
   <DaysOfMonth>All</DaysOfMonth>
   <MonthsOfYear>All</MonthsOfYear>
</OnlineWindow>

<!--  Offline Maintenance Window -->

<!-- NOT CURRENTLY USED

Optional:
Specify when offline automatic maintenance can occur in the Occurrence attribute.
Specify the OfflineWindow using the same method as described above for the OnlineWindow.

 -->

<!--
 <OfflineWindow Occurrence="During" startTime="00:00:00" duration="24" >
   <DaysOfWeek>All</DaysOfWeek>
   <DaysOfMonth>All</DaysOfMonth>
   <MonthsOfYear>All</MonthsOfYear>
 </OfflineWindow>
 -->

</DB2MaintenanceWindows>

Apply the XML and check it's been applied
Note: Comments are stripped out when XML is applied:

64> db2 connect to ed1

   Database Connection Information

 Database server        = DB2/LINUXX8664 9.7.2
 SQL authorization ID   = DB2ED1
 Local database alias   = ED1

65> db2 "call sysproc.automaint_set_policyfile('MAINTENANCE_WINDOW','maintenance-window.xml')"

  Return Status = 0
dv0003:db2ed1 64> db2 "call sysproc.automaint_get_policyfile('MAINTENANCE_WINDOW','CurrentMaintenanceWindowPolicy-20130130.xml')"

  Return Status = 0
66> cat sqllib/tmp/CurrentMaintenanceWindowPolicy-20130130.xml
<?xml version="1.0" encoding="UTF-8"?>
<DB2MaintenanceWindows
xmlns="http://www.ibm.com/xmlns/prod/db2/autonomic/config" >

 <!-- Online Maintenance Window  -->
 <OnlineWindow Occurrence="During" startTime="17:00:00" duration="12" >
  <DaysOfWeek>All</DaysOfWeek>
  <DaysOfMonth>All</DaysOfMonth>
  <MonthsOfYear>All</MonthsOfYear>
 </OnlineWindow>
</DB2MaintenanceWindows>

Monitor automatic runstats by running this SQL (it can take a while and returns a lot of data):

SELECT
  pid,
  tid,
  substr(eventtype, 1,10),
  substr(objtype,1,30) as objtype,
  substr(objname_qualifier,1,20) as objschema,
  substr(objname,1,10) as objname,
  substr(first_eventqualifier,1,26) as event1,
  substr(second_eventqualifiertype,1,2) as event2_type,
  substr(second_eventqualifier,1,20) event2,
  substr(third_eventqualifiertype,1,6) event3_type,
  substr(third_eventqualifier,1,15) event3,
  substr(eventstate,1,20) as eventstate
FROM
  TABLE( SYSPROC.PD_GET_DIAG_HIST
       ( 'optstats', 'EX', 'NONE', CURRENT_TIMESTAMP - 5 days, CAST( NULL AS TIMESTAMP ))) as sl
order by
  timestamp(varchar(substr(first_eventqualifier,1,26),26))

OR - look at the log files in /db2/SID/db2dump/events

$ ls -l /db2/ED1/db2dump/events
total 14308
-rw-rw-rw- 1 db2eq1 dbeq1adm 3146214 Jan 25 02:57 db2optstats.199.log
-rw-rw-rw- 1 db2eq1 dbeq1adm 3146179 Jan 28 02:56 db2optstats.200.log
-rw-rw-rw- 1 db2eq1 dbeq1adm 3146101 Jan 30 06:24 db2optstats.201.log
-rw-rw-rw- 1 db2eq1 dbeq1adm 3146107 Feb  2 19:18 db2optstats.202.log
-rw-rw-rw- 1 db2eq1 dbeq1adm 2028306 Feb  5 09:57 db2optstats.203.log

Note that these logs are automatically rotated when they get to around 3MB so they don't tend to exist for more than a few days.


Copyright HandyDBA 2012