導讀:
前幾天都是用Package來完成streams的配置,但在管理上用OEM會感覺更為直觀,當然對所有相關的Package很瞭解的話,也就都差不多了。在9i的OEM中看上去對streams的功能還不是很強。只是簡單的一些應用。下面有時間就要搞10gR2,想跳過10gR1的。下面帖一個在OEM建立單表複製的過程指令碼。
來源資料庫: GATES
目標資料庫: CLONE
1.設定作業
- Turn on supplemental logging and switch log file at source database.
- Create and set default tablespace for LogMiner at source database.
- 在來源資料庫中捕獲以下各表, 然後傳播並將更改應用於目標資料庫。
"SCOTT"."BONUS"
2.匯出/匯入操作
- 匯出從來源資料庫選擇的所有對象。
- 將它們匯入到目標資料庫。
3.啟動操作
- 首先在目標資料庫中啟動應用進程。
- 在來源資料庫中啟動捕獲進程。
--
Setup Operations:
REM
REM The following sections setup streams at the destination database
REM
ACCEPT dest_strmadmin_passwd PROMPT '請輸入目標資料庫
CLONE 中的使用者 STRMADMIN 的口令 : 'HIDE
connect STRMADMIN/&dest_strmadmin_passwd@CLONE
REM
REM Addapply rules fortables at the destination database
REM
BEGIN
DBMS_STREAMS_ADM.ADD_TABLE_RULES(
table_name =>'"SCOTT"."BONUS"',
streams_type =>'APPLY',
streams_name =>'STRMADMIN_GATES_VONGATES_',
queue_name =>'"STRMADMIN"."STREAMS_QUEUE"',
include_dml =>true,
include_ddl =>true,
source_database =>'GATES.VONGATES.COM');
END;
/
REM
REM The following sections setup streams at the source database
REM
ACCEPT source_strmadmin_passwd PROMPT '請輸入來源資料庫
GATES 中的使用者 STRMADMIN 的口令 : 'HIDE
connect SYS/&source_dba_passwd@GATESasSYSDBA
REM
REM Turn onsupplemental logging
REM
ALTERDATABASEADDSUPPLEMENTAL LOGDATA (PRIMARYKEY,UNIQUEINDEX)
COLUMNS;
REM
REM Switch logfile
REM
ALTERSYSTEM SWITCH LOGFILE;
REM
REM Createlogminer tablespace
REM
CREATETABLESPACE LOGMNRTS DATAFILE 'logmnrts_GATES.dbf'
SIZE 25M REUSE
AUTOEXTEND ONMAXSIZE UNLIMITED;
REM
REM Setlogminer tablespace
REM
BEGIN
DBMS_LOGMNR_D.SET_TABLESPACE('LOGMNRTS');
END;
/
connect STRMADMIN/&source_strmadmin_passwd@GATES
REM
REM Addcapture rules fortables at the source database
REM
BEGIN
DBMS_STREAMS_ADM.ADD_TABLE_RULES(
table_name =>'"SCOTT"."BONUS"',
streams_type =>'CAPTURE',
streams_name =>'STRMADMIN_CAPTURE',
queue_name =>'"STRMADMIN"."STREAMS_QUEUE"',
include_dml =>true,
include_ddl =>true,
source_database =>'GATES.VONGATES.COM');
END;
/
REM
REM Addpropagation rules fortables at the source database
REM
BEGIN
DBMS_STREAMS_ADM.ADD_TABLE_PROPAGATION_RULES(
table_name =>'"SCOTT"."BONUS"',
streams_name =>'STRMADMIN_PROPAGATE',
source_queue_name =>'"STRMADMIN"."STREAMS_QUEUE"',
destination_queue_name =>'"STRMADMIN"."STREAMS_QUEUE"@CLONE.VONGATES.COM',
include_dml =>true,
include_ddl =>true,
source_database =>'GATES.VONGATES.COM');
END;
/
--Export/Import Operations:
expUSERID="STRMADMIN"@GATESTABLES="SCOTT"."BONUS"
FILE=tables.dmp GRANTS=Y ROWS=Y LOG=exportTables.log
OBJECT_CONSISTENT=Y INDEXES=Y
imp USERID="STRMADMIN"@CLONEFULL=Y CONSTRAINTS=Y FILE=tables.dmp
IGNORE=Y GRANTS=Y ROWS=Y COMMIT=Y LOG=importTables.log
STREAMS_CONFIGURATION=Y STREAMS_INSTANTIATION=Y
--Startup Operations:
ACCEPT dest_strmadmin_passwd PROMPT '請輸入目標資料庫
CLONE 中的使用者 STRMADMIN 的口令 : 'HIDE
connect STRMADMIN/&dest_strmadmin_passwd@CLONE
REM
REM Start apply process at the destination database
REM
DECLARE
v_started
number;
BEGIN
SELECTdecode(status, 'ENABLED',
1,
0) INTOv_started
FROMDBA_APPLY WHEREAPPLY_NAME ='STRMADMIN_GATES_VONGATES_';
if(v_started =
0) then
DBMS_APPLY_ADM.START_APPLY(apply_name =>'STRMADMIN_GATES_VONGATES_');
endif;
END;
/
ACCEPT source_strmadmin_passwd PROMPT '請輸入來源資料庫
GATES 中的使用者 STRMADMIN 的口令 : 'HIDE
connect STRMADMIN/&source_strmadmin_passwd@GATES
DECLARE
v_started
number;
BEGIN
SELECTdecode(status, 'ENABLED',
1,
0) INTOv_started
FROMDBA_CAPTURE WHERECAPTURE_NAME ='CAPTURE';
if(v_started =
0) then
DBMS_CAPTURE_ADM.START_CAPTURE(capture_name =>'CAPTURE');
endif;
END;
/
本文轉自
http://oracle.itpub.net/post/20957/146515