SAP System Copy With Db2 For Z - OS - Cookbook
SAP System Copy With Db2 For Z - OS - Cookbook
Cookbook
Version: 17-September-2019
www.sap.com/contactsap
1 INTRODUCTION ............................................................................................................................................... 6
1.1 Scope ................................................................................................................................................................ 6
1.2 Documentation................................................................................................................................................... 6
2 FASTLOAD AND ZLOAD WITH DB2 FOR Z/OS .............................................................................................. 7
2.1 Motivation .......................................................................................................................................................... 7
2.2 Prerequisites ...................................................................................................................................................... 7
2.3 Fastload ............................................................................................................................................................. 7
2.4 zLoad ................................................................................................................................................................. 8
2.5 Known Issues .................................................................................................................................................... 9
3 PREPARATION PHASE .................................................................................................................................. 10
3.1 Verifying the SAP Maintenance Level .............................................................................................................. 10
3.2 Deleting Obsolete Data and Objects................................................................................................................ 10
3.3 Identifying the Target Database ....................................................................................................................... 10
3.4 Changing the Db2 Parameter Settings ............................................................................................................ 11
3.5 Preparing for a Unicode Conversion ................................................................................................................ 11
3.6 Handling Table Storage Attributes ................................................................................................................... 11
3.7 Creating SQL Files .......................................................................................................................................... 11
4 EXPORT PHASE ............................................................................................................................................. 14
4.1 Getting SWPM ................................................................................................................................................. 14
4.2 Setting up File Systems ................................................................................................................................... 14
4.3 Preparing Table Splitting ................................................................................................................................. 14
4.4 Configuring the Database Instance Export ...................................................................................................... 16
4.5 Configuring Parameters for Splitting Tool ........................................................................................................ 17
4.6 Setting General Unload Parameters ................................................................................................................ 18
4.7 Updating Database Statistics ........................................................................................................................... 19
4.8 Executing the Export ........................................................................................................................................ 19
5 IMPORT PHASE.............................................................................................................................................. 20
5.1 Setting Up File Systems .................................................................................................................................. 20
5.2 Setting of Environment Variables..................................................................................................................... 20
5.3 Starting SWPM ................................................................................................................................................ 20
5.4 Merging Packages ........................................................................................................................................... 20
5.5 Moving through the SWPM Dialog Panels ....................................................................................................... 21
5.6 Reviewing the Import Parameter Summary ..................................................................................................... 21
5.7 Executing the Import ........................................................................................................................................ 21
6 MANUALLY STARTING THE MIGRATION MONITOR ................................................................................... 23
6.1 Choosing the SWPM Option ............................................................................................................................ 23
6.2 Waiting for SWPM Prompt ............................................................................................................................... 23
6.3 Logging On to the SAP NetWeaver Application Server ................................................................................... 24
6.4 Adjusting Migration Monitor Properties ............................................................................................................ 24
6.5 Starting the Monitor ......................................................................................................................................... 25
6.6 Restart the Monitor .......................................................................................................................................... 25
6.7 Finalizing SWPM ............................................................................................................................................. 25
7 SPECIFICS OF THE FASTLOAD PROCEDURE ............................................................................................ 26
7.1 Environment Variables..................................................................................................................................... 26
7.2 Creating the FTP Parameter File ..................................................................................................................... 27
7.3 Troubleshooting ............................................................................................................................................... 27
3
8 SPECIFICS OF THE ZLOAD PROCEDURE ................................................................................................... 29
8.1 Environment Variables..................................................................................................................................... 29
8.2 Troubleshooting ............................................................................................................................................... 29
9 APPENDIX....................................................................................................................................................... 30
9.1 Helpful SAP Notes ........................................................................................................................................... 30
9.2 List of Figures and Tables ............................................................................................................................... 31
4
Applies to:
SAP ABAP system copies targeting Db2 for z/OS. The techniques that are presented apply to Unicode
conversions, homogeneous system copies and database migrations.
Summary
This documentation is a technical guideline to copy SAP ABAP systems to Db2 for z/OS with a special focus
on downtime reduction. Furthermore, it provides detailed instructions on how to utilize the Fastload feature
(Db2 11) and zLoad feature (Db2 12).
Authors: Joachim Rese (IBM), Christian Brasse (SAP), Bernd Kohler (SAP)
Created on: 5-Oct-2010
Updated on: 17-Sep-2019
Author Bio
Joachim Rese is a software engineer at the IBM Böblingen Laboratory in Germany. He is a member of the
joint SAP on IBM Z platform team and has over 20 years of experience in the field of SAP on IBM Z. Joachim
holds degrees in mathematics and computer science from the University of Paderborn in Germany.
Christian Brasse joined SAP SE in 1999. Within the SAP on IBM Z porting team he is responsible for the
installation tools. He graduated from University of Paderborn in Germany.
Dr. Bernd Kohler has been with SAP SE since 1996. He heads the SAP on IBM Z platform team (jointly with
IBM’s Thomas Raith). Before becoming manager, he worked in a variety of development areas related to the
integration of SAP with IBM Z and Db2 for z/OS, in particular life-cycle management tools and downtime
minimization technologies. He holds a Ph.D. in theoretical physics.
Acknowledgement
Thanks to the following people. This documentation would not be possible without their contribution.
• Thomas Vogt, SAP SE
• Dr. Burkhard Diekmann, SAP SE
• Bernhard Glaser, SAP SE
• Jennifer Johnson, SAP SE
• Jörg Maier, SAP SE
• Johannes Schützner, formerly IBM Deutschland Research & Development GmbH
• Hung Nguyen, formerly Handl Technology Inc
5
1 INTRODUCTION
1.1 Scope
This documentation is a technical guideline for copying an SAP ABAP system to Db2 for z/OS as part of a
homogeneous system copy, system migration or Unicode conversion. It contains tips and tricks on how to
reduce the downtime to a minimum.
The scope of this documentation covers the export and import phases. Note that in particular a Unicode
conversion requires many more steps, in particular if the source system supports multiple languages. These
steps are not covered in this documentation. For more information related to Unicode, see section 1.2.
1.2 Documentation
The SAP System Copy Guide for your system and information about Unicode are available here:
• Search “System Copy - Target Databases Other than SAP HANA” at help.sap.com
• SAP Note 1738258
• SAP Globalization Services at https://support.sap.com/globalization → Unicode
This cookbook does not replace the above-mentioned documentation. Therefore, be sure to download and
consult the latest version of all relevant guides before starting out.
6
2 FASTLOAD AND ZLOAD WITH DB2 FOR Z/OS
2.1 Motivation
Per default, SAP’s System Copy using the Software Provisioning Manager (SWPM) employs SQL INSERT
for loading the exported data into the target database instance. The method requires frequent SQL COMMIT.
This is rock solid and best suited for small to medium sized systems (typically with up to 2 TB of data).
However, for larger systems SQL INSERT of mass data can take very long and heavily consume logging
volume space. Therefore, alternative load methods are preferable. For Db2 for z/OS, two technologies have
been integrated within the SAP kernel for exploitation by SWPM:
• Fastload – available for Db2 11 and introduced in section 2.3 “Fastload”
• zLoad – based on Db2 12 and introduced in section 2.4 ”zLoad”
2.2 Prerequisites
The following prerequisites must be met to use the Fastload/zLoad features described in the document:
• Target database: Db2 Version 11 or 12 (Db2 10 is out-of-service!)
• NetWeaver 7.00 and higher (ABAP stack)
• SAP kernel release 7.21 and higher
• See the following SAP Notes for latest information:
• Fastload: SAP Note 1062976
• zLoad: SAP Note 2837836
• Check Section 2.5 for known bugs
2.3 Fastload
The feature Fastload has been provided by SAP and IBM since Q3 2007. It is an extension to the standard
SAP system copy process. Using this feature, tables are populated by the Db2 LOAD utility instead of SQL
INSERT operations. As a result, elapsed time during import phase can be reduced considerably.
Furthermore, data can be loaded in compressed format and massive logging activity is avoided. An
additional advantage is that the Db2 LOAD utility builds indexes very quickly.
In Q4 2008 two major enhancements were introduced: Exploitation of z/OS Unix System Services (USS)
named pipes and trusted record format.
The technical details of Fastload are depicted in Figure 1. If the table size exceeds a given threshold, R3load
does not use SQL INSERT to put data into Db2. Instead, data is converted into a format that can be read by
the Db2 LOAD utility. Using ftp that data is transferred into named pipes in the z/OS Unix System Services
(z/OS USS) area of the database host. In a parallel process, the Db2 LOAD utility (started by DSNUTILU)
reads that data from the named pipes and loads it into the table. For both tasks, R3load forks into processes
running the tool db2radm which is part of the SAP kernel.
7
Figure 1: Schematic Overview of Fastload (showing a Unicode conversion)
2.4 zLoad
With Db2 12, zLoad has been introduced. It shares the basic concepts of Fastload, e.g. the usage of the Db2
LOAD utility, but the setup has been heavily simplified, as setting up of named pipes and ftp is no longer
required (refer to Figure 2 for a schematic overview). Instead, data transfer and process control are managed
by Db2 Connect.
zLoad became available with Db2 Version 12 and SWPM 1.0 SP26. All application server platforms are
supported: AIX, Linux (x86, Power Little Endian, IBM Z) and Windows.
We highly encourage customers to use Db2 12 jointly with zLoad for their system copy projects.
8
Figure 2: Schematic Overview of zLoad (showing a Unicode conversion)
9
3 PREPARATION PHASE
10
o Run the CATMAINT utility and utilize option SCHEMA SWITCH. For more information, see the
SAP System Copy Guide for guidance.
• MGEXTSZ=YES
Note: Do not run ABAP Report SMIGR_CREATE_DDL (see section 3.7) before the preparation steps have
been successfully finished. Otherwise the layout of some pool tables might be incorrect in the target
system.
Note: You need to clean table DDSTORAGE before running report SMIGR_CREATE_DDL. Therefore, delete all
rows from table DDSTORAGE before you proceed.
Often storage attributes of tables are not optimal, for example the way that partitions are defined. If you want
some storage parameters in the target system to be different from the source system, modify and save these
within the database utility (transaction SE14). You should not adjust the database after saving the modified
storage parameters, since it would trigger a long running data conversion process. The saved modifications
are read by report SMIGR_CREATE_DDL that generates appropriate SQL DDL (data definition language)
statements (see section 3.7).
The technique described above is particularly helpful in the following cases:
• If you utilize Fastload/zLoad, you should turn secondary indexes on a partitioned table into DPSIs
(data partitioned secondary indexes). You should also turn the primary index into a DPSI. This
increases performance of the index build phase of the Db2 LOAD utility and also avoids the logging
that occurs when an NPI (non-partitioned index) is built.
• Some tables in the source system may have exceeded the 64GB limit and therefore have been
historically partitioned by ranged. With Db2 11 and higher partition-by-range is not necessary for
large tables anymore. Turn these tables into partition-by-growth tablespace (which can hold up to
128TB).
Please note, that if you do not change the storage attribute of a range partitioned table, the table will be
range partitioned in the target system, even though partition-by-growth is activated.
After report SMIGR_CREATE_DDL has run, you should delete the saved (but not activated) storage parameters
by deleting the corresponding records from table DDSTORAGE (either with database means or within
transaction SE14).
11
Note: If you do not carry out this step, all Db2 tables in the target system have default settings (not
partitioned, DSSIZE 4G, default bufferpool).
Note: This step must be performed immediately before downtime if the application utilizes SAP BW
technology, like BW, SRM and SEM. Otherwise system activity might change the layout of some
tables, thus the generated *.SQL files become obsolete and the import phase fails.
• In general, we recommend that you do not choose the option BI settings, thus all table
attributes are copied from source to target system.
12
4. Select Unicode Migration in the screen Additional Parameters and choose a directory to which the
<table category>.SQL files should be written. User <sid>adm must have the permission to write
into that directory.
5. If there is only a single table within a table category, enter the table name in the section Optional
Parameters. Otherwise specify a table category, but no table name. All tables in that table category
are checked for Db2-specific attributes.
6. You need to run this report for all tables / table categories with table attributes that you would like to
retain. If you specify neither a table category nor a table name, all tables are checked for Db2
specific table attributes. For each table category that has at least one table with Db2 specific
attributes, a <table category>.SQL file is written.
Note: We recommend that you specify neither a table category nor a table name and run the
report only once in order to generate all necessary <table category>.SQL files.
7. Since bufferpool assignments are copied, you must ensure that all relevant bufferpools are active in
the target system. Therefore, we recommend that you copy bufferpool settings from the source
system to the target system before the import phase is started.
13
4 EXPORT PHASE
• <EXPDIR> with free space of approximately 1/8 of the uncompressed database size.
Subsequently, execute the following option on the SWPM welcome screen:
<YOUR PRODUCT> → IBM Db2 for z/OS → System Copy → Source System → Based on
AS ABAP → Export Preparation
With this option, SWPM creates the directory structure <EXPDIR>/ABAP/…
Note: Fastload and zLoad do not support parallel processing of split tables that are not ranged partitioned.
In other words, non-partitioned split tables are processed by SQL INSERT processing.
Be sure to use the table splitting feature selectively. Split only those tables that tend to dominate the
aggregate elapsed time of either export or import phase. Tables that are candidates for splitting are the
following:
• Large tables
• Partitioned tables
• Tables with LOB columns and high export time
• Cluster tables (often have a high export elapsed time in Unicode conversion)
Note: Fastload does not support split tables with a LOB column. A split table with a LOB column is always
imported by SQL INSERT processing.
Note: Do not utilize table splitting if you cannot identify an appropriate candidate.
14
For each table that is split in n packages, the files <table name>-[1..n].WHR, must exist in directory
<EXPDIR>/ABAP/DATA. These files contain a WHERE condition that represents the content of a package. The
tool R3ta generates these files.
You proceed as follows to configure R3ta and run it via SWPM:
• You must create file <R3ta_input> in directory <SWPM_INSTDIR_EXP> that contains the line
<table name>%<number of packages>
for each non-partitioned table that is supposed to be split. Dependent on the data distribution, it is
possible that the actual number of packages created by R3ta differs from the number specified in file
<R3ta_input>.
The plus sign (+) instead of the percent (%) instructs R3ta to define packages according to partition
ranges. In other words, a partitioned table is split in a way that each package contains exact the data
of exactly one partition.
Ensure that <number of partitions> is indeed the number of partitions of the table. The following
SQL statement generates the necessary information for partition tables.
SELECT TAB.NAME || '+' || CHAR(COUNT(*))
FROM SYSIBM.SYSTABLES TAB,
SYSIBM.SYSTABLEPART PRT
WHERE TAB.DBNAME = PRT.DBNAME AND
TAB.TSNAME = PRT.TSNAME AND
PRT.PARTITION >= 1 AND
TAB.TYPE = 'T' AND
TAB.CREATOR = '<DB schema>'
GROUP BY TAB.NAME
HAVING COUNT(*) > 1
15
Figure 4: SWPM Dialog – Table Splitting Preparation
16
Figure 5: SWPM Dialog – SAP System Export for Target System
17
Figure 6: SWPM Dialog – Split STR Files
18
Figure 7: SWPM Dialog – Unload Settings
Note: A statistic update is not needed for the complete system if you run an unsorted unload as
recommended (Figure 7). Ensure however that the database statistics for all SAP cluster tables are
up-to-date.
19
5 IMPORT PHASE
This command merges all packages of each split table into a single package.
3. In case, some partitioned tables are extremely large and importing them within a single package
would dominate the elapsed time of the import phase, you should utilize the option –leaveTables to
exclude the corresponding packages from being merged:
java TOCFileMerger.jar –path <EXPDIR>/ABAP/DATA
–leaveTables HUGE_TAB1,HUGE_TAB2
20
5.5 Moving through the SWPM Dialog Panels
In generally, there is no need to start the Migration Monitor manually, in particular if it is the first test import.
Therefore, leave the related check box on panel SAP System Database unmarked (see Figure 8).
21
• To check the status of the export process, see file import_state.properties. This file contains the
import status per package. Each entry looks like
<package name>={0|+|-|?}
The package import is either not yet started (0), successful (+), unsuccessful (-), or currently
running (?).
To see the packages that are currently loading (Unix):
grep –e "=?" import_state.properties
• Only Fastload
For each package that is loaded with Fastload, the following files are written in the installation
directory:
fldlogs/<package name>.mkussfifo.<id>
fldlogs/<package name>.ftp.<id> and
fldlogs/<package name>.loader.<id>
Check file fldlogs/<package name>.ftp.<id> to verify that z/OS USS named pipes have been
utilized, for example:
[...]
This is db2radm executing file upload for loader.
[...]
FTP read :200 Representation type is Image
FTP read :local: | cat ATAB.32684 remote: /usr/temp/ATAB.P32684
FTP read :229 Entering Extended Passive Mode (|||3380|)
FTP read :125 Appending to named pipe /usr/temp/ATAB.P32684
FTP read :250 Transfer completed successfully.
FTP read :226960 bytes sent in 00:01 (122.77 KB/s)
FTP read :200 SITE command was accepted
FTP read :200 SITE command was accepted
Upload of file <ATAB.32684> to file /usr/temp/ATAB.P32684 is successful.
db2radm finished (0000)
db2radm stop:21.09.2019 12:30:11
For an overview on all tables that have been imported so far using Fastload (including start and end
time), see Db2 table DB2FLDPROT. A “D” in field STATUS indicates that the stored procedure that runs
the LOAD utility has finished without errors. (That does not imply that the LOAD utility has finished
successfully).
Note that the number of parallel jobs can be adjusted dynamically (parameter jobNum) within command file
import_monitor_cmd.properties while the import is running.
For troubleshooting, refer to Sections 7.3 (Fastload) and 8.2 (zLoad).
22
6 MANUALLY STARTING THE MIGRATION MONITOR
The following sections describe how to manually start the migration monitor. The related steps are very
similar for the two system copy scenarios Export and Import.
23
Figure 11: SWPM Dialog – Export ABAP
24
• Export: export_monitor_cmd.properties
• Import: import_monitor_cmd.properties
Refer to the SAP System Copy Guide for details on how to adjust these files. If system resources allow, the
number of parallel jobs (jobNum) can be considerably higher than the default 10. This is the most important
tuning parameter in reducing the elapsed time of the export and import phases.
Only Import with Fastload: Before starting the import monitor again, you should delete all old named pipes,
i.e. delete all files with naming schema <package name>.P<pid> from the USS directory specified by
environment variable dbs_db2_uss_dir.
25
7 SPECIFICS OF THE FASTLOAD PROCEDURE
dbs_db2_hlq <HLQ> Yes High level qualifier for temporary z/OS datasets
26
7.2 Creating the FTP Parameter File
To allow an FTP logon to the database host, a configuration file param.ftp is required. Also, a particular
kernel library (db2jcllib.*) is needed for the installation process.
Therefore, proceed as follows:
1. Logon in a separate session to the application server.
2. Switch to the installation directory: <SWPM_INSTDIR_IMP>/sapinst_instdir/…/AS-ABAP
3. Check the version of the db2radm tool by calling:
./db2radm -vl (Unix)
.\db2radm.exe -vl (Windows)
4. Download the matching version of db2jcllib.dll / db2jcllib.so / db2jcllib.o from the
SAP Software Center into the same directory.
5. Set the environment variables LD_LIBRARY_PATH (Linux), LIBPATH (AIX) or Path (Windows) to the
installation directory.
6. Execute the following command to created param.ftp:
./db2radm -m enc -s <DBHOST> -u <DB2_CONNECT_USER>
-p <DB2_CONNECT_USER_PASSWORD> -f param.ftp
The password must be surrounded by single quotes (') if it contains a special character.
7. Test the FTP connection using the command:
./db2radm –m tst –f param.ftp
7.3 Troubleshooting
Symptom: Bad performance due to slow sorting.
Solution: Increase number of sort work datasets for DFSORT. Spread these datasets over a high number of
volumes. Specify a higher number of sort work datasets at Db2 LOAD option SORTNUM by setting
environment variable R3LD_FLD_SORTNUM.
27
Symptom: Message in <package name>.loader.<ID>:
DSNUGDYN - ERROR ALLOCATING DATA SET
DSN=<HLQ>.<DB2 SUBSYSTEM>.<SAPSID>.<GUID>.<ID>.SYSUT1
Solution: In RACF dataset profile for '<HLQ>.**', add ALTER authority for user <DB2_CONNECT_USER>.
Solution: The process that writes into the USS named pipes gets a timeout if after 1 minute the reader
process has not read from the pipe. Increase the timeout value by setting the following
environment variables:
FIFOOPENTIME = 86400
FIFOIOTIME = 86400
28
8 SPECIFICS OF THE ZLOAD PROCEDURE
dbs_db2_hlq <HLQ> Yes High level qualifier for temporary z/OS datasets
8.2 Troubleshooting
Symptom: zLoad process terminates with the following message:
A1EEIMP 010 Task failed with error: (DBS) 'DBExeFastload' failed
A1EEIMP 010 (IMP) DbSlExeModify failed in insert for table '<tname>' with 99
A1EEIMP 010 (IMP) SQL error = -89989
Solution: See SAP Note 2813146. Copy the latest version of dbdb2slib.* to the installation directory
<SWPM_INSTDIR_IMP>/sapinst_instdir/…/SYSTEM/…/AS-ABAP
and continue SWPM with option Retry.
29
9 APPENDIX
General
1738258 System Copy for Systems Based on SAP NetWeaver - Using SWPM 1.0
Prepare / Export
Import
1062976 Fast load with Db2 LOAD utility and USS named pipes (FIFOs)
30
9.2 List of Figures and Tables
Figure 1: Schematic Overview of Fastload (showing a Unicode conversion) ................................................... 8
Figure 2: Schematic Overview of zLoad (showing a Unicode conversion) ....................................................... 9
Figure 3: Report SMIGR_CREATE_DDL ........................................................................................................ 12
Figure 4: SWPM Dialog – Table Splitting Preparation .................................................................................... 16
Figure 5: SWPM Dialog – SAP System Export for Target System ................................................................. 17
Figure 6: SWPM Dialog – Split STR Files ....................................................................................................... 18
Figure 7: SWPM Dialog – Unload Settings...................................................................................................... 19
Figure 8: SWPM Dialog – SAP System Database .......................................................................................... 21
Figure 9: SWPM Dialog – Parameter Summary .............................................................................................. 21
Figure 10: SWPM Dialog – Database Installation Method .............................................................................. 23
Figure 11: SWPM Dialog – Export ABAP ........................................................................................................ 24
Figure 12: SWPM Dialog – Import ABAP ........................................................................................................ 24
31