Stream的主要环节分为捕获(capture),分发(propagation)和应用(apply)。如果从应用这些环节所处的地方,可以分为:
UpStreams(capture和propagation在source数据库,apply在destination数据库)。
DownStream(capture和propagation,以及apply在destination数据库)
如果成对象来分,可以分成:
database级的stream
owner级的stream
table级的stream
下面我们来建立几个stream:
(一)owner级UpStream:
1. 在source和destination机(注以下操作需要在2个机器上进行):
1.1 创建stream用户的表空间:
create tablespace tbs_stream datafile '/oracle/app/oracle/oradata/stream02/tbs_stream02.dbf' size 200M;
1.2 将logmnr的默认表空间转到刚刚建立的表空间:
SQL> execute dbms_logmnr_d.set_tablespace('tbs_stream');
PL/SQL procedure successfully completed.
SQL>
1.3 创建stream user和授权:
SQL> CREATE USER strmadmin IDENTIFIED BY strmadmin
2 DEFAULT TABLESPACE tbs_stream
3 QUOTA UNLIMITED ON tbs_stream;
SQL> grant dba to strmadmin;
Grant succeeded.
SQL>
SQL>
SQL> BEGIN
2 DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE(
3 grantee => 'strmadmin',
4 grant_privileges => true);
END;
/ 5 6
PL/SQL procedure successfully completed.
SQL>
1.4 check stream admin用户的情况:
SQL> SELECT * FROM dba_streams_administrator;
USERNAME LOCAL_ ACCESS
------------------------------------------------------------ ------ ------
STRMADMIN YES YES
SQL>
1.6 查一下arch目录是否设置正确,是否启动归档模式。
1.7 设置tnsname,能tnsping到对方的机器。
1.8 设置global_names
SQL> Alter system set global_names=TRUE scope=BOTH;
System altered.
SQL>
1.9 设置stream需要的初始化参数:
alter system set aq_tm_processes=2 scope=both;
alter system set global_names=true scope=both;
alter system set job_queue_processes=10 scope=both;
alter system set parallel_max_servers=20 scope=both;
alter system set undo_retention=3600 scope=both;
alter system set nls_date_format='YYYY-MM-DD HH24:MI:SS' scope=spfile;
alter system set streams_pool_size=25M scope=spfile;
alter system set utl_file_dir='*' scope=spfile;
alter system set open_links=4 scope=spfile;
1.10 建立dblink。
在source机:
create database link stream02 connect to strmadmin identified by strmadmin using 'stream02';
在destination机:
create database link stream01 connect to strmadmin identified by strmadmin using 'stream01';
2. 在source数据库启用Database 追加日志
alter database add supplemental log data;
3.在source数据库创建stream队列:
connect strmadmin/strmadmin
SQL> exec dbms_streams_adm.set_up_queue;
PL/SQL procedure successfully completed.
注意如果没有指定queue_table和queue_name,数据库是默认给queue_name为STREAMS_QUEUE_TABLE ,queue_name为STREAMS_QUEUE:
SQL> select owner,queue_table,name from dba_queues where owner='STRMADMIN';
OWNER QUEUE_TABLE NAME
-------------------- ------------------------------------------------------------ ------------------------------------------------------------
STRMADMIN STREAMS_QUEUE_TABLE STREAMS_QUEUE
STRMADMIN STREAMS_QUEUE_TABLE AQ$_STREAMS_QUEUE_TABLE_E
SQL>
4. 在destination数据库创建stream队列:
connect strmadmin/strmadmin
begin
dbms_streams_adm.set_up_queue(
queue_table => 'dest_queue_table',
queue_name => 'dest_queue');
end;
/
SQL> select owner,queue_table,name from dba_queues where owner='STRMADMIN';
OWNER QUEUE_TABLE NAME
------------------------------------------------------------ ------------------------------------------------------------ ------------------------------------------------------------
STRMADMIN DEST_QUEUE_TABLE DEST_QUEUE
STRMADMIN DEST_QUEUE_TABLE AQ$_DEST_QUEUE_TABLE_E
SQL>
5. 在source数据库创建capture进程:
connect strmadmin/strmadmin
begin
dbms_streams_adm.add_schema_rules(
schema_name => 'hr',
streams_type => 'capture',
streams_name => 'capture_stream01_to_stream02',
queue_name => 'strmadmin.STREAMS_QUEUE',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
source_database => null,
inclusion_rule => true);
end;
/
此时可以在source数据库看到有c001这样的进程.
6.初始化需要做stream的schema:
6.1 在source数据库导出:
exp userid=hr/hr file='/oracle/hr.dmp' object_consistent=y rows=y
6.2 在destination数据库导入
imp userid=system/oracle@stream02 file='/oracle/hr.dmp' ignore=y commit=y log='/oracle/hr.log' streams_instantiation=y fromuser=hr touser=hr
7.在source数据库创建schema级分发规则:
begin
dbms_streams_adm.add_schema_propagation_rules(
schema_name => 'hr',
streams_name => 'propag_strm01_to_strm02',
source_queue_name => 'strmadmin.STREAMS_QUEUE',
destination_queue_name => 'strmadmin.dest_queue@stream02',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
source_database => 'stream01',
inclusion_rule => true);
end;
/
注意此时job queue进程开始工作(j00x)
8. 在source数据库设置分发作业计划,latency => 0表示实时分发。
begin
dbms_aqadm.alter_propagation_schedule(
queue_name => 'STREAMS_QUEUE',
destination => 'stream02',
latency => 0);
end;
/
9. 在destination数据库创建apply进程:
begin
dbms_streams_adm.add_schema_rules(
schema_name => 'hr',
streams_type => 'apply',
streams_name => 'apply_strm01_to_strm02',
queue_name => 'strmadmin.dest_queue',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
source_database => 'stream01',
inclusion_rule => true);
end;
/
注意此时有a001进程出现。
10. 最后启动stream:
10.1 在destination数据库启动apply:
begin
dbms_apply_adm.start_apply(
apply_name => 'apply_strm01_to_strm02');
end;
/
10.2 在source数据库启动capture:
begin
dbms_capture_adm.start_capture(
capture_name => 'capture_stream01_to_stream02');
end;
/
11. 停止stream:
11.1 在source数据库停止capture:
begin
dbms_capture_adm.stop_capture(
capture_name => 'capture_stream01_to_stream02');
end;
/
11.2 在destination数据库停止apply:
begin
dbms_apply_adm.stop_apply(
apply_name => 'apply_strm01_to_strm02');
end;
/
(二) owner级downstream:
1.1~1.10 同upstream。
2. 在downstream site设置:
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE SCOPE=SPFILE;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='LOCATION=/oracle/app/oracle/arch/standby_arch VALID_FOR=(STANDBY_LOGFILE,PRIMARY_ROLE)' SCOPE=SPFILE;
3. 在source site和downstream site同时设置:
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(stream01,stream02)' SCOPE=SPFILE;
4. 从soruce site创建standby redo:
4.1 在source库查询redo情况:
SQL> select THREAD#, GROUP#, BYTES/1024/1024 from V$LOG;
THREAD# GROUP# BYTES/1024/1024
---------- ---------- ---------------
1 1 50
1 2 50
1 3 50
SQL>
注意创建standby redo时,大小要和source site的redo大小一致,数量上要比source site的redo多一个。
4.2 在downstream site:
ALTER DATABASE ADD STANDBY LOGFILE GROUP 4
('/oracle/app/oracle/oradata/stream02/stdy_redo04.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 5
('/oracle/app/oracle/oradata/stream02/stdy_redo05.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 6
('/oracle/app/oracle/oradata/stream02/stdy_redo06.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 7
('/oracle/app/oracle/oradata/stream02/stdy_redo04.log') SIZE 50M;
4.3 在downstream site上检查一下是否建立成功:
SQL> SELECT GROUP#, THREAD#, SEQUENCE#, ARCHIVED, STATUS FROM V$STANDBY_LOG;
GROUP# THREAD# SEQUENCE# ARCHIV STATUS
---------- ---------- ---------- ------ --------------------
4 0 0 YES UNASSIGNED
5 0 0 YES UNASSIGNED
6 0 0 YES UNASSIGNED
7 0 0 YES UNASSIGNED
SQL>
5. 准备source site的参数:
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE SCOPE=SPFILE;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=stream02 LGWR SYNC NOREGISTER
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=stream02'
SCOPE=SPFILE;
6. 在source site和downstream site同时设置参数:
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(stream01,stream02)' SCOPE=SPFILE;
7. 开始stream配置:
7.1 在source site创建需要复制的schema:
SQL> create user hjm identified by hjm default tablespace users;
User created.
SQL> grant connect, resource, create table to hjm;
Grant succeeded.
SQL>
7.2 在downstream site设置stream queue:
conn strmadmin/strmadmin
BEGIN
DBMS_STREAMS_ADM.SET_UP_QUEUE(
queue_table => 'strmadmin.DOWNSTREAM_Q_TABLE',
queue_name => 'strmadmin.DOWNSTREAM_Q',
queue_user => 'STRMADMIN');
END;
/
1* select name, queue_table,QUEUE_TYPE,USER_COMMENT from user_queues
SQL> /
NAME QUEUE_TABLE QUEUE_TYPE USER_COMMENT
------------------------------ -------------------- ---------------------------------------- ------------------------------
AQ$_DOWNSTREAM_Q_TABLE_E DOWNSTREAM_Q_TABLE EXCEPTION_QUEUE exception queue
DOWNSTREAM_Q DOWNSTREAM_Q_TABLE NORMAL_QUEUE
注意,从最佳实践出发,建议downstream设置一个queue,而不是多个queue。这一个queue将用于catpure和apply的queue,能避免分发和queue to queue传输的冗余。
7.3 在downstream site创建apply进程:
conn strmadmin/strmadmin
BEGIN
DBMS_APPLY_ADM.CREATE_APPLY(
queue_name => 'strmadmin.DOWNSTREAM_Q',
apply_name => 'DOWNSTREAM_APPLY',
apply_captured => TRUE
);
END;
/
7.4 检查 apply的信息:
SQL> SELECT apply_name, status, queue_name FROM DBA_APPLY where APPLY_NAME='DOWNSTREAM_APPLY';
APPLY_NAME STATUS QUEUE_NAME
------------------------------ ---------------- ------------------------------------------------------------
DOWNSTREAM_APPLY DISABLED DOWNSTREAM_Q
SQL>
SQL> l
1 SELECT parameter, value, set_by_user
2 FROM DBA_APPLY_PARAMETERS
3* WHERE apply_name = 'DOWNSTREAM_APPLY'
SQL> /
PARAMETER VALUE SET_BY
-------------------------------------------------- -------------------------------------------------- ------
ALLOW_DUPLICATE_ROWS N NO
COMMIT_SERIALIZATION FULL NO
DISABLE_ON_ERROR Y NO
DISABLE_ON_LIMIT N NO
MAXIMUM_SCN INFINITE NO
PARALLELISM 1 NO
STARTUP_SECONDS 0 NO
TIME_LIMIT INFINITE NO
TRACE_LEVEL 0 NO
TRANSACTION_LIMIT INFINITE NO
TXN_LCR_SPILL_THRESHOLD 10000 NO
WRITE_ALERT_LOG Y NO
12 rows selected.
SQL>
7.5 在downstream site创建capture进程:
conn strmadmin/strmadmin
BEGIN
DBMS_CAPTURE_ADM.CREATE_CAPTURE(
queue_name => 'strmadmin.DOWNSTREAM_Q',
capture_name => 'DOWNSTREAM_CAPTURE',
rule_set_name => NULL,
start_scn => NULL,
source_database => 'stream01',
use_database_link => true,
first_scn => NULL,
logfile_assignment => 'implicit');
END;
/
7.6 检查capture的信息:
SQL> SELECT capture_name, status from dba_capture;
CAPTURE_NAME STATUS
------------------------------------------------------------ ----------------
DOWNSTREAM_CAPTURE DISABLED
SQL>
SQL> SELECT parameter, value, set_by_user FROM DBA_CAPTURE_PARAMETERS;
PARAMETER VALUE SET_BY
-------------------------------------------------- -------------------------------------------------- ------
DISABLE_ON_LIMIT N NO
DOWNSTREAM_REAL_TIME_MINE N NO
MAXIMUM_SCN INFINITE NO
MESSAGE_LIMIT INFINITE NO
PARALLELISM 1 NO
STARTUP_SECONDS 0 NO
TIME_LIMIT INFINITE NO
TRACE_LEVEL 0 NO
WRITE_ALERT_LOG Y NO
9 rows selected.
SQL>
8. 为实时变动设置capture:
8.1 在downstream site:
conn strmadmin/strmadmin
SQL> BEGIN
2 DBMS_CAPTURE_ADM.SET_PARAMETER(
3 capture_name => 'DOWNSTREAM_CAPTURE',
4 parameter => 'downstream_real_time_mine',
5 value => 'y');
6 END;
7 /
PL/SQL procedure successfully completed.
SQL>
8.2 在downstream site设置rule规则:
SQL> BEGIN
2 DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
3 schema_name => 'hjm',
4 streams_type => 'capture',
5 streams_name => 'downstream_capture',
6 queue_name => 'strmadmin.downstream_q',
7 include_dml => true,
8 include_ddl => true,
9 include_tagged_lcr => false,
10 source_database => 'stream01',
11 inclusion_rule => TRUE);
12 END;
13 /
PL/SQL procedure successfully completed.
SQL>
8.3 在downstream site检查rule设置情况:
SQL> l
1 SELECT rule_name, rule_condition
2 FROM DBA_STREAMS_SCHEMA_RULES
3 WHERE streams_name = 'DOWNSTREAM_CAPTURE'
4* AND streams_type = 'CAPTURE'
SQL> /
RULE_NAME RULE_CONDITION
------------------------------------------------------------ ------------------------------------------------------------
HJM15 ((:dml.get_object_owner() = 'HJM') and :dml.is_null_tag() =
'Y' and :dml.get_source_database_name() = 'STREAM01.REGRESS.
RDBMS.DEV.US.ORACLE.COM' )
HJM16 ((:ddl.get_object_owner() = 'HJM' or :ddl.get_base_table_own
er() = 'HJM') and :ddl.is_null_tag() = 'Y' and :ddl.get_sour
ce_database_name() = 'STREAM01.REGRESS.RDBMS.DEV.US.ORACLE.C
OM' )
SQL>
9. 实例化需要同步的owner:
9.1 在source site:
exp system/oracle owner=hjm file=hjm.dump log=hjm.log object_consistent=Y
9.2 在downstream site:
SQL> create user hjm identified by hjm default tablespace users;
User created.
SQL> grant connect, resource, create table to hjm;
Grant succeeded.
SQL>
9.3 在source site:
imp system/oracle@stream02 file=hjm.dump full=y ignore=y STREAMS_INSTANTIATION=Y
10. 在downstream site开始启动apply进程:
conn strmadmin/strmadmin
SQL> exec DBMS_APPLY_ADM.START_APPLY(apply_name => 'DOWNSTREAM_APPLY');
PL/SQL procedure successfully completed.
10.1 检查 apply情况:
SQL> select apply_name, status from dba_apply where APPLY_NAME='DOWNSTREAM_APPLY';
APPLY_NAME STATUS
------------------------------ ----------------
DOWNSTREAM_APPLY ENABLED
SQL>
可以看到已经从disbale变成enabled。
11. 在downstream site启动capture进程:
conn strmadmin/strmadmin
SQL> exec DBMS_CAPTURE_ADM.START_CAPTURE(capture_name => 'DOWNSTREAM_CAPTURE');
PL/SQL procedure successfully completed.
SQL>
11.1 检查 capture情况:
SQL> select capture_name, status from dba_capture;
CAPTURE_NAME STATUS
------------------------------------------------------------ ----------------
DOWNSTREAM_CAPTURE ENABLED
SQL>
看到capture的status也从disable变成enabled了。
至此,downstream建立完毕。
【trouble shooting】:
1.对于upstream,需要检查dba_capture, dba_propagation, dba_apply:
--在source数据库:
SQL> l
1 select propagation_name as name,status,ERROR_MESSAGE from dba_propagation
2 union all
3* select CAPTURE_NAME,status,ERROR_MESSAGE from dba_capture
SQL> /
NAME STATUS ERROR_MESSAGE
------------------------------------------------------------ ---------------- --------------------------------------------------
PROPAG_STRM01_TO_STRM02 ENABLED
CAPTURE_STREAM01_TO_STREAM02 ENABLED
SQL>
--在destination数据库:
1* SELECT apply_name,status,error_message from dba_apply
SQL> /
APPLY_NAME STATUS ERROR_MESSAGE
------------------------------------------------------------ ---------------- ----------------------------------------
APPLY_STRM01_TO_STRM02 ENABLED
以上均为enable说明各个进程正常;
如果为disable,需要用dbms_capture_adm.start_capture/DBMS_PROPAGATION_ADM.start_propagation/dbms_apply_adm.start_apply包来进行启动;
如果是abort,说明是异常终止,需要查对应的error message,排除错误后启动。
案例一:
upstream的apply进程和capture进程都正常,但是无法同步,查dba_propagation,发现异常:
SQL> l
1* select propagation_name,status,ERROR_MESSAGE from dba_propagation
SQL>
PROPAGATION_NAME STATUS ERROR_MESSAGE
----------------------------- --------------------- -----------------------------------------
PROPAG_STRM01_TO_STRM02 DISABLED ORA-12541: TNS:no listener
ORA-12541: TNS:no listener
进一步查alertlog中发现:
Sun Jul 17 06:01:02 2011
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
ORA-12541: TNS:no listener
ORA-12541: TNS:no listener
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) disabled due to 16 consecutive errors.
Sun Jul 17 06:01:46 2011
Error 12541 received logging on to the standby
Check whether the listener is up and running.
Sun Jul 17 06:01:46 2011
Errors in file /oracle/app/oracle/admin/stream01/bdump/stream01_arc1_21844.trc:
ORA-12541: TNS:no listener
PING[ARC1]: Heartbeat failed to connect to standby 'stream02'. Error is 12541.
Sun Jul 17 06:06:46 2011
确实看到了问题存在。我们进一步看:
[oracle@stream1 bdump]$ cat alert*.log |grep Propagation
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) encountered following error:
Propagation Schedule for (STRMADMIN.STREAMS_QUEUE, STREAM02.REGRESS.RDBMS.DEV.US.ORACLE.COM) disabled due to 16 consecutive errors.
[oracle@stream1 bdump]$
我们看到,propagation进程如果尝试连接,发现没有侦听,尝试16次之后,会自动disable propagation进程。
因此我们要做的就是启动侦听,再启动propagation进程。
SQL> BEGIN
2 DBMS_PROPAGATION_ADM.START_PROPAGATION(
3 propagation_name => 'propag_strm01_to_strm02');
4 END;
5 /
PL/SQL procedure successfully completed.
SQL> select propagation_name,,status,ERROR_MESSAGE from dba_propagation;
PROPAGATION_NAME STATUS ERROR_MESSAGE
--------------------------- ---------------- -----------------------------
PROPAG_STRM01_TO_STRM02 ENABLED
SQL>
2. 对于downstream,由于没有propagation进程,我们可以直接看apply和capture进程的情况:
SQL> select propagation_name as name,status,ERROR_MESSAGE from dba_propagation
2 union all
3 select CAPTURE_NAME,status,ERROR_MESSAGE from dba_capture
4 union all
5 SELECT apply_name,status,error_message from dba_apply
6 /
NAME STATUS ERROR_MESSAGE
------------------------------------------------------------ ---------------- ----------------------------------------
DOWNSTREAM_CAPTURE ENABLED
DOWNSTREAM_APPLY ABORTED ORA-26714: User error encountered while
applying
SQL>
在这个案例中,我们看到apply进程出现了问题,问题是ora-26174。进一步:
[oracle@stream2 ~]$ oerr ora 26714
26714, 00000, "User error encountered while applying"
// *Cause: An error was encountered while applying.
// *Action: Query the dba_apply_error view to determine the error and
// take the appropriate action.
[oracle@stream2 ~]$
好,我们进一步来看dba_apply_error:
SQL> l
1* select APPLY_NAME,LOCAL_TRANSACTION_ID,SOURCE_COMMIT_SCN,MESSAGE_NUMBER,ERROR_MESSAGE from dba_apply_error
SQL> /
APPLY_NAME LOCAL_TRAN SOURCE_COMMIT_SCN MESSAGE_NUMBER ERROR_MESSAGE
-------------------- ---------- ----------------- -------------- ------------------------------------------------------------
DOWNSTREAM_APPLY 9.44.280 695025 2 ORA-26687: no instantiation SCN provided for ""."" in source
database "STREAM01.REGRESS.RDBMS.DEV.US.ORACLE.COM"
SQL>
我们看到是downstream site库的是实例化没有成功,我们重新在source库做一次实例化,相关的包可以参见这里:
SQL> DECLARE
2 iscn NUMBER;
3 BEGIN
4 iscn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER();
5 DBMS_APPLY_ADM.SET_SCHEMA_INSTANTIATION_SCN(
6 source_schema_name => 'hjm',
7 source_database_name => 'stream02',
8 instantiation_scn => iscn,
9 recursive => true);
10 END;
11 /
PL/SQL procedure successfully completed.
SQL>
然后重启apply进程:
SQL> exec dbms_apply_adm.stop_apply(apply_name => 'DOWNSTREAM_APPLY');
PL/SQL procedure successfully completed.
SQL> exec dbms_apply_adm.start_apply(apply_name => 'DOWNSTREAM_APPLY');
PL/SQL procedure successfully completed.
检查进程情况,已经恢复正常:
SQL> select propagation_name as name,status,ERROR_MESSAGE from dba_propagation
2 union all
3 select CAPTURE_NAME,status,ERROR_MESSAGE from dba_capture
4 union all
SELECT apply_name,status,error_message from dba_apply
5 6
SQL> /
NAME STATUS ERROR_MESSAGE
------------------------------------------------------------ ---------------- ------------------------------------------------------------
DOWNSTREAM_CAPTURE ENABLED
DOWNSTREAM_APPLY ENABLED
SQL>