java oracle 流复制_Oracle流复制技术
Oracle流復(fù)制是結(jié)合日志挖掘、隊(duì)列等技術(shù),實(shí)現(xiàn)多數(shù)據(jù)庫、異構(gòu)、遠(yuǎn)程等環(huán)境下數(shù)據(jù)同步的一種實(shí)現(xiàn)方式。主要被用于靈活的復(fù)制和容災(zāi)解決方案。
Oracle流復(fù)制相比較其他數(shù)據(jù)庫同步方式,如Dataguard、Advanced
Replication,流復(fù)制擁有以下幾點(diǎn)顯著的優(yōu)勢(shì):
1、靈活的復(fù)制策略:可以分別針對(duì)數(shù)據(jù)庫、模式、表等不同級(jí)別設(shè)定復(fù)制策略,相比Dataguard必須整個(gè)數(shù)據(jù)庫復(fù)制而言,可以節(jié)省相當(dāng)?shù)馁Y源。
2、高可用性:在異構(gòu)環(huán)境下(不同的操作系統(tǒng)),Dataguard無法使用,流復(fù)制可以充分利用現(xiàn)有的設(shè)備與技術(shù)。
3、對(duì)網(wǎng)絡(luò)條件的輕度依賴:流復(fù)制的傳播是經(jīng)過logmnr挖掘并包裝的邏輯變更記錄(LCRs),相比Dataguard傳送archived
redo log、Advanced Replication的mview log與mview刷新的方式,流復(fù)制對(duì)網(wǎng)絡(luò)的需求降低了很多。
4、實(shí)時(shí)性:由監(jiān)控進(jìn)程負(fù)責(zé)實(shí)時(shí)監(jiān)控用戶操作反應(yīng)在log當(dāng)中的記錄并傳遞給目標(biāo)數(shù)據(jù)庫進(jìn)行接收,然后轉(zhuǎn)換為實(shí)際的操作同步目標(biāo)數(shù)據(jù)庫,并可根據(jù)實(shí)際情況調(diào)整同步的間隔。
5、對(duì)主數(shù)據(jù)庫性能的低影響:相對(duì)于其他復(fù)制方式,流復(fù)制基于對(duì)log物理文件進(jìn)行分析等動(dòng)作完成,只占用極少部分資源,并且無論流復(fù)制執(zhí)行成功與否,都不會(huì)影響到主庫的正常使用。
流復(fù)制中,源庫必須設(shè)置為歸檔模式,如果是雙向復(fù)制,則源庫和目標(biāo)庫都要置于歸檔模式。
以下給出一個(gè)在生產(chǎn)環(huán)境中的具體例子來說明流復(fù)制技術(shù)的運(yùn)用方法。這里的需求是主服務(wù)器數(shù)據(jù)庫的一個(gè)名為CMES的模式,包括其表、索引、存儲(chǔ)過程代碼等對(duì)象結(jié)構(gòu)和數(shù)據(jù)的變更都要求能同步到本地節(jié)點(diǎn)的數(shù)據(jù)庫中。
一、搭建流復(fù)制環(huán)境
1、本地節(jié)點(diǎn)的流復(fù)制環(huán)境搭建
conn / as
sysdba
修改實(shí)例參數(shù)
alter
system set global_names=true;
alter system set
aq_tm_processes=1;
創(chuàng)建streams表空間
create
tablespace streams datafile 'd:\oradata\mes\streams01.dbf' size 200m;
將logminer的數(shù)據(jù)字典從system表空間轉(zhuǎn)移到streams表空間
execute
dbms_logmnr_d.set_tablespace('streams');
創(chuàng)建strmadmin用戶并授權(quán)
create
user strmadmin identified by strmadmin default tablespace streams quota
unlimited on streams;
grant
connect, resource, dba, aq_administrator_role to strmadmin;
begin
dbms_streams_auth.grant_admin_privilege(grantee????????? => 'strmadmin',
grant_privileges => true);
end;
/
在tnsnames.ora中添加服務(wù)名,指向主服務(wù)器端
mes_0=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ora11g-1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = mes)
)
)
創(chuàng)建指向主服務(wù)器端的數(shù)據(jù)庫鏈接
create
public database link dl_mes_0 connect to system identified by mesHz2 using
'mes_0';
測(cè)試通過數(shù)據(jù)庫鏈接可以訪問到對(duì)方主機(jī)
select host_name from
v$instance@dl_mes_0;
HOST_NAME
----------------------------------------------------------------
ORA11G-1
創(chuàng)建與數(shù)據(jù)庫鏈接訪問同名的global_name
第一個(gè)本地節(jié)點(diǎn)可命名為dl_mes_1,第二個(gè)本地節(jié)點(diǎn)可命令為dl_mes_2,以此類推
alter
database rename global_name to dl_mes_1;
創(chuàng)建流隊(duì)列
conn
strmadmin/strmadmin
exec
dbms_streams_adm.set_up_queue();
創(chuàng)建應(yīng)用進(jìn)程
conn strmadmin/strmadmin
begin
dbms_streams_adm.add_schema_rules(schema_name???? => 'cmes',
streams_type??? => 'apply',
streams_name??? =>
'apply_streams',
queue_name????? =>
'strmadmin.streams_queue',
include_dml???? => true,
include_ddl???? => true,
source_database => 'dl_mes_0',
inclusion_rule? => true);
end;
/
2、主服務(wù)器端的流復(fù)制環(huán)境搭建
conn / as
sysdba
開啟補(bǔ)充日志
alter database add
supplemental log data;
修改實(shí)例參數(shù)
alter
system set global_names=true;
alter system set
aq_tm_processes=1;
alter
system set open_links=10
scope=spfile;
alter
system setopen_links_per_instance=10 scope=spfile;
創(chuàng)建streams表空間
create
tablespace streams datafile 'd:\oradata\mes\streams01.dbf' size 200m;
將logminer的數(shù)據(jù)字典從系統(tǒng)表空間轉(zhuǎn)移到streams表空間
execute
dbms_logmnr_d.set_tablespace('streams');
創(chuàng)建strmadmin用戶并授權(quán)
create
user strmadmin identified by strmadmin default tablespace streams quota
unlimited on streams;
grant
connect, resource, dba, aq_administrator_role to strmadmin;
begin
dbms_streams_auth.grant_admin_privilege(grantee????????? => 'strmadmin',
grant_privileges => true);
end;
/
在tnsnames.ora中添加指向各個(gè)本地節(jié)點(diǎn)的網(wǎng)絡(luò)服務(wù)名
第一個(gè)本地節(jié)點(diǎn)可命名為mes_1,第二個(gè)本地節(jié)點(diǎn)可命令為mes_2,以此類推,各節(jié)點(diǎn)計(jì)算機(jī)名對(duì)應(yīng)為oraxe11g-1、oraxe11g-2等
mes_1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
oraxe11g-1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = mes)
)
)
創(chuàng)建數(shù)據(jù)庫鏈接
對(duì)應(yīng)各個(gè)本地節(jié)點(diǎn)的網(wǎng)絡(luò)服務(wù)名來創(chuàng)建,如dl_mes_1對(duì)應(yīng)mes_1,dl_mes_2對(duì)應(yīng)mes_2
create public database
link dl_mes_1 connect to system identified by mesHz2 using 'mes_1';
測(cè)試通過數(shù)據(jù)庫鏈接dl_mes_1、dl_mes_2等可以分別訪問到各個(gè)節(jié)點(diǎn)
select host_name from
v$instance@dl_mes_1;
HOST_NAME
----------------------------------------------------------------
ORAXE11G-1
創(chuàng)建與數(shù)據(jù)庫鏈接訪問同名的global_name
alter
database rename global_name to dl_mes_0;
創(chuàng)建流隊(duì)列
conn
strmadmin/strmadmin
exec
dbms_streams_adm.set_up_queue();
創(chuàng)建捕獲進(jìn)程
conn
strmadmin/strmadmin
begin
dbms_streams_adm.add_schema_rules(schema_name??? => 'cmes',
streams_type?? => 'capture',
streams_name?? =>
'capture_streams',
queue_name???? =>
'strmadmin.streams_queue',
include_dml??? => true,
include_ddl??? => true,
inclusion_rule => true);
end;
/
創(chuàng)建傳播進(jìn)程
conn strmadmin/strmadmin
begin
dbms_streams_adm.add_schema_propagation_rules(schema_name??????????? => 'cmes',
streams_name?????????? => 'main_to_node1',
source_queue_name????? =>
'strmadmin.streams_queue',
destination_queue_name => 'strmadmin.streams_queue@dl_mes_1',
include_dml??????????? => true,
include_ddl??????????? => true,
source_database??????? =>
'dl_mes_0',
inclusion_rule???????? => true,
queue_to_queue???????? =>
true);
end;
/
當(dāng)需要?jiǎng)?chuàng)建多個(gè)傳播進(jìn)程向不同節(jié)點(diǎn)發(fā)布時(shí),需要指定不同的stream_name和destination_queue_name,如以下創(chuàng)建指向第二個(gè)本地節(jié)點(diǎn)的傳播進(jìn)程
conn strmadmin/strmadmin
begin
dbms_streams_adm.add_schema_propagation_rules(schema_name??????????? => 'cmes',
streams_name?????????? =>
'main_to_node2',
source_queue_name????? =>
'strmadmin.streams_queue',
destination_queue_name => 'strmadmin.streams_queue@dl_mes_2',
include_dml??????????? => true,
include_ddl??????????? => true,
source_database??????? =>
'dl_mes_0',
inclusion_rule???????? => true,
queue_to_queue???????? =>
true);
end;
/
3、實(shí)例化本地節(jié)點(diǎn)
根據(jù)具體業(yè)務(wù),利用數(shù)據(jù)泵進(jìn)行導(dǎo)入。這里具體業(yè)務(wù)是需要?jiǎng)?chuàng)建幾個(gè)自己的表空間和用戶模式,并從主服務(wù)器上導(dǎo)入模式數(shù)據(jù)到本地。
conn / as
sysdba
創(chuàng)建表空間
create tablespace cmes
datafile 'd:\oradata\mes\cmes01.dbf' size 100m;
create tablespace rmes
datafile 'd:\oradata\mes\rmes01.dbf' size 2g;
create tablespace indx
datafile 'd:\oradata\mes\indx01.dbf' size 2g;
create tablespace hmes
datafile 'd:\oradata\mes\hmes01.dbf' size 2g;
創(chuàng)建RMES、BOSCH、ABS用戶并授權(quán)
create user
rmes identified by rmes default tablespace rmes;
create user
bosch identified by huizhong default tablespace rmes;
create user
abs identified by huizhong default tablespace rmes;
grant
connect,resource to rmes,bosch,abs;
導(dǎo)入主服務(wù)器端的CMES模式基礎(chǔ)數(shù)據(jù)
$impdp
strmadmin/strmadmin network_link=dl_mes_0 schemas=cmes
導(dǎo)入主服務(wù)器端的RMES、BOSCH、ABS模式元數(shù)據(jù)
$impdp
strmadmin/strmadmin network_link=dl_mes_0 schemas=rmes,bosch,abs
content=metadata_only
編譯無效對(duì)象
@?/rdbms/admin/utlrp
4、啟動(dòng)流復(fù)制進(jìn)程
本地節(jié)點(diǎn)啟動(dòng)應(yīng)用進(jìn)程
conn
strmadmin/strmadmin
exec
dbms_apply_adm.start_apply('apply_streams');
主服務(wù)器端啟動(dòng)捕獲進(jìn)程
conn
strmadmin/strmadmin
exec
dbms_capture_adm.start_capture('capture_streams');
檢查主服務(wù)器端警告日志,確認(rèn)日志捕獲的啟動(dòng)
Fri Apr 14 16:47:04 2017
LOGMINER: Begin mining
logfile for session 1 thread 1 sequence 40,
E:\ARCHIVELOG\MES\ARC_78AE6A4D_1_941117583_40.LOG
Fri Apr 14 16:47:05 2017
LOGMINER: End mining
logfile: E:\ARCHIVELOG\MES\ARC_78AE6A4D_1_941117583_40.LOG
Fri Apr 14 16:47:05 2017
LOGMINER: Begin mining
logfile for session 1 thread 1 sequence 41, D:\ORADATA\MES\REDO02.LOG
Fri Apr 14 16:47:14 2017
LOGMINER: End mining
logfile: D:\ORADATA\MES\REDO02.LOG
Fri Apr 14 16:47:14 2017
LOGMINER: Begin mining
logfile for session 1 thread 1 sequence 42, D:\ORADATA\MES\REDO03.LOG
檢查本地節(jié)點(diǎn)警告日志,確認(rèn)日志應(yīng)用的啟動(dòng)
Fri Apr 14 16:46:41 2017
Streams APPLY AP01 for
APPLY_STREAMS started with pid=24, OS id=3144
Fri Apr 14 16:46:42 2017
Streams Apply Server for
APPLY_STREAMS started AS02 with pid=31 OS id=1768
Fri Apr 14 16:46:42 2017
Streams Apply Server for
APPLY_STREAMS started AS03 with pid=32 OS id=2484
Fri Apr 14 16:46:42 2017
Streams Apply Reader for
APPLY_STREAMS started AS01 with pid=29 OS id=4040
Fri Apr 14 16:46:42 2017
Streams Apply Server for
APPLY_STREAMS started AS04 with pid=35 OS id=756
Fri Apr 14 16:46:42 2017
Streams Apply Server for
APPLY_STREAMS started AS05 with pid=36 OS id=740
5、流復(fù)制功能驗(yàn)證
測(cè)試主服務(wù)器端數(shù)據(jù)庫CMES模式的更新,是否能夠自動(dòng)同步到本地節(jié)點(diǎn),包括DML和DDL操作。如未能同步,則檢查主服務(wù)器端和本地節(jié)點(diǎn)的警告日志信息,排查出錯(cuò)原因。
表數(shù)據(jù)更新
select*from cmes.c_emp_t;
update cmes.c_emp_t t set
t.emp_password = '111111' where t.emp_no = 'TEST';
commit;
增加表
create table
cmes.c_emp1_t as select * from cmes.c_emp_t;
select * from
cmes.c_emp1_t;
修改表結(jié)構(gòu)
alter table cmes.c_emp1_t
add remark varchar2(20);
update cmes.c_emp1_t t
set t.remark = 'test' where t.emp_no = 'TEST';
commit;
desc
cmes.c_emp1_t;
增加索引
create index
cmes.idx_emp1_remark on cmes.c_emp1_t(remark) tablespace indx;
select
table_name, index_name, index_type, status, tablespace_name from dba_indexes
where owner='CMES' and table_name='C_EMP1_T';
刪除索引
drop index
cmes.idx_emp1_remark;
select
table_name, index_name, index_type, status, tablespace_name from dba_indexes
where owner='CMES' and table_name='C_EMP1_T';
刪除表
drop table cmes.c_emp1_t
purge;
select * from
cmes.c_emp1_t;
新增存儲(chǔ)過程
create
or replace procedurecmes.my_test(res
out varchar2) as
begin
res := 'OK';
end;
/
更新存儲(chǔ)過程
create
or replace procedurecmes.my_test(res
out varchar2) as
begin
res := 'NOK';
end;
/
刪除存儲(chǔ)過程
drop
procedurecmes.my_test;
6、建立流復(fù)制心跳
為監(jiān)視流復(fù)制的工作狀態(tài),在主服務(wù)器上創(chuàng)建心跳表
create
table cmes.streams_hb(hb_name
varchar2(20), hb_timevarchar2(20)) tablespace cmes;
插入數(shù)據(jù)
insert
into cmes.streams_hbvalues('dl_mes_0',to_char(sysdate, 'yyyy-mm-dd
hh24:mi:ss'));
commit;
創(chuàng)建調(diào)度作業(yè),設(shè)置為每分鐘更新一次心跳時(shí)間
conn
strmadmin/strmadmin
begin
dbms_scheduler.create_job(job_name??????? => 'strmadmin.job_streams_hb',
job_type??????? => 'plsql_block',
job_action????? => 'update cmes.streams_hbset hb_time =to_char(sysdate, ''yyyy-mm-dd hh24:mi:ss'')where hb_name = ''dl_mes_0'';',
start_date????? => sysdate,
repeat_interval
=> 'freq = minutely; interval = 1',
enabled???????? => true,
auto_drop?????? => false);
end;
/
觀察本地節(jié)點(diǎn)的心跳表數(shù)據(jù)是否按心跳時(shí)間同步更新
select *
from cmes.streams_hb;
HB_NAME????????????? HB_TIME
--------------------
--------------------
dl_mes_0???????????? 2017-05-09 12:19:47
二、針對(duì)表級(jí)別的配置說明
如果流復(fù)制定義在表級(jí)別,則幾個(gè)進(jìn)程的創(chuàng)建可采用如下形式。
主服務(wù)器端創(chuàng)建表級(jí)別的傳播進(jìn)程
begin
dbms_streams_adm.add_table_propagation_rules(table_name???????????? => 'scott.emp',
streams_name?????????? => 'scott_emp_main_to_node1',
source_queue_name????? =>
'strmadmin.streams_queue',
destination_queue_name => 'strmadmin.streams_queue@dl_mes_1',
include_dml??????????? => true,
include_ddl??????????? => true,
source_database??????? => 'dl_mes_0',
inclusion_rule???????? => true,
queue_to_queue???????? =>
true);
end;
/
主服務(wù)器端創(chuàng)建表級(jí)別的捕獲進(jìn)程
begin
dbms_streams_adm.add_table_rules(table_name???? => 'scott.emp',
streams_type?? => 'capture',
streams_name?? => 'scott_emp_capture_streams',
queue_name???? =>
'strmadmin.streams_queue',
include_dml??? => true,
include_ddl??? => true,
inclusion_rule => true);
end;
/
本地節(jié)點(diǎn)創(chuàng)建表級(jí)別的應(yīng)用進(jìn)程
begin
dbms_streams_adm.add_table_rules(table_name????? => 'scott.emp',
streams_type??? => 'apply',
streams_name??? => 'scott_emp_apply_streams',
queue_name????? =>
'strmadmin.streams_queue',
include_dml???? => true,
include_ddl???? => true,
source_database => 'dl_mes_0',
inclusion_rule? => true);
end;
/
本地節(jié)點(diǎn)的實(shí)例化
本地節(jié)點(diǎn)導(dǎo)入主服務(wù)器端的表
$impdp strmadmin/strmadmin network_link=dl_mes_0schemas=scott
include=table:"in('EMP')"table_exists_action=replace
三、流復(fù)制配置的刪除
停止應(yīng)用進(jìn)程
conn
strmadmin/strmadmin
execdbms_apply_adm.stop_apply(apply_name => 'apply_streams');
刪除應(yīng)用進(jìn)程
conn
strmadmin/strmadmin
begin
dbms_apply_adm.drop_apply(apply_name??????????? => 'apply_streams',
drop_unused_rule_sets => true);
end;
/
如果刪除應(yīng)用進(jìn)程時(shí)報(bào)錯(cuò)應(yīng)用進(jìn)程的錯(cuò)誤隊(duì)列必須為空,則需要先刪除之前應(yīng)用進(jìn)程所有的錯(cuò)誤信息,然后再執(zhí)行刪除進(jìn)程的操作
conn
strmadmin/strmadmin
select *
from dba_apply_error;
exec
dbms_apply_adm.delete_all_errors(apply_name=>'apply_streams');
停止捕獲進(jìn)程
conn
strmadmin/strmadmin
begin
dbms_capture_adm.stop_capture(capture_name
=> 'capture_streams',
force??????? => true);
end;
/
刪除捕獲進(jìn)程
conn
strmadmin/strmadmin
begin
dbms_capture_adm.drop_capture(capture_name????????? => 'capture_streams',
drop_unused_rule_sets => true);
end;
/
停止傳播進(jìn)程
conn
strmadmin/strmadmin
begin
dbms_propagation_adm.stop_propagation(propagation_name =>
'main_to_node1',
force??????????? => true);
end;
/
刪除傳播進(jìn)程
conn
strmadmin/strmadmin
begin
dbms_propagation_adm.drop_propagation(propagation_name????? => 'main_to_node1',
drop_unused_rule_sets => true);
end;
/
刪除主服務(wù)器端和本地節(jié)點(diǎn)的隊(duì)列及隊(duì)列表
conn
strmadmin/strmadmin
begin
dbms_streams_adm.remove_queue(queue_name????????????? => 'STREAMS_QUEUE',
cascade???????????????? => true,
drop_unused_queue_table => true);
end;
/
刪除流配置
conn
strmadmin/strmadmin
exec
dbms_streams_adm.remove_streams_configuration;
刪除流用戶
conn / as
sysdba
drop user
strmadmin cascade;
四、流復(fù)制的狀態(tài)查詢
查看創(chuàng)建的流隊(duì)列和隊(duì)列表
select owner, name,
queue_table, queue_type from dba_queues where owner = 'STRMADMIN';
OWNER????? NAME?????????????????????????? QUEUE_TABLE??????????????????? QUEUE_TYPE
----------
------------------------------ ------------------------------
--------------------
STRMADMIN? AQ$_STREAMS_QUEUE_TABLE_E????? STREAMS_QUEUE_TABLE??????????? EXCEPTION_QUEUE
STRMADMIN? STREAMS_QUEUE????????????????? STREAMS_QUEUE_TABLE??????????? NORMAL_QUEUE
查看流隊(duì)列表信息
select
owner,queue_table,object_type from dba_queue_tables where
owner='STRMADMIN';
OWNER????? QUEUE_TABLE??????????????????? OBJECT_TYPE
----------
------------------------------ --------------------------
STRMADMIN? STREAMS_QUEUE_TABLE??????????? SYS.ANYDATA
查看傳播進(jìn)程信息
col destination_dblink
for a30
select propagation_name,
source_queue_name, destination_queue_name, destination_dblink, status from
dba_propagation;
PROPAGATION_NAME?????????????? SOURCE_QUEUE_NAME????????????? DESTINATION_QUEUE_NAME???????? DESTINATION_DBLINK???????????? STATUS
------------------------------
------------------------------ ------------------------------
------------------------------ ----------
MAIN_TO_NODE2????????????????? STREAMS_QUEUE????????????????? STREAMS_QUEUE????????????????? DL_MES_2?????????????????????? ENABLED
MAIN_TO_NODE1????????????????? STREAMS_QUEUE????????????????? STREAMS_QUEUE????????????????? DL_MES_1?????????????????????? ENABLED
查看捕獲進(jìn)程信息
select capture_name,
queue_name, start_scn, status, capture_type from dba_capture;
CAPTURE_NAME?????????????????? QUEUE_NAME????????????????????? START_SCN STATUS???? CAPTURE_TY
------------------------------
------------------------------ ---------- ---------- ----------
CAPTURE_STREAMS??????????????? STREAMS_QUEUE???????????????????? 6156463 ENABLED??? LOCAL
查看應(yīng)用進(jìn)程信息
select
apply_name,queue_name,status from dba_apply;
APPLY_NAME???????????????????? QUEUE_NAME???????????????????? STATUS
------------------------------
------------------------------ --------
APPLY_STREAMS????????????????? STREAMS_QUEUE????????????????? ENABLED
五、補(bǔ)充說明
1、可以基于Database級(jí)別或Table級(jí)別啟用追加日志(Supplemental Log)
alter database add
supplemental log data;
在建立根據(jù)Schema粒度進(jìn)行復(fù)制的Oracle
Stream環(huán)境中,如果確認(rèn)Schema下所有Table都有合理的主鍵(Primary Key),則可不需要啟用追加日志。
2、根據(jù)需要可修改傳播進(jìn)程的休眠時(shí)間,如改為0,表示實(shí)時(shí)傳播
begin
dbms_aqadm.alter_propagation_schedule(queue_name??????? => 'streams_queue',
destination?????? => 'dl_mes_1',
destination_queue => 'streams_queue',
latency?????????? => 0);
end;
/
3、如果等了很長(zhǎng)時(shí)間數(shù)據(jù)還沒有復(fù)制過來,仔細(xì)檢查capture/propagation/apply各進(jìn)程的狀態(tài)是否有異常。并可嘗試修改以下隱含參數(shù)并重啟
alter system set
"_job_queue_interval"=1 scope=spfile;
4、如果本地節(jié)點(diǎn)長(zhǎng)時(shí)間關(guān)閉或無法與主服務(wù)器端保持網(wǎng)絡(luò)連接,可能導(dǎo)致主服務(wù)器端的傳播進(jìn)程狀態(tài)變?yōu)閐isabled,此時(shí)即便恢復(fù)了連接,仍然不能保持正常的同步復(fù)制。這種情況可以嘗試先停止主服務(wù)器端到本地節(jié)點(diǎn)的傳播進(jìn)程,然后重新啟動(dòng)傳播進(jìn)程,一般情況下問題都可以得到解決。
查詢傳播進(jìn)程狀態(tài),發(fā)現(xiàn)到dl_mes_2的傳播是disabled
select propagation_name,
source_queue_name, destination_queue_name, destination_dblink, status from
dba_propagation;
PROPAGATION_NAME?????????????? SOURCE_QUEUE_NAME????????????? DESTINATION_QUEUE_NAME???????? DESTINATION_DBLINK???????????? STATUS
------------------------------
------------------------------ ------------------------------
------------------------------ --------
MAIN_TO_NODE1????????????????? STREAMS_QUEUE????????????????? STREAMS_QUEUE????????????????? DL_MES_1?????????????????????? ENABLED
MAIN_TO_NODE2????????????????? STREAMS_QUEUE????????????????? STREAMS_QUEUE????????????????? DL_MES_2?????????????????????? DISABLED
停止該傳播進(jìn)程
begin
dbms_propagation_adm.stop_propagation(propagation_name =>
'main_to_node2',
force??????????? => true);
end;
/
此時(shí)該進(jìn)程狀態(tài)變?yōu)閍borted
select propagation_name,
source_queue_name, destination_queue_name, destination_dblink, status from
dba_propagation;
PROPAGATION_NAME?????????????? SOURCE_QUEUE_NAME????????????? DESTINATION_QUEUE_NAME???????? DESTINATION_DBLINK???????????? STATUS
------------------------------
------------------------------ ------------------------------
------------------------------ --------
MAIN_TO_NODE1????????????????? STREAMS_QUEUE????????????????? STREAMS_QUEUE????????????????? DL_MES_1?????????????????????? ENABLED
MAIN_TO_NODE2????????????????? STREAMS_QUEUE????????????????? STREAMS_QUEUE????????????????? DL_MES_2?????????????????????? ABORTED
重啟傳播進(jìn)程
execdbms_propagation_adm.start_propagation(propagation_name =>
'main_to_node2');
查看狀態(tài)已恢復(fù)正常
select propagation_name,
source_queue_name, destination_queue_name, destination_dblink, status from
dba_propagation;
PROPAGATION_NAME?????????????? SOURCE_QUEUE_NAME????????????? DESTINATION_QUEUE_NAME???????? DESTINATION_DBLINK???????????? STATUS
------------------------------
------------------------------ ------------------------------
------------------------------ --------
MAIN_TO_NODE1????????????????? STREAMS_QUEUE????????????????? STREAMS_QUEUE????????????????? DL_MES_1?????????????????????? ENABLED
MAIN_TO_NODE2????????????????? STREAMS_QUEUE????????????????? STREAMS_QUEUE????????????????? DL_MES_2?????????????????????? ENABLED
5、如果本地節(jié)點(diǎn)應(yīng)用進(jìn)程狀態(tài)變?yōu)閍bort,可嘗試以下操作
停止應(yīng)用進(jìn)程
execdbms_apply_adm.stop_apply(apply_name => 'apply_streams');
查看應(yīng)用進(jìn)程的報(bào)錯(cuò)信息
select *
from dba_apply_error;
在確認(rèn)錯(cuò)誤已排除后,刪除錯(cuò)誤信息
exec
dbms_apply_adm.delete_all_errors(apply_name=>'apply_streams');
重啟應(yīng)用進(jìn)程
exec
dbms_apply_adm.start_apply('apply_streams');
再次檢查應(yīng)用進(jìn)程狀態(tài)是否已恢復(fù)為enabled
select
apply_name,queue_name,status from dba_apply;
APPLY_NAME???????????????????? QUEUE_NAME???????????????????? STATUS
------------------------------
------------------------------ ----------
APPLY_STREAMS????????????????? STREAMS_QUEUE????????????????? ENABLED
總結(jié)
以上是生活随笔為你收集整理的java oracle 流复制_Oracle流复制技术的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 云计算之多租户理解
- 下一篇: 2016-2045年新兴科技趋势报告