wdug storage basics

87
© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice. www.xtivia.com 888.685.3101 ext. 2 Storage Basics for Db2: Faster I/O, Fewer Headaches

Upload: others

Post on 27-Dec-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

www.xtivia.com 888.685.3101 ext. 2

Storage Basics for Db2: Faster I/O, Fewer Headaches

Page 2: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Agenda

● Db2 Storage Basics

● System Storage Basics

● Db2 “Optimal Filesystem Architecture”

● Key Performance Metrics

● Finding I/O Bottlenecks

Page 3: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Db2 Storage Basics

Page 4: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Logical Hierarchy

Tables

Page 5: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Logical Hierarchy

Tables

Tablespace

Page 6: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Logical Hierarchy

Tables

Tablespace

Tables

Tablespace

Page 7: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Logical Hierarchy

Tables

Tablespace

Tables

Tablespace

Storage Group

Page 8: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Logical Hierarchy

Page 9: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Logical Hierarchy

Storage Path(s) Storage Path(s)

Page 10: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Tablespaces

● Each tablespace has a page size: 4096, 8192, 16384 or 32768 bytes

Page 11: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Tablespaces

● Each tablespace has a page size: 4096, 8192, 16384 or 32768 bytes

● Tablespace Types

● Regular

● Large

● System Temporary

● User Temporary

Page 12: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Tablespaces

● Each tablespace has a page size: 4096, 8192, 16384 or 32768 bytes

● Tablespace Types

● Regular

● Large

● System Temporary

● User Temporary

❌ Limits on size, rows/page; not reclaimable

Page 13: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Tablespaces

● Each tablespace has a page size: 4096, 8192, 16384 or 32768 bytes

● Tablespace Types

● Regular

● Large

● System Temporary

● User Temporary

● Storage Types

● Automatic Storage

● Managed by Database (DMS)

● Managed by System (SMS)

❌ Limits on size, rows/page; not reclaimable

Page 14: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Tablespaces

● Each tablespace has a page size: 4096, 8192, 16384 or 32768 bytes

● Tablespace Types

● Regular

● Large

● System Temporary

● User Temporary

● Storage Types

● Automatic Storage

● Managed by Database (DMS)

● Managed by System (SMS)

❌ Deprecated

❌ Deprecated

❌ Limits on size, rows/page; not reclaimable

Page 15: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Storage Groups

● Storage is defined on one or more directories on the server

● STOGROUP Parameters

● OVERHEAD: Seek time (milliseconds)

● DEVICE READ RATE: Throughput (megabytes/s)

● Cases for using multiple STOGROUPS in a database

● “Multi-Temperature” Storage (SSD vs Disk)

● Limiting Temporary Tablespace Utilization

Page 16: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Where is my database stored?

$ db2 "SELECT type, path FROM sysibmadm.dbpaths ORDER BY 1,2"

Page 17: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Where is my database stored?

$ db2 "SELECT type, path FROM sysibmadm.dbpaths ORDER BY 1,2"

TYPE PATH -------------------- ------------------------------------------------------- DB_STORAGE_PATH /database/data/ DBPATH /database/data/db2inst1/NODE0000/SQL00001/ DBPATH /database/data/db2inst1/NODE0000/SQL00001/MEMBER0000/ LOCAL_DB_DIRECTORY /database/data/db2inst1/NODE0000/sqldbdir/ LOGPATH /database/data/db2inst1/NODE0000/SQL00001/LOGSTREAM0000/ 5 record(s) selected.

Page 18: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECT type, path FROM sysibmadm.dbpaths UNION ALL SELECT 'ARCHIVE_LOGPATH', replace(value,'DISK:','') FROM sysibmadm.dbcfg WHERE name in ('logarchmeth1','logarchmeth2') AND value like ‘DISK:%' UNION ALL SELECT upper(name), value FROM sysibmadm.dbmcfg WHERE name = 'keystore_location' AND EXISTS (SELECT 1 FROM sysibmadm.dbcfg WHERE name = 'encrypted_database' AND value = 'YES');

Where is my database stored?

Page 19: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECT type, path FROM sysibmadm.dbpaths UNION ALL SELECT 'ARCHIVE_LOGPATH', replace(value,'DISK:','') FROM sysibmadm.dbcfg WHERE name in ('logarchmeth1','logarchmeth2') AND value like 'DISK:%' UNION ALL SELECT upper(name), value FROM sysibmadm.dbmcfg WHERE name = 'keystore_location' AND EXISTS (SELECT 1 FROM sysibmadm.dbcfg WHERE name = 'encrypted_database' AND value = 'YES');

Where is my database stored?

Page 20: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECT type, path FROM sysibmadm.dbpaths UNION ALL SELECT 'ARCHIVE_LOGPATH', replace(value,'DISK:','') FROM sysibmadm.dbcfg WHERE name in ('logarchmeth1','logarchmeth2') AND value like ‘DISK:%' UNION ALL SELECT upper(name), value FROM sysibmadm.dbmcfg WHERE name = 'keystore_location' AND EXISTS (SELECT 1 FROM sysibmadm.dbcfg WHERE name = 'encrypted_database' AND value = 'YES');

Where is my database stored?

Page 21: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECT type, pathFROM sysibmadm.dbpaths

UNION ALLSELECT 'ARCHIVE_LOGPATH', replace(value,'DISK:','')

FROM sysibmadm.dbcfgWHERE name in ('logarchmeth1','logarchmeth2')

AND value like 'DISK:%'UNION ALLSELECT upper(name), value

FROM sysibmadm.dbmcfgWHERE name = 'keystore_location'

AND EXISTS (SELECT 1 FROM sysibmadm.dbcfgWHERE name = 'encrypted_database' AND value = 'YES');

Where is my database stored?

Page 22: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECT 'ARCHIVE_LOGPATH', replace(value,'DISK:','') FROM sysibmadm.dbcfg WHERE name in ('logarchmeth1','logarchmeth2') AND value like 'DISK:%' UNION ALL SELECT upper(name), value FROM sysibmadm.dbmcfg WHERE name = 'keystore_location' AND EXISTS (SELECT 1 FROM sysibmadm.dbcfg WHERE name = 'encrypted_database' AND value = 'YES');

TYPE PATH -------------------- ------------------------------------------------------- ARCHIVE_LOGPATH /database/config/db2inst1/archive_logs/ DB_STORAGE_PATH /database/data/ DBPATH /database/data/db2inst1/NODE0000/SQL00001/ DBPATH /database/data/db2inst1/NODE0000/SQL00001/MEMBER0000/ KEYSTORE_LOCATION /database/config/db2inst1/.security/db2inst1.p12 LOCAL_DB_DIRECTORY /database/data/db2inst1/NODE0000/sqldbdir/ LOGPATH /database/data/db2inst1/NODE0000/SQL00001/LOGSTREAM0000/ 7 record(s) selected.

Where is my database stored?

Page 23: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Important Database Files

Location Requires OS-Level Backup

Storage Path(s) No

Active Transaction Logs No

Archive Logs Yes

Local Database Directory Yes

Keystore - Encryption Yes

Page 24: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Important Database Files

Location Requires OS-Level Backup

Storage Path(s) No

Active Transaction Logs No

Archive Logs Yes

Local Database Directory Yes

Keystore - Encryption Yes

† If using LOGARCHMETH DISK

Page 25: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

System Storage Basics

Disk

Page 26: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Storage Types and Devices

● Direct-Attached Storage Devices

● Stand-alone Disks

● Local Storage Arrays - RAID

● SAN

● Virtual Machines: VDisks

● Network Attached Storage

Page 27: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Logical Volume Manager

● A tool to create virtual block devices from physical devices

● Eliminates restrictions from partitioning hard drives

● One block device can span multiple physical devices

● Used on AIX, Linux

● Logical Device Manager & Storage Spaces provide similar functionality on Windows

Page 28: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Mapping Filesystems to Physical Disks with LVM

Task Linux AIX

List Volume Groups vgs lsvg

List Logical Volumeslvs <vg> lvdisplay <vg>

lsvg -l <vg>

List Physical Volumes pvslspv lsvg -p <vg>

List Filesystems on a Physical Volume

pvdisplay <pv> -m lsblk

lspv -l <pv>

† Requires root privileges

Page 29: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 96G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 95.5G 0 part ├─vglocal20161128-swap00 253:1 0 2G 0 lvm [SWAP] ├─vglocal20161128-tmp00 253:2 0 12G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm / sdb 8:16 0 128G 0 disk └─sdb1 8:17 0 128G 0 part └─data_vg-data_lv 253:0 0 128G 0 lvm /data sde 8:64 0 20G 0 disk └─sde1 8:65 0 20G 0 part ├─vglocal20161128-tmp00 253:2 0 128G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm /

Exploring lsblk

Page 30: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 96G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 95.5G 0 part ├─vglocal20161128-swap00 253:1 0 2G 0 lvm [SWAP] ├─vglocal20161128-tmp00 253:2 0 12G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm / sdb 8:16 0 128G 0 disk └─sdb1 8:17 0 128G 0 part └─data_vg-data_lv 253:0 0 128G 0 lvm /data sde 8:64 0 20G 0 disk └─sde1 8:65 0 20G 0 part ├─vglocal20161128-tmp00 253:2 0 128G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm /

Exploring lsblk

Volume Group

Page 31: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 96G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 95.5G 0 part ├─vglocal20161128-swap00 253:1 0 2G 0 lvm [SWAP] ├─vglocal20161128-tmp00 253:2 0 12G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm / sdb 8:16 0 128G 0 disk └─sdb1 8:17 0 128G 0 part └─data_vg-data_lv 253:0 0 128G 0 lvm /data sde 8:64 0 20G 0 disk └─sde1 8:65 0 20G 0 part ├─vglocal20161128-tmp00 253:2 0 128G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm /

Exploring lsblk

Logical Volume

Page 32: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 96G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 95.5G 0 part ├─vglocal20161128-swap00 253:1 0 2G 0 lvm [SWAP] ├─vglocal20161128-tmp00 253:2 0 12G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm / sdb 8:16 0 128G 0 disk └─sdb1 8:17 0 128G 0 part └─data_vg-data_lv 253:0 0 128G 0 lvm /data sde 8:64 0 20G 0 disk └─sde1 8:65 0 20G 0 part ├─vglocal20161128-tmp00 253:2 0 128G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm /

Exploring lsblk

Filesystem

Page 33: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 96G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 95.5G 0 part ├─vglocal20161128-swap00 253:1 0 2G 0 lvm [SWAP] ├─vglocal20161128-tmp00 253:2 0 12G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm / sdb 8:16 0 128G 0 disk └─sdb1 8:17 0 128G 0 part └─data_vg-data_lv 253:0 0 128G 0 lvm /data sde 8:64 0 20G 0 disk └─sde1 8:65 0 20G 0 part ├─vglocal20161128-tmp00 253:2 0 128G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm /

Exploring lsblk

Sharing 1 physical device

Page 34: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 96G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 95.5G 0 part ├─vglocal20161128-swap00 253:1 0 2G 0 lvm [SWAP] ├─vglocal20161128-tmp00 253:2 0 12G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm / sdb 8:16 0 128G 0 disk └─sdb1 8:17 0 128G 0 part └─data_vg-data_lv 253:0 0 128G 0 lvm /data sde 8:64 0 20G 0 disk └─sde1 8:65 0 20G 0 part ├─vglocal20161128-tmp00 253:2 0 128G 0 lvm /tmp └─vglocal20161128-root00 253:3 0 171.5G 0 lvm /

Exploring lsblk

1 filesystem spanning multiple physical devices

Page 35: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

RAID Arrays and Db2

● RAID Arrays are typically N+1 disks

● Strip (aka Element) size is commonly 32kb or 64kb

Disk Disk Disk Disk Disk Disk

RAID-5

Stripe Size

Strip Size

Strip size 64 kbStripe size 320 kb

EXTENTSIZE 320K

Page 36: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

RAID Arrays and Db2

● RAID Arrays are typically N+1 disks

● Strip (aka Element) size is commonly 32kb or 64kb

● Match Db2 extent size to RAID stripe size

Disk Disk Disk Disk Disk Disk

RAID-5

Stripe Size

Strip Size

Strip size 64 kbStripe size 320 kb

EXTENTSIZE 320K

Page 37: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

RAID Arrays and Db2

● RAID Arrays are typically N+1 disks

● Strip (aka Element) size is commonly 32kb or 64kb

● Match Db2 extent size to RAID stripe size

● With SAN virtualization, a single LUN may be spread over multiple RAID arrays

● Use EXTENTSIZE 256K

Disk Disk Disk Disk Disk Disk

RAID-5

Stripe Size

Strip Size

Strip size 64 kbStripe size 320 kb

EXTENTSIZE 320K

Page 38: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Disk Disk Disk

RAID-5

Hardware Level 1 logical unit on

multiple physical disks

Understanding Striping

Page 39: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Disk Disk Disk

RAID-5

Disk Disk Disk

RAID-5

/db2/data01

LVM Level 1 logical volume on

multiple physical volumes

Hardware Level 1 logical unit on

multiple physical disks

Understanding Striping

Page 40: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

IBMSTOGROUP

Disk Disk Disk

RAID-5

Disk Disk Disk

RAID-5

/db2/data01 /db2/data02

Db2 Level 1 STOGROUP with

multiple storage paths

LVM Level 1 logical volume on

multiple physical volumes

Hardware Level 1 logical unit on

multiple physical disks

Understanding Striping

Page 41: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Understanding Striping

IBMSTOGROUP

Disk Disk Disk

RAID-5

Disk Disk Disk

RAID-5

/db2/data01 /db2/data02

Db2 Level 1 STOGROUP with

multiple storage paths

LVM Level 1 logical volume on

multiple physical volumes

Hardware Level 1 logical unit on

multiple physical disks

Page 42: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Understanding Striping

IBMSTOGROUP

Disk Disk Disk

RAID-5

Disk Disk Disk

RAID-5

/db2/data01 /db2/data02

Db2 Level 1 STOGROUP with

multiple storage paths

LVM Level 1 logical volume on

multiple physical volumes

Hardware Level 1 logical unit on

multiple physical disks

Page 43: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

How Db2 Processes I/O

Disk Disk Disk

RAID-5

Disk Disk Disk

RAID-5

/db2/data01 /db2/data02

● Db2 allocates new extents to each storage path in a round-robin fashion

IBMSTOGROUP

Page 44: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

How Db2 Processes I/O

Disk Disk Disk

RAID-5

Disk Disk Disk

RAID-5

● Db2 allocates new extents to each storage path in a round-robin fashion

● When reading, multiple prefetchers can run in parallel, 1 per storage path

IBMSTOGROUP

/db2/data01 /db2/data02

Page 45: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

How Db2 Processes I/O

Disk Disk Disk

RAID-5

Disk Disk Disk

RAID-5

● Db2 allocates new extents to each storage path in a round-robin fashion

● When reading, multiple prefetchers can run in parallel, 1 per storage path

● When DB2_PARALLEL_IO is enabled, multiple prefetchers will be used for each storage path

IBMSTOGROUP

db2set DB2_PARALLEL_IO=*,3

/db2/data01 /db2/data02

Page 46: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Db2 Optimal Filesystem Architecture

Page 47: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Db2 OFA Purpose

Define a standard directory structure that provides flexibility and support for multiple instances and databases on a single system.

Using this recommendation will provide a solid foundation for building out Db2 servers regardless of database size and performance requirements.

Page 48: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Directory Layout

● System-Level Directories

● Installation path

● Global Registry

● Database Backups

● Instance-Level Directories

● Instance Owner home

● Diagnostic Log Path

● Database-Level Directories

● Database Path

● Storage Path(s)

● Active Log Path

● Archive Log Path

Resolved Path

/opt/ibm/db2/V11.5.4.0

/var/db2

/db2/backups

/db2/db2inst1

/db2/db2dump/db2inst1/DIAG0000

/db2/db2inst1/NODE0000/SQL00001/

/db2/data01/db2inst1/NODE0000/TESTDB/

/db2/active_logs/db2inst1/TESTDB/NODE0000/LOGSTREAM0000

/db2/archive_logs/db2inst1/TESTDB/NODE0000/LOGSTREAM0000

Page 49: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

● System-Level Directories

● Installation path

● Global Registry

● Database Backups

● Instance-Level Directories

● Instance Owner home

● Diagnostic Log Path

● Database-Level Directories

● Database Path

● Storage Path(s)

● Active Log Path

● Archive Log Path

Resolved Path (Filesystem shown in Red)

/opt/ibm/db2/V11.5.4.0

/var/db2

/db2/backups

/db2/db2inst1

/db2/db2dump/db2inst1/DIAG0000

/db2/db2inst1/NODE0000/SQL00001/

/db2/data01/db2inst1/NODE0000/TESTDB

/db2/active_logs/db2inst1/TESTDB/NODE0000/LOGSTREAM0000

/db2/archive_logs/db2inst1/TESTDB/NODE0000/LOGSTREAM0000

FS Size

10 Gb

Default

Varies

8 Gb

8 Gb

Varies

Varies

Varies

Directory – Filesystem Layout

Page 50: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

● System-Level Directories

● Installation path

● Global Registry

● Database Backups

● Instance-Level Directories

● Instance Owner home

● Diagnostic Log Path

● Database-Level Directories

● Database Path

● Storage Path(s)

● Active Log Path

● Archive Log Path

Resolved Path (Filesystem shown in Red)

/opt/ibm/db2/V11.5.4.0

/var/db2

/db2/backups

/db2/db2inst1

/db2/db2dump/db2inst1/DIAG0000

/db2/db2inst1/NODE0000/SQL00001/

/db2/data01/db2inst1/NODE0000/TESTDB/

/db2/active_logs/db2inst1/TESTDB/NODE0000/LOGSTREAM0000

/db2/archive_logs/db2inst1/TESTDB/NODE0000/LOGSTREAM0000

FS Size

Default

Varies

Directory – Filesystem Layout - Flexibility

Page 51: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Creating a Database using Db2 OFA

$ db2 create database testdb \on /db2/data01, /db2/data02 \dbpath on /db2

Page 52: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Creating a Database using Db2 OFA

$ db2 create database testdb \on /db2/data01, /db2/data02 \dbpath on /db2

DB20000I The CREATE DATABASE command completed successfully.

Page 53: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Creating a Database using Db2 OFA

$ db2 create database testdb \on /db2/data01, /db2/data02 \dbpath on /db2

DB20000I The CREATE DATABASE command completed successfully.

$ db2 update db cfg for testdb using \newlogpath /db2/active_logs/db2inst1/TESTDB \logarchmeth1 DISK:/db2/archive_logs

DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.

Page 54: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Creating a Database using Db2 OFA

$ db2 create database testdb \ on /db2/data01, /db2/data02 \ dbpath on /db2DB20000I The CREATE DATABASE command completed successfully.

$ db2 update db cfg for testdb using \ newlogpath /db2/active_logs/db2inst1/TESTDB \ logarchmeth1 DISK:/db2/archive_logsDB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.

$ db2 backup database testdb to /db2/backups/db2inst1

Backup successful. The timestamp for this backup image is : 20200625002633

Page 55: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Filesystem Separation

● Store active transaction logs on separate physical disk(s)

● DW / BLU Workloads may need temporary tablespaces physically separated from primary storage.

● Create separate filesystems:

● /db2/tempNN/db2inst1/NODE0000/TESTDB/

● Create new STOGROUP

● CREATE STOGROUP sg_temp ON /db2/temp01, /db2/temp02

● Move temporary tablespaces

● ALTER TABLESPACE TEMPSPACE1 USING STOGROUP sg_temp

● ALTER TABLESPACE USERTEMP4K USING STOGROUP sg_temp

Page 56: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Key Performance Metrics

Page 57: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Average I/O Read Time

● Represents the average time it takes for Db2 to read a page from disk

● Calculate using these metrics:

● POOL_DATA_P_READS

● POOL_XDA_P_READS

● POOL_COL_P_READS

● POOL_TEMP_INDEX_P_READS

● POOL_TEMP_XDA_P_READS

● POOL_TEMP_COL_P_READS

● POOL_READ_TIME

● Available at database level, tablespace level and from many other MON_GET functions

avg read ms = POOL_READ_TIME∑ POOL_ * _P_READS

Page 58: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECTmember,pool_read_time * 1.0 /

NULLIF(pool_data_p_reads + pool_xda_p_reads + pool_col_p_reads +pool_temp_index_p_reads + pool_temp_xda_p_reads +pool_temp_col_p_reads, 0) AS avg_read_ms

FROM TABLE (mon_get_database(-2));

Average I/O Read Time

Page 59: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECT member, pool_read_time * 1.0 / NULLIF(pool_data_p_reads + pool_xda_p_reads + pool_col_p_reads + pool_temp_index_p_reads + pool_temp_xda_p_reads + pool_temp_col_p_reads, 0) AS avg_read_ms FROM TABLE (mon_get_database(-2));

MEMBER AVG_READ_MS ------ ----------------------------------- 0 0.94642857142 1 record(s) selected.

Average I/O Read Time

Page 60: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Average I/O Write Time

● Represents the average time it takes for Db2 to write a page to disk

● Calculate using these metrics:

● POOL_DATA_WRITES

● POOL_INDEX_WRITES

● POOL_XDA_WRITES

● POOL_COL_WRITES

● POOL_WRITE_TIME

● Available at database level, tablespace level and from many other MON_GET functions

avg write ms = POOL_WRITE_TIME∑ POOL_ * _WRITES

Page 61: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECTtbsp_name,pool_write_time * 1.0 /

NULLIF(pool_data_writes + pool_index_writes +pool_xda_writes + pool_col_writes,0) AS avg_write_ms

FROMTABLE (mon_get_tablespace(NULL, -2));

Average I/O Write Time

Page 62: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECT tbsp_name, pool_write_time * 1.0 / NULLIF(pool_data_writes + pool_index_writes + pool_xda_writes + pool_col_writes,0) AS avg_write_ms FROM TABLE (mon_get_tablespace(NULL, -2));

TBSP_NAME AVG_WRITE_MS -------------------- --------------------------------- SYSCATSPACE 0.15384615384 TEMPSPACE1 0.19390190480 USERSPACE1 0.27419473202 SYSTOOLSPACE - 1 record(s) selected.

Average I/O Write Time

Page 63: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Average Log I/O Write Time

● Represents the average time for DB2 to write a log page

● Calculate using these monitor elements:

● LOG_WRITES

● LOG_WRITE_TIME

● Monitor elements available in MON_GET_TRANSACTION_LOG

avg log write ms = LOG_WRITE_TIMELOG_WRITES

Page 64: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECTmember,log_write_time * 1.0 / NULLIF(log_writes,0) AS log_write_ms

FROMTABLE (mon_get_transaction_log(-2));

Average I/O Write Time

Page 65: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

SELECT member, log_write_time * 1.0 / NULLIF(log_writes,0) AS log_write_ms FROM TABLE (mon_get_transaction_log(-2));

MEMBER LOG_WRITE_MS ------ --------------------------------- 0 0.35634328358 1 record(s) selected.

Average I/O Write Time

Page 66: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

dmctop – Overview

Page 67: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

dmctop – Overview

Page 68: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

dmctop – Logging

Page 69: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

dmctop – Logging

Page 70: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Other Considerations for I/O Metrics

● Direct I/O Read and Write Times

● Direct Reads and Writes do not go through the bufferpool

● Includes Temp Tablespaces, LOBs, Database Backups

● Synchronous vs Asynchronous I/O

● Synchronous I/O times are more impactful to workload

● Understand workload characteristics

Page 71: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Finding I/O Bottlenecks

Page 72: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

I/O Wait

● I/O Wait time is a type of idle time – occurs when a CPU is idle and there are outstanding I/O requests

● Reported as wa in vmstat output

● Generally good at under 20-30%

$ vmstat 5 5 procs -----------memory---------- ---swap-- -----io---- --system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 1 1 0 2574952 142484 837652 0 0 315 199 0 0 4 1 94 1 0 1 1 0 2574952 142492 837652 0 0 2066 7913 22238 4726 2 1 96 2 0 0 2 0 2754268 142500 837652 0 0 1419 7320 30958 5943 3 2 93 1 0 0 1 0 2754528 142508 837652 0 0 1340 8239 23108 5288 2 1 95 2 0 2 1 0 2574292 142516 837652 0 0 1334 8061 24161 5477 3 1 94 2 0

Page 73: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

I/O Wait

● I/O Wait time is a type of idle time – occurs when a CPU is idle and there are outstanding I/O requests

● Reported as wa in vmstat output

● Generally good at under 20-30%

$ vmstat 5 5 procs -----------memory---------- ---swap-- -----io---- --system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 1 1 0 2574952 142484 837652 0 0 315 199 0 0 4 1 94 1 0 1 1 0 2574952 142492 837652 0 0 2066 7913 22238 4726 2 1 96 2 0 0 2 0 2754268 142500 837652 0 0 1419 7320 30958 5943 3 2 93 1 0 0 1 0 2754528 142508 837652 0 0 1340 8239 23108 5288 2 1 95 2 0 2 1 0 2574292 142516 837652 0 0 1334 8061 24161 5477 3 1 94 2 0

Page 74: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Device-Level Statistics - AIX

● iostat – get statistics for individual disk devices

●% tm_act - percentage of time device was active

●Kbps - transfer rate of data to/from disk

$ iostat -d hdisk46 5 5

Disks: % tm_act Kbps tps Kb_read Kb_wrtn hdisk46 0.0 1809.6 24.0 9048 0

Disks: % tm_act Kbps tps Kb_read Kb_wrtn hdisk46 0.0 0.0 0.0 0 0

Disks: % tm_act Kbps tps Kb_read Kb_wrtn hdisk46 2.0 301.6 4.0 1508 0

AIX

Page 75: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Device-Level Statistics - Linux

● iostat – get statistics for individual disk devices

● tps - transfers per second (IOPS)

●kB_read/s - transfer rate of data from disk

$ iostat -d -N b2cnaprvg-table04 5 3

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn db2vg-table04 9.00 56.00 0.00 280 0

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn db2vg-table04 21.00 74.80 61.60 374 308

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn db2vg-table04 5.40 45.40 0.00 227 0

Linux

Page 76: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

Device-Level Statistics - Linux

● iostat – get statistics for individual disk devices

● tps - transfers per second (IOPS)

●kB_read/s - transfer rate of data from disk

$ iostat -d -N b2cnaprvg-table04 5 3

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn db2vg-table04 9.00 56.00 0.00 280 0

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn db2vg-table04 21.00 74.80 61.60 374 308

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn db2vg-table04 5.40 45.40 0.00 227 0

Linux

Page 77: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

nmon - System Performance

● nmon provides a terminal-based interface to system statistics

●Display CPU statistics and I/O statistics on a single screen

●Use disk groups for viewing I/O statistics

$ cat ~/dgvglocal00 dm-42 dm-39 dm-37 dm-41 dm-40 dm-38 dm-33 dm-32 dm-34 dm-36 dm-35db2-base dm-11 dm-12 dm-14db2-tbsp dm-15 dm-16 dm-17 dm-18 dm-19 dm-20db2-logarc dm-21db2-log dm-13backupvg dm-10

Page 78: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

nmon - System Performance

● nmon provides a terminal-based interface to system statistics

●Display CPU statistics and I/O statistics on a single screen

●Use disk groups for viewing I/O statistics

$ cat ~/dgvglocal00 dm-42 dm-39 dm-37 dm-41 dm-40 dm-38 dm-33 dm-32 dm-34 dm-36 dm-35 db2-base dm-11 dm-12 dm-14 db2-tbsp dm-15 dm-16 dm-17 dm-18 dm-19 dm-20 db2-logarc dm-21 db2-log dm-13 backupvg dm-10

$ NMON=lg nmon -g ~/dg

Page 79: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

nmon

Page 80: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

nmon

Page 81: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

nmon

Page 82: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

nmon

Page 83: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

dmctop – Time Spent

Page 84: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

dmctop – Time Spent

Page 85: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

dmctop – Time Spent

Page 86: WDUG Storage Basics

© Copyright 2020 XTIVIA, Inc. The information contained herein is subject to change without notice.

dmctop – Time Spent

Page 87: WDUG Storage Basics

Speaker: Ian Bjorhovde

Email Address: [email protected] Phone: 719-309-1127