GoldenGate for DB2 on zos GoldenGate for DB2 on zos Objective Upon completion of this lesson, you will be able to configure GoldenGate to provide DB2 synchronization on a zos platform. During this lesson, you will learn how to: Prepare your user environment. Configure and execute the initial data synchronization process. Configure and start the change capture process of database operations. Configure and start the change delivery process of database operations. DB2 zos configuration The following diagram illustrates the configuration for capturing changes from a zos database and replicating them to a zos database. zos server <source> zos <target> DB2 <datasource> Source <owner/schema> Manager Network Manager Log Extract Collector Trails DB2<datasource> Replicat Target <owner/schema> Page 1
GoldenGate for DB2 on zos Overview of Tasks Prepare the Environment In order to execute this lesson, the GoldenGate application must be installed on both the source and target systems. The installation includes a sample database and scripts to generate initial data as well as subsequent update operations. The source and target tables are created and loaded with initial data. The GoldenGate Manager processes are also started so that other processes may be configured and started. Configure Initial Data Synchronization Initial database synchronization is almost always required. GoldenGate provides the ability to perform initial data synchronization while your application remains active. This lesson demonstrates using Extract to pull data from the source files and send it directly to the Replicat component on the target system. zos <source> server zos server <target> <datasource> Network <datasource> Source <owner/schema> Initial Extract Replicat Target <owner/schema> Configure Change Capture For log-based DB2, Extract captures database changes directly from the DB2 logs and distributes them to files known as GoldenGate trails. Configure Change Delivery Once the tables have been initially loaded with data, the Delivery process is configured to deliver the captured change data into the target database. Page 2
Prepare the Environment Exercise 1. Prepare the Environment Objective The goals of this exercise are to: Configure and start the Manager processes Prepare source and target sample databases Configure database connections Prepare the source DB2 environment 1. Configure the Manager process on the source Execute the following commands on the <source> system. Start the command interface Shell> cd <install location> Shell> ggsci Specify the port that the Manager should use. GGSCI> EDIT PARAMS MGR GoldenGate Manager Parameter file PORT <port> Start Manager GGSCI> START MANAGER GGSCI> INFO MANAGER 2. Create source tables and load with initial data Execute the following commands on the <source> system. Execute the scripts demo_db2_create_os390.sql and demo_db2_insert.sql to create the source tables and load with data. Shell> odb2 tf demo_db2_create_os390.sql Shell> odb2 tf demo_db2_insert.sql Page 3
Prepare the Environment Shell> odb2 odb2> select * from TCUSTMER; odb2> select * from TCUSTORD; odb2> exit Prepare your DB2 target environment 1. Configure the Manager process on the target system Execute the following commands on the <target> system. Start the command interface Shell> cd <install location> Shell> ggsci Specify the port that the Manager should use. GGSCI> EDIT PARAMS MGR GoldenGate Manager Parameter file PORT <port> Start Manager GGSCI> START MANAGER GGSCI> INFO MANAGER 2. Create target DB2 tables Execute the following commands on the <target> system. Execute the script demo_db2_create_os390.sql to create the source tables. Shell> odb2 tf demo_db2_create_os390.sql Shell> odb2 odb2> select * from TCUSTMER; odb2> select * from TCUSTORD; odb2> exit Page 4
Initial Data Load Exercise 1. Initial Data Load Objective The goals of this exercise are to: Configure the initial load capture task. Configure the delivery of the data to the target system. Execute and verify the initial load of data. Configure initial load capture 1. Add the initial load Extract batch task group Execute the following commands on the <source> system to create an Extract process called EINI<unique id> 1. GGSCI> ADD EXTRACT EINI<unique id>, SOURCEISTABLE GGSCI> INFO EXTRACT *, TASKS 2. Configure the initial load Extract parameter file Execute the following commands on the <source> system to create an initial load Extract parameter file with the listed parameters. GGSCI> EDIT PARAMS EINI<unique id> 11 The process names used in lab exercises, for example EINIBD1, are made up of 1) one character to identify the type of process (E for Extract, R for Replicat); 2) three characters to describe the type of process (INI for initial data load, ORA for capture from or delivery to an Oracle database, etc.) and 3) three characters usually made up of the student s initials plus a sequential number to uniquely identify multiple occurrences of that type of process. Page 5
Initial Data Load GoldenGate Initial Data Capture for TCUSTMER and TCUSTORD EXTRACT EINI<unique id> SOURCEDB <datasource>, USERID <login>, PASSWORD <password> RMTHOST <target>, MGRPORT <port> RMTTASK REPLICAT, GROUP RINI<unique id> TABLE <owner/schema>.tcustmer; TABLE <owner/schema>.tcustord; GGSCI> EXIT Configure initial load delivery 3. Configure the initial load Replicat parameter file Execute the following commands on the <target> system to create the initial load Replicat parameter file with the listed parameters. GGSCI> EDIT PARAM RINI<unique id> Type in the following parameters: GoldenGate Initial Load Delivery for TCUSTMER REPLICAT RINI<unique id> TARGETDB <datasource>, USERID <login>, PASSWORD <password> ASSUMETARGETDEFS MAP <owner/schema>.tcustmer, TARGET <owner/schema>.tcustmer; MAP <owner/schema>.tcustord, TARGET <owner/schema>.tcustord; 4. Add the initial load Replicat batch task group Execute the following commands on the <target> system. GGSCI> ADD REPLICAT RINI<unique id>, SPECIALRUN GGSCI> INFO REPLICAT *, TASKS 5. Execute the initial load process Execute the following commands on the <source> system. GGSCI> START EXTRACT EINI<unique id> Page 6
Initial Data Load GGSCI> VIEW REPORT EINI<unique id> On the <target> system: GGSCI> VIEW REPORT RINI<unique id> Page 7
Configure Change Capture Exercise 2. Configure Change Capture Objective The goals of this exercise are to: Add the Extract process that will capture changes. Add the trail that will store the changes. Start the Extract process. Configure change capture 1. Add the Extract group Execute the following commands on the <source> DB2 system to create the Extract group. GGSCI> ADD EXTRACT EDB2<unique id>, TRANLOG <bsds>, BEGIN NOW GGSCI> INFO EXTRACT EDB2<unique id> 2. Create the Extract parameter file Execute the following commands on the <source> system. GGSCI> EDIT PARAM EDB2<unique id> Change capture parameter file to capture TCUSTMER and TCUSTORD changes EXTRACT EDB2<unique id> SOURCEDB <datasource>, USERID <login>, PASSWORD <password> RMTHOST <target>, MGRPORT <port> RMTTRAIL./dirdat/<trail id> TABLE <owner/schema>.tcustmer; TABLE <owner/schema>.tcustord; Note: Record the two characters selected for your <trail id>:. You will need this in the next step and when you set up the Replicat. Close the parameter file and verify the results. GGSCI> VIEW PARAMS EDB2<unique id> Page 8
Configure Change Capture 3. Define the GoldenGate trails Execute the following on the <source> system. GGSCI> ADD RMTTRAIL./dirdat/<trail id>, EXTRACT EDB2<unique id>, MEGABYTES 5 GGSCI> INFO RMTTRAIL * 4. Start the capture process Execute the following on the <source> system. GGSCI> START EXTRACT EDB2<unique id> GGSCI> INFO EXTRACT EDB2<unique id>, DETAIL GGSCI> VIEW REPORT EDB2<unique id> Discussion Points 1. Identifying a remote system What parameter is used to identify the remote target system? 2. Sizing the GoldenGate trail Where do you set how large a GoldenGate trail file may get before it rolls to the next file? What option do you use? Page 9
Configure Change Delivery Exercise 3. Configure Change Delivery Objective The goals of this exercise are to: Set up the checkpoint table on the target system. Create a named group that includes the Replicat process and the checkpoint tables. Configure the Replicat group by adding parameters. Start the Replicat group. Set up the checkpoint table 1. Create a GLOBALS file on the target system Execute the following commands on the <target> system. Create and edit the GLOBALS parameter file to add the checkpoint table. Shell> cd <install location> Shell> ggsci GGSCI> EDIT PARAMS./GLOBALS In the text editor, type: CHECKPOINTTABLE <owner/schema>.ggschkpt Record the checkpoint table owner and name, then save and close the file. Table owner name Note: You could name the table anything you want, but for training purposes we are using ggschkpt. Verify that the GLOBALS file was created in the root GoldenGate directory, and remove any file extension that was added. 2. Activate the GLOBALS parameters For the GLOBALS configuration to take effect, you must exit the session in which the changes were made. Execute the following command to exit GGSCI. GGSCI> EXIT Page 10
Configure Change Delivery 3. Add a Replicat checkpoint table On the <target> system, execute the following commands in GGSCI: Shell> cd <install location> Shell> ggsci GGSCI> DBLOGIN SOURCEDB <datasource>, USERID <login>, PASSWORD <password> GGSCI> ADD CHECKPOINTTABLE Configure Change Delivery 4. Add the Replicat group Execute the following command on the <target> system to add a delivery group named RDB2<unique id>. GGSCI> ADD REPLICAT RDB2<unique id>, EXTTRAIL./dirdat/<trail id> Note: Refer to your Extract set up for the correct two-character <trail id>. 5. Create Replicat parameter file Execute the following commands on the <target> system to bring up the parameter file in the editor. GGSCI> EDIT PARAM RDB2<unique id> Type in the following parameters Change Delivery parameter file to apply TCUSTMER and TCUSTORD Changes REPLICAT RDB2<unique id> TARGETDB <datasource>, USERID <login>, PASSWORD <password> HANDLECOLLISIONS ASSUMETARGETDEFS DISCARDFILE./dirrpt/RDB2<unique id>.dsc, PURGE MAP <owner/schema>.tcustmer, TARGET <owner/schema>.tcustmer; MAP <owner/schema>.tcustord, TARGET <owner/schema>.tcustord; 6. Start the Replicat process GGSCI> START REPLICAT RDB2<unique id> GGSCI> INFO REPLICAT RDB2<unique id> Page 11
Configure Change Delivery Discussion points Search in the Windows/UNIX Reference Guide for the information on the following questions. 1. When to use HANDLECOLLISIONS When would you use HANDLECOLLISIONS? What does it do? 2. When to use ASSUMETARGETDEFS What should be the same on the source and target when ASSUMETARGETDEFS is used? 3. What is the purpose of the DISCARDFILE? Page 12
Generate Activity and Verify Results Exercise 4. Generate Activity and Verify Results Objective The goals of this exercise are to: Execute miscellaneous update, insert, and delete operations on the source system. Verify the delivery of the changes to the target. Turn off the error handling used for the initial load. Generate database operations 1. Execute miscellaneous update, insert, and delete operations Execute the following commands on the <source> system. Shell> cd <install location> Shell> odb2 tf demo_db2_misc.sql Verify change capture and delivery 2. Verify your results on the source system Execute the following commands on the <source> system. Shell> odb2 odb2> select * from TCUSTMER; odb2> select * from TCUSTORD; odb2> exit Shell> ggsci GGSCI> SEND EXTRACT EDB2<unique id>, REPORT GGSCI> VIEW REPORT EDB2<unique id> 3. Verify your results on the target system Execute the following commands on the <target> system to verify the target data. Shell> cd <install location> Shell> odb2 odb2> select * from TCUSTMER; odb2> select * from TCUSTORD; odb2> exit Page 13
Generate Activity and Verify Results Shell> ggsci GGSCI> SEND REPLICAT RDB2<unique id>, REPORT GGSCI> VIEW REPORT RDB2<unique id> Turn off error handling 4. Turn off initial load error handling for the running delivery process GGSCI> SEND REPLICAT RDB2<unique id>, NOHANDLECOLLISIONS 5. Remove initial load error handling from the parameter file GGSCI> EDIT PARAMS RDB2<unique id> Remove the HANDLECOLLISIONS parameter. Page 14
Exercise Name 15