資料庫複製

csbin發表於2007-01-27

中心庫

--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;
/

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

相關文章