oracle 高级数据复制案例

上传人:xzh****18 文档编号:33766869 上传时间:2018-02-17 格式:DOC 页数:6 大小:39.50KB
返回 下载 相关 举报
oracle 高级数据复制案例_第1页
第1页 / 共6页
oracle 高级数据复制案例_第2页
第2页 / 共6页
oracle 高级数据复制案例_第3页
第3页 / 共6页
oracle 高级数据复制案例_第4页
第4页 / 共6页
oracle 高级数据复制案例_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《oracle 高级数据复制案例》由会员分享,可在线阅读,更多相关《oracle 高级数据复制案例(6页珍藏版)》请在金锄头文库上搜索。

1、案例:Oracle 高级数据复制(Advanced Replication)2007-03-23 19:27一、试验环境:A机:IP:10.1.8.201OS:WindowsServer 2003 Standard Edition SP1;DB:Oracle 10g Enterprise Edition Release 10.1.0.2.0;数据库字符集:NLS_CHARACTERSET ZHS16GBKB机:IP:10.1.9.49OS:WindowsServer 2003 Standard Edition SP1;DB:Oracle 10g Enterprise Edition Relea

2、se 10.1.0.2.0;数据库字符集:NLS_CHARACTERSET ZHS16GBK二、试验步骤:1. 初始化参数设置A机:db_domain=global_names=truejob_queue_processes=10 # 缺省值open_links=4 # 缺省值B机:db_domain=global_names=truejob_queue_processes=10 # 缺省值open_links=4 # 缺省值2. 配置数据库连接数据库名: A、B:orcl数据库域名: A、B:数据库 sid号: A、B:orclListener端口号: A、B:1521 确认两个数据库之间可

3、以互相访问,在 tnsnames.ora里设置数据库连接字符串。A机:ORCL_49 =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.9.49)(PORT = 1521)(CONNECT_DATA =(SERVICE_NAME = )tnsping orcle_49 测试连通B机:ORCL_201 =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.8.201)(PORT = 1521)(CONNECT_DATA =

4、(SERVICE_NAME = )tnsping orcle_201 测试连通3. 用 system 用户连接数据库,改数据库全局名称,建公共的数据库链接。A机:alter database rename global_name to ;B机:alter database rename global_name to ;A机:create public database link using orcl_49;select * from global_; - 验证数据库连接B机:create public database link using orcl_201;select * from g

5、lobal_; - 验证数据库连接4. 用 system 用户连接数据库,建立管理数据库复制的用户 repadmin,并赋权A、B 机:create user repadmin identified by repadmin default tablespace users temporary tablespace temp; execute dbms_defer_sys.register_propagator(repadmin);grant execute any procedure to repadmin;execute dbms_repcat_admin.grant_admin_any_r

6、epgroup(repadmin);execute dbms_repcat_admin.grant_admin_any_schema(username = REPADMIN);grant comment any table to repadmin;grant lock any table to repadmin;grant select any dictionary to repadmin;5. 用 repadmin 用户连接数据库,下创建私有的数据库链接A机:create database link connect to repadmin identified by repadmin;se

7、lect * from global_; - 验证数据库连接B机:create database link connect to repadmin identified by repadmin;select * from global_; - 验证数据库连接6. 创建实现数据库复制的用户和对象,给用户赋权,表必须有主关键字。A机:- 用 sys 连接数据库,创建用户并授权 create user testuser identified by testuser default tablespace users temporary tablespace temp; grant connect,

8、resource to testuser; grant execute on sys.dbms_defer to testuser;- 用 testuser 连接数据库,创建表测试表 dept create table dept (deptno number(2) primary key, dname varchar2(14), loc varchar2(13) ); - 创建主关键字的序列号,范围避免和 B 机 的冲突create sequence dept_no increment by 1 start with 1 maxvalue 44 cycle nocache;- 插入初始化数据i

9、nsert into dept values (dept_no.nextval,accounting,new york); insert into dept values (dept_no.nextval,research,dallas); commit;B机:- 用 sys 连接数据库,创建用户并授权create user testuser identified by testuser default tablespace users temporary tablespace temp; grant connect, resource to testuser; grant execute o

10、n sys.dbms_defer to testuser;- 用 testuser 连接数据库,创建表测试表 dept create table dept (deptno number(2) primary key, dname varchar2(14), loc varchar2(13) ); - 创建主关键字的序列号,范围避免和 B 机 的冲突create sequence dept_no increment by 1 start with 45 maxvalue 99 cycle nocache;- 插入初始化数据insert into dept values (dept_no.next

11、val,sales,chicago); insert into dept values (dept_no.nextval,operations,boston); commit;7. 创建要复制的组 testuser_mg,加入数据库对象,产生对象的复制支持A机:- 用 repadmin 身份登录 orcl 数据库,创建主复制组 testuser_mg: execute dbms_repcat.create_master_repgroup(testuser_mg); - 在复制组 testuser_mg 里加入数据库对象: execute dbms_repcat.create_master_re

12、pobject(sname=testuser,oname=dept, type=table,use_existing_object=true,gname=testuser_mg); 参数说明: sname 实现数据库复制的用户名称; oname 实现数据库复制的数据库对象名称; type 实现数据库复制的数据库对象类别; use_existing_object true 表示用主复制节点已经存在的数据库对象; gname 主复制组名; - 对数据库对象产生复制支持: execute dbms_repcat.generate_replication_support(testuser,dept,t

13、able); - 确认复制的组和对象已经加入数据库的数据字典: select gname, master, status from dba_repgroup; select * from dba_repobject; 8. 创建主复制节点A机:- 用 repadmin 身份登录 orcl 数据库,创建主复制节点execute dbms_repcat.add_master_database (gname=testuser_mg,master=,use_existing_objects=true, copy_rows=false, propagation_mode = asynchronous);

14、 参数说明: gname 主复制组名; master 加入主复制节点的另一个数据库; use_existing_object true 表示用主复制节点已经存在的数据库对象; copy_rows false 表示第一次开始复制时不用和主复制节点保持一致; propagation_mode 异步地执行; - 确认复制的任务队列已经加入数据库的数据字典select * from user_jobs; 9. 使同步组的状态由停顿(quiesced )改为正常(normal)A机:- 用 repadmin 连接数据库,运行以下命令execute dbms_repcat.resume_master_ac

15、tivity(testuser_mg,true); - 确认同步组的状态为正常(normal)select gname, master, status from dba_repgroup; 10. 创建复制数据库的时间表,10 分钟复制一次A机:- 用 repadmin 身份登录数据库,运行以下命令 begin dbms_defer_sys.schedule_push ( destination = , 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

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 法律文献 > 理论/案例

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号