Skip to main content

Db2 for z/OS initial setup

Db2 for z/OS system requirements

Performing CDC from Db2 for z/OS with Striim requires a Linux server to host the Db2 Connect and Rocket Data Replication Software (RDRS) 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 Rocket Data Replication Software (RDRS) license.

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

  3. Get Db2 Connect (see Db2 Connect overview) from IBM and install the IBM ODBC driver on the Linux host where you will install RDRS. Alternatively, if you already have DRDA in your Db2 for z/OS environment, you may use that.

  4. Have an Oracle or PostgreSQL repository for use by RDRS. 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 repository on the Linux host where you will install RDRS.

  6. Enable Striim's internal Kafka server.

  7. Install Confuent 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. (RDRS cannot capture change data from tables without primary keys.)

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

  10. Create and deploy a Striim application including the Kafka-persisted stream to which Striim Connect will write the data captured by RDRS. The persisted stream details must be specified in the configuration file in the next step.

  11. Populate the RDRS_DB2zOS.properties configuration file. This is required by the setup script in the next step.

  12. Run the script to Install, configure, and start RDRS.

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 Connect

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 RDRS 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 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 DALLASD -host 10.10.138.10 -port 5045
  2. Add the data source name (dsn).

    db2cli writecfg add -dsn db2z13 -database DALLASD -host 10.10.138.10 -port 5045

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 RDRS repository

RDRS 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 RDRS's repository. Otherwise, if you do not have another Oracle or PostgreSQL instance available to host the RDRS repository, we recommend installing PostgreSQL (a free open-source DBMS). You may install it on the same Linux server you use to host RDRS.

[to be added: install PostgreSQL or Oracle driver in the RDRS Linux server]

5. Enable Striim's internal Kafka server

See Using Striim's internal Kafka server.

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 addresses and ports of Striim's internal Kafka server or your external Kafka server.

CREATE PROPERTYSET KafkaPropSet (
  zk.address:192.0.2.92:2181',
  bootstrap.brokers: '192.0.2.92:9092',
  kafkaversion: '2.1',
  partitions: '1'
);

6. Enable the Confluence Schema Registry

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

  1. On the Linux server hosting RDRS, 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

7. Add primary keys

In Db2, if any tables to be captured do not have primary keys, add them. (RDRS 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.

8. 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

9. Create and deploy the Striim application

Create an application to create the persisted stream that must be referenced in the RDRS configuration file. Creating a persisted stream also creates a topic of the same name in Kafka.

USE ns1;
CREATE APPLICATION Db2zOS_CDC;

CREATE STREAM Db2zOSStream OF WAEvent 
  PERSIST USING KafkaPropSet;

CREATE EXTERNAL SOURCE Db2zOSReader (
  connector: 'db2',
  dataFormat: 'AvroExternalDb2zOS',
  schemaRegistry: 'http://192.0.2.92:8085'
)
OUTPUT TO Db2zOSStream;

END APPLICATION Db2zOS_CDC;

10. Populate the RDRS 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 RDRS.

If you create multiple RDRS pipelines, each needs a separate configuration file. The SOURCE_NAME, TARGET_NAME, and TOPIC must be different for each pipeline. TABLE_REGEX will typically be different and SCHEMA_REGEX may be different. The other properties typically will be the same.

Property name

Description

Syntax

Example(s)

notes

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 RDRS license file

absolute file path to RDRS license file

/home/ubuntu/License.tcVLC

file will be provided by Striim Support

REPO

database type of the RDRS repository host

ORCL for Oracle Database or PSQL for PostgreSQL

PSQL

ORCL

REPO_HOST

RDRS repository database hostname

IP Address or hostname

localhost

192.168.0.5

REPO_PORT

RDRS repository database port

port number

1521

5432

REPO_DB

RDRS repository database name

database name

ORCL

postgres

REPO_ID

RDRS repository database user id

SQL ID for repository database

admin

postgres

REPO_SCHEMA

schema to be used exclusively for the RDRS repository

repository database schema name

RDRS

DB2_ALIAS

Name of Db2 alias registered on Db2 Client

database alias defined on the Db2 Client

DB2Z

DB2_ID

user id of the source Db2

SQL ID for source Db2 user

IBMUSER

SOURCE_NAME

name to be set for this new Db2 source on RDRS

user preferred source name

Db2_zOS_Source

must be different for each RDRS pipeline

SCHEMA_REGEX

schema(s) to read

regular expression for schemas to read

SCHEMA1|SCHEMA2

Regex documentation will be provided by Striim.

To specify multiple schemas, separate with | (pipe) characters.

TABLE_REGEX

tables to read

regular expression for tables to read

^.*$

TABLE1|TABLE2

Regex documentation will be provided by Striim.

^.*$ will read all tables in the specified schema(s).

To specify multiple tables, separate with | (pipe) characters.

db2compdict

include Db2 compression dictionaries (Y or N)

Boolean Y/N

Y

N

TARGET_NAME

name to be set for the target on RDRS

user-specified target name

zOS_Kafka

must be different for each RDRS pipeline

KAFKA_BROKER

hostname and port for the Kafka broker

host name or IP with port separated by colon (:)

localhost:9092

TOPIC

name of the Kafka topic / persisted stream

namespace, underscore, name of the Kafka topic / persisted stream

using the sample TQL above, the value would be ns1_Db2zOSStream; must be different for each RDRS pipeline

SCHEMA_REGISTRY

hostname and port for the Confluent Schema Registry

host name or IP with port separated by colon (:)

localhost:8081

PROCESS_NAME

name of the RDRS process to be set for CDC process

user-specified pipeline/process name

zOS_CDC

RBA_LRSN

LRSN or RBA value to start reading from in the Db2 log

hex string of the LRSN or RBA value

000000000000FA3E4376

Required only when specifying a specific start point of CDC pipeline. If not specified, reading will start with new data, that is, from the end of the log

Example configuration file

Example configuration file with PostgreSQL repository, to capture change data from all tables in MYSCHEMA1 and MYSCHEMA2, starting with new data (that is, from the latest index, since RBA_LRSN is not specified):

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
REPO=PSQL
REPO_HOST=localhost
REPO_PORT=5432
REPO_DB=postgres
REPO_ID=postgres
REPO_SCHEMA=rdrs
DB2_ALIAS=DB2Z
DB2_ID=IBMUSER
SOURCE_NAME=Db2zOS
SCHEMA_REGEX=MYSCHEMA1|MYSCHEMA2|MYSCHEMA3
TABLE_REGEX=^.*$
db2compdict=N
TARGET_NAME=StriimKafka
KAFKA_BROKER=localhost:9092
TOPIC=RDRSzOS
SCHEMA_REGISTRY=localhost:8081
PROCESS_NAME=zOS_CDC

11. Run the RDRS setup script

Prerequisites

  • After you purchase Db2 for z/OS Support, Striim Support will provide you with an RDRS installation bundle, which includes the RDRS distribution, a sample configuration file, and a set of scripts for installation and other tasks.

  • Striim Support will also provide you with an RDRS license file, the path to which must be specified in the configuration file.

  • All properties in he RDRS configuration file must be specified as described in the previous step.

  • If the RDRS repository will be hosted on PostgreSQL, the psql command-line terminal must be available on the RDRS host.

  • If the RDRS repository will be hosted on Oracle, the sqlplus command-line terminal must be available on the RDRS host.

To install and configure RDRS, initialize the RDRS repository database, create an RDRS pipeline to send data from Db2 to the Striim application's Kafka-persisted stream (external source), start the RDRS Agent, and start the pipeline, extract the installation bundle on the RDRS host system and run the following full command:

setupDb2.sh -a full -s <db2 password> -r <RDRS repository password> -p <path to configuration file>

Alternatively, you may run the following install command to install and configure RDRS and initialize the RDRS repository database without creating a pipeline:

setupDb2.sh -a install -r <RDRS repository password> -p <path to configuration file>

Then use the create command to create one or more pipelines. Each pipeline must have a different configuration file and write to a different Kafka-persisted stream (external source) in Striim.

setupDb2.sh -a create -s <db2 password> -r <RDRS repository password> -p <path to configuration file>

Then use the start command to run the pipeline.

setupDb2.sh -a start -p <path to configuration file>

Once an RDRS pipeline is running you may start the corresponding Striim application.

Enabling SSL / TLS between Db2 and RDRS

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