IBM Support

What could cause tablespace and container path's difference on HADR primary and standby databases?

Technical Blog Post


Abstract

What could cause tablespace and container path's difference on HADR primary and standby databases?

Body

In DB2 Information Center, it is stated:

Table spaces and their containers must be identical on the primary and standby databases. Properties that must be identical include the table space type (DMS or SMS), table space size, container path, container size, and container file type (raw device or file system). 

...

Storage groups are fully supported by HADR, including replication of the CREATE STOGROUP, ALTER STOGROUP and DROP STOGROUP statements. Similar to table space containers, the storage paths must exist on both primary and standby.

But when performing database restore, the ON option could lead to undesired difference of storage path on primary and standby databases.

 

# rhel67a (primary)

 

mkdir /tj02
chown -R db2inst6:db2iadm1 /tj02
su - db2inst6

db2set DB2_RESTORE_GRANT_ADMIN_AUTHORITIES=YES      # To avoid possible permission issues when doing restore to a different instance
db2 create db tj02 on /tj02,/tj02,/tj02 dbpath on /tj02                    # Here I assign 3 paths to the default storage group
db2 update db cfg for tj02 using LOGARCHMETH1 logretain HADR_LOCAL_HOST rhel67a HADR_LOCAL_SVC 38010 HADR_REMOTE_HOST rhel67b HADR_REMOTE_SVC 38011 HADR_REMOTE_INST db2inst3 HADR_TIMEOUT 120 HADR_PEER_WINDOW 120 LOGINDEXBUILD yes
db2stop

db2start

db2 backup db tj02 to .

scp TJ02.0.db2inst6.DBPART000.20170921121634.001 db2inst3@rhel67b:/home/db2inst3/work

 

# rhel67b (standby)

 

mkdir /tj02
chown -R db2inst3:db2iadm1 /tj02
su - db2inst6

db2set DB2_RESTORE_GRANT_ADMIN_AUTHORITIES=YES

db2stop

db2ckbkp -s TJ02.0.db2inst6.DBPART000.20170921121634.001    # By checking the backup image, I can see there are 3 storage paths

        Number of storage paths:   3
        Storage path # 0:          /tj02 (id = 0, state = 0x0)
        Storage path # 1:          /tj02 (id = 1, state = 0x0)
        Storage path # 2:          /tj02 (id = 2, state = 0x0)

db2start

db2 restore db tj02 from . on /tj02                                                 # the ON option tells DB2 to change the storage path

db2 update db cfg for tj02 using HADR_LOCAL_HOST rhel67b HADR_LOCAL_SVC 38011 HADR_REMOTE_HOST rhel67a HADR_REMOTE_SVC 38010 HADR_REMOTE_INST db2inst6 HADR_TIMEOUT 120 HADR_PEER_WINDOW 120 LOGINDEXBUILD yes

db2 start hadr on db tj02 as standby

# rhel67a (primary)

db2 start hadr on db tj02 as primary

db2 activate db tj02

db2pd -db tj02 -storagepaths

Storage Group Paths:
Address            SGID  PathID    PathState    PathName
0x00007F23FBCDA000 0     0         InUse        /tj02
0x00007F23FBCDC000 0     1         InUse        /tj02
0x00007F23FBCDD000 0     2         InUse        /tj02

db2pd -db tj02 -tables

Containers:
Address            TspId ContainNum Type    TotalPgs   UseablePgs PathID     StripeSet  Container
0x00007F23FC698120 0     0          File    10912      10908      0          0          /tj02/db2inst6/NODE0000/TJ02/T0000000/C0000000.CAT
0x00007F23FC698350 0     1          File    10912      10908      1          0          /tj02/db2inst6/NODE0000/TJ02/T0000000/C0000001.CAT
0x00007F23FC698580 0     2          File    10912      10908      2          0          /tj02/db2inst6/NODE0000/TJ02/T0000000/C0000002.CAT
0x00007F23FC6D4000 1     0          Path    1          1          0          0          /tj02/db2inst6/NODE0000/TJ02/T0000001/C0000000.TMP
0x00007F23FC6D4230 1     1          Path    1          1          1          0          /tj02/db2inst6/NODE0000/TJ02/T0000001/C0000001.TMP
0x00007F23FC6D4460 1     2          Path    1          1          2          0          /tj02/db2inst6/NODE0000/TJ02/T0000001/C0000002.TMP
0x00007F23FC690800 2     0          File    2720       2688       0          0          /tj02/db2inst6/NODE0000/TJ02/T0000002/C0000000.LRG
0x00007F23FC690A30 2     1          File    2720       2688       1          0          /tj02/db2inst6/NODE0000/TJ02/T0000002/C0000001.LRG
0x00007F23FC690C60 2     2          File    2720       2688       2          0          /tj02/db2inst6/NODE0000/TJ02/T0000002/C0000002.LRG
0x00007F23FC68B440 3     0          File    2728       2724       0          0          /tj02/db2inst6/NODE0000/TJ02/T0000003/C0000000.LRG
0x00007F23FC68B670 3     1          File    2728       2724       1          0          /tj02/db2inst6/NODE0000/TJ02/T0000003/C0000001.LRG
0x00007F23FC68B8A0 3     2          File    2728       2724       2          0          /tj02/db2inst6/NODE0000/TJ02/T0000003/C0000002.LRG

# rhel67b (standby)

db2pd -db tj02 -storagepaths

Storage Group Paths:
Address            SGID  PathID    PathState    PathName
0x00007FC3CD073000 0     0         InUse        /tj02

db2pd -db tj02 -tables

Containers:
Address            TspId ContainNum Type    TotalPgs   UseablePgs PathID     StripeSet  Container
0x00007FC3CDA2EC40 0     0          File    32728      32724      0          0          /tj02/db2inst3/NODE0000/TJ02/T0000000/C0000000.CAT
0x00007FC3CDA6B000 1     0          Path    1          1          0          0          /tj02/db2inst3/NODE0000/TJ02/T0000001/C0000000.TMP
0x00007FC3CDA2FCC0 2     0          File    8096       8064       0          0          /tj02/db2inst3/NODE0000/TJ02/T0000002/C0000000.LRG
0x00007FC3CDA27340 3     0          File    8176       8172       0          0          /tj02/db2inst3/NODE0000/TJ02/T0000003/C0000000.LRG

 

At the beginning, the difference of tablespace containers on primary and standby databases do not seem to be a big trouble. HADR takeover could execute without issue.

But it could lead to potential issue when any storage group/tablespace/container is managed from the primary database where the difference on the standby is ignored sometime.

 

 

 

 

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSEPGG","label":"DB2 for Linux, UNIX and Windows"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

UID

ibm13286185