單例項和RAC打造的ORACLE STREAM(完)

season0891發表於2010-04-16
第十二步,備庫下建立應用程式:
USER is "SCOTT"
SQL> conn strmadmin/strmadmin
Connected.
SQL> begin
  2  dbms_streams_adm.add_schema_rules(
  3  schema_name => 'scott',
  4  streams_type => 'apply',
  5  streams_name => 'apply_storm',
  6  queue_name => 'strmadmin.storm_queue',
  7  include_dml => true,
  8  include_ddl => true,
  9  include_tagged_lcr => false,
 10  source_database => 'ora',
 11  inclusion_rule => true);
 12  end;
 13  /
PL/SQL procedure successfully completed.
 
第十三步,主庫備庫分別啟動stream:
備庫:
SQL> begin
  2  dbms_apply_adm.start_apply(
  3  apply_name => 'apply_storm');
  4  end;
  5  /
PL/SQL procedure successfully completed.
 
主庫:
SQL> begin
  2  dbms_capture_adm.start_capture(
  3  capture_name => 'capture_ora');
  4  end;
  5  /
PL/SQL procedure successfully completed.
 
第十四步,測試過程:
1,主庫下以scott使用者登陸並建立一張表:
SQL> conn scott/tiger
Connected.
SQL> CREATE TABLE TTT(id NUMBER PRIMARY KEY,name VARCHAR2(50));
Table created.
 
2,備庫下進行檢視是否有相應表:
$ sqlplus scott/tiger
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jan 19 15:45:54 2010
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> desc ttt
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                        NOT NULL NUMBER
 NAME                                               VARCHAR2(50)
 
storm2:
SQL> desc ttt;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                        NOT NULL NUMBER
 NAME                                               VARCHAR2(50)
 
3,主庫下插入資料:
SQL> insert into ttt values (1,'storm is a good guy');
1 row created.
SQL> select * from ttt;
        ID NAME
---------- --------------------------------------------------
         1 storm is a good guy

 
4,備庫下進行檢驗:
SQL> select * from ttt;
no rows selected
這時看到沒有任何資料生成,在這個地方需要注意的是,主庫插入了資料但是並沒有提交,所以備庫無法檢視資料生成結果。
 
5,主庫進行提交:
SQL> commit;
Commit complete.
 
6,備庫再次檢視:
SQL> select * from ttt;
        ID NAME
---------- --------------------------------------------------
         1 storm is a good guy
 
storm2:
SQL> select * from ttt;
        ID NAME
---------- --------------------------------------------------
         1 storm is a good guy
 
至此,整個實驗過程宣告結束。仔細對比兩次實驗可以發現,兩個單例項構建的stream和單例項、RAC構建的stream的基本步驟都是相同 的,所不同的地方只是體現在歸檔模式的設定,只要本著一個資料庫的概念,一切都能順利完成了。
 
全文畢。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90618/viewspace-659949/,如需轉載,請註明出處,否則將追究法律責任。

相關文章