Configuring Db2 for z/OS as the build metadata database

To correctly use a DBB metadata store with Db2 for z/OS®, a Db2 storage group and a Db2 database must be created. After the tables are created in the Db2 database, users must be granted to access these tables.

1. Create the Db2 storage group and the Db2 database

To do so, you can use the create_DB2z.sql script, which is available by default in /usr/lpp/IBM/dbb/ddl.
This script contains sample commented CREATE STOGROUP and CREATE DATABASE statements that you can uncomment from the script (if you plan to run this script for the tables creation) or extract from the script and run manually.

The following items give guidelines on how to customize the provided commands:

  1. Create a storage group

    CREATE STOGROUP <storage group name> VOLUMES ('*') VCAT <HLQ name>;
    

    In this command, specify the following parameters:

    • The storage group name.
    • The name of the high-level qualifier of your Db2 files. This qualifier must exist on your system, and the DBB JDBC user must have full access to it.
  2. Create the database statements

    To create the database statements, enter the following command.

    You must create the database with UNICODE as the CCSID. The following example shows Db2 SQL create statements:

    CREATE DATABASE <database name> STOGROUP <storage group name> BUFFERPOOL <buffer pool name> CCSID UNICODE;  
    COMMIT;
    

    In this command, specify the following parameters:

    • The database name. This name is used during table creation so the script must be changed to match.
    • The storage group name.
    • The buffer pool name. On z/OS, a 16 K page size or larger is required. This buffer pool is used for creating tables. Table spaces are created in the default 16 K buffer pool, unless you selected a larger buffer pool.

2. Create the Db2 tables required by DBB

The minimum authority to create the tables and indexes in the next step requires DBADM access to the database and USE access to the storage group.

GRANT USE OF STOGROUP <storage group name> TO <dbbuser>;
GRANT DBADM ON DATABASE <database name> TO <dbbuser>;

You can use tools such as Data Studio or SPUFI to run the script to create the database tables used by DBB. Run the /usr/lpp/IBM/dbb/ddl/create_DB2z.sql script to create the tables for Db2 for z/OS.

3. Grant Db2 authorizations to the DBB tables

Although it is not recommended, the DBADM authority can be used with the metadata store APIs. It is recommended to set the minimum authority for users to access the database, which requires DELETE, INSERT, SELECT, and UPDATE on the database tables.

Sample commands are provided in /usr/lpp/IBM/dbb/ddl/grant_DB2z.sql. Review this script, customize it accordingly, and run it.

Alternatively, you can run the commands manually, after customizing them:

SET SCHEMA DBBZ;
GRANT DELETE, INSERT, SELECT, UPDATE
     ON TABLE
          A_CONTENT_MAPPING,
          ARTIFACT,
          ARTIFACT_CONTENT,
          BR_ATTACHMENT_MAPPING,
          BR_PROP_MAPPING,
          BR_REPORT_DATA_MAPPING,
          BR_REPORT_MAPPING,
          BUILD_RESULT,
          BUILD_RESULT_PROPERTY,
          COL_LF_MAPPING,
          COLLECTION,
          DBB_SEQ_TABLE,
          DBB_TABLE_VERSIONS,
          LD_CATEGORIES,
          LD_LIBRARIES,
          LF_DEP_MAPPING,
          LF_LANGUAGES,
          LOGICAL_DEPENDENCY,
          LOGICAL_FILE,
          PERMISSIONS
     TO <dbbuser>;  
COMMIT ;  

In this command, specify the DBB user name.

In addition to permissions for the above tables, the DBB_ROLE_MAPPING table should have DELETE, INSERT, SELECT, and UPDATE on the database table for an administrator only.

GRANT DELETE, INSERT, SELECT, UPDATE
    ON TABLE
        DBB_ROLE_MAPPING
    TO <admuser>;  
COMMIT ;

In this command, specify the DBB administrator name.

For all the other users, the DBB_ROLE_MAPPING table should have SELECT on the database table.

GRANT SELECT ON TABLE DBB_ROLE_MAPPING
    TO <dbbuser>;  
COMMIT ;

In this command, specify the DBB user name.

With DBB 3.0.2 and 2.0.2.4, the user must be granted SELECT on the SYSIBM.SYSDUMMY1 table.

GRANT SELECT ON TABLE SYSIBM.SYSDUMMY1 TO <dbbuser>;
COMMIT ;

The build result attachments, build report, and build report data are stored as BLOBs. The supplied scripts set the BLOB size to 100 M. If you anticipate attaching larger files or have an exceptionally large source code repository, you might want to consider increasing the BLOB size.

If you find that your BLOB size is too small (SQLCODE -302 from INSERT into table ARTIFACT_CONTENT) after installation, you can modify the BLOB definition, for example to 150 M, by using the following command:

alter table ARTIFACT_CONTENT alter column CONTENT_DATA set data type blob(150M)

3. Store your database drivers in an accessible location.

  • Remote Db2 for z/OS

If your Db2 for z/OS installation resides on a different z/OS machine or even a different LPAR than the DBB Toolkit installation, then you need to copy the db2jcc4.jar and db2jcc_license_cisuz.jar files from your z/OS system installation directory of Db2 for z/OS to a location accessible to the DBB installation. These files are typically located in the <baseInstallDir>/jdbc/classes directory.

  • Local Db2 for z/OS

If your Db2 for z/OS is already accessible to the DBB installation, then there are no additional copying steps. Add the db2jcc4.jar and db2jcc_license_cisuz.jar files from your z/OS system installation directory of Db2 for z/OS to your CLASSPATH. These files are typically located in the <baseInstallDir>/jdbc/classes directory.

4. Configure additional environment variables to support direct Db2 connections

After you have stored your available Db2 JDBC drivers in a location that is accessible to the DBB toolkit, you must allow DBB to access them.

So, besides the existing required DBB environment variables DBB_HOME and DBB_CONF, the Db2 direct connections require modifications to at least the CLASSPATH environment variable as well as to the STEPLIB and LIBPATH environment variables depending on the type of Db2 connection. See DBB environment variables for more information on how to configure your z/OS UNIX environment variables to use the direct Db2 connections.

5. Set database artifact permissions

Users that run DBB builds must be granted the correct access permissions for build artifacts stored in the database. For more information, see Granting roles to users.