下面的这个示例是一个同步的复制环境,在同步复制中,任何一个站点Down掉都将会导致数据库服务的中断。
◆1.首先停掉主体的定义站点(CONNER.HURRAY.COM.CN)
[oracle@jumper oracle]$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Thu Feb 17 16:07:26 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
◆2.登陆的主体站点(TESTORA9.HURRAY.COM.CN)
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
60 ORACLE BEIJING
70 oracle beijing
6 rows selected.
注意:此时主体站点上对于扶植对象的任何DML操作都不能进行了。
SQL> insert into dept values(80,'oracle','beijing');
insert into dept values(80,'oracle','beijing')
*
ERROR at line 1:
ORA-02068: following severe error from CONNER
ORA-03113: end-of-file on communication channel
ORA-02068: following severe error from CONNER
ORA-03113: end-of-file on communication channel
◆3.然后大家可以使用复制管理员登陆主体站点
假如此时尝试删除复制对象,打破复制关系都会收到错误。
ORA-23312说明这不是主体定义站点。
SQL> connect repadmin/repadmin
Connected.
SQL> exec DBMS_REPCAT.DROP_MASTER_REPOBJECT(sname => 'scott',oname => 'dept',type => 'table');
BEGIN DBMS_REPCAT.DROP_MASTER_REPOBJECT(sname => 'scott',oname => 'dept',type => 'table'); END;
*
ERROR at line 1:
ORA-23312: not the masterdef according to TESTORA9.HURRAY.COM.CN
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.DBMS_REPCAT_UTL4", line 2928
ORA-06512: at "SYS.DBMS_REPCAT_UTL4", line 2720
ORA-06512: at "SYS.DBMS_REPCAT", line 643
ORA-06512: at line 1
◆4.此处需要使用DBMS_REPCAT.RELOCATE_MASTERDEF切换主体定义站点
SQL> BEGIN
2 DBMS_REPCAT.RELOCATE_MASTERDEF (
3 gname => 'rep_tt',
4 old_masterdef => 'CONNER.HURRAY.COM.CN',
5 new_masterdef => 'TESTORA9.HURRAY.COM.CN',
6 notify_masters => TRUE,
7 include_old_masterdef => FALSE);
8 END;
9 /
PL/SQL procedure successfully completed.
◆5.然后把原主体定义站点(CONNER.HURRAY.COM.CN)从主体库中删除
SQL> execute dbms_repcat.remove_master_databases
(gname=>'rep_tt',master_list=>'CONNER.HURRAY.COM.CN');
PL/SQL procedure successfully completed.
◆6.复制关系被打破以后,DML操作得以继续使用
SQL> connect scott/tiger
Connected.
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
60 ORACLE BEIJING
70 oracle beijing
6 rows selected.
SQL> insert into dept values (80,'oracle','beijing');
1 row created.
SQL> commit;
Commit complete.
SQL>
◆7.假如原站点恢复正常后,大家可以再次添加至复制组中。