Look after the Db2 databases on the Stelo VM¶
Stelo Capture keeps the changes its Capture Agents capture, and its own configuration, in Db2 for LUW on the Stelo
Capture server: the control database SQDRC and one staging database per Capture Agent (SQDRP0, SQDRP1, ...).
On the Stelo VM, SQDRC is also the Replicator Service's control database. Db2 is
installed for Stelo Capture's exclusive use and needs little administration. Use this page when you need to:
- find the staging database of a Capture Agent;
- back up the databases, or restore them;
- free disk space: reclaim space after a backlog, add storage to a full drive or move a database to another drive;
- make the transaction log larger or limit Db2's memory;
- fix a Db2 error that a Capture Agent or the Replicator Service reports;
- update, reinstall or license Db2.
The steps are for the Stelo VM, where SQDR runs on one Windows server. Run the commands in a Db2 command window on that server (see Open a Db2 command window); most tasks also need replication stopped first (see Stop replication for Db2 maintenance).
SQDR on another server (split tier)
When the Replicator Service runs on a server of its own, its control database isn't SQDRC on the Stelo VM. Where a step stops the Replicator Service, instead pause the incremental groups that replicate from the Stelo Capture server in the Data Replicator Manager. Back up the control database on its own server (see Back up the control database).
Docker
In the Stelo Replicator container, Db2 runs inside the container. Run Db2 commands as the instance owner: open a
shell with docker exec -ti stelo-full bash, then su - db2inst1. The databases are on the db2-data and
db2-logs volumes, and the backups volume (/backups) is there for backup images (see
Volumes). Db2 comes with the image: you don't install, update or license it as
on Windows (see The control database and Upgrade the Docker
container).
Find an agent's staging database¶
In the SQDR Control Center, select the server: the control database column of the Agents tab names each agent's
staging database and schema. SQDRP1(SQDR0) means database SQDRP1, schema SQDR0; no schema means the default
SQDR. The agent's controlDbUrl also names it. In Db2, db2 list db directory
lists all the databases and the drive each is on.
| Database | What it holds | Created by |
|---|---|---|
SQDRC |
The Launch Agent's list of Capture Agents and their configuration, and, on the Stelo VM, the Replicator Service's control tables. | The SQDR Plus installer, on a first install (see Changes to Db2). |
SQDRPn |
A Capture Agent's staging database: the changes it captured, waiting for the Replicator Service, and the agent's control tables. Several agents can share one, each in its own schema (SQDR, SQDR0, SQDR1, ...). |
The Launch Agent, when you add a Capture Agent with <New Control DB> (see Step 2: Control DB). |
Default locations on Windows:
| What | Where |
|---|---|
| Db2 program files | C:\Program Files\IBM\SQLLIB |
| Db2 instance files | C:\ProgramData\IBM\DB2\DB2COPY1 (C:\ProgramData is a hidden folder) |
Db2 diagnostic log db2diag.log |
C:\ProgramData\IBM\DB2\DB2COPY1\DB2, or its DIAG0000 subfolder (see db2diag.log) |
| The databases and their transaction logs | The drives you chose for Location of DB2 databases: and Location of DB2 logs: when you installed Stelo Capture (see DB2 LUW Parameters) |
Open a Db2 command window with the right authority¶
Run Db2 commands in DB2 Command Window - Administrator (db2cmd, run as administrator), in the Start menu's Db2
folder. Commands that control the instance, such as db2start, db2stop and db2licm, need this administrator
window.
A message that you aren't authorized to do something (for example SQL0552N ... does not have the privilege to
perform operation) is about your authority in Db2, not in Windows: running the window as administrator doesn't help.
Instead, run the command window as a user that has the authority:
- For instance-level tasks (start, stop, backup, restore, configuration): the Db2 instance's service account (for
example
db2admin), or a member of the server's local Administrators group. Hold Shift, right-click DB2 Command Window - Administrator and choose Run as different user. - For grants in a staging database: the account that created the database. The SQDR Plus installer creates SQDRC,
and the Launch Agent the staging databases, both as the Local System account, which therefore has security
administrator (SECADM) authority in them. To run a command window as Local System, use Microsoft's Sysinternals
psexec:psexec64 -i -s db2cmd.
Keep Db2's SYSADM_GROUP parameter unset: when it's set, Db2 no longer gives the local administrators (and Local
System) SYSADM authority, and Stelo Capture can't create staging databases (see Why the Db2 user needs no
authority). When the Stelo Capture services run as a domain user, that
user must be a local administrator (see Run SQDR as a domain
user). To check that a user can create databases, open a
command window as that user and run db2 create database temp, then db2 drop database temp.
Stop replication for Db2 maintenance¶
Most tasks on this page need the databases free of connections. On the Stelo VM:
- Let running group runs finish.
- Stop the Replicator Service (StarQuest Data Replicator,
SQDRSVC; see Start and stop the service). Incremental groups stop applying changes until it runs again. - In Services, stop SQDR Plus Derby (
sqdr+derby). Windows also stops the services that depend on it: the Launch Agent (sqdr+capagent), and with it every Capture Agent, and Jetty (sqdr+jetty, the SQDR Control Center). If the work includes a reboot, set the four services to Disabled first so that they don't start too early. - Check that nothing is connected:
db2 list applicationsshows no connections to the database (or reports that there are none).
To start again, reverse the order: check that Db2 is running, start SQDR Plus Derby, SQDR Plus Jetty and SQDR Plus Launch Agent (set them back to Automatic if you disabled them), check in the SQDR Control Center that the Capture Agents run, then start the Replicator Service (set back to Automatic (Delayed Start)). In the Data Replicator Manager, check that the groups apply changes again.
For a task on one staging database only, stopping the Capture Agents that use it (and the Replicator Service's groups that read from them) is enough. For moves to another server, see Move Stelo Capture to a new server and The standard stop.
Back up the databases¶
Back up SQDRC and the staging databases together, from the same stop, before upgrades and maintenance, and on a
regular schedule: SQDRC holds the list of Capture Agents and, on the Stelo VM, the whole replication setup; each
staging database holds its agent's captured changes and control tables. They belong together: restore them together.
Also keep a copy of the folders under C:\ProgramData\StarQuest\sqdrplus\conf and the files in
Back up the configuration.
SQDRC and the staging databases use circular logging, so Db2 can back them up only offline, with replication stopped (see Offline backup). To back up without stopping replication, turn on archive logging first (see Archive logging and online backups).
Plan the disk space: a backup is roughly as large as the data in the database, which depends on how many changes are staged at the time. To make backups smaller, reclaim table-space storage first. Keep copies on another server or storage: a backup on the same disk doesn't survive a disk failure.
Take an offline backup¶
Replication stops while an offline backup runs.
- Check the free space in the backup folder (for example
D:\backups), and that it holds no older backup images you still need. - Stop replication (see Stop replication for Db2 maintenance).
-
For each database, deactivate it and back it up:
db2 deactivate db SQDRC db2 backup db SQDRC to D:\backups compress db2 deactivate db SQDRP0 db2 backup db SQDRP0 to D:\backups compressEach backup creates one image file whose name includes the database and a timestamp, for example
SQDRC.0.DB2.DBPART000.20261101120000.001. If the backup fails withSQL1035N The operation failed because the specified database cannot be connected to in the mode requested, the database is still active or in use: checkdb2 list applicationsand deactivate it. -
Start replication again (see Stop).
To do all of this in one step, Stelo provides the script
controldb-backup.bat: it stops
and disables the Replicator Service and the Stelo Capture services, backs up every database whose name contains SQDR
into C:\Stelo (change BACKUPDIR in the script for another folder), and starts the services again. Run it in a
DB2 Command Window - Administrator. To keep only the newest 2 backups when you run it repeatedly, run
setbackupretn.bat once in the same
kind of window: it turns on Db2's automatic deletion of older backup images for those databases.
Check SQDRC's automatic backups¶
The SQDR Plus installer turns on Db2's automatic backups for SQDRC, keeping the last 2 backups and 7 days of backup history (see Changes to Db2). With circular logging, Db2 takes them only offline, when nothing is connected to the database; on a running server SQDRC always has connections. Check whether automatic backups were taken, and don't rely on them alone:
db2 list history backup all for SQDRC
The staging databases have no automatic backups.
Archive logging and online backups¶
With archive logging, Db2 keeps its filled log files instead of reusing them. That lets you back up a database online, without stopping replication, and recover it to a point in time after a failure, even without a recent full backup. The cost is disk space: archived logs and online backups (which include the log files written during the backup) accumulate, and must be cleaned up, or the disk fills up and replication stops.
Use it for SQDRC at least, where the configuration is. For staging databases, which change constantly, archive logging produces large amounts of log files; turn it on only if you have the space and the need.
Turn on archive logging (once per database):
- Choose a folder for the archived logs, on another drive than the active logs (for example
V:\db2archive), and one for the backups, on another drive or a network share (for exampleW:\backups). - Stop replication (see Stop).
-
Set the archive folder, then take a full offline backup: after the change, Db2 doesn't allow connections until the database is backed up.
mkdir V:\db2archive db2 update db cfg for SQDRC using LOGARCHMETH1 DISK:V:\db2archive db2 deactivate db SQDRC db2 backup db SQDRC to W:\backups compress -
Start replication again.
Stelo's PowerShell script
db2_archivelog.ps1 does step 3 for one
database, with the backup in your home folder (./db2_archivelog.ps1 -dbname SQDRC -archivedir V:\db2archive).
Back up online, by hand or from a scheduled task:
db2 backup db SQDRC online to W:\backups compress
Stelo's script db2_backup.ps1 runs
online backups of a list of databases; edit the list, the destination (a network share as \\server\share\folder, not
a mapped drive letter) and the user, and run it from a Windows scheduled task as a user that can write to the
destination.
Or let Db2 back up automatically, online, for example once a week (every 168 hours) to W:\backups during a
nightly maintenance window. Connect to the database and set the policies:
db2 connect to SQDRC
db2 "CALL SYSPROC.AUTOMAINT_SET_POLICY('AUTO_BACKUP', BLOB('<?xml version=\"1.0\" encoding=\"UTF-8\"?><DB2AutoBackupPolicy xmlns=\"http://www.ibm.com/xmlns/prod/db2/autonomic/config\"><BackupOptions mode=\"Online\"><BackupTarget><DiskBackupTarget><PathName>W:\backups</PathName></DiskBackupTarget></BackupTarget></BackupOptions><BackupCriteria numberOfFullBackups=\"1\" timeSinceLastBackup=\"168\" logSpaceConsumedSinceLastBackup=\"6400\"/></DB2AutoBackupPolicy>'))"
db2 "CALL SYSPROC.AUTOMAINT_SET_POLICY('MAINTENANCE_WINDOW', BLOB('<?xml version=\"1.0\" encoding=\"UTF-8\"?><DB2MaintenanceWindows xmlns=\"http://www.ibm.com/xmlns/prod/db2/autonomic/config\"><OnlineWindow Occurrence=\"During\" startTime=\"00:30:00\" duration=\"4\"><DaysOfWeek>All</DaysOfWeek><DaysOfMonth>All</DaysOfMonth><MonthsOfYear>All</MonthsOfYear></OnlineWindow></DB2MaintenanceWindows>'))"
db2 connect reset
For another database, also turn on automatic maintenance and backups (SQDRC has them from the installer):
db2 update db cfg for SQDRP0 using AUTO_MAINT ON AUTO_DB_BACKUP ON. The sample policy
C:\Program Files\IBM\SQLLIB\samples\automaintcfg\DB2DefaultAutoBackupPolicy.xml explains the other options. New
values can need a deactivation of the database to take effect.
Clean up old backups and archived logs. Db2 does it after each full backup when these are set (the installer sets them for SQDRC):
db2 update db cfg for SQDRP0 using AUTO_DEL_REC_OBJ ON NUM_DB_BACKUPS 2 REC_HIS_RETENTN 14
| Parameter | What it does |
|---|---|
AUTO_DEL_REC_OBJ |
ON: when Db2 prunes its backup history, it also deletes the backup images and archived log files it no longer needs. |
NUM_DB_BACKUPS |
The number of full backups to keep. |
REC_HIS_RETENTN |
The number of days of backup history to keep. |
Cleanup happens only after a full backup. With archive logging but no regular full backups, delete old archived logs with a scheduled task instead: Stelo's db2clean.ps1 prunes the history and archived logs older than a number of days (edit the list of databases, the user and the days).
For more, see IBM's BACKUP DATABASE command, Automatic database backup and Automating database recovery object management.
Restore the databases from a backup¶
A restore replaces the database with its content at the time of the backup. Restore SQDRC and the staging databases from the same stop. Afterwards, the Capture Agents and the Replicator Service carry on from that point: changes staged or applied after the backup are not in the restored databases, so check the incremental groups and run a new baseline where needed (Stelo Support can help you decide).
- Stop replication (see Stop) and check the free space on the Db2 data drive.
- Find the backup's timestamp: it's in the image file name, or listed by
db2 list history backup all for SQDRC. -
Restore over the existing database, answering
yto the warning that it will be replaced:db2 deactivate db SQDRC db2 restore db SQDRC from D:\backups taken at 20261101120000 replace existingFor an online backup, then apply the logs it contains:
db2 rollforward db SQDRC to end of backup and complete(orto end of logs and completeto also apply the archived logs written since). -
Check the database with
db2 connect to SQDRC, thendb2 connect reset. - Repeat for each staging database, then start replication again (see Stop).
To restore several databases in one step, Stelo provides
controldb-restore.bat. It stops
the Replicator Service and the SQDR Plus Launch Agent and Jetty services, then drops and restores each database
listed in list_of_dbs.txt (one name per line, in the script's folder) from C:\Stelo, onto the drives set in
DRIVE_DB2_DATA and DRIVE_DB2_LOGS. Edit those values, and check the list carefully: every database in it is
dropped. Write the list yourself; the companion script controldb-list.bat reads the list of agents from Derby,
which Stelo Capture no longer uses. The folder must hold only one backup image per database. Start the
services and set them back to automatic afterwards.
Reclaim disk space after a backlog¶
A staging database grows when changes pile up in it, for example when the Replicator Service couldn't fetch changes
for a while; its size depends on the number of subscribed tables and on how many changes are waiting, not on the size
of the source tables. When the backlog has been applied and pruned, the space is free inside Db2 but the
files on disk don't shrink. To give the space back to Windows, reorganize the staging tables, then
reduce the table spaces. Do it in a quiet period with the Capture Agents that use the database stopped: a
REORG locks each table while it runs.
Check the table spaces first; tbsp_free_pages shows the free space inside each:
db2 connect to SQDRP0
db2 "SELECT VARCHAR(tbsp_name, 30) AS tbsp_name, reclaimable_space_enabled, tbsp_free_pages, tbsp_page_top, tbsp_usable_pages FROM TABLE(MON_GET_TABLESPACE('', -2)) AS t ORDER BY tbsp_free_pages"
And the largest staging tables, in pages:
db2 "SELECT VARCHAR(tabschema, 10) AS tabschema, VARCHAR(tabname, 40) AS tabname, data_object_p_size + index_object_p_size + long_object_p_size + lob_object_p_size + xml_object_p_size AS total_size FROM SYSIBMADM.ADMINTABINFO WHERE tabschema LIKE 'SQDR%' ORDER BY total_size DESC FETCH FIRST 20 ROWS ONLY"
Reorganize the staging tables¶
-
Generate a
REORGstatement for each table of the agents' schemas (SQDR,SQDR0, ...) and run them:db2 connect to SQDRP0 db2 -x "SELECT 'REORG TABLE', SUBSTR(RTRIM(tabschema) || '.' || RTRIM(tabname), 1, 60), 'LONGLOBDATA;' FROM SYSCAT.TABLES WHERE type = 'T' AND tabschema LIKE 'SQDR%'" > reorg_sqdr.sql db2 -tvf reorg_sqdr.sqlA single table:
db2 reorg table SQDR.<table>. AREORGcan take from minutes to an hour. -
If a
REORGfails withSQL0289N(SQLCODE=-289), the table space has no room for the reorganized copy. Give it a temporary table space with the same page size, for exampledb2 reorg table SQDR.<table> use TEMPSPACE1for a table inUSERSPACE1, or add storage first.
Reduce the table spaces¶
The staging tables are in the table spaces USERSPACE1 and SQDRSPACE. After the reorganization, lower their high
water mark and release the free space:
db2 connect to SQDRP0
db2 ALTER TABLESPACE USERSPACE1 LOWER HIGH WATER MARK
db2 ALTER TABLESPACE USERSPACE1 REDUCE MAX
db2 ALTER TABLESPACE SQDRSPACE LOWER HIGH WATER MARK
db2 ALTER TABLESPACE SQDRSPACE REDUCE MAX
db2 connect reset
The reduction is usually quick. If it's slow, don't run it again (Db2 reports that the table space is in use); follow it with:
db2 "SELECT num_extents_left FROM TABLE(SYSPROC.MON_GET_EXTENT_MOVEMENT_STATUS('SQDRSPACE', -1))"
Sometimes the disk space is given back only after you disconnect, restart Db2 or restart the server.
See also IBM's Steps to reclaim all available space from a reclaimable storage DMS automatic storage tablespace.
Reclaim space in every staging database at once¶
To reorganize and reduce every staging database, save this as a batch file and run it in a Db2 command window, with
the Capture Agents stopped. It writes its output to reorg.log:
@ECHO OFF
setlocal enableDelayedExpansion
for /f "tokens=4" %%x in ('db2 list database directory ^| find "Database name" ^| find "SQDRP"') do (
db2 connect to %%x >> reorg.log
db2 -x "SELECT 'REORG TABLE', SUBSTR(RTRIM(tabschema) || '.' || RTRIM(tabname), 1, 60), 'LONGLOBDATA;' FROM SYSCAT.TABLES WHERE type = 'T' AND tabschema LIKE 'SQDR%%'" > reorg_sqdr.sql
db2 -tvf reorg_sqdr.sql >> reorg.log
db2 ALTER TABLESPACE USERSPACE1 LOWER HIGH WATER MARK >> reorg.log
db2 ALTER TABLESPACE USERSPACE1 REDUCE MAX >> reorg.log
db2 ALTER TABLESPACE SQDRSPACE LOWER HIGH WATER MARK >> reorg.log
db2 ALTER TABLESPACE SQDRSPACE REDUCE MAX >> reorg.log
db2 disconnect all
)
Let Db2 reorganize the tables automatically¶
Staging databases created by SQDR Plus 6.60 and later have Db2's automatic reorganization turned on. For an older one, you can turn it on; a reorganization Db2 starts by itself can slow replication, so set Db2's maintenance window to a period of little replication:
db2 update db cfg for SQDRP0 using AUTO_MAINT ON AUTO_TBL_MAINT ON AUTO_RUNSTATS ON AUTO_REORG ON
Automatic reorganization doesn't reduce the table spaces: do that yourself when you need the disk space.
Add storage when a drive is full¶
The staging table spaces use automatic storage: they grow until their drive is full. Then Db2 can't allocate new
pages (SQL0289N, see SQLCODE=-289) and the Capture
Agent stops staging changes. Your options:
- Move the database to a larger drive.
- Enlarge the drive, for example by enlarging the virtual disk of the virtual machine.
- Add a path on another drive to the database's storage group. This is the quickest, and suits space you need only for a while, for example for a reorganization.
To add a path:
-
Find the storage group (normally
IBMSTOGROUP):db2 connect to SQDRP0 db2 "SELECT sgname FROM SYSCAT.STOGROUPS" -
Add the drive and spread the table spaces over it:
db2 "ALTER STOGROUP IBMSTOGROUP ADD 'F:'" db2 ALTER TABLESPACE USERSPACE1 REBALANCE db2 ALTER TABLESPACE SQDRSPACE REBALANCEIf
REBALANCEreturnsSQL2094W ... Reason code: "1", restart Db2 (see Start and stop Db2) and run it again.
To stop using the path later, drop it and rebalance again, so Db2 moves the data off it:
db2 "ALTER STOGROUP IBMSTOGROUP DROP 'F:'", then the two REBALANCE statements. See IBM's documentation on
altering automatic storage table spaces.
Move a database to another drive¶
Move a staging database or SQDRC to another drive when its drive runs out of space or is too slow: the staging databases do best on fast disks, such as SSDs (see Requirements). To give a full drive more room without moving, see also Add storage when a drive is full.
- Check the free space on the new drive and in a temporary backup folder (for example
D:\temp), and that the folder holds no older backup image of the database. - Stop replication (see Stop).
-
Back up the database, drop it, and restore it onto the new drives.
ONis the drive for the data,DBPATH ONthe drive for the database directory and its transaction logs:db2 deactivate db SQDRP0 db2 backup db SQDRP0 to D:\temp compress db2 drop db SQDRP0 db2 restore db SQDRP0 from D:\temp on E: dbpath on L: -
Check the database:
db2 connect to SQDRP0, thendb2 connect reset. - Start replication again (see Stop), and check in the SQDR Control Center that the agents that use the database run (green).
If the restore fails with SQL1224N, see
SQL1224N when restoring a staging database.
Create new staging databases on other drives¶
New staging databases are created on the drives chosen when Stelo Capture was installed. They're in the Launch Agent
property db2DftDbPath, for example ON 'E:' DBPATH ON 'L:' (data on E:, database directory and logs on L:).
To use other drives for the staging databases created from now on:
- In the SQDR Control Center, select the server and open its Configuration tab (see Configuration).
- Change
db2DftDbPath, keeping the same form:ON '<data drive>' DBPATH ON '<log drive>'. Click Save. - Restart the SQDR Plus Launch Agent service, which reads the value only when it starts. This restarts the Capture Agents: do it at a quiet time.
Existing databases stay where they are; move them as above. If the Launch Agent's configuration has no
db2DftDbPath (installed before SQDR Plus 6.60), the drives are part of the *TemplateDB_DB2 properties (for example
DB2iTemplateDB_DB2 for Db2 for i sources), as ON <drive> and DBPATH ON <drive> after the template path.
Move only the transaction logs¶
To move a database's transaction logs to another folder, with the database not in use:
db2 update db cfg for SQDRP0 using NEWLOGPATH L:\DB2Logs
db2 deactivate db SQDRP0
db2 activate db SQDRP0
Db2 moves the logs when the database is next activated.
Make the transaction log larger¶
Each database has a fixed amount of transaction log: the log file size (LOGFILSIZ, in 4 KB pages) times the number
of primary (LOGPRIMARY) and secondary (LOGSECOND) log files. A very large transaction fills it, and Db2 rolls it
back with SQL0964C The transaction log for the database is full (see
The transaction log for the database is full).
| Database | Set by Stelo Capture |
|---|---|
| SQDRC | LOGFILSIZ 16384, by the installer; Db2's defaults for the number of log files. |
| Staging databases created by SQDR Plus 6.60 and later | LOGFILSIZ 8192, LOGPRIMARY 56, LOGSECOND 200. |
| Older staging databases | Often LOGFILSIZ 4096. Stelo recommends 8192. |
To make the log larger:
-
Look at the current values:
db2 get db cfg for SQDRC | findstr /i "LOGFILSIZ LOGPRIMARY LOGSECOND" -
Raise the number of log files or their size. Db2 allows at most 256 primary and secondary log files together: at 56 + 200, raise the size instead, for example double it. Either way, the logs take more space on the log drive (doubling the size doubles it): check the free space first. For example, for a staging database at 8192:
db2 update db cfg for SQDRP0 using LOGFILSIZ 16384 -
For SQDRC, stop the Replicator Service and the Stelo Capture services; for a staging database, stop the Capture Agents that use it (see Stop). Then deactivate and activate the database, so the new size applies:
db2 deactivate db SQDRP0 db2 activate db SQDRP0 -
Start the services or agents again.
Limit Db2's memory¶
The Capture Agents, each a Java process, and the Replicator Service need memory next to Db2. Without a limit, Db2 can
take so much memory that the replication services fail. On a first install, the SQDR Plus installer limits Db2 to 60%
of the server's memory (INSTANCE_MEMORY 60, see Changes to Db2).
To check or set it:
- Look at the value:
db2 get dbm cfg | findstr /i INSTANCE_MEMORY. - Stop replication (see Stop).
-
Set it, then restart Db2:
db2 update dbm cfg using INSTANCE_MEMORY 60 immediate db2stop db2start -
Start replication again.
Db2 sizes its memory from what the server has when it starts. On a virtual machine with Hyper-V Dynamic Memory, a low startup memory leaves Db2 short (see SQLCODE=-101, SQLSTATE=54001): give the virtual machine at least the memory in Requirements as its startup and minimum memory. For Capture Agents that don't start because the server's memory is overcommitted, see Capture Agents don't start: memory overcommitted.
Fix common Db2 errors¶
Capture Agents report Db2 errors as SQLCODE, SQLSTATE and SQLERRMC values, for example
SQLCODE=-289, SQLSTATE=57011, SQLERRMC=USERSPACE1. The SQLCODE gives the Db2 message number: -289 is SQL0289N
(four digits, N for an error). Look it up in IBM's Db2 11.5 documentation; SQLERRMC
holds the message's values, here the table space. Errors that come up in the tasks on this page:
| Message | What to do |
|---|---|
SQL0552N ... does not have the privilege to perform operation |
Run the command window as a user with the authority in Db2 (see Open a Db2 command window). |
SQL1035N The operation failed because the specified database cannot be connected to in the mode requested, on a backup |
The database is still active or in use: check db2 list applications and deactivate it (see Offline backup). |
SQL0289N, SQLCODE=-289 |
The table space's drive is full: add storage, move the database or reclaim space. During a REORG, see Reorganize the staging tables. Details: SQLCODE=-289. |
SQL0964C The transaction log for the database is full |
Make the transaction log larger. Details: The transaction log for the database is full. |
SQLCODE=-101, SQLSTATE=54001 |
See Limit Db2's memory and SQLCODE=-101, SQLSTATE=54001. |
SQLCODE=-443, SQLSTATE=38553 after a Db2 update |
Rebind the Db2 CLI packages in the agent's staging database (see SQLCODE=-443 after a Db2 update). |
Package failed to rebind in db2diag.log |
Update the database's system catalog with db2updv115 (see Update Db2). |
SQL1224N when restoring a database |
See SQL1224N when restoring a staging database. |
SQL2094W ... Reason code: "1" on REBALANCE |
Restart Db2 (see Start and stop Db2) and run it again. |
| "Db2 detected a multiple partition instance" when updating Db2 | The server was renamed without updating Db2: see Rename the Stelo VM. |
'C:\Program' is not recognized in the Db2 command window |
See The Db2 command window reports 'C:\Program' is not recognized and Reinstall Db2. |
SQL4306N on SQDR.GETJARVERSION |
See SQL4306N on SQDR.GETJARVERSION. |
| Replication stops because Db2 isn't running | Start Db2 (see Start and stop Db2) and Replication stops: Db2 on the Stelo VM isn't running. |
For more errors, look in db2diag.log.
Check db2diag.log for Db2 errors and advice¶
Db2 writes its errors and warnings, with tuning advice, to its diagnostic log db2diag.log (see Find an agent's
staging database for its folder; in the container,
/home/db2inst1/sqllib/db2dump/DIAG0000/db2diag.0.log). The SQDR Control Center shows it under Server
Diagnostics, and Stelo Support gets it with the Stelo Capture
logs. Look in it when a Capture Agent or the Replicator Service
reports a Db2 error: entries name the database (DB : SQDRP0), and many say what to change.
| Entry in db2diag.log | What to do |
|---|---|
ADM4000W A catalog cache overflow condition has occurred |
Raise the database's catalog cache, for example db2 update db cfg for SQDRP0 using CATALOGCACHE_SZ 1000 (staging databases created by SQDR Plus 6.60 and later have 1000; older ones often 350). |
jdk_path dbm cfg parameter not a directory |
Db2 can't start Java for the Capture Agents' stored procedures. Set the Java folder of the Db2 installation, then restart Db2: db2 update dbm cfg using JDK_PATH C:\PROGRA~1\IBM\SQLLIB\java\jdk. |
The DB2DETAILDEADLOCK event monitor's queue is full |
In a staging database created before SQDR Plus 4.96, turn the event monitor off: connect to the database, then db2 "set event monitor DB2DETAILDEADLOCK state 0" and db2 "drop event monitor DB2DETAILDEADLOCK". |
Keep its size limited. On a first install, the SQDR Plus installer sets DIAGSIZE 2, so that Db2 rotates the log
over a fixed set of files (db2diag.0.log, db2diag.1.log, ...) instead of letting one file grow (see Changes to
Db2). On a server where Db2 was configured otherwise (for example
after reinstalling Db2), set it again, with replication stopped (see Stop):
db2 get dbm cfg | findstr /i DIAGSIZE
db2 update dbm cfg using DIAGSIZE 2
db2stop
db2start
Without DIAGSIZE, run db2diag -A to close the current db2diag.log and start a new one; you can then delete the
old one (see Free disk space on the server).
Start and stop Db2¶
Db2 runs as the Windows service of its instance, whose name ends with the instance name (for example DB2 - DB2COPY1
- DB2-0, service name DB2-0). It starts automatically with Windows.
- Start: start the service in Services, or run
db2startin an administrator Db2 command window. When the service starts, the scheduled task DB2ActivateSQDRC activates SQDRC (see Activate and deactivate). - Stop: do the stop for Db2 maintenance, then run
db2stop, or stop the service. Ifdb2stopreports that applications are still connected, find them withdb2 list applications;db2stop forcedisconnects them.
If replication stopped because Db2 isn't running, see Replication stops: Db2 on the Stelo VM isn't running.
Docker: as db2inst1 in the container, db2start and db2stop. Stopping the containers stops Db2.
Activate and deactivate a database¶
An active database stays loaded in memory, ready for connections, until you deactivate it or Db2 stops. Without activation, the first connection starts the database and the last disconnection stops it, which slows connections.
- SQDRC is activated by the installer and, at every start of the Db2 service, by the scheduled task
DB2ActivateSQDRC (log:
DB2activate.loginC:\ProgramData\StarQuest\sqdrplus). The task starts on the Db2 service's start event in the Application log (event 1, source the Db2 service name you entered in the installer). - Staging databases are activated by the Launch Agent when it starts a Capture Agent.
Deactivate a database before an offline backup, before dropping it, and for configuration changes that take effect
only when it's activated again (such as LOGFILSIZ). With no connections left (see Stop):
db2 list active databases
db2 deactivate db SQDRP0
db2 activate db SQDRP0
Update Db2 to a later fix pack¶
Install Db2 fix packs, and move to the Db2 level Stelo recommends (see Requirements), in a maintenance window. To update Db2 11.5 to a later 11.5 fix pack:
- Get the Db2 installer (ask Stelo Support for the recommended level), extract it, and unblock the download if Windows blocked it (Properties › Unblock).
- Back up the databases (see Offline backup).
- Stop replication (see Stop), and check with
db2 list applicationsthat nothing is connected. - Run the Db2 installer as an administrator and choose to update the existing Db2 copy. Restart the server if the installer asks.
-
Update the system catalog of each database, in a Db2 command window (it doesn't need replication stopped):
db2updv115 -d SQDRC db2updv115 -d SQDRP0 -
Start replication again. If a Capture Agent then fails with
SQLCODE=-443, SQLSTATE=38553, rebind the Db2 CLI packages in its staging database (see SQLCODE=-443 after a Db2 update).
Without db2updv115, db2diag.log can show Package failed to rebind errors for the database.
Docker: Db2 is updated with the image; when the release notes say a release brings a new Db2 level, run
db2updv115 as described in Upgrade the Docker container.
Reinstall Db2¶
Updating in place is enough in most cases. Remove Db2 and install it again only to move its program files to another drive, to repair an installation, for example one installed where Windows short (8.3) file names are turned off (see The Db2 command window reports 'C:\Program' is not recognized), or to start clean. To move to a new server, see Move Stelo Capture to a new server.
The databases stay on their drives: you catalog them again after the reinstall.
Prepare
- Note the account and password the Db2 services run as (for example
db2admin); uninstalling Db2 asks whether to remove that account. - Note the databases and their drive:
db2 list db directory(the Local database directory, for exampleL:). - Back up the databases (see Offline backup), to a folder outside the Db2 folders.
- Stop replication (see Stop) and set the Replicator Service and the Stelo Capture services to Disabled.
- Coming from a Db2 level before 11.5, check that each database can be upgraded with IBM's
db2ckupgrade(db2ckupgrade SQDRP0 -l SQDRP0.log), from thedb2\Windows\utilitiesfolder of the new installer. Stelo's db2cat_fix.zip has scripts that list the databases and run it for each.
Reinstall
- Uninstall Db2 in Settings › Apps, and restart the server.
- Install Db2 as in Install Db2 for LUW, as a new copy. Check that the instance's TCP/IP port is 50000: Stelo Capture and the Replicator Service connect to that port. Keep the Db2 services' account as before.
After
-
Set the Db2 configuration the SQDR Plus installer set (see Changes to Db2):
db2 update dbm cfg using JAVA_HEAP_SZ 204800 db2 update dbm cfg using DIAGSIZE 2 db2 update dbm cfg using INSTANCE_MEMORY 60 db2set DB2_CPU_FEATURE_DISABLE=AVX512 db2stop db2start -
Catalog each database on its drive.
db2 list db directory on L:lists the databases on a drive, even before they're cataloged:db2 catalog db SQDRC on L: db2 catalog db SQDRP0 on L: -
Coming from a Db2 level before 11.5, upgrade each database:
db2 upgrade db SQDRP0. - Update each database's system catalog:
db2updv115 -d SQDRP0. - Check each database:
db2 connect to SQDRP0, thendb2 connect reset. - Apply the Db2 license (see Apply a Db2 license).
- If the Db2 service has a different name now (for example
DB2-0instead ofDB2), edit the scheduled task DB2ActivateSQDRC in Task Scheduler: on its trigger, set the event source to the new service name (see Activate and deactivate). - Set the Stelo Capture services back to Automatic and start them, check the Capture Agents in the SQDR Control Center, then set the Replicator Service to Automatic (Delayed Start) and start it.
Stelo Capture reinstalls the Capture Agents' Java stored procedures (UDBProcs.jar) in each database when the Launch
Agent starts, if needed (see What the Stelo Capture upgrade changes).
Apply a Db2 license¶
The Db2 11.5 installer includes IBM's Community Edition license, which limits the cores and memory Db2 uses. When
Stelo sends you a Db2 license file (for example db2std_vpc.lic), apply it in an administrator command window, in
the folder where you saved it:
db2licm -a db2std_vpc.lic
db2licm -r db2dec
db2licm -l
db2licm -a adds the license, db2licm -r db2dec removes the Community Edition license, and db2licm -l shows the
licenses in effect. Licenses for earlier Db2 versions don't work with 11.5.
Docker: place the license file db2std_vpc.lic in /home/db2inst1; it's applied when the container starts (see
The control database).
Rename the Stelo VM¶
Db2 records the computer name: after renaming the Stelo VM, update Db2 as IBM describes in Changing hostname of the DB2 server. Otherwise later Db2 updates can fail with the misleading message "Db2 detected a multiple partition instance".
For Stelo Capture and the Replicator Service, a new name or address is like a move to another computer: see Move to another computer: Stelo Capture. Each Capture Agent publishes its connection string on the source when it starts; refresh each incremental source in the Data Replicator Manager so the Replicator Service uses the new one.
Encrypt connections to the staging databases¶
The Replicator Service reads staged changes from each agent's staging database over StarSQL, with the connection string the agent publishes on the source (property clientODBCString). To encrypt that connection with TLS:
- Set up TLS in the Stelo VM's Db2, as for a Db2 for LUW source (see Set up TLS in Db2), and note the TLS port, for example 50448.
- On each agent's Configuration tab, add
clientODBCStringwith the current connection string (the Agent field of the source's Incremental Replication settings shows it) changed to the TLS port and the TLS network library, for exampleDRIVER={StarSQL 32};HostName=sqdrplus.mydomain.com;Port=50448;Server=SQDRP0;PkgColId=STARSQL;UseJumboPackages=Yes;Netlib=SQSSL.DLL, and save. The agent restarts and publishes the new string. - In the Data Replicator Manager, open each incremental source that uses the agent and click Refresh (see Incremental Replication), so that the Replicator Service reads the new string. Agent then shows it.
Reach a remote Db2 or Informix source through this server's Db2¶
When SQDR runs outside the network of a Db2 or Informix source (for example in a cloud), it can reach the source through the Stelo VM's Db2, encrypted with TLS. Catalog the source there:
db2 catalog tcpip node dbserv remote dbserv server 50000
db2 catalog database mydb as mydb at node dbserv authentication SERVER
Then connect the SQDR source to the Stelo VM's TLS port: with StarSQL,
HostName=sqdrplus;Netlib=SQSSL.DLL;Port=50448;Server=mydb;PkgColID=SQDR; with the IBM Db2 ODBC driver, a GSKit
keystore holding the server's certificate and
Hostname=sqdrplus;Port=50448;Database=mydb;Protocol=TCPIP;Authentication=SERVER;SECURITY=SSL;Ssl_client_keystoredb=C:\SSL\keystore.kdb;Ssl_client_keystash=C:\SSL\keystore.sth
(see Connect SQDR with TLS). For an Informix source, catalog its DRDA
port (see Informix: Create the SQDR source).
Create a staging database with another code set¶
A staging database uses the UTF-8 code set, which suits nearly every source. An older Db2 for LUW source with another code set may call for a staging database with a matching one. You then create the database yourself and let a new Capture Agent use it, in its own schema (agents can share a staging database, each in its own schema).
Ask Stelo Support first
This is an advanced technique, written for SQDR Plus 5.18 and later. Stelo Capture now creates staging databases differently (it no longer restores a template), so check the steps with Stelo Support before you use them.
The example keeps the existing agent and its database SQDRP0 as they are, and creates SQDRP1 with the code set
IBM-1252.
- In the SQDR Control Center, add a placeholder Capture Agent for any source (it needs no relation to the real
one). In the wizard's control database step, choose
. - Don't start the placeholder agent: disable it as soon as it's created. In the server's agent summary, check that
its database is
SQDRP1. - Restart the SQDR Plus Jetty service (in Windows Services), which otherwise keeps a connection to
SQDRP1. -
Drop the database the wizard created:
db2 deactivate db SQDRP1 db2 drop db SQDRP1 -
As the Db2 administrator (for example
db2admin), create it again with the code set you need, on the drives the staging databases use (see Create new staging databases on other drives), and grant the Stelo Capture user (SQDR) what it needs:db2 create db SQDRP1 on E: dbpath on L: USING CODESET IBM-1252 TERRITORY US db2 connect to SQDRP1 user db2admin db2 grant secadm on database to SQDR db2 grant create_external_routine on database to user SQDR db2 grant implicit_schema on database to user SQDR db2 grant bindadd on database to user SQDR db2 commit db2 disconnect SQDRP1 -
As
SQDR, install the JAR file of the Java stored procedures, and create a dummy table in theSQDRschema so that the new agent uses a schema of its own (SQDR0):db2 connect to SQDRP1 user SQDR db2 CALL sqlj.install_jar('file:C:\Program Files\StarQuest\sqdrplus\capagent\UDBProcs.jar', 'CAPTUREPROCS_JAR') db2 create table SQDR.TAB1 (fld1 int) db2 commit db2 disconnect all -
If the placeholder agent was started after all, make sure the StarSQL packages are bound when the new agent first starts: in a Db2 command window, run
db2 connect to SQDRC, thendb2 "delete from SQDR.SQPKGINFO where name='SQDRP1'"(SQDRis the Launch Agent's control schema). - Add the Capture Agent you need. In the wizard's control database step, choose the existing database
SQDRP1. - In the agent summary, check that the new agent uses
SQDRP1(SQDR0). Start it. - Check the agent's Diagnostics: its tables and stored procedures are created in
the schema
SQDR0. The Launch Agent's diagnostics show the StarSQL packages bound in the collectionSTARSQL. - Create some subscriptions and check that they replicate.
- Delete the placeholder agent. Because the schema
SQDR0exists, its database isn't dropped.
Related¶
- Programs, services and files: what the installer changes in Db2, and freeing disk space
- Control database
- Control how staged changes are pruned
- Control and staging databases (Troubleshooting)
- Manage the Docker container
- Move Stelo Capture to a new server and Run a standby Stelo Capture server with Db2 HADR