Skip to content

XStream

By default the agent reads the log with LogMiner. With Use XStream-Out on step 2, it reads the changes from an XStream outbound server instead (to compare the two, and for XStream's licensing, see LogMiner or XStream).

The database administrator does these steps before you add the agent, after everything in Prepare the database: XStream also needs ARCHIVELOG mode, supplemental logging and the agent user.

Stelo Capture also installs the SQL of these steps as scripts, in C:\Program Files\StarQuest\sqdrplus\Tools\Oracle_XStream\XStream.zip, with a non-PDB and a PDB folder. The comments at the start of each script say what to edit and which user runs it:

Script Runs as Does See
step1.sql SYS AS SYSDBA Creates the XStream administrator and its tablespace, and grants its privileges. Once per database. XStream administrator
step1a.sql SYS AS SYSDBA CDB only: the PDB part of step1.sql, for another PDB. XStream administrator
step2.sql The XStream administrator Creates and starts an outbound server. Run it once for each agent, with a new server name each time. Outbound server
step3.sql SYS AS SYSDBA Revokes the DBA role from the XStream administrator. Outbound server
cleanup0.sql, cleanup1.sql SYS AS SYSDBA, then the XStream administrator Grant the DBA role again, then stop and drop the outbound server. Re-create the outbound server
cleanup2.sql SYS AS SYSDBA Drops the XStream administrator and its tablespace, when you no longer use XStream.

The zip file also has tuning.sql, which holds no settings at present.

XStream licensing

Capture with XStream needs licensing that takes the source's processors into account. Run these queries on the Oracle database (on each instance of an Oracle RAC database) and send the output to Stelo:

SELECT STAT_NAME, TO_CHAR(VALUE) AS VALUE, COMMENTS FROM V$OSSTAT
 WHERE STAT_NAME IN ('NUM_CPUS', 'NUM_CPU_CORES', 'NUM_CPU_SOCKETS');
SELECT PLATFORM_NAME FROM V$DATABASE;

Instead, you can send the operating system's processor details from each database server, such as the output of cat /proc/cpuinfo on Linux, or of lparstat -i on AIX on IBM Power servers.

Required patches

Apply these Oracle patches if your release is listed. In My Oracle Support (Patches & Updates), search by the bug number below and your platform, and download the patch for your Oracle version.

Oracle release Patch for
19.12, 19.13, 19.14, 19.15, 21.4, 21.5 Bug 34010877: ORA-4031 on the streams pool area with multiple subpools
19.12, 19.14, 19.15 on Linux x86-64; 19.16 on IBM AIX on Power Systems Bug 34470389: the XStream client stops retrieving changes, with the propagation receiver waiting for memory
19.15 Bug 32338220: ORA-600 [knacpft_ProcessFetchedTxns250] (fixed in the 19c October 2022 release update and in 21.3)

Database settings

XStream needs enable_goldengate_replication set to TRUE, and the outbound server keeps the changes in the streams pool (Stelo recommends at least 6 GB). Neither change needs a restart.

SHOW PARAMETER enable_goldengate_replication
SHOW PARAMETER streams_pool_size

ALTER SYSTEM SET enable_goldengate_replication = TRUE SCOPE = BOTH;
ALTER SYSTEM SET streams_pool_size = 6G SCOPE = BOTH;

XStream administrator

The agent connects to the outbound server as an XStream administrator, XSTRMADMIN by default (C##XSTRMADMIN for a CDB). It needs its own tablespace, the XStream administrator privilege, and the DBA role while it creates the outbound server. If the user and tablespace already exist (for example for another agent), skip to the next step; for another PDB of the same CDB, repeat only the PDB part.

For a database that isn't a CDB, as SYS AS SYSDBA:

CREATE TABLESPACE XSTREAM_TBS DATAFILE '/u01/oradata/ORCL/xstream_tbs01.dbf'
  SIZE 250M AUTOEXTEND ON MAXSIZE UNLIMITED;
CREATE USER XSTRMADMIN IDENTIFIED BY "password"
  DEFAULT TABLESPACE XSTREAM_TBS QUOTA UNLIMITED ON XSTREAM_TBS ACCOUNT UNLOCK;
GRANT CREATE SESSION, CONNECT, RESOURCE, UNLIMITED TABLESPACE TO XSTRMADMIN;
GRANT DBA TO XSTRMADMIN;    -- only while you create the outbound server
BEGIN
  DBMS_XSTREAM_AUTH.GRANT_ADMIN_PRIVILEGE(
    grantee                 => 'XSTRMADMIN',
    privilege_type          => '*',
    grant_select_privileges => TRUE);
END;
/

With Oracle Managed Files (for example on ASM), leave out the file name: DATAFILE SIZE 250M AUTOEXTEND ON ....

For a CDB, as SYS AS SYSDBA; replace PDB1 with your PDB. The example uses Oracle Managed Files; without them, give a file name as above.

ALTER SESSION SET CONTAINER = CDB$ROOT;
CREATE TABLESPACE XSTREAM_TBS DATAFILE SIZE 250M AUTOEXTEND ON MAXSIZE UNLIMITED;
CREATE USER C##XSTRMADMIN IDENTIFIED BY "password"
  DEFAULT TABLESPACE XSTREAM_TBS QUOTA UNLIMITED ON XSTREAM_TBS ACCOUNT UNLOCK CONTAINER = ALL;
GRANT CREATE SESSION, CONNECT, RESOURCE, UNLIMITED TABLESPACE, SET CONTAINER TO C##XSTRMADMIN;
GRANT DBA TO C##XSTRMADMIN;    -- only while you create the outbound server

-- PDB part: repeat for each PDB you capture from with XStream
ALTER SESSION SET CONTAINER = PDB1;
CREATE TABLESPACE XSTREAM_TBS DATAFILE SIZE 250M AUTOEXTEND ON MAXSIZE UNLIMITED;
GRANT CREATE SESSION, CONNECT, RESOURCE, UNLIMITED TABLESPACE, SET CONTAINER TO C##XSTRMADMIN;
ALTER SESSION SET CONTAINER = CDB$ROOT;
BEGIN
  DBMS_XSTREAM_AUTH.GRANT_ADMIN_PRIVILEGE(
    grantee                 => 'C##XSTRMADMIN',
    privilege_type          => '*',
    grant_select_privileges => TRUE,
    container               => 'PDB1');
END;
/

-- Root only, once
BEGIN
  DBMS_XSTREAM_AUTH.GRANT_ADMIN_PRIVILEGE(
    grantee                 => 'C##XSTRMADMIN',
    privilege_type          => '*',
    grant_select_privileges => TRUE,
    container               => 'CDB$ROOT');
END;
/

Outbound server

Create one outbound server for each Capture Agent. Agents that share an outbound server fail, and they leave inactive sessions on the database until it runs out of processes (ORA-00020) and the listener refuses new connections.

  1. As the XStream administrator (for a CDB, in the root container), create and start the outbound server. Its name is the XStream-Out Name on step 2. For a CDB, source_database is the PDB's global name; for other databases, leave that line out.

    BEGIN
      DBMS_XSTREAM_ADM.CREATE_OUTBOUND(
        server_name     => 'SQDRAGENT1',
        source_database => 'PDB1.EXAMPLE.COM',
        include_ddl     => TRUE);
    END;
    /
    BEGIN
      DBMS_XSTREAM_ADM.START_OUTBOUND(server_name => 'SQDRAGENT1');
    END;
    /
    
  2. Check that the XStream administrator owns the outbound server. If CONNECT_USER is SYS, it was created as SYS and the agent can't attach to it ("ORA-26827: Insufficient privileges to attach to XStream outbound server"): drop it and create it again as the XStream administrator.

    SELECT SERVER_NAME, CONNECT_USER FROM DBA_XSTREAM_OUTBOUND;
    
  3. As SYS AS SYSDBA, revoke the DBA role from the XStream administrator (for a CDB, C##XSTRMADMIN, in the root):

    REVOKE DBA FROM XSTRMADMIN;
    
  4. Oracle RAC: make the capture process use the RAC service. Get its name with SELECT CAPTURE_NAME FROM DBA_CAPTURE;, then:

    BEGIN
      DBMS_CAPTURE_ADM.SET_PARAMETER(
        capture_name => 'CAP$_SQDRAGENT1_1',
        parameter    => 'use_rac_service',
        value        => 'Y');
    END;
    /
    

Use XStream with the agent

A new agent: on step 2, select Use XStream-Out (property xstream):

Option What it does Default When to change it
XStream-Out Name The outbound server, created with DBMS_XSTREAM_ADM.CREATE_OUTBOUND, one for each agent. — —
XStream User The XStream administrator. XSTRMADMIN (C##XSTRMADMIN for a CDB) When your XStream administrator has another name.

After you start the agent, check that it reads from XStream (see Check capture on the database).

An existing LogMiner agent: switching is like a warm start and can miss changes. Choose a time when the source tables don't change, or be ready to run new baselines.

  1. Set up the outbound server as described above.
  2. In the Data Replicator Manager, Pause the incremental groups that use the agent.
  3. On the agent's Configuration tab, set xstream to true and set xstreamServer, xstreamUser and xstreamPassword (stored encrypted). Saving restarts the agent.
  4. Check the Diagnostics tab for entries from XStreamsReader, then Resume the groups. Run TargetChecker to compare the source and destination tables, and run new baselines if anything is missing.

Re-create the outbound server

Re-create the outbound server when it can't continue, usually because archived logs it needed were deleted. The changes in those logs can't be captured: the subscriptions need new baselines.

  1. Connect as the XStream administrator (for a CDB, in the root) and note the server's settings:

    SELECT SERVER_NAME, SOURCE_DATABASE FROM ALL_XSTREAM_OUTBOUND_PROGRESS;
    SELECT * FROM DBA_CAPTURE_PARAMETERS WHERE SET_BY_USER = 'YES';
    SELECT * FROM DBA_APPLY_PARAMETERS WHERE SET_BY_USER = 'YES';
    
  2. As SYS AS SYSDBA, grant the DBA role to the XStream administrator again.

  3. As the XStream administrator, stop and drop the outbound server, then create and start it with the same name (see Outbound server):

    BEGIN
      DBMS_XSTREAM_ADM.STOP_OUTBOUND(server_name => 'SQDRAGENT1', force => TRUE);
    END;
    /
    BEGIN
      DBMS_XSTREAM_ADM.DROP_OUTBOUND(server_name => 'SQDRAGENT1');
    END;
    /
    
  4. Set again the parameters you noted in step 1: capture parameters (such as use_rac_service) with DBMS_CAPTURE_ADM.SET_PARAMETER, using the new name from SELECT CAPTURE_NAME FROM DBA_CAPTURE;, and outbound server parameters with DBMS_XSTREAM_ADM.SET_PARAMETER, for example:

    BEGIN
      DBMS_XSTREAM_ADM.SET_PARAMETER(
        streams_name => 'SQDRAGENT1',
        streams_type => 'apply',
        parameter    => 'max_sga_size',
        value        => '4096');
    END;
    /
    
  5. Revoke the DBA role again, restart the Capture Agent, and run new baselines for its subscriptions.

XStream diagnostics

When XStream capture is slow or stops, or the agent waits without an error, these queries show what the capture process and the outbound server are doing. Run them as the XStream administrator, in the root container for a CDB, in SQL*Plus or SQL Developer. When you contact Stelo Support about XStream, send their output with the agent's logs (see Send logs to Stelo).

Run this first, so that dates show the time too:

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

Capture latency. LATENCY_SECONDS is the age of the last change the capture process read. A large value, for example right after the agent was stopped for several days, means capture is behind: find out why.

SELECT CAPTURE_NAME, STATE,
       ((SYSDATE - CAPTURE_MESSAGE_CREATE_TIME) * 86400) LATENCY_SECONDS,
       ((SYSDATE - CAPTURE_TIME) * 86400) LAST_STATUS,
       TO_CHAR(CAPTURE_TIME, 'HH24:MI:SS MM/DD/YY') CAPTURE_TIME,
       TO_CHAR(CAPTURE_MESSAGE_CREATE_TIME, 'HH24:MI:SS MM/DD/YY') CREATE_TIME
  FROM GV$XSTREAM_CAPTURE;

Outbound server position. PROCESSED_LOW_POSITION is the outbound server's low-water mark: it should move forward regularly while the database changes. The query also shows the outbound server's name and the source database.

SELECT SERVER_NAME, SOURCE_DATABASE, PROCESSED_LOW_POSITION,
       TO_CHAR(PROCESSED_LOW_TIME, 'HH24:MI:SS MM/DD/YY') PROCESSED_LOW_TIME
  FROM ALL_XSTREAM_OUTBOUND_PROGRESS;

Capture state. On a busy database, TOTAL_MESSAGES_CAPTURED and TOTAL_MESSAGES_ENQUEUED (counted since the capture process last started) should grow.

SELECT CAPTURE_NAME, STATE, TOTAL_MESSAGES_CAPTURED, TOTAL_MESSAGES_ENQUEUED FROM GV$XSTREAM_CAPTURE;
STATE What it means
CAPTURING CHANGES The capture process is reading changes.
WAITING FOR TRANSACTION The capture process waits for LogMiner to provide more transactions.
WAITING FOR REDO The capture process waits for the redo or archived log named in the state (for example WAITING FOR REDO: FILE <path>, THREAD 1, SEQUENCE <n>, SCN <scn>). If that log is missing, the capture process and the agent wait, without an error, until it's available again (see Archive log retention).
PAUSED FOR FLOW CONTROL The capture process can't queue more changes, because memory is low or because the outbound server takes them more slowly than it captures them. Oracle slows capture to limit spilling.

Outbound server memory. The streams pool memory the outbound server's apply reader uses and has allocated, in MB, and how many messages it dequeued and spilled. Many spilled messages slow capture and may need tuning.

SELECT APPLY_NAME AS APP, SGA_USED/(1024*1024) AS USED, SGA_ALLOCATED/(1024*1024) AS ALLOCATED,
       TOTAL_MESSAGES_DEQUEUED AS DEQUEUED, TOTAL_MESSAGES_SPILLED AS SPILLED
  FROM GV$XSTREAM_APPLY_READER;

Streams pool. Look at the pool's free memory and at apply shared t, the memory the outbound server uses. With the previous query, this confirms a low-memory condition (see Database settings).

SELECT * FROM GV$SGASTAT WHERE POOL LIKE '%streams%' AND BYTES > 1000 ORDER BY BYTES DESC;

Events and errors. Starts, stops and errors of the capture and apply processes, with any ORA- error in ERROR_NUMBER and ERROR_MESSAGE. To see fewer rows, add WHERE EVENT_TIME > SYSDATE - 3 or WHERE ERROR_NUMBER IS NOT NULL. For example, ORA-26920: outbound server "" has been stopped follows a stop of the outbound server.

SELECT * FROM ALL_REPLICATION_PROCESS_EVENTS ORDER BY EVENT_TIME DESC;

For a fuller report, run Oracle's Streams Configuration Report and Health Check Script (My Oracle Support Doc ID 273674.1) as a user with SYSDBA, on each node of an Oracle RAC database. It also runs on releases after Oracle 12. See also Monitoring XStream Out in Oracle's XStream guide for your release (for example Oracle 19c).