文章詳情頁
利用oracle高級(jí)復(fù)制功能實(shí)現(xiàn)數(shù)據(jù)同步的問題
瀏覽:2日期:2023-11-20 15:42:31
/* 從DPS到EMIS,表dpsuser.gg_web_info_m *//* 首先確保在EMIS數(shù)據(jù)庫中已經(jīng)建立了dpsuser和相應(yīng)的表空間dpsdata *//* 第一步,配置主體端 */connect system/manager@dpsgrant connect,dba,resource to dpsuser;/* 創(chuàng)建復(fù)制治理員repadmin */create user repadmin identified by repadmin;alter user repadmin default tablespace users;alter user repadmin temporary tablespace temp;grant connect,resource to repadmin;/* 授予repadmin用戶權(quán)限可以治理當(dāng)前站點(diǎn)中任何主體組 */execute dbms_repcat_admin.grant_admin_any_schema('repadmin');/* 授予repadmin用戶權(quán)限可以為任何表創(chuàng)建snapshot logs */grant comment any table to repadmin;grant lock any table to repadmin;/* 指定repadmin用戶為propagator,并授予執(zhí)行任何procedure的權(quán)限 */execute dbms_defer_sys.register_propagator('repadmin');grant execute any procedure to repadmin;/* 分配proxy snapshot administration權(quán)限給repadmin,list_of_gnames為null,意味著可以治理所有對(duì)象組 */begindbms_repcat_admin.register_user_repgroup(username => 'repadmin',privilege_type => 'proxy_snapadmin',list_of_gnames => null);end;//* 分配'receiver'權(quán)限給repadmin */begindbms_repcat_admin.register_user_repgroup(username => 'repadmin',privilege_type => 'receiver',list_of_gnames => null);end;/grant select any table to repadmin;/* 以repadmin身份登錄 */connect repadmin/repadmin@DPS/* 在DPS上建立主體組,主體組名為REP_DPS,并往主體組中加入一個(gè)表 *//* 建立主體組 */begindbms_repcat.create_master_repgroup(gname => 'rep_dps',qualifier => '',group_comment => '');end;//* 向主體組中加入表gg_web_info_m */begindbms_repcat.create_master_repobject(gname => 'rep_dps',type => 'table',oname => 'gg_web_info_m',sname => 'dpsuser',copy_rows => true,use_existing_object => true);end;//* 建立相應(yīng)的快照日志 */create snapshot logon dpsuser.gg_web_info_mtablespace systemwith primary keyexcluding new values;/* 生成復(fù)制支持 */begindbms_repcat.generate_replication_support(sname => 'dpsuser',oname => 'gg_web_info_m',type => 'table',min_communication => true,generate_80_compatible => false);end;//* 第二步,配置快照端 */connect system/manager@emis/* 修改用戶權(quán)限 */grant connect,dba,resource to dpsuser;/* 創(chuàng)建復(fù)制治理員repadmin */create user repadmin identified by repadmin;alter user repadmin default tablespace users;alter user repadmin temporary tablespace temp;grant connect,resource to repadmin;/* 授予repadmin用戶權(quán)限可以治理當(dāng)前站點(diǎn)中任何主體組 */execute dbms_repcat_admin.grant_admin_any_schema('repadmin');/* 授予repadmin用戶權(quán)限可以為任何表創(chuàng)建snapshot logs */grant comment any table to repadmin;grant lock any table to repadmin;/* 指定repadmin用戶為propagator,并授予執(zhí)行任何procedure的權(quán)限 */ execute dbms_defer_sys.register_propagator('repadmin');grant execute any procedure to repadmin;/* 授予repadmin用戶可以創(chuàng)建快照 */grant create any snapshot to repadmin;grant alter any snapshot to repadmin;/*在EMIS服務(wù)器上添加到DPS的連接,可以通過修改tnsnames.ora實(shí)現(xiàn) *//* 在EMIS建立與DPS的數(shù)據(jù)庫鏈接 */create public database link dps connect to repadmin identified by repadmin using 'dps';/* 在EMIS建立刷新組ref_dps */begindbms_refresh.make(name => 'dpsuser.ref_dps',list => '',next_date => sysdate,interval => '/*1:Secs*/ sysdate + 1/(60*60*24)',implicit_destroy => false,lax => false,job => 0,rollback_seg => null,push_deferred_rpc => true,refresh_after_errors => true,purge_option => null,parallelism => null,heap_size => null);end;//* 在EMIS建立快照組 同步為synchronous,異步為asynchronous*/begindbms_repcat.create_snapshot_repgroup(gname => 'rep_dps',master => 'dps',propagation_mode => 'asynchronous');end;//*建立快照,快照要在表所屬的用戶下建立,所以要先用dpsuser登陸 */connect dpsuser/dps@emis/* 建立gg_web_info_m的快照 */create snapshot dpsuser.gg_web_info_mbuild immediaterefresh forcenext sysdate + 1/86400for updateasselect * from dpsuser.gg_web_info_m@dps/* 將快照加入刷新組 */begindbms_refresh.add(name => 'dpsuser.ref_dps',list => 'dpsuser.gg_web_info_m',lax => true);end;//* 將快照加入快照組 */begindbms_repcat.create_snapshot_repobject(gname => 'rep_dps',sname => 'dpsuser',oname => 'gg_web_info_m',type => 'snapshot',min_communication => false);end;//* 第三步,在DPS端激活主體組 */connect system/manager@dpsbegindbms_repcat.resume_master_activity(gname => 'rep_dps');end;/
標(biāo)簽:
Oracle
數(shù)據(jù)庫
排行榜
