oracle 11g streams各種型別搭建主要步驟
1、資料庫級別streams複製
2、模式級別streams複製--完整引數示例 connect strmadmin/[email protected] Connected. begin dbms_streams_adm.maintain_global ( source_database => 'DBXA.WORLD', source_directory_object => 'STREAMS_DP_DIR', destination_database => 'DBXB.WORLD', destination_directory_object => 'STREAMS_DP_DIR', capture_name => 'DBXA_CAP', capture_queue_name => 'DBXA_CAP_Q', capture_queue_table => 'DBXA_CAP_Q_T', capture_queue_user => 'STRMADMIN', propagation_name => 'DBXA_TO_DBXB_PROP', apply_name => 'DBXA_APP', apply_queue_name => 'DBXA_APP_Q', apply_queue_table => 'DBXA_APP_Q_T', apply_queue_user => 'STRMADMIN', script_name => 'cr_streams_global.sql', script_directory_object => 'STREAMS_DP_DIR', dump_file_name => NULL, log_file => NULL, bi_directional => FALSE, include_ddl => TRUE, perform_actions => TRUE, instantiation => DBMS_STREAMS_ADM.INSTANTIATION_FULL ); end; / job finished PL/SQL procedure successfully completed. --如果不需要使用者為streams元件定義有意義的名稱 connect strmadmin/
[email protected] Connected. begin dbms_streams_adm.maintain_global ( source_database => 'DBXA.WORLD', source_directory_object => 'STREAMS_DP_DIR', destination_database => 'DBXB.WORLD', destination_directory_object => 'STREAMS_DP_DIR', include_ddl => TRUE ); end; / job finished PL/SQL procedure successfully completed.
--完整引數
connect strmadmin/[email protected]
Connected.
declare
schemas dbms_utility.uncl_array;
begin
schemas(1) := 'SCOTT';
schemas(2) := 'HR';
dbms_streams_adm.maintain_schemas (
schema_names => schemas,
source_database => 'DBXA.WORLD',
source_directory_object => 'STREAMS_DP_DIR',
destination_database => 'DBXB.WORLD',
destination_directory_object => 'STREAMS_DP_DIR',
capture_name => 'DBXA_CAP',
capture_queue_name => 'DBXA_CAP_Q',
capture_queue_table => 'DBXA_CAP_Q_T',
propagation_name => 'DBXA_TO_DBXB_PROP',
apply_name => 'DBXA_APP',
apply_queue_name => 'DBXA_APP_Q',
apply_queue_table => 'DBXA_APP_Q_T',
dump_file_name => 'schemas_expimp.dmp',
log_file => 'schemas_expimp.log',
bi_directional => FALSE,
include_ddl => TRUE,
perform_actions => TRUE
);
end;
/
job finished
PL/SQL procedure successfully completed.
--如果不需要使用者為streams元件定義有意義的名稱
connect strmadmin/ [email protected]
Connected.
declare
schemas dbms_utility.uncl_array;
begin
schemas(1) := 'SCOTT';
schemas(2) := 'HR';
dbms_streams_adm.maintain_schemas (
schema_names => schemas,
source_database => 'DBXA.WORLD',
source_directory_object => 'STREAMS_DP_DIR',
destination_database => 'DBXB.WORLD',
destination_directory_object => 'STREAMS_DP_DIR',
include_ddl => TRUE,
instantiation => DBMS_STREAMS_ADM.INSTANTIATION_SCHEMA_NETWORK
);
end;
/
PL/SQL procedure successfully completed.
3、表級別streams複製--完整引數
connect strmadmin/[email protected]
Connected.
declare
tables dbms_utility.uncl_array;
begin
tables(1) := 'SCOTT.DEPT';
tables(2) := 'SCOTT.EMP';
tables(3) := 'HR.SALGRADE';
tables(4) := 'HR.BONUS';
dbms_streams_adm.maintain_tables (
table_names => tables,
source_database => 'DBXA.WORLD',
source_directory_object => 'STREAMS_DP_DIR',
destination_database => 'DBXB.WORLD',
destination_directory_object => 'STREAMS_DP_DIR',
capture_name => 'DBXA_CAP',
capture_queue_name => 'DBXA_CAP_Q',
capture_queue_table => 'DBXA_CAP_Q_T',
propagation_name => 'DBXA_TO_DBXB_PROP',
apply_name => 'DBXA_APP',
apply_queue_name => 'DBXA_APP_Q',
apply_queue_table => 'DBXA_APP_Q_T',
dump_file_name => NULL,
log_file => NULL,
bi_directional => FALSE,
include_ddl => TRUE,
perform_actions => TRUE,
instantiation => DBMS_STREAMS_ADM.INSTANTIATION_TABLE
);
end;
/
job finished
PL/SQL procedure successfully completed.
4、表空間級別streams複製
--在源資料庫中建立 目錄物件
create directory example_ts_dir as '/u01/oradata/DBXA';
Directory created.
grant read on directory example_ts_dir to strmadmin;
Grant succeeded
--在目標資料庫中建立目錄物件
create directory example_ts_dir as '/u02/app/oradata/DBXB';
Directory created.
--使用maintain_simple_tts過程建立表空間streams複製
connect strmadmin/[email protected]
Connected.
begin
dbms_streams_adm.maintain_simple_tts(
tablespace_name => 'EXAMPLE_TS',
source_directory_object => 'STREAMS_DP_DIR',
source_database => 'DBXA.WORLD',
destination_directory_object => 'EXAMPLE_TS_DIR',
destination_database => 'DBXB.WORLD',
perform_actions => TRUE,
script_name => 'cr_maintain_simple_tts_uni.sql',
script_directory_object => 'STREAMS_DP_DIR',
bi_directional => FALSE
);
end;
/
PL/SQL procedure successfully completed.
--使用MAINTAIN_TTS過程建立表空間streams複製
connect strmadmin/[email protected]
Connected.
declare
ts_names dbms_streams_tablespace_adm.tablespace_set;
begin
ts_names(1) := 'DATA_TS';
ts_names(2) := 'INDEX_TS';
ts_names(3) := 'EXAMPLE_TS';
dbms_streams_adm.maintain_tts(
tablespace_names => ts_names,
source_directory_object => 'STREAMS_DP_DIR',
destination_directory_object => 'EXAMPLE_TS_DIR',
source_database => 'DBXA.WORLD',
destination_database => 'DBXB.WORLD',
perform_actions => TRUE,
script_name => 'cr_streams_maintain_tts_uni.sql',
script_directory_object => 'STREAMS_DP_DIR',
dump_file_name => 'maint_tts.dmp',
capture_name => 'DBXA_CAP',
capture_queue_table => 'DBXA_CAP_Q_T',
capture_queue_name => 'DBXA_CAP_Q',
capture_queue_user => 'STRMADMIN',
propagation_name => 'DBXA_TO_DBXB_PROP',
apply_name => 'DBXA_APP',
apply_queue_table => 'DBXA_APP_Q_T',
apply_queue_name => 'DBXA_APP_Q',
apply_queue_user => 'STRMADMIN',
log_file => 'maintain_tts.log',
bi_directional => FALSE,
include_ddl => TRUE
);
end;
/
PL/SQL procedure successfully completed
5、使用MAINTAIN儲存過程配置下游捕獲程序--儲存過程執行在目標資料庫DBXB.WORKD中
--不需要傳播程序,如果指定了傳播程序也不會建立
--捕獲程序和應用程序的佇列名和隊列表名一樣
connect strmadmin/[email protected]
Connected.
declare
schemas dbms_utility.uncl_array;
begin
schemas(1) := 'SCOTT';
schemas(2) := 'HR';
dbms_streams_adm.maintain_schemas (
schema_names => schemas,
source_database => 'DBXA.WORLD',
source_directory_object => 'STREAMS_DP_DIR',
destination_database => 'DBXB.WORLD',
destination_directory_object => 'STREAMS_DP_DIR',
capture_name => 'DBXA_CAP',
capture_queue_name => 'DBXA_CAP_Q',
capture_queue_table => 'DBXA_CAP_Q_T',
propagation_name => 'DBXA_TO_DBXB_PROP',
apply_name => 'DBXA_APP',
apply_queue_name => 'DBXA_CAP_Q',
apply_queue_table => 'DBXA_CAP_Q_T',
dump_file_name => NULL,
log_file => NULL,
bi_directional => FALSE,
include_ddl => TRUE,
perform_actions => TRUE
);
end;
/
job finished
PL/SQL procedure successfully completed.
--配置從資料庫DBXA.WORLD到DBXB.WORLD的streams複製的方法
--儲存過程執行在DBXB.WORLD資料庫中
--傳播定義從DBXB.WORLD到DBXC.WORLD
--捕獲程序和應用程序的佇列名和隊列表名不同
connect strmadmin/[email protected]
Connected.
declare
schemas dbms_utility.uncl_array;
begin
schemas(1) := 'SCOTT';
schemas(2) := 'HR';
dbms_streams_adm.maintain_schemas (
schema_names => schemas,
source_database => 'DBXA.WORLD',
source_directory_object => 'STREAMS_DP_DIR',
destination_database => 'DBXC.WORLD',
destination_directory_object => 'STREAMS_DP_DIR',
capture_name => 'DBXA_CAP',
capture_queue_name => 'DBXA_CAP_Q',
capture_queue_table => 'DBXA_CAP_Q_T',
propagation_name => 'DBXB_TO_DBXC_PROP',
apply_name => 'DBXA_APP',
apply_queue_name => 'DBXA_APP_Q',
apply_queue_table => 'DBXA_APP_Q_T',
dump_file_name => NULL,
log_file => NULL,
bi_directional => FALSE,
include_ddl => TRUE,
perform_actions => TRUE
);
end;
/
PL/SQL procedure successfully completed.
6、建立檢視來檢視streams
儲存過程的狀態和進度--主要是基於DBA_RECOVERABLE_SCRIPT檢視和DBA_RECOVERABLE_SCRIPT_BLOCKS檢視建立
connect sys as sysdba
set long 100000000
create or replace view streams_build_status
as
select to_char(rs.creation_time,'HH24:Mi:SS MM/DD/YY') CREATE_DATE,
rs.status,
rs.done_block_num||' of ' ||rs.total_blocks ||' Steps Completed' PROGRESS,
to_char(to_number(sysdate-rs.creation_time)*86400,9999.99) ELAPSED_SECONDS,
substr(rsb.forward_block,1,5000) CURRENT_STEP,
rs.invoking_package||'.'||rs.invoking_procedure PROCEDURE,
rs.script_id
from dba_recoverable_script rs,
dba_recoverable_script_blocks rsb
where rs.script_id = rsb.script_id
and rsb.block_num = rs.done_block_num + 1;
create public synonym streams_build_status for streams_build_status;
grant select on streams_build_status to public;
--查詢進度資訊(儲存過程當前正在執行、一共有14個過程塊已經完成13個、已經運行了276秒)
select status,
progress,
elapsed_seconds elapsed,
script_id
from streams_build_status;
STATUS PROGRESS ELAPSED SCRIPT_ID
--------- ------------------------- ------- --------------------------------
EXECUTING 13 of 14 Steps Completed 276.00 7CC97F3B9169704BE040A8C014006E63
--檢視正在執行的過程塊
SQL> select current_step
2 from streams_build_status;
CURRENT_STEP
-----------------------------------------------------------------------
-- Start capture process DBXA$CAP
--
BEGIN
dbms_capture_adm.start_capture(
capture_name => '"DBXA$CAP"'
);
EXCEPTION WHEN OTHERS THEN
IF sqlcode = -26666 THEN NULL; -- CAPTURE process already running
ELSE RAISE;
END IF;
END;
--提取指令碼及過程塊
set long 10000000
set pages 1000
spool maintain_script.sql
select '-- Block: ' || block_num,
forward_block
from dba_recoverable_script_blocks
where script_id = '7CC97F3B9169704BE040A8C014006E63'
order by block_num;
spool off
7、從MAINTAIN儲存過程的錯誤中恢復--下面展示配置模式級別的複製時,對於一個造成MAINTAIN儲存過程失敗的簡單錯誤處理
connect strmadmin/[email protected]
Connected.
declare
schemas dbms_utility.uncl_array;
begin
schemas(1) := 'SCOTT';
schemas(2) := 'HR';
dbms_streams_adm.maintain_schemas (
schema_names => schemas,
source_database => 'DBXA.WORLD',
source_directory_object => 'STREAMS_DP_DIR',
destination_database => 'DBXB.WORLD',
destination_directory_object => 'STREAMS_DP_DIR',
include_ddl => TRUE,
instantiation => DBMS_STREAMS_ADM.INSTANTIATION_SCHEMA_NETWORK
);
end;
/
declare
*
ERROR at line 1:
ORA-23616: Failure in executing block 7 for script
7CD4E8B08BD40E08E040A8C014007723 with
ORA-39001: invalid argument value
ORA-06512: at "SYS.DBMS_RECO_SCRIPT_INVOK", line 139
ORA-06512: at "SYS.DBMS_STREAMS_RPC", line 465
ORA-06512: at "SYS.DBMS_RECOVERABLE_SCRIPT", line 659
ORA-06512: at "SYS.DBMS_RECOVERABLE_SCRIPT", line 682
ORA-06512: at "SYS.DBMS_STREAMS_MT", line 7972
ORA-06512: at "SYS.DBMS_STREAMS_ADM", line 2674
ORA-06512: at line 7
--通過錯誤提示的script_id檢視錯誤的具體資訊
select forward_block
from dba_recoverable_script_blocks
where script_id = '7CD4E8B08BD40E08E040A8C014007723'
and block_num = 7;
FORWARD_BLOCK
-----------------------------------------------------------
--
-- Datapump SCHEMA MODE IMPORT (NETWORK)
--
DECLARE
h1 NUM
......
......
--由上可以看出是資料庫連線丟失造成的錯誤
--在建立資料庫連線時候作業在恢復之後便可以成功完成
begin
dbms_streams_adm.recover_operation(
script_id => '7CD4E8B08BD40E08E040A8C014007723',
operation_mode => 'FORWARD'
);
end;
/
PL/SQL procedure successfully completed.
8、含有本地程序的單向複製--配置schema級別的streams,source:DBXA.WORLD、target:DBXB.WORLD
--連線到目標資料庫並且建立streams佇列和表
conn strmadmin/[email protected]
Connected.
begin
dbms_streams_adm.set_up_queue(
queue_name => 'DBXA_APP_Q',
queue_table => 'DBXA_APP_Q_T',
queue_user => 'STRMADMIN'
);
end;
/
--在target資料庫中建立應用程序和規則
begin
dbms_streams_adm.add_schema_rules (
schema_name => 'SCOTT',
streams_type => 'APPLY',
streams_name => 'DBXA_APP',
queue_name => 'DBXA_APP_Q',
include_dml => true,
include_ddl => true,
inclusion_rule => true,
include_tagged_lcr => false,
source_database => 'DBXA.WORLD',
and_condition => ' :lcr.get_compatible() < dbms_streams.max_compatible()'
);
end;
/
PL/SQL procedure successfully completed.
--連線source資料庫並建立Streams佇列
conn strmadmin/[email protected]
Connected.
set serveroutput on size unlimited
set echo on
begin
dbms_streams_adm.set_up_queue(
queue_name => 'DBXA_CAP_Q',
queue_table => 'DBXA_CAP_Q_T',
queue_user => 'STRMADMIN'
);
end;
/
PL/SQL procedure successfully completed.
--在source資料庫建立傳播程序和傳播規則
begin
dbms_streams_adm.add_schema_propagation_rules (
schema_name => 'SCOTT',
streams_name => 'DBXA_TO_DBXB_PROP',
source_queue_name => 'DBXA_CAP_Q',
destination_queue_name => '[email protected]',
include_dml => true,
include_ddl => true,
inclusion_rule => true,
include_tagged_lcr => false,
queue_to_queue => true,
source_database => 'DBXA.WORLD',
and_condition => ' :lcr.get_compatible() < dbms_streams.max_compatible()'
);
end;
/
PL/SQL procedure successfully completed.
--在source資料庫中建立捕獲程序和捕獲規則
begin
dbms_streams_adm.add_schema_rules (
schema_name => 'SCOTT',
streams_type => 'CAPTURE',
streams_name => 'DBXA_CAP',
queue_name => 'DBXA_CAP_Q',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
inclusion_rule => true,
source_database => 'DBXA.WORLD',
and_condition => ' :lcr.get_compatible() < dbms_streams.max_compatible()'
);
end;
/
PL/SQL procedure successfully completed.
--在target資料庫中例項化物件
--使用data pump匯出,引數檔案內容示例
directory=data_pump_dir
schemas=SCOTT
parallel=4
dumpfile=schemas_%u.dmp
logfile=schemas_expdp.log
--使用data pump匯入,引數檔案內容示例
directory=data_pump_dir
full=y
parallel=4
table_exists_action=truncate
dumpfile=schemas_%u.dmp
logfile=schemas_expdp.log
--在target資料庫中啟動APPLY程序
conn strmadmin/[email protected]
Connected.
begin
dbms_apply_adm.start_apply('DBXA_APP');
end;
/
PL/SQL procedure successfully completed.
--在source資料庫中啟動CAPTURE程序
conn strmadmin/[email protected]
Connected.
begin
dbms_capture_adm.start_capture('DBXA_CAP');
end;
/
PL/SQL procedure successfully completed.
--檢查 alter 警告日誌檔案
--看見如下訊息就說明capture程序正在挖掘日誌
LOGMINER: Begin mining logfile for session 23 thread 1 sequence 230,
/u01/oradata/DBXA/redo01.log
LOGMINER: End mining logfile for session 23 thread 1 sequence 230,
/u01/oradata/DBXA/redo01.log
LOGMINER: Begin mining logfile for session 23 thread 1 sequence 231,
/u01/oradata/DBXA/redo01.log
9、包含下游捕獲程序的單向複製(歸檔日誌下游捕獲)
--DBXB.WORLD作為下游資料庫和目標資料庫使用
--通過log_archive_dest_2來建立重做傳輸
connect sys/[email protected] as sysdba
Connected.
alter system set log_archive_dest_2=
'service=DBXB.WORLD ASYNC NOREGISTER VALID_FOR=(online_logfiles, all_roles)
3 TEMPLATE=DBXA_arch_%t_%s_%r.arc' scope=both;
System altered.
alter system set log_archive_dest_state_2=ENABLE scope=both;
System altered.
connect sys/[email protected] as sysdba
Connected.
alter system set log_archive_dest_2=
'location=/u01/oradata/DBXA_logs VALID_FOR=(standby_logfiles, primary_role)'
scope=both;
System altered.
alter system set log_archive_dest_state_2=ENABLE scope=both;
System altered.
--由於目標資料庫也是下游資料庫,因此不需要配置傳播程序。捕獲程序和應用程序將共享streams佇列和隊列表
connect strmadmin/[email protected]
Connected.
-- Create Streams Queue.
begin
dbms_streams_adm.set_up_queue(
queue_name => 'DBXA_CAP_APP_Q',
queue_table => 'DBXA_CAP_APP_Q_T',
queue_user => 'STRMADMIN'
);
end;
/
PL/SQL procedure successfully completed.
-- Create apply process and rules.
begin
dbms_streams_adm.add_schema_rules (
schema_name => 'SCOTT',
streams_type => 'APPLY',
streams_name => 'DBXA_APP',
queue_name => 'DBXA_CAP_APP_Q',
include_dml => true,
include_ddl => true,
inclusion_rule => true,
include_tagged_lcr => false,
source_database => 'DBXA.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
-- No need to create propagation, since apply
-- and capture run in the same database.
-- Explicitly create the capture process.
-- Note that use_database_link is set to TRUE.
begin
dbms_capture_adm.create_capture(
capture_name => 'DBXA_CAP',
queue_name => 'DBXA_CAP_APP_Q',
use_database_link => TRUE,
source_database => 'DBXA.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
-- Add capture rules.
begin
dbms_streams_adm.add_schema_rules (
schema_name => 'SCOTT',
streams_type => 'CAPTURE',
streams_name => 'DBXA_CAP',
queue_name => 'DBXA_CAP_APP_Q',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
inclusion_rule => true,
source_database => 'DBXA.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
--之後就和前面一樣例項化物件和啟動應用程序和捕獲程序
9、包含下游捕獲程序的單向複製(實時下游捕獲)--source資料庫DBXA.WORLD、target資料庫DBXB.WORLD
--在source資料庫中找到重做日誌檔案大小和重做日誌檔案數目
conn sys/[email protected] as sysdba
Connected.
select group#,
bytes/1048576 MB
from v$log;
GROUP# MB
---------- ----------
1 50
2 50
3 50
--在下游資料庫中建立備份重做日誌,並且比source資料庫的重做日誌多一組(和配置dataguard一樣)
conn sys/[email protected] as sysdba
Connected.
alter database add standby logfile group 4
('/u01/oradata/DBXA/standby_logs/standby_redo04.log') size 50M;
Database altered.
alter database add standby logfile group 5
('/u01/oradata/DBXA/standby_logs/standby_redo05.log') size 50M;
Database altered.
alter database add standby logfile group 6
('/u01/oradata/DBXA/standby_logs/standby_redo06.log') size 50M;
Database altered.
alter database add standby logfile group 7
('/u01/oradata/DBXA/standby_logs/standby_redo07.log') size 50M;
Database altered.
-- Check created Standby logs
select thread#,
group#,
sequence#,
status,
archived
from v$standby_log;
THREAD# GROUP# SEQUENCE# STATUS ARC
---------- ---------- ---------- ---------- ---
0 4 0 UNASSIGNED YES
0 5 0 UNASSIGNED YES
0 6 0 UNASSIGNED YES
0 7 0 UNASSIGNED YES
--這步和使用歸檔日誌一樣,為source和target資料庫配置傳輸初始化引數
--和使用歸檔日誌一樣,建立捕獲程序和應用程序
--注意:需要修改捕獲程序引數
conn strmadmin/[email protected]
Connected.
-- Modify capture Parameter
begin
dbms_capture_adm.set_parameter(
capture_name => 'DBXA_CAP',
parameter => 'downstream_real_time_mine',
value => 'Y'
);
end;
/
PL/SQL procedure successfully completed.
conn sys/[email protected] as sysdba
Connected.
alter system archive log current;
System altered.
conn sys/[email protected] as sysdba
Connected.
select thread#,
group#,
sequence#,
archived,
status
from v$standby_log;
THREAD# GROUP# SEQUENCE# ARC STATUS
---------- ---------- ---------- --- ----------
1 4 289 YES ACTIVE
0 5 0 YES UNASSIGNED
0 6 0 YES UNASSIGNED
0 7 0 YES UNASSIGNED
--之後就和前面一樣例項化物件和啟動應用程序和捕獲程序
10、雙向複製-- Connect to DBXB Database.
conn strmadmin/[email protected]
Connected.
-- Create Queue for apply in DBXB.
begin
dbms_streams_adm.set_up_queue(
queue_name => 'DBXA_APP_Q',
queue_table => 'DBXA_APP_Q_T',
queue_user => 'STRMADMIN'
);
end;
/
PL/SQL procedure successfully completed.
-- Create Queue for capture in DBXB.
begin
dbms_streams_adm.set_up_queue(
queue_name => 'DBXB_CAP_Q',
queue_table => 'DBXB_CAP_Q_T',
queue_user => 'STRMADMIN'
);
end;
/
PL/SQL procedure successfully completed.
-- Create apply process and rules in DBXB.
begin
dbms_streams_adm.add_schema_rules (
schema_name => 'SCOTT',
streams_type => 'APPLY',
streams_name => 'DBXA_APP',
queue_name => 'DBXA_APP_Q',
include_dml => true,
include_ddl => true,
inclusion_rule => true,
include_tagged_lcr => false,
source_database => 'DBXA.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
-- Create capture process and rules in DBXB.
begin
dbms_streams_adm.add_schema_rules (
schema_name => 'SCOTT',
streams_type => 'CAPTURE',
streams_name => 'DBXB_CAP',
queue_name => 'DBXB_CAP_Q',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
inclusion_rule => true,
source_database => 'DBXB.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
-- Create propagation in DBXB to send changes to DBXA.
begin
dbms_streams_adm.add_schema_propagation_rules (
schema_name => 'SCOTT',
streams_name => 'DBXB_TO_DBXB_PROP',
source_queue_name => 'DBXB_CAP_Q',
destination_queue_name => '[email protected]',
include_dml => true,
include_ddl => true,
inclusion_rule => true,
include_tagged_lcr => false,
queue_to_queue => true,
source_database => 'DBXB.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
-- Connect to DBXA Database
conn strmadmin/[email protected]
Connected.
-- Create Queue for apply in DBXA.
begin
dbms_streams_adm.set_up_queue(
queue_name => 'DBXB_APP_Q',
queue_table => 'DBXB_APP_Q_T',
queue_user => 'STRMADMIN'
);
end;
/
PL/SQL procedure successfully completed.
-- Create Queue for capture in DBXA.
begin
dbms_streams_adm.set_up_queue(
queue_name => 'DBXA_CAP_Q',
queue_table => 'DBXA_CAP_Q_T',
queue_user => 'STRMADMIN'
);
end;
/
PL/SQL procedure successfully completed.
-- Create apply Process and Rules in DBXA.
begin
dbms_streams_adm.add_schema_rules (
schema_name => 'SCOTT',
streams_type => 'APPLY',
streams_name => 'DBXB_APP',
queue_name => 'DBXB_APP_Q',
include_dml => true,
include_ddl => true,
inclusion_rule => true,
include_tagged_lcr => false,
source_database => 'DBXB.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
-- Create capture process and rules in DBXA.
begin
dbms_streams_adm.add_schema_rules (
schema_name => 'SCOTT',
streams_type => 'CAPTURE',
streams_name => 'DBXA_CAP',
queue_name => 'DBXA_CAP_Q',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
inclusion_rule => true,
source_database => 'DBXA.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
-- Create propagation in DBXA to send changes to DBXB.
begin
dbms_streams_adm.add_schema_propagation_rules (
schema_name => 'SCOTT',
streams_name => 'DBXA_TO_DBXB_PROP',
source_queue_name => 'DBXA_CAP_Q',
destination_queue_name => '[email protected]',
include_dml => true,
include_ddl => true,
inclusion_rule => true,
include_tagged_lcr => false,
queue_to_queue => true,
source_database => 'DBXA.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
--接下來將source資料庫的物件匯入到target資料庫中,並設立例項化scn(data pump匯入就不演示了)
--在source資料庫中也例項化scn(對需要的表)。如下手動設定
-- Connect to DBXB database.
conn strmadmin/[email protected]
Connected.
declare
v_scn number;
begin
v_scn := dbms_flashback.get_system_change_number();
[email protected](
source_schema_name => 'SCOTT',
source_database_name => 'DBXB.WORLD',
instantiation_scn => v_scn,
recursive => true
);
end;
/
PL/SQL procedure successfully completed.
--以上都操作完之後可以在兩個資料庫都啟動capture和apply程序(每個資料庫都要啟動這兩個程序)
11、使用同步捕獲程序的複製-- Connect to Destination Database.
conn strmadmin/[email protected]
Connected.
-- Create Streams Queue.
begin
dbms_streams_adm.set_up_queue(
queue_name => 'DBXA_APP_Q',
queue_table => 'DBXA_APP_Q_T',
queue_user => 'STRMADMIN'
);
end;
/
PL/SQL procedure successfully completed.
-- Create the Apply Process.
-- The APPLY_CAPTURED is set to FALSE by default.
-- But, it is included for documentation purpose.
--
begin
dbms_apply_adm.create_apply(
apply_name => 'DBXA_APP',
queue_name => 'DBXA_APP_Q',
apply_captured => FALSE
);
end;
/
PL/SQL procedure successfully completed.
begin
dbms_streams_adm.add_schema_rules (
schema_name => 'SCOTT',
streams_type => 'APPLY',
streams_name => 'DBXA_APP',
queue_name => 'DBXA_APP_Q',
include_dml => true,
source_database => 'DBXA.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
-- Connect to the Source Database.
conn strmadmin/[email protected]
Connected.
-- Create Streams Queue for synchronous capture.
begin
dbms_streams_adm.set_up_queue(
queue_name => 'DBXA_SYNC_CAP_Q',
queue_table => 'DBXA_SYNC_CAP_Q_T',
queue_user => 'STRMADMIN'
);
end;
/
PL/SQL procedure successfully completed.
-- Create Synchronous capture process
-- and add capture rules for replicated tables.
begin
dbms_streams_adm.add_table_rules (
table_name => 'SCOTT.DEPT',
streams_type => 'SYNC_CAPTURE',
streams_name => 'DBXA_SYNC_CAP',
queue_name => 'DBXA_SYNC_CAP_Q',
include_dml => true,
inclusion_rule => true,
source_database => 'DBXA.WORLD'
);
dbms_streams_adm.add_table_rules (
table_name => 'SCOTT.EMP',
streams_type => 'SYNC_CAPTURE',
streams_name => 'DBXA_SYNC_CAP',
queue_name => 'DBXA_SYNC_CAP_Q',
include_dml => true,
inclusion_rule => true,
source_database => 'DBXA.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
-- Create propagation Process and add rules.
-- We can add rules at Schema or Global level.
begin
dbms_streams_adm.add_schema_propagation_rules (
schema_name => 'SCOTT',
streams_name => 'DBXA_TO_DBXB_PROP',
source_queue_name => 'DBXA_SYNC_CAP_Q',
destination_queue_name => '[email protected]',
include_dml => true,
queue_to_queue => true,
source_database => 'DBXA.WORLD'
);
end;
/
PL/SQL procedure successfully completed.
-- Since the Source and Destination tables are
-- already in sync, no need to export/import data.
-- We perform the instantiation manually.
declare
v_scn number;
begin
v_scn := dbms_flashback.get_system_change_number();
[email protected](
source_object_name => 'SCOTT.DEPT',
source_database_name => 'DBXA.WORLD',
instantiation_scn => v_scn);
[email protected](
source_object_name => 'SCOTT.EMP',
source_database_name => 'DBXA.WORLD',
instantiation_scn => v_scn
);
end;
/
PL/SQL procedure successfully completed.
12、還有以下幾種配置策略(P228)
1)從單個源到多個目標資料庫
2)使用佇列轉發的複製
3)使用應用轉發的複製
4)輻射型別複製
5)點對點複製
相關推薦
oracle 11g streams各種型別搭建主要步驟
1、資料庫級別streams複製 --完整引數示例 connect strmadmin/[email protected] Connected. begin dbms_streams_adm.maintain_global ( sour
[Oracle]11g內存占用調整步驟
spa 出現 tex 11g eat shu dmi nis 新的 按如下的步驟調整內存 1. sqlplus /nolog2. conn / as sysdba 3. show parameter target 4. show parameter sgaalter
ORACLE 11G 搭建dataguard詳細步驟(所有操作總結)
http://blog.itpub.net/26230597/viewspace-1432637/ https://wenku.baidu.com/view/c323c0a30975f46526d3e103.html
oracle 11g r2 rac 安裝整理 附詳細步驟(親測VMware和exsi都可以完美安裝物理機自然沒有問題)
oracle 11g r2 rac由於前面安裝了,由於時間關系沒有來得及整理,今天閑下來,整理了安裝步驟,還是活的一些收獲的,下面附上步驟:1.安裝操作系統最小化安裝即可2.關閉防火墻3.替換yum4.添加共享磁盤5.創建用戶和用戶組6.添加用戶環境變量7.調整內核參數8.安裝依賴包9.配置hosts10.
Oracle 11g服務器安裝詳細步驟——圖文教程
取消 標識符 wide 規則 ast ima mage 不顯示 ade 方法/步驟 1 大家可以根據自己的操作系統是多少位(32位或64位)的,到官網下載相應的安裝程序,如下圖所示。 有一點需要註意,Oracle的安裝程序分
linux下oracle 11g dg環境搭建
oracle dataguard項目192.168.12.22(主)192.168.12.23(從)oracle sidorclorcldb_unique_nameuniquepdguniquesdgtnsnameTns_pdgTns_sdg一、主庫操作確認主庫是否打開歸檔、force loggingSQL
Oracle 11g安裝步驟詳談
分享圖片 默認 net mon scott賬戶 mes pda 最新 軟件 又是十月南京陰雨天氣 圖書館花了一個多小左右把11g安裝折騰好了。其中折騰SQL Developer 花了好長時間,總算搞定了。好了,先總結下安裝步驟,希望給後面的童鞋提高安裝效率。 相互
Linux 下 Oracle 11g DG搭建
ide iat 修改 環境變量 狀態 add 文件目錄 log 行數據 環境:模擬主庫的創建 使用DBCA 啟動圖形界面 選項中的install option --->選中create and configure a database 模擬備庫
Oracle 11g R2 for Win10(64位)的安裝步驟
mar blog 11g r2 list sta 配置文件 目錄 body 11gr2 下載 官網下載地址: win64_11gR2_database_1of2.zip win64_11gR2_database_2of2.zip 將兩個壓縮包解壓到同一個目錄下,即“data
在win7系統上搭建django+oracle 11g時,註意事項
註意事項 win 1.8 cli for order style 示例 tab 在win7系統上搭建django+oracle 11g時,註意事項【示例用的是python 2.7】: 重要:python、oracle、oracle client這三個的OS bit 一定一定
Oracle 11g超詳細安裝步驟
img 成功 In 分享圖片 acl oracle的安裝 數據庫 服務 數據 一、首先是Oracle的安裝 軟件請自行到網上下載 18、等待,出現選擇項時點擊next 二、打開服務 三、驗證數據庫是否安裝成功 Or
Oracle 11g R2 ADG 搭建
desc word server 拷貝 iat 閃回 ssi mkdir col --============Oracle ADG搭建==============--==========準備階段=========1.檢查primary為archivelog模式。select
Oracle 11g各種服務作用以及哪些需要開啟
成功安裝Oracle 11g資料庫後,你會發現自己電腦執行速度會變慢,配置較低的電腦甚至出現非常卡的狀況,通過禁止非必須開啟的Oracle服務可以提升電腦的執行速度。那麼,具體該怎麼做呢? 按照win7 64位環境下Oracle 11g R2安裝詳解中的方法成功安裝Or
SSM專案搭建的主要步驟
一、說明 因本人個人習慣,一般將專案的核心的配置分為如下幾個配置檔案配置(名字也是本人的個人愛好,不喜別噴),下文說到配置檔案時就不會再進行解釋。 spring-mybatis.xml:springMybatis配置檔案,主要用來配置與mybatis有關的配置
redhat6.4 下安裝oracle 11g詳細完整的步驟
** 一、虛擬機器安裝作業系統** Redhat 6.4 注意:linux下安裝oracle 11,如果是redhat系統,選擇redhat6版本的,因為redhat7版本里面少一個安裝資料庫用到的包compat-libstdc+±33,沒有這個包,安裝之後後面會出錯。 1.1 安
Oracle 11g資料庫詳細安裝步驟圖解,附帶安裝包
1.下載11g安裝包 第一步:開始安裝 第二步:配置安全更新 第三步:安全選項 第四步:系統類 第五步:典型安裝 第六步:先決條件檢查 第七步:安裝產品 第八步:等待安裝 第九步:安裝完成 2.開始安裝 將兩個檔案一起解壓到同一目錄下的同一資料夾內(雲盤下載
Oracle 11g RAC關機 開機操作步驟
首先關閉防火牆iptables -F 兩臺都要操作 CRS-4639: Could not contactOracle High Availability Services 原因,crs沒有啟動 方法1、oracle中的bug, 啟動之前需要執行 /bin/dd if=/
Oracle 11g資料庫詳細解除安裝步驟圖解
如看不清圖中文字可按住Ctrl滾動滑鼠滾輪來縮放網頁大小 完全解除安裝oracle11g步驟: 1、 開始-->設定-->控制面板-->管理工具-->服務 停止所有Oracle服務。 2、 開始-->程式-->oracle - OraHome81-->
Oracle 11g 快速搭建指令碼
一、root使用者 1、安裝前準備 mv /home/vsftpd/linux.x64_11gR2_database_* /tmp && cd /tmp unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64
Oracle 11g 快速搭建腳本
start sid tac custom png 11.2 led init scu 一、root用戶 1、安裝前準備 mv /home/vsftpd/linux.x64_11gR2_database_* /tmp && cd /tmp unzip lin