oracle stream之schema級複製
今天測試了一下
stream之schema複製,如下:[@more@]
source database是linux oracle10g
target database是 window oracle11g
1,配置前準備 global_names引數必須等於true
資料庫必須為archive模式
查詢global name的方法
2,source database上執行SQL> select * from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------------
ORACLE10G.COM.CN
SQL> create tablespace stream_tbs datafile '/u01/oradata/oracle10/stream_tbs.dbf' size 100m;
Tablespace created.
SQL> create user strmadmin identified by strmadmin default tablespace stream_tbs;
User created.
SQL> grant connect,resource,dba,aq_administrator_role to strmadmin;
Grant succeeded.
SQL> begintarget database上執行
2 dbms_streams_auth.grant_admin_privilege(
3 grantee => 'strmadmin',
4 grant_privileges => true);
5 end;
6 /
PL/SQL procedure successfully completed.
SQL> create tablespace stream_tbs datafile 'd:apporadataorclstream_tbs.dbf' size 100m;
Tablespace created.
SQL> create user strmadmin identified by strmadmin default tablespace stream_tbs;
User created.
SQL> grant connect,resource,dba,aq_administrator_role to strmadmin;
Grant succeeded.
SQL> begin
2 dbms_streams_auth.grant_admin_privilege(
3 grantee => 'strmadmin',
4 grant_privileges => true);
5 end;
6 /
PL/SQL procedure successfully completed.
3,在source database 和target database 中配置tnsname.ora和listener.ora
4,建立database link
source database (database link名字必須和global_name一樣)
target database上SQL> conn strmadmin/strmadmin
Connected.
SQL> create database link test.com.cn connect to strmadmin identified by "strmadmin" using 'test';
Database link created.
5.建立流佇列SQL> conn strmadmin/strmadmin
Connected.
SQL> create database link oracle10g.com.cn connect to strmadmin identified by "strmadmin" using 'oracle10g';
Database link created.
source database
SQL> show usertarget database
USER is "STRMADMIN"
SQL> begin
2 dbms_streams_adm.set_up_queue(
3 queue_table=> 'source_queue_table',
4 queue_name=> 'source_queue'
5 );
6 end;
7 /
PL/SQL procedure successfully completed
SQL> show user
USER is "STRMADMIN"
SQL> begin
2 dbms_streams_adm.set_up_queue(
3 queue_table=> 'target_queue_table',
4 queue_name=> 'target_queue'
5 );
6 end;
7 /
PL/SQL procedure successfully completed.
6,source database 中建立捕獲程式
7,source database中建立傳播程式SQL> show user
USER is "STRMADMIN"SQL> begin
2 dbms_streams_adm.add_schema_rules(
3 schema_name => 'scott',
4 streams_type=> 'capture',
5 streams_name=> 'capture_stream',
6 queue_name=> 'strmadmin.source_queue',
7 include_dml=> true,
8 include_ddl=> true,
9 inclusion_rule => true);
10 end;
11 /
SQL> show user
USER is "STRMADMIN"SQL> begin
2 dbms_streams_adm.add_schema_propagation_rules(
3 schema_name=> 'scott',
4 streams_name=> 'source_to_target',
5 source_queue_name=> 'strmadmin.source_queue',
6 destination_queue_name=> 'strmadmin.target_queue@test.com.cn',
7 include_ddl=> true,
8 include_dml=> true,
9 inclusion_rule => true,
10 queue_to_queue=>true,
11 source_database=> 'oracle10g.com.cn'
12 );
13 end;
14 /
PL/SQL procedure successfully completed.
8,例項化複製資料庫
在target端執行
SQL> DECLARE
2 iscn NUMBER;
3 BEGIN
4 iscn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER();
5 DBMS_APPLY_ADM.SET_TABLE_INSTANTIATION_SCN@test.com.cn(
6 source_object_name => 'scott',
7 source_database_name => 'oracle10g.com.cn',
8 instantiation_scn => iscn);
9 END;
10 /
PL/SQL procedure successfully completed.
9.target database建立應用程式
SQL> begin
2 dbms_streams_adm.add_schema_rules(
3 schema_name => 'scott',
4 streams_type=> 'apply',
5 streams_name=> 'apply_stream',
6 queue_name=> 'strmadmin.target_queue',
7 include_dml=> true,
8 include_ddl=> true,
9 inclusion_rule => true,
10 source_database=> 'oracle10g.com.cn');
11 end;
12
13 /
PL/SQL procedure successfully completed.
10,啟動stream
source database啟動capture程式
target database啟動apply程式SQL> begin
2 dbms_capture_adm.start_capture(capture_name=>'capture_stream' );
3 end;
4 /
PL/SQL procedure successfully completed.停止capture 程式SQL> begin
2 dbms_capture_adm.stop_capture(capture_name=>'capture_stream' );
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_apply_adm.start_apply(apply_name=> 'apply_stream');
3 end;
4 /
PL/SQL procedure successfully completed.
11,清除所有配置停止apply程式SQL> begin
2 dbms_apply_adm.stop_apply(apply_name=> 'apply_stream');
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> exec DBMS_STREAMS_ADM.remove_streams_configuration();
PL/SQL procedure successfully completed.
測試指令碼================================================================================begindbms_streams_adm.set_up_queue(
queue_table=> 'source_queue_table',
queue_name=> 'source_queue'
);
end;
begin
dbms_streams_adm.set_up_queue(
queue_table=> 'target_queue_table',
queue_name=> 'target_queue'
);
end;
===========================
source database:
exec dbms_streams_adm.set_up_queue();
target database:
exec dbms_streams_adm.set_up_queue();
grant connect,resource,dba,aq_administrator_role to strmadmin;
begin
dbms_streams_auth.grant_admin_privilege(
grantee => 'strmadmin',
grant_privileges => true);
end;------------------------------------------------------------------------------------------------------------------------------begin
dbms_streams_adm.add_schema_rules(
schema_name => 'scott',
streams_type=> 'capture',
streams_name=> 'capture_stream',
queue_name=> 'strmadmin.streams_queue',
include_dml=> true,
include_ddl=> true,
inclusion_rule => true);
end;
===========================
begin
dbms_streams_adm.add_schema_rules(
schema_name => 'scott',
streams_type=> 'capture',
streams_name=> 'capture_stream',
queue_name=> 'strmadmin.source_queue',
include_dml=> true,
include_ddl=> true,
inclusion_rule => true);
end;------------------------------------------------------------------------------------------------------------------------------begin
dbms_streams_adm.add_schema_propagation_rules(
schema_name=> 'scott',
streams_name=> 'source_to_target',
source_queue_name=> 'strmadmin.streams_queue',
destination_queue_name=> 'strmadmin.streams_queue@test.com.cn',
include_ddl=> true,
include_dml=> true,
inclusion_rule => true,
queue_to_queue=>true,
source_database=> 'oracle10g.com.cn'
);
end;
=============================
begin
dbms_streams_adm.add_schema_propagation_rules(
schema_name=> 'scott',
streams_name=> 'source_to_target',
source_queue_name=> 'strmadmin.source_queue',
destination_queue_name=> 'strmadmin.target_queue@test.com.cn',
include_ddl=> true,
include_dml=> true,
inclusion_rule => true,
queue_to_queue=>true,
source_database=> 'oracle10g.com.cn'
);
end;------------------------------------------------------------------------------------------------------------------------------connect strmadmin/strmadmin@oracle10g
set serveroutput on
DECLARE
iscn NUMBER;
BEGIN
iscn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER();
DBMS_OUTPUT.PUT_LINE ('Instantiation SCN is: ' || iscn);
END;
connect strmadmin/strmadmin
BEGIN
DBMS_APPLY_ADM.SET_SCHEMA_INSTANTIATION_SCN(
source_schema_name=> 'scott',
source_database_name => 'oracle10g',
instantiation_scn => &iscn);
END;
===========================================
DECLARE
iscn NUMBER;
BEGIN
iscn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER();
DBMS_APPLY_ADM.SET_TABLE_INSTANTIATION_SCN@test.com.cn(
source_object_name => 'scott',
source_database_name => 'oracle10g.com.cn',
instantiation_scn => iscn);
END;------------------------------------------------------------------------------------------------------------------------------begin
dbms_streams_adm.add_schema_rules(
schema_name => 'scott',
streams_type=> 'apply',
streams_name=> 'apply_stream',
queue_name=> 'strmadmin.target_queue',
include_dml=> true,
include_ddl=> true,
inclusion_rule => true,
source_database=> 'oracle10g.com.cn');
end;------------------------------------------------------------------------------------------------------------------------------begin
dbms_capture_adm.start_capture(capture_name=>'capture_stream' );
end;
begin
dbms_capture_adm.stop_capture(capture_name=>'capture_stream' );
end;
======================================
begin
dbms_apply_adm.start_apply(apply_name=> 'apply_stream');
end;
begin
dbms_apply_adm.stop_apply(apply_name=> 'apply_stream');
end;
begin
dbms_apply_adm.stop_apply(apply_name=> 'target_apply_stream');
end;
exec DBMS_STREAMS_ADM.remove_streams_configuration();
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-1060147/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE10g Stream表級複製配置Oracle
- ORACLE10g Stream使用者級複製配置Oracle
- GoldenGate schema級複製 實施過程Go
- 資料複製_Stream
- Oracle 10g stream 一對多複製Oracle 10g
- Oracle Stream(3)--Stream與高階複製和邏輯Dataguard的比較Oracle
- DM7資料複製之模式級複製模式
- oracle 10g-->11g schema級別下游實時捕獲stream配置Oracle 10g
- DM7資料複製之資料庫級複製資料庫
- Oracle 之 Duplicate 複製資料庫Oracle資料庫
- oracle複製Oracle
- 一次通過stream複製解決資料單向複製的案例
- oracle 流複製Oracle
- MySQL主從複製之GTID複製MySql
- MySQL主從複製之半同步複製MySql
- MySQL主從複製之非同步複製MySql非同步
- Schema之簡單元素、複合元素和屬性
- oracle複製軟體排名『複製技術系列』Oracle
- oracle 高階複製Oracle
- Oracle高階複製Oracle
- MysqL主從複製_模式之GTID複製MySql模式
- iOS之物件複製iOS物件
- 建立Oracle 10gR2的local stream和downstream real-time apply 流複製Oracle 10gAPP
- 【Mongo】單節點升級為複製集再升級為分片加複製集Go
- Mysql 5.6庫級表級複製的搭建MySql
- Oracle流複製技術Oracle
- 為Oracle配置DDL複製Oracle
- MySQL入門--MySQL複製技術之主從從級聯複製MySql
- oracle schema物件Oracle物件
- python複製之坑Python
- Mysql分散式部署 - 多級複製MySql分散式
- MySQL級聯複製中資料同步MySql
- MySQL 5.5級聯複製配置流程MySql
- oracle goldengate 雙活複製避免迴圈複製引數OracleGo
- 【SqlServer】【Oracle】sql複製表定義及複製資料行SQLServerOracle
- 使用dbms_schema_copy 進行不同使用者間資料複製
- 淺複製和深複製的概念與值複製和指標複製(引用複製)有關 淺複製 “指標複製 深複製 值複製指標
- Oracle活動資料庫複製Oracle資料庫