New approach for data migration using Redirected Recovery
As mentioned in many of my previous blog posts, we use
Redirected Recovery of Recovery Expert for migrating data from one Db2
sub-system to other sub-system.
We are facing some hurdles whenever we do data
migration using Redirected Recovery. Some
of the major hurdles are
- TAPE handling: All our Image copy datasets are written to TAPE with STACK YES option. Currently, Redirected Recovery is not able to generate the Recovery JCLs appropriately when the Image Copy datasets are on TAPE. I created RFE 114350 for the product to do upfront analysis on the objects (included for data migration) to ensure all the objects on the same TAPE are included in the same Recovery job.
- Data verification after migration: There is no simple approach for verifying that the data is copied properly from source database to target database.
I devised a new approach to overcome the hurdles. The new approach is lengthy in execution but makes the data migration process less painful.
1. Create
DISK backups
We may go with DISK backups even after
TAPE related problems are resolved as data migration will be faster with DISK
backups.
Even after excluding the objects with
structure mismatches, there are chances of data migration jobs failing due to
version mismatches. REPAIR CATALOG utility will be executed on the objects
failed due to version mismatches.
- Comparing source’s COPYPAGESF (from SYSCOPY) with target’s NACTIVE (from SYSTABLESPACESTATS)
I coded a SQL query that can compare source database with target database.
But, the results are not 100% accurate as COPY utility will not copy empty pages.
WITH
TSSTAT(NAME, NACTIVE, TYPE) AS
(SELECT
ST.NAME
,SUM(ST.NACTIVE)
,TS.TYPE
FROM SYSIBM.SYSTABLESPACESTATS ST
INNER JOIN
SYSIBM.SYSTABLESPACE TS ON
ST.DBNAME = TS.DBNAME AND
ST.NAME = TS.NAME
WHERE
ST.DBNAME = <target db> AND
TS.NTABLES > 0
GROUP BY ST.NAME, TS.TYPE)
,TSCOPY(NAME, COPYPAGES) AS
(SELECT
TSNAME
,SUM(COPYPAGESF)
FROM SYSIBM.SYSCOPY
WHERE
DBNAME = <source db> AND
ICDATE = 171226 AND
ICTYPE = 'F' AND
ICBACKUP <> 'LB'
GROUP BY TSNAME)
SELECT
TSSTAT.NAME
,TSSTAT.TYPE
,TSCOPY.COPYPAGES AS SRC_ICPAGES
,TSSTAT.NACTIVE AS TGT_TSPAGES
FROM
TSSTAT
INNER JOIN
TSCOPY ON
TSSTAT.NAME=TSCOPY.NAME
WHERE TSSTAT.NACTIVE <> TSCOPY.COPYPAGES;
- Comparing source’s CARDF (from SYSIBM.SYSTABLES_HIST) with target’s CARDF (from SYSIBM.SYSTABLES after RUNSTATS are done)
- Reading source’s SYSTABLESPACESTATS data into a personal Table on daily basis, and comparing the data in personal Table with target’s real-time stats data (when needed)
- Take backups of target after data migration is done, and compare source’s COPYPAGESF (from SYSCOPY) with target’s COPYPAGESF (from SYSCOPY)
We decided to go with the third idea as that is easy to implement.
8. Execute
RUNSTATS
No comments:
Post a Comment