Avoid Tablespace Full condition with Automatic Storage
DB2 v9 for LUW introduces a new kind of Tablespaces - Managed by Automatic Storage.
'Till DB2 v8.2, one of the most time expensive tasks for a DB2 DBA was monitoring and extending Tablespaces. Pretty often, the most important tablespace of your database ran out of space on a Sunday and you got calls while you were sleeping.
DB2 v9 introduced a new kind of tablespaces/databases called Automatic Storage. With this new feature, DB2 is able to provide the best from the 2 other types of tablespaces:
- space is allocated as needed automatically (the good point from SMS tablespaces);
- performance is the same as a DMS tablespace, since the containers are files or block devices (old raw devices containers)
I´ve been working with DB2 v9 for a couple of months and in my opinion the best thing from this kind of tablespace is that we no longer need to monitor/extend tablespaces. We just need to keep an eye on disks/file systems usage.
Step by step to use Automatic Storage tablespaces:
1) Create the database: in v9, database is enabled to use Automatic Storage by default. The point here is that you´re able to create the database in more the one path (disk or file system). It will give you performance benefits since DB2 will be able to read/write physical disks in parallel.
db2 create database sample on /db2/data1,/db2/data2,...
This statement will create the database control files on /db2/data1, but all tablespaces will be spread over the both file systems specified.
You´re also able to add 'storage paths' to an existing database, altough your previous tablespaces will not use the new paths automatically.
db2 alter database sample add storage on /db2/data3
All tablespaces created from this point on will have containers created on all 3 file systems.
2) Create the tablespaces: once you have a database enabled to use Automatic Storage, you no longer need to specify the container paths of your tablespaces. DB2 will automatically create the containers on the paths used by the database. So the CREATE TABLESPACE statement is pretty simple:
db2 create tablespace my_tbspace pagesize 8k managed by automatic
storage bufferpool bp8k
Tip: the statement above will create small containers that will grow as needed. To reduce the impact of frequently extend the tablespace, you can specify the grow rate of this tablespace. You can do that by setting up the INCREASESIZE parameter of the tablespace:
db2 alter tablespace my_tbspce increasesize 30 percent
or
db2 alter tablespace my_tbspce increasesize 500 M
Another great feature of Automatic Storage is that you no longer need to do REDIRECTED RESTORES. Yes, that´s true. Databases with AUTOMATIC STORAGE can be restored over diferent paths without those boring REDIRECT RESTORES and SET CONTAINERS PATHS. But this is subject to another post.
See you.