oracle 前置库交换数据,数据库复制

中心库

--1、更改全局名(system)

alter database rename global_name to center.test.com.cn;

--2、创建复制用户(system)

create user repadmin identified by repadmin default tablespace users temporary tablespace temp;

--3、赋权限(system)

grant create session to repadmin;

grant select any table to repadmin;

execute dbms_defer_sys.register_propagator('repadmin');

grant execute any procedure to repadmin;

execute dbms_repcat_admin.grant_admin_any_repgroup('repadmin');

execute dbms_repcat_admin.grant_admin_any_schema('REPADMIN');

grant comment any table to repadmin;

grant lock any table to repadmin;

grant select any dictionary to repadmin;

--4、建数据库链接(repadmin)

create database link front.test.com.cn

connect to repadmin identified by repadmin

using 'apts221';

--5、创建需要复制的表(aptstest)

create table t

(

id number primary key,

name varchar2(14)

);

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

--6、创建要复制的组(repadmin)

execute dbms_repcat.create_master_repgroup('aptstest_mg');

execute dbms_repcat.create_master_repobject(sname=>'aptstest',oname=>'t', type=>'table',use_existing_object=>true,gname=>'aptstest_mg');

execute dbms_repcat.generate_replication_support('aptstest','t','table');

--7、创建主复制节点(repadmin)

execute dbms_repcat.add_master_database(gname=>'aptstest_mg',master=>'front.test.com.cn',use_existing_objects=>true, copy_rows=>false, propagation_mode => 'asynchronous');

--8、同步组

execute dbms_repcat.resume_master_activity('aptstest_mg',false);

--9、定时任务

begin

dbms_defer_sys.schedule_push (

destination => 'front.test.com.cn',

interval => 'sysdate + 10/1440',

next_date => sysdate);

end;

/

begin

dbms_defer_sys.schedule_purge (

next_date => sysdate,

interval => 'sysdate + 10/1440',

delay_seconds => 0,

rollback_segment => '');

end;

/

前置库

--1、更改全局名(system)

alter database rename global_name to front.test.com.cn;

--2、创建复制用户(system)

create user repadmin identified by repadmin default tablespace users temporary tablespace temp;

--3、赋权限(system)

grant create session to repadmin;

grant select any table to repadmin;

execute dbms_defer_sys.register_propagator('repadmin');

grant execute any procedure to repadmin;

execute dbms_repcat_admin.grant_admin_any_repgroup('repadmin');

execute dbms_repcat_admin.grant_admin_any_schema('REPADMIN');

grant comment any table to repadmin;

grant lock any table to repadmin;

grant select any dictionary to repadmin;

--4、建数据库链接(repadmin)

create database link center.test.com.cn

connect to repadmin identified by repadmin

using 'apts208';

--5、创建需要复制的表

create table t

(

id number primary key,

name varchar2(14)

)

--6、定时任务

begin

dbms_defer_sys.schedule_push (

destination => 'front.test.com.cn',

interval => 'sysdate + 10/1440',

next_date => sysdate);

end;

/

begin

dbms_defer_sys.schedule_purge (

next_date => sysdate,

interval => 'sysdate + 10/1440',

delay_seconds => 0,

rollback_segment => '');

end;

/

你可能感兴趣的:(oracle,前置库交换数据)