/* 从DPS到EMIS,表dpsuser.gg_web_info_m */
/* 首先确保在EMIS数据库中已经建立了dpsuser和相应的表空间dpsdata */
/* 第一步,配置主体端 */
connect system/manager@dps
grant connect,dba,resource to dpsuser;
/* 创建复制治理员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用户权限可以治理当前站点中任何主体组 */
execute dbms_repcat_admin.grant_admin_any_schema('repadmin');
/* 授予repadmin用户权限可以为任何表创建snapshot logs */
grant comment any table to repadmin;
grant lock any table to repadmin;
/* 指定repadmin用户为propagator,并授予执行任何procedure的权限 */
execute dbms_defer_sys.register_propagator('repadmin');
grant execute any procedure to repadmin;
/* 分配proxy snapshot administration权限给repadmin,list_of_gnames为null,意味着可以治理所有对象组 */
begin
dbms_repcat_admin.register_user_repgroup(
username => 'repadmin',
privilege_type => 'proxy_snapadmin',
list_of_gnames => null);
end;
/
/* 分配'receiver'权限给repadmin */
begin
dbms_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,并往主体组中加入一个表 */
/* 建立主体组 */
begin
dbms_repcat.create_master_repgroup(
gname => 'rep_dps',
qualifier => '',
group_comment => '');
end;
/
/* 向主体组中加入表gg_web_info_m */
begin
dbms_repcat.create_master_repobject(
gname => 'rep_dps',
type => 'table',
oname => 'gg_web_info_m',
sname => 'dpsuser',
copy_rows => true,
use_existing_object => true);
end;
/
/* 建立相应的快照日志 */
create snapshot log
on dpsuser.gg_web_info_m
tablespace system
with primary key
excluding new values;
/* 生成复制支持 */
begin
dbms_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
/* 修改用户权限 */
grant connect,dba,resource to dpsuser;
/* 创建复制治理员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用户权限可以治理当前站点中任何主体组 */
execute dbms_repcat_admin.grant_admin_any_schema('repadmin');
/* 授予repadmin用户权限可以为任何表创建snapshot logs */
grant comment any table to repadmin;
grant lock any table to repadmin;
/* 指定repadmin用户为propagator,并授予执行任何procedure的权限 */
execute dbms_defer_sys.register_propagator('repadmin');
grant execute any procedure to repadmin;
/* 授予repadmin用户可以创建快照 */
grant create any snapshot to repadmin;
grant alter any snapshot to repadmin;
/*在EMIS服务器上添加到DPS的连接,可以通过修改tnsnames.ora实现 */
/* 在EMIS建立与DPS的数据库链接 */
create public database link dps connect to repadmin identified by repadmin using 'dps';
/* 在EMIS建立刷新组ref_dps */
begin
dbms_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*/
begin
dbms_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_m
build immediate
refresh force
next sysdate + 1/86400
for update
as
select * from dpsuser.gg_web_info_m@dps;
/* 将快照加入刷新组 */
begin
dbms_refresh.add(
name => 'dpsuser.ref_dps',
list => 'dpsuser.gg_web_info_m',
lax => true);
end;
/
/* 将快照加入快照组 */
begin
dbms_repcat.create_snapshot_repobject(
gname => 'rep_dps',
sname => 'dpsuser',
oname => 'gg_web_info_m',
type => 'snapshot',
min_communication => false);
end;
/
/* 第三步,在DPS端激活主体组 */
connect system/manager@dps
begin
dbms_repcat.resume_master_activity(
gname => 'rep_dps');
end;
/