Search docs.molo17.com
    Configuration guide Connectors

    Set up an IBM i CDC source from scratch

    Gluesync reads the changes of an IBM i table from its journal. This guide takes a table that is not journaled yet to a running pipeline: it creates the journal, journals the table with both images, creates a Gluesync user with only the authorities it needs, connects it in the Control Plane, and copies the table to SQL Server with a snapshot followed by live changes.

    In this guide

    You will learn how to create a journal receiver and a journal, start journaling a table with IMAGES(*BOTH), create a user profile without special authorities, grant it the authorities on the journal, the receivers, the library and the table, create the IBM i source connection with its own Gluesync library, add the entity, run a snapshot and change data capture (CDC), and check the result with SQL.

    The steps were run on IBM i 7.4 as the source and SQL Server 2022 as the target.

    Quick information

    Goal

    Replicate an IBM i table with a snapshot and journal-based CDC, using a Gluesync user that has only the authorities it needs

    Audience

    IBM i administrators and data engineers who set up pipelines

    Level

    Intermediate; the IBM i steps need a user with *SECADM and authority to the objects

    Time required

    About 30 minutes

    Area

    IBM i command line or Run SQL Scripts; Control Plane → Pipelines

    Applies to

    Gluesync 2.3

    Before you begin

    Make sure that:

    1. Core Hub can reach the IBM i host servers. The agent uses the database host server (port 8471) and the remote command server (port 8475), and the server mapper (port 449);

    2. You can sign on to the IBM i with a user that can create user profiles and grant authorities, for example a security officer, to run the IBM i steps;

    3. You can run SQL on the IBM i, from Run SQL Scripts or any SQL client, and run CL commands. In SQL, wrap a CL command in CALL QSYS2.QCMDEXC('…​');

    4. A pipeline target exists or can be created. In this guide it is SQL Server.

    A table created with CREATE TABLE in a library made with CREATE SCHEMA is journaled already, to the journal QSQJRN of that library. Check its images in step 2 and skip the journal creation. A library made with CRTLIB, as in this guide, has no journal.

    Guide steps

    Optional: create the demo library and table

    SQL

    Skip this step if you use your own table.

    CALL QSYS2.QCMDEXC('CRTLIB LIB(GSGSRC) TEXT(''Gluesync guide source'')');
    
    CREATE TABLE GSGSRC.CUSTOMERS (
      CUSTOMER_ID  INTEGER NOT NULL PRIMARY KEY,
      NAME         VARCHAR(60) NOT NULL,
      CITY         VARCHAR(40),
      CREDIT_LIMIT DECIMAL(11,2) NOT NULL DEFAULT 0
    );
    
    INSERT INTO GSGSRC.CUSTOMERS VALUES
      (1,'Rossi Costruzioni','Milano',25000),
      (2,'Bianchi Srl','Roma',8000),
      (3,'Verdi Logistica','Torino',12000);
    Journal the table with both images

    CLI + SQL

    Gluesync needs the before image and the after image of every change. Create a journal receiver and a journal, then start journaling the table with IMAGES(*BOTH):

    CRTJRNRCV JRNRCV(GSGSRC/GSGRCV0001) TEXT('Gluesync guide receiver')
    CRTJRN    JRN(GSGSRC/GSGJRN) JRNRCV(GSGSRC/GSGRCV0001) MNGRCV(*SYSTEM) DLTRCV(*NO) TEXT('Gluesync guide journal')
    STRJRNPF  FILE(GSGSRC/CUSTOMERS) JRN(GSGSRC/GSGJRN) IMAGES(*BOTH) OMTJRNE(*OPNCLO)

    To change a table that is journaled already with after images only, run CHGJRNOBJ OBJ((<library>/<table> *FILE)) ATR(*IMAGES) IMAGES(*BOTH).

    Check the result:

    SELECT OBJNAME, JOURNALED, JOURNAL_LIBRARY, JOURNAL_NAME, JOURNAL_IMAGES
    FROM TABLE(QSYS2.OBJECT_STATISTICS('GSGSRC', '*FILE')) X;
    Expected result
    OBJNAME   | JOURNALED | JOURNAL_LIBRARY | JOURNAL_NAME | JOURNAL_IMAGES
    CUSTOMERS | YES       | GSGSRC          | GSGJRN       | *BOTH

    DLTRCV(*NO) keeps detached receivers until you delete them. Keep them until Gluesync has read them: a receiver deleted too early means a new snapshot. See Recover when a journal receiver was deleted.

    Create the Gluesync user and grant its authorities

    CLI + SQL

    1. Create a user profile with no special authorities and no interactive sign-on:

      CRTUSRPRF USRPRF(GSGUIDE) PASSWORD(<password>) USRCLS(*USER) SPCAUT(*NONE) INLMNU(*SIGNOFF) LMTCPB(*YES) TEXT('Gluesync CDC user')
    2. Grant the authorities. The journal needs two commands, because *USE cannot be combined with another value in one GRTOBJAUT:

      GRTOBJAUT OBJ(GSGSRC)           OBJTYPE(*LIB)    USER(GSGUIDE) AUT(*EXECUTE)
      GRTOBJAUT OBJ(GSGSRC/CUSTOMERS) OBJTYPE(*FILE)   USER(GSGUIDE) AUT(*USE)
      GRTOBJAUT OBJ(GSGSRC/CUSTOMERS) OBJTYPE(*FILE)   USER(GSGUIDE) AUT(*OBJREF)
      GRTOBJAUT OBJ(GSGSRC/GSGJRN)    OBJTYPE(*JRN)    USER(GSGUIDE) AUT(*USE)
      GRTOBJAUT OBJ(GSGSRC/GSGJRN)    OBJTYPE(*JRN)    USER(GSGUIDE) AUT(*OBJEXIST)
      GRTOBJAUT OBJ(GSGSRC/*ALL)      OBJTYPE(*JRNRCV) USER(GSGUIDE) AUT(*USE)

      When the journal and its receivers are in other libraries than the table, also grant *EXECUTE on those libraries.

    3. Check the grants:

      SELECT SYSTEM_OBJECT_SCHEMA, SYSTEM_OBJECT_NAME, OBJECT_TYPE, OBJECT_AUTHORITY, OBJECT_EXISTENCE, OBJECT_REFERENCE
      FROM QSYS2.OBJECT_PRIVILEGES
      WHERE AUTHORIZATION_NAME = 'GSGUIDE'
        AND (SYSTEM_OBJECT_SCHEMA = 'GSGSRC' OR (SYSTEM_OBJECT_SCHEMA = 'QSYS' AND SYSTEM_OBJECT_NAME = 'GSGSRC'))
      ORDER BY OBJECT_TYPE;

    What each authority is for:

    Object Authority Why

    The table

    *USE

    Read the rows during the snapshot and the journal entries of the table.

    The table

    *OBJREF

    Let the agent see the primary key of the table. Without it, Field mapping reports No key on the source (see step 5).

    The journal

    *USE and *OBJEXIST

    Read the journal; *OBJEXIST is needed when the journal is read without a list of files. See Authorities of the Gluesync user.

    The receivers

    *USE

    Read the entries in each receiver. A receiver that CHGJRN JRNRCV(*GEN) creates later gets the authorities of the one it replaces.

    The libraries of the table, the journal and the receivers

    *EXECUTE

    Reach the objects in them.

    Expected result
    SYSTEM_OBJECT_SCHEMA | SYSTEM_OBJECT_NAME | OBJECT_TYPE | OBJECT_AUTHORITY | OBJECT_EXISTENCE | OBJECT_REFERENCE
    GSGSRC               | CUSTOMERS          | *FILE       | USER DEFINED     | NO               | YES
    GSGSRC               | GSGJRN             | *JRN        | USER DEFINED     | YES              | NO
    GSGSRC               | GSGRCV0001         | *JRNRCV     | *USE             | NO               | NO
    QSYS                 | GSGSRC             | *LIB        | USER DEFINED     | NO               | NO

    The library appears under QSYS, where libraries live. USER DEFINED means a set of authorities that is not one of the named sets: *USE plus *OBJREF on the table, *USE plus *OBJEXIST on the journal, *EXECUTE alone on the library.

    Create the source connection

    UI

    1. In the Control Plane, select Create pipeline (or Create your first pipeline);

    2. In Select source agent, search for IBM i and select IBM Db2 for IBM i CDC agent;

    3. In Base settings, fill in Host name / Address, Username (GSGUIDE) and Password;

    4. Under Advanced connection properties, select Add property, choose the key Gluesync library and type its name, here GSGGS. Each Gluesync agent that reads the same IBM i needs its own library;

    5. Select Test and continue.

    Base settings of the IBM Db2 for IBM i agent with Username GSGUIDE
    Figure 1. The Base settings of the IBM i agent, with the Gluesync user and its own Gluesync library.
    Expected result

    The test passes and the agent shows GSGUIDE@<host>. If the Gluesync library does not exist, Gluesync creates it, owned by the Gluesync user. With the default journal reader it stays empty: no Gluesync program or job runs on the IBM i.

    1. Select Next, set up the target (here MS SQL Server agent), name the pipeline and select Finish.

    Add the entity

    UI

    1. Open the pipeline and select Entities +;

    2. In the Object browser, type the library name, GSGSRC+, and select Open schema GSGSRC directly. Check the table +CUSTOMERS;

    3. In Field mapping, choose the target schema and table. To have Gluesync create the table, type a new name and select Create table "<name>";

    4. Check that the key column has the key icon, then select Confirm, then Confirm and continue.

    Field mapping from GSGSRC.CUSTOMERS to a new dbo.CUSTOMERS table
    Figure 2. With *OBJREF on the table, the primary key CUSTOMER_ID is recognised on both sides and Confirm is enabled.

    Without *OBJREF, the same user sees the columns but not the key. Field mapping shows There are multiple errors, the Error tab lists No key on the source and No key on the target, and Confirm stays disabled.

    Field mapping with the banner There are multiple errors and the errors No key on the source and No key on the target
    Figure 3. The errors when the Gluesync user cannot see the primary key.

    Grant *OBJREF on the table, then cancel Field mapping and open the table again. If the table has no primary key, mark the key yourself: see Choose keys for tables without a primary key.

    Start the snapshot and CDC

    UI

    1. Open the entity and select Start;

    2. Keep Full copy and Keep and merge, then select Start entity.

    Entity page of GSGSRC.CUSTOMERS to dbo.CUSTOMERS
    Figure 4. The entity is Active. Last Transaction ID shows the journal library, the receiver and the sequence number Gluesync has read up to.
    Expected result

    On SQL Server, SELECT * FROM dbo.CUSTOMERS returns the three rows of the table.

    Check the live changes

    SQL

    1. On the IBM i, insert, update and delete a row:

      INSERT INTO GSGSRC.CUSTOMERS VALUES (4,'Neri Consulting','Bologna',5000);
      UPDATE GSGSRC.CUSTOMERS SET CREDIT_LIMIT = 30000 WHERE CUSTOMER_ID = 1;
      DELETE FROM GSGSRC.CUSTOMERS WHERE CUSTOMER_ID = 2;
    2. After a few seconds, read the target:

      SELECT * FROM dbo.CUSTOMERS ORDER BY CUSTOMER_ID;
    Expected result
    CUSTOMER_ID NAME              CITY    CREDIT_LIMIT
    ----------- ----------------- ------- ------------
    1           Rossi Costruzioni Milano  30000.00
    3           Verdi Logistica   Torino  12000.00
    4           Neri Consulting   Bologna  5000.00
    Verify the result

    You set up the IBM i source successfully if:

    • the table is journaled to your journal with *BOTH images;

    • the Gluesync user has no special authority and only the grants of step 3;

    • the connection test passes with that user, and the key of the table is recognised in Field mapping;

    • the snapshot copied the rows, and an insert, an update and a delete reached the target.

    Data type notes

    Character columns are read in their CCSID and written as text. Columns FOR BIT DATA are copied as binary unless Translate binary is on. For the full mapping and the CCSID options, see Map IBM i data types.

    Troubleshooting

    Problem Possible cause What to do

    Failed to save and Password is incorrect.:<user> on Test and continue

    Wrong password, or the profile is disabled

    Type the password again, and check the status of the profile with DSPUSRPRF

    No key on the source and No key on the target in Field mapping, though the table has a primary key

    The Gluesync user has no *OBJREF on the table

    GRTOBJAUT ... AUT(*OBJREF) on the table, then open the table again in Field mapping

    CPF0006 on GRTOBJAUT ... AUT(*USE *OBJEXIST)

    *USE cannot be combined with other values

    Run two GRTOBJAUT commands, one with *USE and one with *OBJEXIST

    [SQL0443] Not authorized to object on the journal or a receiver

    A journal authority is missing

    See Fix SQL0443 Not authorized to object on a journal

    The start fails because the table is not journaled, or is journaled with after images only

    Journaling was not started with IMAGES(*BOTH)

    See Fix a table that is not journaled

    Clean up

    To remove what this guide created on the IBM i, stop and delete the entity first, then:

    DLTUSRPRF USRPRF(GSGUIDE) OWNOBJOPT(*DLT)
    DLTLIB    LIB(GSGSRC)

    OWNOBJOPT(*DLT) also deletes the Gluesync library, which the user owns.

    Run DLTLIB from an IBM i command line rather than through QSYS2.QCMDEXC in SQL. In the test, DLTLIB of the library holding the journal and its receiver did not return to the SQL session, although the library was deleted.