ITPub博客

首页 > 数据库 > Oracle > 数据库复制

数据库复制

原创 Oracle 作者:csbin 时间:2007-01-27 14:50:53 0 删除 编辑

中心库

--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博客 ” ,链接:https://blog.itpub.net/720091/viewspace-894494/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 固定缓存对象
请登录后发表评论 登录
全部评论

注册时间:2009-01-12

  • 博文量
    69
  • 访问量
    1479820