More about preparing a Db2 for i destination¶
Authorities¶
Why each step in Create the user profile and the library is needed:
| Step | Why it's needed |
|---|---|
| A user profile with a password | To connect. Any user class works; the Replicator Service needs no special authorities. |
CREATE SCHEMA (not CRTLIB) |
An SQL schema has the journal QSQJRN, and the tables created in it are journaled automatically, which commitment control needs (see Prepare the database). |
SQDRUSER owns the library and its journal |
The owner has all authority to the library, so the profile can create tables and indexes in it and journal them to QSQJRN; the tables it creates belong to it, so it can alter, empty and drop them, and read and change their rows. |
Test the authorities¶
The authorities and the journaling are first used when a subscription runs. When you create subscriptions, you can test them first with a snapshot subscription of a small table. Its replication events show each step and any Db2 for i error.
Why the tables must be journaled¶
The Replicator Service writes under commitment control: its connection for incremental changes always asks for the
read committed isolation level (*CS), and the connection string templates for snapshots and baselines do too
(IsolationLevel=2 for StarSQL, CommitMode=1 for IBM i Access). Db2 for i doesn't allow changes under commitment
control to an unjournaled table, so every insert, update and delete would fail. The error can be misleading: emptying
an unjournaled table before a baseline reports "The UPDATE or DELETE statement does not include a WHERE clause".
Journal receivers¶
Every change the Replicator Service applies is journaled, so the receivers grow with the replicated volume. Use the
system's receiver management (for example MNGRCV(*SYSTEM) and DLTRCV(*YES) on CHGJRN), as for any journaled
application library.
A library created with CRTLIB¶
A library created with CRTLIB has no journal. Before you replicate to it, have the administrator create a journal
and start journaling the library, so tables created in it are journaled automatically, for example:
CRTJRNRCV JRNRCV(MYLIB/SQDRJRN0001)
CRTJRN JRN(MYLIB/SQDRJRN) JRNRCV(MYLIB/SQDRJRN0001)
STRJRNLIB LIB(MYLIB) JRN(MYLIB/SQDRJRN)
Tables you create yourself¶
For existing tables the profile doesn't own, use Use existing table for baseline (incremental) or Use existing table (snapshot) in their subscriptions, so the Replicator Service never creates, alters, indexes or drops them. Then:
- Make sure each table is journaled, for example
STRJRNPF FILE(MYLIB/MYTABLE) JRN(MYLIB/QSQJRN). -
Give the profile the authority to use the library and to change the tables:
GRTOBJAUT OBJ(QSYS/MYLIB) OBJTYPE(*LIB) USER(SQDRUSER) AUT(*USE) GRTOBJAUT OBJ(MYLIB/MYTABLE) OBJTYPE(*FILE) USER(SQDRUSER) AUT(*CHANGE)*CHANGEon the table covers reading, inserting, updating and deleting rows: the loads, the changes, and emptying the table withDELETE. 3. Create the index on the replication key yourself (see The key at the destination). Merge groups still declare their temporary merge tables, which needs no authority.
ALTER processing¶
If incremental groups replicate schema changes to this destination and the IBM i release is older than 7.4 TR1 or
7.3 TR7, add a system reply list entry so DROP COLUMN doesn't stop at inquiry message CPA32B2:
ADDRPYLE SEQNBR(1500) MSGID(CPA32B2) RPY(I)
The Replicator Service sets its job to use the system reply list before each ALTER. See
ALTER processing: destination notes.