Skip to main content

Db2 for z/OS initial setup for CDC

Db2 for z/OS system requirements

Performing CDC from Db2 for z/OS with Striim requires a Linux server to host the Db2 Connect client (with Db2 Connect license applied) and Striim Agent for Db2 for z/OS and, depending on your environment, possibly also PostgreSQL and Confluent. Kafka and curl must be installed.

Db2 for z/OS setup overview

The following are prerequisites for setting up CDC from Db2 for z/OS:

  1. Purchase a Striim Db2 for z/OS Support license. Striim will then procure you a Striim Agent for Db2 for z/OS license.

  2. Install the stored procedures provided by Striim in Db2 for z/OS.

    1. Transfer the program binaries (MVSLOAD.BIN) to the Mainframe server and perform a TSO Receive Operation.

    2. APF authorise the received Load library. ( This task may need to be executed with z/OS System Programmer or z/OS System Administrator personnel.)

    3. Define the Load library to the Db2 Application environment.

    4. Define the DB2 User defined function.

  3. Get Db2 Connect (see Db2 Connect overview) from IBM and install the Db2 client and IBM ODBC driver on the Linux host where you will install Striim Agent for Db2 for z/OS.

  4. Have an Oracle or PostgreSQL repository for use by Striim Agent for Db2 for z/OS. If the Striim metadata repository is hosted on Oracle or PostgreSQL, you can use that. Otherwise, we recommend installing PostgreSQL.

  5. Install the ODBC driver for the Oracle or PostgreSQL repository on the Linux host where you will install Striim Agent for Db2 for z/OS.

  6. Enable Striim's internal Kafka server.

  7. Install Confluent and enable its Schema Registry. (See Schema Registry for Confluent Platform.)

  8. In Db2 for z/OS, if any tables to be captured do not have primary keys, add them. (Striim Agent for Db2 for z/OS cannot capture change data from tables without primary keys.)

  9. In Db2 for z/OS, enable data capture flags.

  10. Populate the configuration file. This is required by the setup script in the next step.

  11. Run the script to Install, configure, and start Striim Agent for Db2 for z/OS.

  12. Create and deploy a Striim application including the Kafka-persisted stream to which Striim Connect will write the data captured by Striim Agent for Db2 for z/OS. The persisted stream details must be specified in the configuration file in the next step.

1. Purchase Striim Db2 for z/OS Support license

Contact Striim Sales to purchase Db2 for z/OS Support.

2. Install the stored procedures in Db2

This part of the setup requires expertise in IBM z/OS mainframe administration. It involves loading binary file(s) onto the mainframe and implementing (installing) the binary file(s) as datasets and load libraries on the mainframe. The load library contains JCL (Job Control Language) scripts, which will be called and used via the Db2 stored procedure. This is the stored procedure that will be added onto the Db2 database once the load library has been properly loaded onto the mainframe. Our recommendation is to have your mainframe administrator handle this setup. Alternatively, you may engage Striim professional services.

Contact Striim Support for detailed instructions for performing this step, which requires a z/OS terminal emulator.

After completing the mainframe setup, load the stored procedure by running the following command in the SQL command executor of your choice, replacing <environment name> with the name of your WLM application environment (for example, WLM ENVIRONMENT DBDGENVG.

CREATE FUNCTION TCVUDT_V7 (VARBINARY(300),VARBINARY(32000))
  RETURNS TABLE (OUTVALUE BLOB(200K))
PARAMETER CCSID EBCDIC
EXTERNAL NAME TCSD2UDT
LANGUAGE ASSEMBLE
PROGRAM TYPE SUB
STAY RESIDENT YES
CONTINUE AFTER FAILURE
WLM ENVIRONMENT <environment name>
RUN OPTIONS
'H(,,ANY),STAC(,,ANY,),STO(,,,4K),BE(4K,,),LIBS(4K,,),ALL31(ON)'
PARAMETER STYLE SQL
NO SQL
NO EXTERNAL ACTION
FENCED
SCRATCHPAD
FINAL CALL
DISALLOW PARALLEL;

3. Get and install Db2 client

Contact IBM to purchase Db2 Connect (see Db2 Connect overview). This includes support for secure SSL / TLS connections with Striim. IBM offers several distributions, including the full Client, Runtime Client, and the ODBC and CLI package. We recommend using the IBM Data Server Driver for ODBC and CLI version 11.5.9 (or a later version of 11.5, if available), as it is the most lightweight option and requires the least installation effort. You may download it from DB2 ODBC CLI driver Download and Installation information.

Perform the following steps on the Linux host where Striim Agent for Db2 for z/OS is installed.

  1. Create a directory for the installation of the IBM Data Server Driver for ODBC and CLI software.

    mkdir $HOME/db2_cli_odbc_driver
  2. Copy the IBM Data Server Driver for ODBC and CLI software (vxx_xx_odbc_cli.tar.gz) into the above directory.

    cp vxx_xx_odbc_cli.tar.gz $HOME/db2_cli_odbc_driver
  3. Extract the IBM Data Server Driver for ODBC and CLI.

    tar -xvf vxx_xx_odbc_cli.tar
  4. Export the following environment variables.

    export DB2_CLI_DRIVER_INSTALL_PATH=$HOME/db2_cli_odbc_driver/odbc_cli/clidriver
    export LD_LIBRARY_PATH=$HOME/db2_cli_odbc_driver/odbc_cli/clidriver/lib
    export LIBPATH=$HOME/db2_cli_odbc_driver/odbc_cli/clidriver/lib
    export PATH=$HOME/db2_cli_odbc_driver/odbc_cli/clidriver/bin:$PATH
    export PATH=$HOME/db2_cli_odbc_driver/odbc_cli/clidriver/adm:$PATH
  5. To connect to the Db2 for z/OS server, download the Db2 Connect license file db2consv_xx.lic and copy it to the license folder.

    $HOME/db2_cli_odbc_driver/odbc_cli/clidriver/license

To configure the driver with a new connection:

  1. Add the database.

    db2cli writecfg add -database <database name> -host <IP address> -port <port>
  2. Add the data source name (dsn).

    db2cli writecfg add -dsn db2z13 -database <database name> -host <IP address> -port <port>

You can then test the connection with the following command.

db2cli validate -dsn db2z13 -connect -user <user name> -passwd <password>

4. Select the Oracle or PostgreSQL instance to host the Striim Agent for Db2 for z/OS repository

Striim Agent for Db2 for z/OS requires an Oracle or PostgreSQL instance to host its repository. If your Striim instance's metadata repository is hosted on Oracle or PostgreSQL, you may use the same instance for Striim Agent for Db2 for z/OS's repository. Otherwise, if you do not have another Oracle or PostgreSQL instance available to host the Striim Agent for Db2 for z/OS repository, we recommend installing PostgreSQL (a free open-source DBMS). You may install it on the same Linux server you use to host Striim Agent for Db2 for z/OS. Create a new schema to hold the repository database.

Also install the ODBC driver for the repository database in the Striim Agent for Db2 for z/OS host. For Oracle, see DB2 ODBC CLI driver Download and Installation information. For PostgreSQL, use your Linux environment's package manager, such as yum or apt-get.

5. Install the ODBC driver for the repository

Install the ODBC driver for the Oracle or PostgreSQL repository on the Linux host where you will install Striim Agent for Db2 for z/OS.

6. Enable Striim's internal Kafka server

See Configuring Kafka for persisted streams.Configuring Kafka for persisted streams

We recommend using Striim's internal Kafka server, but alternatively you may use an external Kafka server.

In the Striim console or web UI, create a property set for the Kafka server similar to the following, using the IP address and port of Striim's internal Kafka server or your external Kafka server.

CREATE PROPERTYSET KafkaPropSet (
  bootstrap.brokers: '192.0.2.92:9092'
);

7. Enable the Confluent Schema Registry

Purchase and install Confluent Platform (see Install Confluent Platform On-Premisesand enable its Schema Registry (see Schema Registry for Confluent Platform).

  1. On the Linux server hosting Striim Agent for Db2 for z/OS, download the Confluent Schema Registry directly from the command line using the following command. Alternatively, download a specific version (7.6.1 or later) from Previous Versions and load it to the environment .

    curl -O https://packages.confluent.io/archive/7.6/confluent-7.6.1.tar.gz
  2. Extract the contents:

    tar -xvf confluent-7.6.1.tar.gz
  3. Adjust the Schema Registry configuration to reflect your Kafka setup by editing <Confluent root>/etc/schema-registry/schema-registry.properties.

  4. To start the Schema Registry, enter the following command in the Confluent root directory.

    bin/schema-registry-start etc/schema-registry/schema-registry.properties

8. Add primary keys

In Db2, if any tables to be captured do not have primary keys, add them. (Striim Agent for Db2 for z/OS cannot capture change data from tables without primary keys.) Note that the VARBINARY type is supported in composite primary keys only if it is the last column in the key.

9. Enable capture flags

In Db2, enable capture flags by executing the following command for each table to be captured:

ALTER TABLE <schema>.<table name> DATA CAPTURE CHANGES

10. Populate the Striim Agent for Db2 for z/OS configuration file

The setup script you will run in the next step requires a configuration file with the following contents. In this context, localhost is the system running Striim Agent for Db2 for z/OS.

Property name

Description

Syntax

Example(s)

LIBRDKAFKA_PATH

path to the Kafka shared object library for Linux

absolute file path to Kafka library (librdkafka.so)

/usr/lib/x86_64-linux-gnu/librdkafka.so.1

LIBCURL_PATH

path to the curl shared object library for Linux

absolute file path to CURL library (libcurl.so)

/usr/lib/x86_64-linux-gnu/libcurl.so.4

LICENSE_PATH

path to the Striim Agent for Db2 for z/OS license file (to be provided by Striim Support)

absolute file path to Striim Agent for Db2 for z/OS license file

/home/ubuntu/License.tcVLC

REPO

database type of the Striim Agent for Db2 for z/OS repository host

ORCL for Oracle Database or PSQL for PostgreSQL

PSQL

ORCL

REPO_HOST

Striim Agent for Db2 for z/OS repository database hostname

IP Address or hostname

localhost

192.168.0.5

REPO_PORT

Striim Agent for Db2 for z/OS repository database port

port number

1521

5432

REPO_DB

Striim Agent for Db2 for z/OS repository database name

database name

ORCL

postgres

REPO_ID

Striim Agent for Db2 for z/OS repository database user id

SQL ID for repository database

admin

postgres

REPO_SCHEMA

the name of the schema you created in step 4 to be used exclusively for the Striim Agent for Db2 for z/OS repository

repository database schema name

SA4DB2

HOSTNAME

host name of load-balancer-backed DNS or floating alias

network name

dns.load-balancer.db2.agent.striim.com

SHARED_PATH

local system path to mounted NFS for checkpoint data

path

/mnt/nfs/db2

Example configuration file

Example configuration file with PostgreSQL repository:

# -----------------------------
# Library Paths
# -----------------------------
LIBRDKAFKA_PATH=/usr/lib/x86_64-linux-gnu/librdkafka.so.1
LIBCURL_PATH=/usr/lib/x86_64-linux-gnu/libcurl.so.4
LICENSE_PATH=/home/ubuntu/License.tcVLC

# -----------------------------
# Repository Configuration
# -----------------------------
REPO=PSQL
REPO_HOST=localhost
REPO_PORT=5432
REPO_DB=postgres
REPO_ID=postgres
REPO_SCHEMA=rdrs

# -----------------------------
# High Availability Configuration
# -----------------------------
HOSTNAME=dns.load-balancer.db2.agent.striim.com
SHARED_PATH=/mnt/nfs/db2 

11. Run the Striim Agent for Db2 for z/OS setup script

Once all the above steps have been completed, enter the following command to install and configure Striim Agent for Db2 for z/OS and initialize the Striim Agent for Db2 for z/OS repository database:

setupDb2.sh -a full -r <Striim Agent for Db2 for z/OS repository password> -p <path to configuration file>

After installation is complete, optionally, to run the agent as a service:

  1. Go to the RDRS directory and run chmod for two service scripts:

    chmod 777 RegService.sh
    chmod 777 RegRestService.sh
  2. Run the two service scripts:

    sudo ./RegService.sh
    sudo ./RegRestService.sh
  3. Check the status of the services:

    sudo systemctl status rdrs.service
    sudo systemctl status rdrsrest.service

When running as a service, the API server will be on port 3080 instead of 8080.

12. Create and deploy the Striim application

You may create a Db2 for z/OS CDC application using Flow Designer or TQL. A Db2 external source has the following properties:

property

type

default value

notes

Data Format

Enum

Avro External Db2 for z/OS

Do not change this setting.

Database Alias

String

Specify the database alias (or name) registered in Db2 Client, for example, DBNAME.

Db2 Agent

String

Specify the IP address or network name and port of the Striim Agent for Db2, for example, hostname.for.db2.agent:8080.

Enable Db2 Dumps

Boolean

False

If set to True, generates z/OS system log dumps inside the Striim Agent for Db2 system. This may be useful for debugging.

Enable Tracing

Boolean

False

If set to True, generates verbose tracing logs inside the Striim Agent for Db2 system. This may be useful for debugging.

Kafka Max Message Size

Integer

1048576

Maximum message size in bytes. If the message size exceeds this value, the application and Striim Agent for Db2 will halt.

Important: if you increase this value, you must also adjust the following Kafka parameters:

Broker settings: message.max.bytes and replica.fetch.max.bytes must be greater than or equal to Kafka Max Message Size; log.segment.bytes must be greater than Kafka Max Message Size.

Consumer settings: fetch.message.max.bytes and max.partition.fetch.bytes must be greater than or equal to Kafka Max Message Size; receive.message.max.bytes must be greater than or equal to Kafka Max Message Size plus protocol overhead.

Kafka Property Set

Enum

Select the property set for the Kafka instance: see step 6 above.

Password

encrypted password

The password for the specified user. See Encrypted passwords.

Schema Registry

String

Specify the URI for the schema registry: see step 7 above.

Schema Registry Config

String

Specify any necessary configuration properties for the schema registry. See CREATE EXTERNAL SOURCE.CREATE EXTERNAL SOURCE

SSL Certificate Authority Path

String

Appears in UI only when Use Kafka SSL is True.

Specify the path to the CA certificate on the Striim Agent for Db2 host.

SSL Client Certificate Path

String

Appears in UI only when Use Kafka SSL is True.

Specify the path to the client certificate on the Striim Agent for Db2 host.

SSL Key Password

encrypted password

Appears in UI only when Use Kafka SSL is True.

Specify the password for the SSL key.

SSL Key Path

String

Appears in UI only when Use Kafka SSL is True.

Specify the path to the SSL key on the Striim Agent for Db2 host

Start Position

String

If blank, reading will start with new data. Optionally, to start at an earlier posiiton, specify a hex string of a LRSN or RBA value. If you need to specify a different start position, you must first drop and re-create the application.

Tables

String

Specify the tables, views, or materialized query tables to be read using the syntax <schema name>.<table name>.

You may specify multiple tables and views as a list separated by semicolons or with the % wildcard. For example, HR% would read all the tables whose names start with HR. You may use the % wildcard only for tables, not for schemas or databases. The wildcard is allowed only at the end of the string: for example, mydb.prefix% is valid, but mydb.%suffix is not.

If you change this value after starting the application, tables will be read only after the point in time of the recovery checkpoint.

UDT Function Location

String

If the RACF (Db2) ID is IBMUSER, but the Stored Procedure (UDT Function) is NOT inside the IBMUSER schema, specify the location in the format <schema>.<UDT function name>, for example, MYSCHEMA.TCVUDTV7.

Use Kafka SSL

Boolean

False

Set to True to use SSL.

Username

String

Specify the Db2 user Striim will use to read data.

The following example TQL creates the application and persisted stream using a property set for the Kafka server.

CREATE APPLICATION Db2ExampleApp;

CREATE EXTERNAL SOURCE Db2_External_Source ( 
  kafkaMaxMessageSize: 1048576, 
  username: 'DBUSER', 
  enableTracing: false, 
  password_encrypted: 'true', 
  tables: 'DBUSER.TESTTSPRECISION;', 
  schemaRegistry: 'http://hostname.for.schema.registry:8081', 
  databaseAlias: 'DBNAME', 
  useKafkaSSL: false, 
  password: '********', 
  enableDb2Dumps: false, 
  dataFormat: 'AvroExternalDb2zOS', 
  db2Agent: 'striim.agent.for.db2:8080') 
OUTPUT TO db2data PERSIST USING ps1;

END APPLICATION Db2ExampleApp;

Enabling SSL / TLS between Db2 and Striim Agent for Db2 for z/OS

See Configuring connections under the IBM Data Server Driver for JDBC and SQLJ to use TLS.