+ All Categories
Home > Documents > Adding, Dropping Storage Path(s) and Rebalancing Tablespaces...1. Take a tablespace snapshot and run...

Adding, Dropping Storage Path(s) and Rebalancing Tablespaces...1. Take a tablespace snapshot and run...

Date post: 03-Feb-2021
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
22
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 1 Adding, Dropping Storage Path(s) and Rebalancing Tablespaces Applies to: All SAP releases on DB2 9.7 for Linux, UNIX, and Windows. For more information, visit the Landscape Design and Architecture homepage . Summary One of the DB2 9.7 manageability enhancements with automatic storage supports removing storage paths from a database and rebalancing the tablespaces online. In this document, we provide step by step instructions on how to rebalance an automatic storage tablespace after storage paths have been added to or removed from a database. Some of the performance data is also provided based on the test done at our lab. Author: Cong Lin Company: IBM Canada Created on: 01 November 2009 Author Bio Cong Lin is a member of the IBM SAP Integration and Support Center at the IBM Toronto Lab. Her current activities include testing of SAP applications with DB2 for LUW and helping customers with problem analysis and troubleshooting. She is also a customer advocate, providing support for large customer accounts running SAP and DB2 LUW.
Transcript
  • SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 1

    Adding, Dropping Storage Path(s)

    and Rebalancing Tablespaces

    Applies to:

    All SAP releases on DB2 9.7 for Linux, UNIX, and Windows. For more information, visit the Landscape Design and Architecture homepage.

    Summary

    One of the DB2 9.7 manageability enhancements with automatic storage supports removing storage paths from a database and rebalancing the tablespaces online. In this document, we provide step by step instructions on how to rebalance an automatic storage tablespace after storage paths have been added to or removed from a database. Some of the performance data is also provided based on the test done at our lab.

    Author: Cong Lin

    Company: IBM Canada

    Created on: 01 November 2009

    Author Bio

    Cong Lin is a member of the IBM SAP Integration and Support Center at the IBM Toronto Lab. Her current activities include testing of SAP applications with DB2 for LUW and helping customers with problem analysis and troubleshooting. She is also a customer advocate, providing support for large customer accounts running SAP and DB2 LUW.

    http://www.sdn.sap.com/irj/sdn/landscapedesignhttp://www.sdn.sap.com/irj/sdn/landscapedesign

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 2

    Table of Contents

    1 Overview .......................................................................................................................................................... 3

    2 Preparation ...................................................................................................................................................... 4

    3 Step by Step Instructions ................................................................................................................................. 6

    3.1 Adding Storage Paths ............................................................................................................................... 6 3.1.1 Procedures ........................................................................................................................................................ 6

    3.1.2 Performance Data ............................................................................................................................................. 9

    3.2 Removing Storage Paths ........................................................................................................................ 10 3.2.1 Procedure ....................................................................................................................................................... 10

    3.2.2 Performance Data ........................................................................................................................................... 13

    3.3 Adding and Removing Storage Paths at the Same Time ....................................................................... 14 3.3.1 Procedure ....................................................................................................................................................... 14

    3.3.2 Performance Data ........................................................................................................................................... 14

    3.4 Rebalancing Tablespaces ....................................................................................................................... 15 3.4.1 Rebalance the Tablespaces ............................................................................................................................ 15

    3.4.2 Monitor the Status of the Rebalancing Process .............................................................................................. 16

    3.4.3 Throttling the Rebalancing Process (Optional) ................................................................................................ 18

    4 Other Considerations ..................................................................................................................................... 20

    5 Related Content ............................................................................................................................................. 21

    Disclaimer and Liability Notice .......................................................................................................................... 22

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 3

    1 Overview

    Automatic storage is a DB2 feature intended to make storage management easier. Databases that are enabled for automatic storage have a set of one or more storage paths associated with it. You can modify this set of storage paths using the ALTER DATABASE statement.

    In DB2 releases prior to DB2 9.7, you were only able to add storage paths to a database that was enabled for automatic storage. Once added, there was no possibility to remove them without bringing the database down and causing an outage. Newly added storage paths were also not immediately used by existing automatic storage tablespaces. Only if the disk space on the existing storage paths was full and existing tablespace containers could not be extended to accommodate the growth, the newly added storage paths was used. As a result, adding new storage paths alone could only address the issue of capacity. To improve the I/O parallelism as well, redirected restore is needed.

    As of DB2 9.7, you can immediately use any storage that you add to an automatic storage database by rebalancing the automatic storage tablespaces. Rebalancing initiates the creation of containers on recently added storage paths, reallocates the data across the new, expanded set of containers and stripe sets. Therefore, rebalancing after new storage paths have been added to the database improves I/O parallelism for the tablespaces. Also starting from DB2 9.7, you no longer need to perform a redirect restore to remove some existing storage paths. You can now online remove existing storage paths from database enabled for automatic storage.

    Following are the three user scenarios that take advantage of these new features in DB2 9.7:

    Adding storage paths and rebalancing automatic storage tablespaces

    Removing storage paths and rebalancing automatic storage tablespaces

    Adding and removing storage paths and rebalancing automatic storage tablespaces

    In this document, we provide a step by step guide on how to perform above storage management tasks and to illustrate the impact of adding and removing storage paths on automatic storage tablespaces.

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 4

    2 Preparation

    Before you start working on any of the three scenarios described in this document, make sure you read the following checklist:

    1. Check if you instance is at the correct level: DB2 9.7 GA and higher

    This document is meant for DB2 9.7 and higher. To check, run the db2level command.

    2. Check if your current database is already enabled for automatic storage.

    The following example shows a database that has not yet been enabled for automatic storage:

    saplp4: db2ax4> db2pd –db AX4 -storagepath

    Database Partition 0 -- Database AX4 -- Active -- Up 0 days 00:49:18

    Any value that does not equal 0 in the “Number of Storage Paths” indicates that the database is enabled for automatic storage. Take a note on how many storage paths your database has and continue with the next step.

    If your database has not yet enabled for automatic storage, see document “Enable Automatic Storage for Your SAP Database and Table Spaces” for details.

    3. Check if your tablespaces are already enabled for automatic storage.

    In this document, we also assume that all your permanent tablespaces are managed by automatic storage. If this is not the case, see document “Enable Automatic Storage for Your SAP Database and Table Spaces” for details.

    You can use following SQL command to check if table spaces are managed by automatic storage, A value “1‟ in the field TBSP_USING_AUTO_STORAGE indicates this table space is managed by automatic storage.

    SELECT SUBSTR(TBSP_NAME, 1,30) as TBSP_NAME, TBSP_USING_AUTO_STORAGE

    from TABLE(SNAP_GET_TBSP_V91('')) AS T

    saplp4: db2ax4> db2pd –db AX4 -storagepaths

    Database Partition 0 -- Database AX4 -- Active -- Up 0 days 00:49:18

    Database Storage Paths:

    Number of Storage Paths 0

    Database Storage Paths:

    TBSP_NAME TBSP_USING_AUTO_STORAGE

    ------------------------------ -----------------------

    PSAPTEMP16 1

    D97#ODSD 1

    D97#ODSI 1

    D97#DIMD 1

    D97#DIMI 1

    D97#FACTD 1

    D97#FACTI 1

    http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70da5b8c-d651-2c10-37ac-9eb76853d987http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70da5b8c-d651-2c10-37ac-9eb76853d987http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70da5b8c-d651-2c10-37ac-9eb76853d987http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70da5b8c-d651-2c10-37ac-9eb76853d987

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 5

    4. Get the new storage paths ready.

    If you plan to add new storage paths or move data from existing storage paths to new paths, make sure these new storage paths have been created. If you have a multi partition database, make sure these new storage paths exist on all partitions.

    5. Make sure that there is enough disk space available. This step is critical for a successful rebalance as described in the following:

    For adding new storage path case, since the new containers on the new storage paths must be created before the data could be moved, the tablespaces will have a much bigger total size during and after the rebalancing. Make sure the new storage paths have enough disk space to host the new containers for the data. For more information about the layout of a tablespace before and after it was rebalanced, see the Figure 1below.

    For example, if your tablespace currently has 4 containers over 2 existing storage paths (2 containers per path), you just add one more storage path to the database. Rebalancing this tablespace creates 2 new containers of the same size like those existing ones on the new storage path. If your tablespace has a size of approx. 100 GB, then 50 GB free space on the new storage path is needed for a successful rebalancing process. After the rebalancing is done, the size of the tablespace will be 150 GB. However, the high-water mark of the tablespace should stay the same as before the rebalancing process. You can reduce the total size of the tablespace using ALTER TABLESPACE… REDUCE statement.

    To drop a storage path, make sure that the rest of the existing storage paths have enough space to host the containers for existing data plus data from the dropped path. For more information about the layout of a rebalanced tablespace before and after the storage path was dropped, see Figure 2.

    Figure 1. Adding a storage path and rebalancing an automatic storage table space

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 6

    Figure 2. Dropping a storage path and rebalancing an automatic storage table space

    3 Step by Step Instructions

    3.1 Adding Storage Paths

    3.1.1 Procedures

    In this example, the original database was created on two storage paths (sapdata5 and sapdata6). Two more storage paths (sapdata7 and sapdata8) are added.

    1. Take a tablespace snapshot and run db2pd to keep a record of the starting status.

    In the following example, there are two storage paths in this database:

    saplp4: db2ax4>db2pd –d AX4 -storagepaths

    Database Partition 0 -- Database AX4 -- Active -- Up 5 days 02:25:28

    Database Storage Paths:

    Number of Storage Paths 2

    Address PathID PathState PathName

    0x078000024077CB20 0 InUse /db2/AX4/sapdata5

    0x078000024077C840 1 InUse /db2/AX4/sapdata6

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 7

    The following is an example of a tablespace snapshot for AX4#DDICD. Take note of the number and

    location of the containers. The tablespace map shows one stripe set.

    2. Add the storage paths using the following ALTER DATABASE statement:

    ALTER DATABASE ADD STORAGE ON [,,...,]

    Example:

    Note:

    After the new storage paths are added, they are not immediately used by the tablespaces. Run db2pd to check the status of all 4 database storage paths and note down the data in „PathState‟ column.

    saplp4: db2ax4> db2pd –db AX4 -storagepaths

    Database Partition 0 -- Database AX4 -- Active -- Up 5 days 02:47:09

    Database Storage Paths:

    Number of Storage Paths 4

    Address PathID PathState PathName

    0x078000024077CB20 0 InUse /db2/AX4/sapdata5

    0x078000024077C840 1 InUse /db2/AX4/sapdata6

    0x078000024D8EE5C0 4 NotInUse /db2/AX4/sapdata7

    0x078000024D81F560 5 NotInUse /db2/AX4/sapdata8

    alter database AX4 add storage on '/db2/AX4/sapdata7', '/db2/AX4/sapdata8';

    saplp4: db2ax4>db2 get snapshot for tablespaces on AX4

    Tablespace name = AX4#DDICD

    Total number of pages = 250368

    Number of used pages = 206844

    High water mark (pages) = 206844

    Number of containers = 2

    Container Name = /db2/AX4/sapdata5/db2ax4/NODE0000/AX4/T0000036/C0000000.LRG

    Container Name = /db2/AX4/sapdata6/db2ax4/NODE0000/AX4/T0000036/C0000001.LRG

    Table space map:

    Range Stripe Stripe Max Max Start End Adj. Containers

    Number Set Offset Extent Page Stripe Stripe

    [ 0] [ 0] 0 125181 250363 0 62590 0 2 (0,1)

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 8

    3. Identify all the tablespaces that should be striped across both existing and new paths. Assume that you want all your permanent tablespaces take advantage of the new storage paths right away. To determine all of the affected permanent tablespaces, you can manually scan the tablespace snapshot or using a SQL statement. The following SQL statement generates a list of all the regular and large automatic storage tablespaces in the database:

    4. Rebalance all the tablespaces provided in the previous step.

    To rebalance a table space, issue the following statement:

    Note:

    The rebalancing process might significantly impact your system performance. For more information, see section 3.4 “Rebalance the tablespaces” before kicking off any table spaces rebalance activity. Careful planning on

    when, how and which tablespace should be rebalanced at a certain time is important.

    5. Confirm that the rebalancing process for all affected tablespaces has finished. To check the number of containers and their locations for all affected tablespaces, take a tablespace snapshot. In the following example, the number of containers was increased from 2 to 4. There should be only one stripe set in the tablespace map.

    ALTER TABLESPACE REBALANCE;

    Tablespace name = AX4#DDICD

    Total number of pages = 500736

    Number of used pages = 206844

    High water mark (pages) = 206844

    Number of containers = 4

    Container Name = /db2/AX4/sapdata5/db2ax4/NODE0000/AX4/T0000036/C0000000.LRG

    Container Name = /db2/AX4/sapdata6/db2ax4/NODE0000/AX4/T0000036/C0000001.LRG

    Container Name = /db2/AX4/sapdata7/db2ax4/NODE0000/AX4/T0000036/C0000002.LRG

    Container Name = /db2/AX4/sapdata8/db2ax4/NODE0000/AX4/T0000036/C0000003.LRG

    Table space map:

    Range Stripe Stripe Max Max Start End Adj. Containers

    Number Set Offset Extent Page Stripe Stripe

    [ 0] [ 0] 0 250363 500727 0 62590 0 4 (0,1,2,3)

    SELECT TBSP_NAME FROM SYSIBMADM.SNAPTBSP WHERE TBSP_USING_AUTO_STORAGE=1

    AND TBSP_CONTENT_TYPE IN ('ANY','LARGE') ORDER BY TBSP_ID;

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 9

    6. Optionally, reduce the tablespace size if needed. In the above example, note down the “Total number of pages” and “High-water mark” fields of the tablespace AX4#DDICD and compare the values with those in step 1. You will notice that the high-water mark stays the same but that Total number of pages has been doubled. This is due to the fact that the size of two new containers (one on each new path) created at the start of the rebalance process is the same as those of the two existing containers. Once the tablespace has been rebalanced, you could optionally reduce the size of this tablespace by running following SQL statement: ALTER TABLESPACE REDUCE; Here is an example:

    3.1.2 Performance Data

    The following describes how performance data is collected for our test scenario. While the rebalancing process was running, there were not many other concurrent activities on the database system.

    The time needed to rebalance a tablespace with a similar size on your system might vary in your particular environment. This will be affected by the file system layout, the ratio of new paths to existing storage paths, other concurrent system activities and hardware, and so on. Start with only one small and one medium size tablespace, which is followed by a large tablespace. Use your own results as a reference to estimate how long it takes to rebalance each of the remaining tablespaces and schedule the rebalancing process for each tablespace accordingly.

    TableSpace Size Time Used for Rebalance

    41.7GB 4 hour 26 min

    4.0 GB 24 min

    alter tablespace AX4#DDICD reduce;

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 10

    3.2 Removing Storage Paths

    3.2.1 Procedure

    In following example, the current database has four storage paths: sapdata5, sapdata6, sapdata7, and sapdata8. Storage path sapdata5 and sapdata6 are going to be removed from the database as follows:

    1. Take a tablespace snapshot and run db2pd to keep a record of the starting status.

    2. Drop the storage paths with following ALTER DATABASE statement:

    Here is an example:

    Note: This action puts the mentioned storage paths in a “drop pending” state. Path(s) are not removed until all

    data on these storage paths are moved to other paths. To check the „Pathstate‟ column of all 4 storage paths,

    run db2pd.

    alter database drop storage on '/db2/AX4/sapdata5', '/db2/AX4/sapdata6'

    ALTER DATABASE DROP STORAGE ON ,,...,]

    db2pd –d AX4 -storagepaths

    Database Partition 0 -- Database AX4 -- Active -- Up 5 days 18:35:51

    Database Storage Paths:

    Number of Storage Paths 4

    Address PathID PathState PathName

    0x078000024077CB20 0 InUse /db2/AX4/sapdata5

    0x078000024077C840 1 InUse /db2/AX4/sapdata6

    0x078000024D8EE5C0 4 InUse /db2/AX4/sapdata7

    0x078000024D81F560 5 InUse /db2/AX4/sapdata8

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 11

    3. Identify all of the affected non temporary tablespaces that might have containers on the drop pending storage paths. You can either do this manually by scanning the output of the tablespace snapshot or by using an SQL statement. The following SQL statement generates a list of all the regular and large automatic storage tablespaces that have containers residing on a "Drop Pending" path:

    4. Rebalance all the tablespaces identified in step 3.

    To rebalance a table space, issue the following statement:

    Rebalancing these tablespaces moves the permanent data off the containers on the drop pending paths onto the remaining storage paths and then the empty containers are dropped.

    Note: The rebalancing process might have significant performance impact on your system. Before starting

    the rebalancing process for any tablespace, see section 3.4 “Rebalance the table spaces” for more information. It is important that you carefully plan when, how and which tablespace should be rebalanced at a certain point in time.

    5. Identify all affected temporary tablespaces. To determine the list of affected temporary table spaces, you can manually scan a tablespace snapshot output or you can execute a SQL statement. The following SQL statement generates a list of all the system temporary and user temporary automatic storage tablespaces in a database that have containers residing on a "Drop Pending" path:

    ALTER TABLESPACE REBALANCE;

    SELECT DISTINCT A.TBSP_NAME FROM SYSIBMADM.SNAPTBSP A, SYSIBMADM.SNAPTBSP_PART B WHERE A.TBSP_ID = B.TBSP_ID AND A.TBSP_CONTENT_TYPE IN ('USRTEMP','SYSTEMP') AND B.TBSP_PATHS_DROPPED=1

    db2pd –d AX4 –storagepaths

    -----------------------------

    Database Partition 0 -- Database AX4 -- Active -- Up 5 days 18:58:10

    Database Storage Paths:

    Number of Storage Paths 4

    Address PathID PathState PathName

    0x078000024077CB20 0 DropPending /db2/AX4/sapdata5

    0x078000024077C840 1 DropPending /db2/AX4/sapdata6

    0x078000024D8EE5C0 4 InUse /db2/AX4/sapdata7

    0x078000024D81F560 5 InUse /db2/AX4/sapdata8

    SELECT DISTINCT A.TBSP_NAME FROM SYSIBMADM.SNAPTBSP A, SYSIBMADM.SNAPTBSP_PART B WHERE A.TBSP_ID = B.TBSP_ID AND A.TBSP_CONTENT_TYPE IN ('ANY','LARGE') AND B.TBSP_PATHS_DROPPED = 1

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 12

    6. Move temporary tablespace off all “Drop Pending” paths if any exists

    In a standard SAP system database, there are two SMS temporary tablespaces: PSAPTEMP16 and SYSTOOLSTMPSPACE. If one of them has containers on the drop pending paths, you can either stop (deactivate) and start (activate) the database, which results in the containers being redefined. Alternatively, you can rename the existing temporary tablespace, re-create it on the correct paths and then drop the old temporary tablespace.

    The following is an example script that you can use to rename and re-create the tablespace. First, run the script recreate_tmptbs.sql and then runt the script drop_oldtmp.sql.

    Content of recreate_tmptbs.sql:

    Content of drop_oldtmp.sql

    Note: If you were not able to drop one of your old temporary tablespaces, it might still be used. Try to drop it

    at a later time.

    drop tablespace oldTEMP16;

    drop tablespace oldTOOLSTMPSPACE ;

    rename tablespace PSAPTEMP16 to oldTEMP16;

    rename tablespace SYSTOOLSTMPSPACE to oldTOOLSTMPSPACE;

    create temporary tablespace PSAPTEMP16

    in nodegroup IBMTEMPGROUP pagesize 16k extentsize 2 prefetchsize automatic

    no file system caching

    dropped table recovery off;

    create user temporary tablespace SYSTOOLSTMPSPACE

    in nodegroup IBMCATGROUP pagesize 16k extentsize 2 prefetchsize automatic

    no file system caching

    dropped table recovery off;

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 13

    7. Confirm that the dropped storage paths are no longer listed.

    Once there are no tablespaces actively using the storage path that were dropped, the paths are immediately removed from the database. To check, run db2pd again.

    Note: If at this step, the paths to be dropped are still listed as „Drop pending‟, then one or more tablespaces

    are still using it. In this case, repeat step 3 to step 6 to remove all the data from drop pending paths.

    3.2.2 Performance Data

    The following describes how performance data is collected for our scenario. While the rebalancing process was running, there were not many other concurrent activities on the database system.

    The time needed to rebalance a tablespace with a similar size on your system might vary in your particular environment. This will be affected by the file system layout, ratio of new paths to existing storage paths, other concurrent system activities and hardware, and so on. Start with only one small and one medium size tablespace, which is then followed by a large tablespace. Use your own results as a reference to estimate how long it takes to rebalance each of the remaining tablespaces and schedule the rebalancing process for each tablespace accordingly.

    Tablespace Size Time Used for Rebalance

    41.7 GB 7 hour 5 min

    4.0 GB 41 min

    saplp4: db2ax4>db2pd –d AX4 -storagepaths

    Database Partition 0 -- Database AX4 -- Active -- Up 6 days 10:10:33

    Database Storage Paths:

    Number of Storage Paths 2

    Address PathID PathState PathName

    0x078000024D8EE5C0 4 InUse /db2/AX4/sapdata7

    0x078000024D81F560 5 InUse /db2/AX4/sapdata8

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 14

    3.3 Adding and Removing Storage Paths at the Same Time

    3.3.1 Procedure

    You can add and drop storage path from the database using a single ALTER DATABASE statement or using multiple ALTER DATABASE statements that you issue at different points in time.

    To use a single SQL statement, enter the following:

    Here is an example:

    The rest of the procedure is the same as described in section 3.2 “Removing Storage Paths”. However, there is one difference that you have to be aware of: when you identify all the tablespaces for rebalancing, you need to include all regular and large automatic storage tablespaces instead of only the tablespaces residing on the “Drop pending” paths. The following SQL statement generates a list of all regular and large automatic storage tablespaces in the database:

    3.3.2 Performance Data

    The following describes how performance data is collected for our test scenario. The database started with two storage paths, a new path was added and an existing one was dropped. While the rebalancing process was running, there were not many other concurrent activities on the system.

    The time needed to rebalance a tablespace with a similar size on your system might vary in your particular environment. This will be affected by the file system layout, ratio of new paths to existing storage paths, other concurrent system activities and hardware, and so on. Start with only one small and one medium size tablespace, which is then followed by a large tablespace. Use your own results as a reference to estimate how long it takes to rebalance each of the remaining tablespaces and schedule the rebalancing process for each tablespace accordingly.

    Tablespace Size Time Used for Rebalance

    41.7 GB 4 hour 27 min

    4.0 GB 43 min

    SELECT DISTINCT TBSP_ID, TBSP_NAME FROM SYSIBMADM.SNAPTBSP

    WHERE TBSP_USING_AUTO_STORAGE = 1

    AND TBSP_CONTENT_TYPE IN ('ANY','LARGE') ORDER BY TBSP_ID

    alter database add storage on '/db2/AX4/sapdata3' drop '/db2/AX4/sapdata8';

    ALTER DATABASE ADD STORAGE ON […] DROP STORAGE ON

    [,,…]

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 15

    3.4 Rebalancing Tablespaces

    3.4.1 Rebalance the Tablespaces

    Once you have identified the tablespaces, the next step is to run the following statement for each of the listed tablespaces. Provided that there is sufficient space on the storage paths, it should not matter in what sequence the rebalances are performed. You can rebalance one tablespace at a time or a group of tablespaces in parallel. However, rebalancing has an impact of the performance of your system. Avoid rebalancing during system peak times and consider rebalancing really large tablespaces in smaller groups or individually. Alternatively, you could also use the throttling utility to limit the performance impact of rebalancing on your system. For more information, see section 3.4.3 “Throttling the Rebalance Process”.

    To rebalance a tablespace, issue the following SQL statement:

    Here is an example:

    It can be seen in the output of this command that the rebalancing job runs asynchronous in the background and does not affect the availability of the data.

    Alter tablespace AX4#ES700D rebalance;

    ALTER TABLESPACE REBALANCE;

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 16

    3.4.2 Monitor the Status of the Rebalancing Process

    To monitor the status, you could either run the “db2list utilities show detail” or take a tablespace snapshot.

    In example above, the tablespaces with ID 37 and 36 are still being rebalanced.

    Db2 list utilities show detail

    Here is an example output:

    ID = 6219

    Type = REBALANCE

    Database Name = AX4

    Partition Number = 0

    Description = Tablespace ID: 37

    Start Time = 04/27/2009 21:37:37.932471

    State = Executing

    Invocation Type = User

    Throttling:

    Priority = Unthrottled

    Progress Monitoring:

    Estimated Percentage Complete = 15

    Total Work = 22366 extents

    Completed Work = 3318 extents

    Start Time = 04/27/2009 21:37:37.932500

    ID = 6216

    Type = REBALANCE

    Database Name = AX4

    Partition Number = 0

    Description = Tablespace ID: 36

    Start Time = 04/27/2009 21:37:37.634176

    State = Executing

    Invocation Type = User

    Throttling:

    Priority = Unthrottled

    Progress Monitoring:

    Estimated Percentage Complete = 4

    Total Work = 103440 extents

    Completed Work = 4404 extents

    Start Time = 04/27/2009 21:37:37.634202

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 17

    As soon as the tablespace has been rebalanced, the “Rebalancer Mode” in the tablespace snapshot for this tablespace shows “No Rebalancing”. Otherwise, you see “DMS rebalancer is active” for that tablespace in the tablespace snapshot.

    In the following example, tablespace < SYSCATSPACE > has only one stripe set in the table space map after having been rebalanced:

    The rebalancing process is logged in the db2diag.log. You can calculate the time used to rebalance a tablespace based on these log entries:

    2009-04-07-17.59.31.665152-240 E1342A392 LEVEL: Info

    PID : 1298682 TID : 4379 PROC : db2sysc 0

    INSTANCE : db2ax4 NODE : 000

    EDUID : 4379 EDUNAME: db2rebal (AX4) 0

    FUNCTION : DB2 UDB, buffer pool services, sqlb_rev_rebalance, probe:10

    MESSAGE : ADM6058I Rebalancer for table space "AX4#ES700I" (ID "21") was

    started.

    ...

    2009-04-07-19.24.48.030229-240 E6339A396 LEVEL: Info

    PID : 1298682 TID : 4379 PROC : db2sysc 0

    INSTANCE : db2ax4 NODE : 000

    EDUID : 4379 EDUNAME : db2rebal (AX4) 0

    FUNCTION : DB2 UDB, buffer pool services, sqlb_rebalance, probe:2876

    MESSAGE : ADM6062I Rebalance for table space "AX4#ES700I" (ID "21") has been completed.

    Tablespace name = SYSCATSPACE

    Rebalancer Mode = No Rebalancing

    Number of containers = 2

    Container Name =

    /db2/AX4/sapdata7/db2ax4/NODE0000/AX4/T0000000/C0000000.CAT

    Container Name =

    /db2/AX4/sapdata8/db2ax4/NODE0000/AX4/T0000000/C0000001.CAT

    Table space map:

    Range Stripe Stripe Max Max Start End Adj. Containers

    Number Set Offset Extent Page Stripe Stripe

    [ 0] [ 0] 0 57269 114539 0 28634 0 2 (0,1)

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 18

    3.4.3 Throttling the Rebalancing Process (Optional)

    The database manager configuration parameter util_impact_lim sets the limit on the impact that throttled utilities can have on the overall workload of the machine. By default, parameter util_impact_lim is set to 10, which means all utilities combined can have no more than an impact of 10% average on the total workload as judged by the throttling algorithm. Value 100 indicates no throttling.

    To run in throttled mode, a utility must also be invoked with a non zero priority. You could use the SET UTIL_IMPACT_PRIORITY command to throttle a tablespace rebalancing process. To do so, you need to obtain the utility ID with the LIST UTILITIES command and to set the priority to a value. Here is the command:

    SET UTIL_IMPACT_PRIORITY FOR TO ;

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 19

    Here is an example:

    augsburg2:db2ax4 68> db2 list utilities show detail

    ID = 4

    Type = REBALANCE

    Database Name = AX4

    Partition Number = 0

    Description = Tablespace ID: 0

    Start Time = 05/28/2009 09:43:43.303254

    State = Executing

    Invocation Type = User

    Throttling:

    Priority = Unthrottled

    Progress Monitoring:

    Estimated Percentage Complete = 8

    Total Work = 49333 extents

    Completed Work = 3884 extents

    Start Time = 05/28/2009 09:43:43.303275

    augsburg2:db2ax4 69> db2 set UTIL_IMPACT_PRIORITY FOR 4 to 50

    DB20000I The SET UTIL_IMPACT_PRIORITY command completed successfully.

    augsburg2:db2ax4 70> db2 list utilities show detail

    ID = 4

    Type = REBALANCE

    Database Name = AX4

    Partition Number = 0

    Description = Tablespace ID: 0

    Start Time = 05/28/2009 09:43:43.303254

    State = Executing

    Invocation Type = User

    Throttling:

    Priority = 50

    Progress Monitoring:

    Estimated Percentage Complete = 17

    Total Work = 49333 extents

    Completed Work = 8150 extents

    Start Time = 05/28/2009 09:43:43.303275

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 20

    4 Other Considerations

    In a partitioned database environment, consider the following:

    If you add more storage paths to the database, the same set of storage paths must be used on each database partition (unless database partition expression is used). If the specified path does not exist on every database partition, the statement is rolled back.

    If you remove a storage path from the database, the path is maintained independently on each partition. Once a “Drop Pending” path is no longer in use on a given database partition, it is removed physically from that partition. On other partitions, it might still show the path as being in "Drop Pending" state.

    You have to issue the rebalancing command on every partition.

    If a storage path is added to a database multiple times, you also to be aware of the following: You can add a given storage path to a database multiple times. This will result in multiple containers on that path. If you are using the DROP STORAGE ON clause, specifying that particular path once drops all instances of the path from the database.

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 21

    5 Related Content

    For more information, see the SAP on DB2 for Linux, UNIX, and Windows Web page in the SAP Community Network.

    For more information, visit the Landscape Design and Architecture homepage.

    http://www.sdn.sap.com/irj/sdn/db6http://www.sdn.sap.com/irj/sdn/landscapedesign

  • Adding, Dropping Storage Path(s) and Rebalancing Tablespaces

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 22

    Disclaimer and Liability Notice

    This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

    SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

    SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.


Recommended