eygle.com   eygle.com
eygle.com  
 

« February 13, 2005 | Blog首页 | February 18, 2005 »



February 17, 2005

在高级复制中如何切换主体定义站点

作者:eygle

出处:http://blog.eygle.com

这是一个同步复制环境,在同步复制中,任何一个站点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.如果原站点恢复正常后,可以再次添加到复制组中。

Posted by eygle at 5:40 PM | Comments (3)



CopyRight © 2004-2008 eygle.com, All rights reserved.