DB2 Automatic Storage
DB2 Automatic Storage
Agenda
New Concepts
Auto-Resize Tablespaces
Automatic Storage
Automatic Storage Tablespaces
2
IBM Information Management
Agenda
New Concepts
Auto-Resize Tablespaces
Automatic Storage
Automatic Storage Tablespaces
3
IBM Information Management
4
IBM Information Management
Auto-Resize Tablespaces
Without Auto-Resize User
Tablespace A
1. -289 returned from SQL Tablespace A
2. Page out administrator
3. Administrator RESIZEs container(s)
4. Notifies users that space has been added
Container
Container
Container 5. Operations resume
Container
Container
Container
Admin
Tablespace A
DB2 automatically RESIZEs Tablespace A
Container
Container
Container
Container
Container
Container
Admin
5
IBM Information Management
6
IBM Information Management
7
IBM Information Management
8
IBM Information Management
Examples
CREATE TABLESPACE TS1 MANAGED BY DATABASE
USING (FILE ‘TS1’ 1000) AUTORESIZE YES
9
IBM Information Management
Can use fast storage allocation where available (eg. AIX JFS2, Windows)
Only those containers that are part of the last range in the tablespace map will grow
(see next slide for an explanation of ranges)
Ensures that a rebalance will never take place as part of an auto-resize
One of the containers in the last range cannot grow any further
– To preserve the level of striping, DB2 will not automatically extend the other containers in
the last range
– To continue growth, can add space to file system, or a new stripe set
10
IBM Information Management
Containers
Range Stripe Max Start End Containers
0 1 2 Number Set Extent Stripe Stripe
0 0 8 0 2 3 (0, 1, 2)
0 0 1 2
1 0 12 3 4 2 (0, 1)
1 3 4 5 Range #0
Stripes 2 6 7 8
3 9 10
Range #1
4 11 12
* Using containers that are of differing sizes is not
recommended – this is simply shown as an example
11
IBM Information Management
12
IBM Information Management
Agenda
New Concepts
Auto-Resize Tablespaces
Automatic Storage
Automatic Storage Tablespaces
13
IBM Information Management
Database “Y”
Database “X”
Table Table Table
Space “A” Space “B” Space “C”
Table Table Table
Space “A” Space “B” Space “C”
14
IBM Information Management
15
IBM Information Management
tblspace-defn:
MANAGED BY { SYSTEM USING ('string' [ {,'string'} ... ] ) |
DATABASE USING ({FILE | DEVICE} 'string' number-of-pages
[ {,{FILE | DEVICE} 'string' number-of-pages} ... ]) | AUTOMATIC
STORAGE}
[EXTENTSIZE number-of-pages] [PREFETCHSIZE number-of-pages]
[OVERHEAD number-of-milliseconds] [TRANSFERRATE number-of-
milliseconds]
[NO FILE SYSTEM CACHING | FILE SYSTEM CACHING]
[AUTORESIZE {NO | YES}] [INITIALSIZE integer {K|M|G}]
[INCREASESIZE integer {PERCENT|K|M|G}] [MAXSIZE {NONE | integer
{K|M|G}}]
(Existing (non-automatic storage) behavior is the default if the new syntax is not explicitly used)
16
IBM Information Management
17
IBM Information Management
The paths listed with the ON option are the database’s storage paths.
If ON is not specified then the database has one storage path, determined by database manager
configuration parameter dftdbpath
18
IBM Information Management
19
IBM Information Management
Transactional in nature
Log record is written and eligible for replay during a roll forward command
Syntax:
Examples:
20
IBM Information Management
Agenda
New Concepts
Auto-Resize Tablespaces
Automatic Storage
Automatic Storage Tablespaces
21
IBM Information Management
Selected via new MANAGED BY AUTOMATIC STORAGE clause (or by not specifying a
MANAGED BY clause at all)
Not really a new tablespace type, more like a new "storage management style"
Still uses the DMS infrastructure (SMS for temps – more on this later)
Have all of the other tablespace attributes (extent size, prefetch size, etc.)
Can only be created in Automatic Storage databases (ie. databases that have storage
paths defined)
22
IBM Information Management
23
IBM Information Management
Examples:
/db2data/path1/kschlamb/NODE0000/TESTDB/T0000002/C0000000.USR
E:\Storage\db2\NODE0000\PRODDB\T0000000\C0000000.CAT
24
IBM Information Management
25
IBM Information Management
Attempts are made to create containers with equal sizes (where possible)
E.g. Three storage paths with 5 MB, 500 MB, and 600 MB of free space
respectively. Table space is created with an initial size of 800 MB
– The tablespace will be created with one container on each of the last two paths (each
400 MB in size)
26
IBM Information Management
Recently added storage paths are not used until a new stripe set is
needed
This is different than the basic auto-resize case discussed earlier (which
would fail at this point with an SQL0289N error)
It is at this time that recently added storage paths can be considered for new
containers
27
IBM Information Management
C0 C1 C0 C1 C0 C1
3rd storage TS grows until New stripe set
path is added C0 can't grow added automatically
C0 C1 C0 C1 C0 C1
TS grows until New stripe set
C2 C3 C0 can't grow
C2 C3
added automatically
C2 C3
C4
NOTE: For
simplicity, we're
just showing one
tablespace within
the database
28
IBM Information Management
C2 C3
29
IBM Information Management
Remember that SMS is already an auto-extend type of infrastructure (where objects grow by a page or extent at a time)
A redirected restore operation can be used The storage paths for the database can be
to redefine the containers associated with redefined via database restore and/or
the tablespace. relocate DB (more on these later), since
storage management occurs at the
database level.
30
IBM Information Management
E.g. two containers with 10 MB and 100 MB – tablespace will be full after
using 20 MB (10 MB in each)
31
IBM Information Management
P1
(100 MB)
P2
(200 MB)
Choice #3: Use P3, P4 Choice #4: Use P4
Result: Effective size is 800 MB Result: Effective size is 400 MB
P3 P4
(400 MB) (400 MB)
C0 C1 C0
32
IBM Information Management
Agenda
New Concepts
Auto-Resize Tablespaces
Automatic Storage
Automatic Storage Tablespaces
33
IBM Information Management
34
IBM Information Management
35
IBM Information Management
select tbsp_name,
tbsp_id,
tbsp_using_auto_storage,
tbsp_auto_resize_enabled
from table(snap_get_tbsp('TESTDB', -1)) as tbsinfo
select tbsp_name,
tbsp_id,
dbpartitionnum,
tbsp_initial_size,
tbsp_current_size,
tbsp_max_size,
tbsp_increase_size,
tbsp_increase_size_percent,
tbsp_last_resize_time,
tbsp_last_resize_failed
from table(snap_get_tbsp_part('TESTDB', -1)) as tbspartinfo
36
IBM Information Management
37
IBM Information Management
Agenda
New Concepts
Auto-Resize Tablespaces
Automatic Storage
Automatic Storage Tablespaces
38
IBM Information Management
restore-options:
[USER username [USING password]] [TABLESPACE [ONLINE] |
TABLESPACE (tblspace-name [ {,tblspace-name} ... ]) [ONLINE] |
HISTORY FILE [ONLINE] | LOGS [ONLINE] | COMPRESSION LIBRARY [ONLINE]]
[INCREMENTAL [AUTOMATIC | ABORT]] [USE {TSM | XBSA} [OPEN num-sess
SESSIONS]
[OPTIONS {options-string | options-filename}] |
FROM dir/dev [{,dir/dev} ... ] | LOAD shared-lib [OPEN num-sess SESSIONS]
[OPTIONS {options-string | options-filename}]] [TAKEN AT date-time]
[[TO target-directory] | [ON path[{,path}...][DBPATH ON path]]]
[INTO target-database-alias] [LOGTARGET directory]
[NEWLOGPATH directory] [WITH num-buff BUFFERS] [BUFFER buffer-size]
[DLREPORT file-name] [REPLACE HISTORY FILE] [REPLACE EXISTING] [REDIRECT]
[PARALLELISM n] [COMPRLIB lib-name] [COMPROPTS options-string]
[WITHOUT ROLLING FORWARD] [WITHOUT DATALINK] [WITHOUT PROMPTING]
39
IBM Information Management
The database path (which is where DB2 stores various control files for the database)
If the TO clause or the DBPATH ON clause is specified: it indicates the database path
Else, if the ON clause is used, then the first path listed in the ON clause is used as the
database path
If none of the TO, ON, or DBPATH ON clauses are specified, the dftdbpath database
manager configuration parameter determines the database path
However, if a database with the same name exists on disk, the above is all ignored and
the database is restored into the same database path as the existing database.
The storage paths (where DB2 creates automatic storage tablespace containers)
If the ON clause is specified, all of the paths listed are considered storage paths, and
these paths are used instead of the ones stored within the backup image.
If the ON clause is not specified, no change is made to the storage paths (the storage
paths stored within the backup image are maintained).
40
IBM Information Management
Restore (cont.)
CREATE DATABASE TESTDB ON /fs1, /fs2, /fs3 DBPATH ON /fs4
{Database is then backed up and eventually dropped}
41
IBM Information Management
Rollforward
(The assumption is that you are choosing a final storage configuration for the
database)
(The assumption is that after you restore and rollforward you wish the
database to be in the same state it was in prior to the restore)
42
IBM Information Management
db2relocatedb
Can be used to change the database name, database path, and the
location of tablespace containers
Can also be done using backup/restore
Benefit of the tool is speed (can use OS/file system tools to do the moving)
43
IBM Information Management
Agenda
New Concepts
Auto-Resize Tablespaces
Automatic Storage
Automatic Storage Tablespaces
44
IBM Information Management
Can only be enabled if all of the containers are file (no raw devices)
For tablespaces with raw device containers you can do the following:
45
IBM Information Management
46
IBM Information Management
Agenda
New Concepts
Auto-Resize Tablespaces
Automatic Storage
Automatic Storage Tablespaces
47
IBM Information Management
Best Practices
When adding new containers to
an auto-resize DMS tablespace C0 C1 C2 C0 C1 C2
Add them via a new stripe set
Add containers that are the same size
C5 C4 C5 C6
C4
When defining/adding database storage
paths, try to ensure the file systems
associated with the paths are
approximately equal in capacity
Use the DBPATH clause to keep the database directory control data on different
storage than the storage paths, and avoid using the file systems associated with
the database storage paths for anything but DB2 tablespace data
Depending on the non-DB2 activity that is occurring, it can cause strange growth patterns
for the automatic storage tablespaces
When determining free space on a storage path, DB2 will not use the last nn MB of space if
it shares a file system with the following:
• The database path (32 MB)
• The system directory (Windows only – 64 MB)
48
IBM Information Management
NODE0000
Database path: /db1/inst/NODE0000/SQL00000
/path2/inst/NODE0001/mydb
Database path: /db1/inst/NODE0001/SQL00000
NODE0001
49
IBM Information Management
NODE0000
Database path: /db1/inst/NODE0000/SQL00000
NODE0001
50
IBM Information Management
Examples: