久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

Oracle數(shù)據(jù)庫10gR2中stream多源復(fù)制方法

瀏覽:116日期:2023-11-23 10:57:54

在10gR2中,oracle簡化了stream的配置的全過程,在9iR2及10gR1中,需要針對(duì)stream的捕獲、傳播、應(yīng)用進(jìn)程進(jìn)行配置的步驟

已經(jīng)被dbms_streams_adm新提供的過程(pre_instantiation_setup/post_instantiation_setup)給封裝起來啦,

配置stream只需要調(diào)用兩個(gè)存儲(chǔ)過程就可以搞定啦,真是太激動(dòng)人心啦,下面簡單地介紹一下dbms_streams_adm的新過程的用法。

1.在stream進(jìn)行配置前,需要做些準(zhǔn)備工作

a 源庫與目標(biāo)庫初始化參數(shù)的設(shè)置

alter system set aq_tm_processes=4 scope=spfile;

alter system set job_queue_processes=5 scope=spfile;

alter system set global_names=true scope=spfile;

alter system set streams_pool_size=51m scope=spfile;

說明streams_pool_size在生產(chǎn)環(huán)境中最好>200m

b 源庫與目標(biāo)庫tnsnames.ora配置

確保正確,可用tnsping通

c 源庫與目標(biāo)庫復(fù)制管理員的創(chuàng)建

create user strmadmin identified by strmadminpw

default tablespace &tbs_name quota unlimited on &tbs_name;

grant connect, resource, dba to strmadmin;

d 源庫與目標(biāo)庫創(chuàng)建互連的數(shù)據(jù)鏈

connect strmadmin/strmadminpw@test96

create database link test99.net connect to strmadmin

identified by strmadminpw using 'test99';

connect strmadmin/strmadminpw@test99

create database link test96.net connect to strmadmin

identified by strmadminpw using 'test96';

說明:必須確保雙方的數(shù)據(jù)庫鏈?zhǔn)强梢赃B通.

用pre_instantiation_setup/post_instantiation_setup過程時(shí)

db link必須用db_name.domain的格式

e 源庫與目標(biāo)庫必須處于歸檔模式

shutdown immediate;

startup mount;

alter database archivelog;

alter database open;

2.執(zhí)行pre_instantiation_setup過程

在調(diào)用dbms_streams_adm的pre_instantiation_setup/post_instantiation_setup過程時(shí), 它們必須成對(duì)出現(xiàn),pre_instantiation_setup過程中,maintain_mode參數(shù)可取GLOBAL與 TRANSPORTABLE TABLESPACES,如果取GLOBAL時(shí),表示全庫復(fù)制,否則可以定義需要復(fù)制的表空間; perform_actions參數(shù)為TRUE,進(jìn)行配置產(chǎn)生的源腳本將記錄在dba_recoverable_*字典表, 如果pre_instantiation_setup執(zhí)行時(shí)遇到錯(cuò)誤,可以通過執(zhí)行dbms_steams_adm的

recover_operation過程 在更正錯(cuò)誤后繼續(xù)執(zhí)行復(fù)制配置; source_database/destination_database是我們已經(jīng)創(chuàng)建好的dblink,必須確保正確啊, 否則pre_instantiation_setup過程將會(huì)失敗,報(bào)ORA-23621錯(cuò)誤,解決辦法在后面會(huì)介紹; bi_directional參數(shù)設(shè)置為true時(shí),表示是多源復(fù)制,即目標(biāo)與源庫雙向同步, 否則即只從源庫向目標(biāo)庫同步數(shù)據(jù); exclude_schemas參數(shù)指需要排除在全庫同步的表空間,多個(gè)表空間的話用逗號(hào)分開,

*表示排除配置stream時(shí)庫中已經(jīng)存在的表空間;

start_processes參數(shù)指配置完成后啟動(dòng)捕獲及應(yīng)用進(jìn)程。

SQL>connect strmadmin/strmadminpw@test96

declare

empty_tbs dbms_streams_tablespace_adm.tablespace_set;

begin

dbms_streams_adm.pre_instantiation_setup(

maintain_mode => 'GLOBAL',

tablespace_names => empty_tbs,

source_database => 'test96.net',

destination_database => 'test99.net',

perform_actions => true,

bi_directional => true,

include_ddl => true,

start_processes => true,

exclude_schemas => 'WMSYS,STRMADMIN,DBSNMP,TSMSYS,',

exclude_flags => dbms_streams_adm.exclude_flags_unsupported +

dbms_streams_adm.exclude_flags_dml + dbms_streams_adm.exclude_flags_ddl);

end;

/

如果參與復(fù)制的源庫與目標(biāo)庫的db link等配置的正確,該過程將成功結(jié)束,

并且在strmadmin模式創(chuàng)建一系統(tǒng)用于復(fù)制的隊(duì)列與字典表,如果db link配置出錯(cuò),

執(zhí)行pre_instantiation_setup過程時(shí),將會(huì)報(bào)如下錯(cuò)誤:

ORA-23621: Operation corresponding

3.用rman復(fù)制源庫到目標(biāo)庫

a 對(duì)源庫用rman進(jìn)行備份,拷貝備份集與產(chǎn)生的歸檔到目標(biāo)庫,

并將目標(biāo)庫down下來,啟動(dòng)nomount狀態(tài)。

rman nocatalog target /

rman>backup database;

rman>sql'alter system archive log current';

b 求得源庫的scn

SQL>connect strmadmin/strmadminpw@test96

SQL>set serveroutput on size 1000000

SQL>declare

until_scn number;

begin

until_scn:= dbms_flashback.get_system_change_number;

dbms_output.put_line('until scn: '||until_scn);

end;

/

until scn: 429596

c 用rman將源庫復(fù)制到目標(biāo)庫

rman nocatalog target /

rman> connect auxiliary sys/sys@test99

rman> run

{

set until scn 429596;

duplicate target database to 'TEST'

nofilenamecheck

open restricted;

}

d 重新命名目標(biāo)庫的global_name

alter database rename global_name to test99.net;

e 重新創(chuàng)建目標(biāo)庫的db link

connect strmadmin/strmadminpw@test99

create database link test96.net connect to strmadmin

identified by strmadminpw using 'test96';

4.執(zhí)行post_instantiation_setup過程

post_instantiation_setup也在源庫執(zhí)行,需要注意的參數(shù)是instantiation_scn

它的取值是我們從源庫上獲的scn的值-1=429595.

SQL>connect strmadmin/strmadminpw@test96

SQL>declare

empty_tbs dbms_streams_tablespace_adm.tablespace_set;

begin

dbms_streams_adm.post_instantiation_setup(

maintain_mode => 'GLOBAL',

tablespace_names => empty_tbs,

source_database => 'test96.net',

destination_database => 'test99.net',

perform_actions => true,

bi_directional => true,

include_ddl => true,

start_processes => true,

instantiation_scn => 429595,

exclude_schemas => '*',

exclude_flags => dbms_streams_adm.exclude_flags_unsupported +

dbms_streams_adm.exclude_flags_dml + dbms_streams_adm.exclude_flags_ddl);

end;

/

在目標(biāo)庫禁止restricted session

SQL>connect sys/sys@test99.net as sysdba

SQL>alter system disable restricted session;

5.測試stream的配置結(jié)果

a 在test96上創(chuàng)建一個(gè)schema,并在該schema下創(chuàng)建一些對(duì)象,可以在test99上看到

b 在test99上創(chuàng)建一個(gè)schema,并在該schema下創(chuàng)建一些對(duì)象,可以在test96上看到

6 關(guān)于雙向復(fù)制中avoid change cycling

查看目標(biāo)庫apply進(jìn)程的tag:

COLUMN APPLY_NAME HEADING 'Apply Process Name' FORMAT A30

COLUMN APPLY_TAG HEADING 'Tag Value' FORMAT A30

SQL>connect sys/sys@test99 as sysdba;

SELECT APPLY_NAME, APPLY_TAG FROM DBA_APPLY;

Apply Process Name Tag Value

------------------------------ -----------

APPLY$_TEST96_42 010781

查看源庫apply進(jìn)程的tag:

COLUMN APPLY_NAME HEADING 'Apply Process Name' FORMAT A30

COLUMN APPLY_TAG HEADING 'Tag Value' FORMAT A30

SQL>connect sys/sys@test99 as sysdba;

SELECT APPLY_NAME, APPLY_TAG FROM DBA_APPLY;

Apply Process Name Tag Value

------------------------------ ------------------------------

APPLY$_TEST99_15 010498

說明:消除多源復(fù)制中的遞歸問題,stream中已經(jīng)有很好的消除機(jī)制,

源端正常作業(yè)寫入的redo entry的tag是NULL的,如果是由于源端的apply進(jìn)程

產(chǎn)生的redo entry,在redo entry中將帶有tag標(biāo)志,這樣在源端捕獲進(jìn)程在

捕獲的redo entry中,過慮掉tag是NULL的,然后就可以消除change cycling.

10gR2stream全庫復(fù)制

以上主要為大家介紹了pre_instantiation_setup/post_instantiation_setup過程在配置全庫復(fù)制的方法,以下介紹dbms_streams_adm的maintain_global過程如何配置stream全庫復(fù)制方法,適用于10gR2及以后版本。

1l.在stream進(jìn)行配置前,需要做些準(zhǔn)備工作

a 源庫與目標(biāo)庫初始化參數(shù)的設(shè)置

alter system set aq_tm_processes=4 scope=spfile;

alter system set job_queue_processes=5 scope=spfile;

alter system set global_names=true scope=spfile;

alter system set streams_pool_size=51m scope=spfile;

說明streams_pool_size在生產(chǎn)環(huán)境中最好>200m

b 源庫與目標(biāo)庫tnsnames.ora配置

確保正確,可用tnsping通

c 源庫與目標(biāo)庫復(fù)制管理員的創(chuàng)建

create user strmadmin identified by strmadminpw

default tablespace &tbs_name quota unlimited on &tbs_name;

grant connect, resource, dba to strmadmin;

d 源庫與目標(biāo)庫創(chuàng)建互連的數(shù)據(jù)鏈

connect strmadmin/strmadminpw@test96

create database link test99.net connect to strmadmin

identified by strmadminpw using 'test99';

connect strmadmin/strmadminpw@test99

create database link test96.net connect to strmadmin

identified by strmadminpw using 'test96';

說明:必須確保雙方的數(shù)據(jù)庫鏈?zhǔn)强梢赃B通.

用pre_instantiation_setup/post_instantiation_setup過程時(shí)

db link必須用db_name.domain的格式

e 源庫與目標(biāo)庫必須處于歸檔模式

shutdown immediate;

startup mount;

alter database archivelog;

alter database open;

f 源庫與目標(biāo)庫必須創(chuàng)建directory

create directory dir_test96 as '/home/oracle/worksh';

create directory dir_test99 as '/home/oracle/worksh';

2.在源庫執(zhí)行MAINTAIN_GLOBAL過程

SQL>connect strmadmin/strmadminpw@test96

begin

dbms_streams_adm.maintain_global(

source_directory_object => 'dir_test96',

destination_directory_object => 'dir_test99',

source_database => 'test96.net',

destination_database => 'test99.net',

perform_actions => true,

include_ddl => true,

instantiation => DBMS_STREAMS_ADM.INSTANTIATION_FULL_NETWORK);

end;

說明:在執(zhí)行maintain_global時(shí),源庫與目標(biāo)庫必須創(chuàng)建directory,然后在源庫執(zhí)行, 目標(biāo)庫幾乎什么都不用做,stream環(huán)境已經(jīng)配置完畢。

標(biāo)簽: Oracle 數(shù)據(jù)庫
主站蜘蛛池模板: 奉新县| 西城区| 长子县| 马关县| 汉寿县| 武陟县| 丹巴县| 济南市| 尤溪县| 霞浦县| 四子王旗| 永和县| 浦县| 林周县| 灵宝市| 开鲁县| 汪清县| 商洛市| 和硕县| 古田县| 房山区| 阿拉善右旗| 龙口市| 宣恩县| 河间市| 温州市| 青海省| 崇阳县| 丁青县| 克拉玛依市| 尖扎县| 林口县| 德州市| 黑水县| 崇州市| 鄯善县| 东丰县| 子长县| 会同县| 壤塘县| 同德县|