ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【DataGuard】10g物理standby主备switchover方式切换详述

【DataGuard】10g物理standby主备switchover方式切换详述

原创 Linux操作系统 作者:secooler 时间:2009-03-27 17:06:50 0 删除 编辑
以下给大家展现一下10g物理standby主备之间通过switchover方式进行切换的详细步骤,供参考。

1、主库检查是否为“TO STANDBY”状态,若不是,需要重新启动一下主库(主库ora10g操作)
sys@ora10g> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE

sys@ora10g> startup force ;
ORACLE instance started.

Total System Global Area  104857600 bytes
Fixed Size                  1266056 bytes
Variable Size              83889784 bytes
Database Buffers           16777216 bytes
Redo Buffers                2924544 bytes
Database mounted.
Database opened.
sys@ora10g> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
TO STANDBY

2.将primary转换为standby角色(主库ora10g操作)
sys@ora10g> alter database commit to switchover to physical standby;

Database altered.

3.原主库重启动到mount状态(原主库ora10g操作)
NotConnected@> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
NotConnected@>
NotConnected@> startup mount;
ORACLE instance started.

Total System Global Area  104857600 bytes
Fixed Size                  1266056 bytes
Variable Size              88084088 bytes
Database Buffers           12582912 bytes
Redo Buffers                2924544 bytes
Database mounted.

4.检查原备库是否为“TO PRIMARY”状态,如果为“SWITCHOVER PENDING”状态,需要先进行一下恢复再切换 (待切换备库ora10gdg操作)
ora10g@linux5 /home/oracle$ export ORACLE_SID=ora10gdg
ora10gdg@linux5 /home/oracle$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 28 08:26:53 2009

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Data Mining and Real Application Testing options

NotConnected@> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
SWITCHOVER PENDING

NotConnected@> alter database commit to switchover to primary;
alter database commit to switchover to primary
*
ERROR at line 1:
ORA-16139: media recovery required

NotConnected@> alter database recover managed standby database disconnect from session;

Database altered.

NotConnected@> alter database recover managed standby database cancel;

Database altered.

NotConnected@> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
TO PRIMARY

5.原备库转换角色到primary (待切换备库ora10gdg操作)
NotConnected@> alter database commit to switchover to primary;

Database altered.

6.主备切换完成,open新的primary数据库  (待切换备库ora10gdg操作)
NotConnected@> alter database open;

Database altered.

7.最后验证阶段
1).新的primary库在sec用户创建一个新表test_new
sec@ora10g> create table test_new (a int);

Table created.

sec@ora10g> insert into test_new values ( 100 );

1 row created.

sec@ora10g> commit;

Commit complete.

sec@ora10g> select * from test_new;

         A
----------
       100

sec@ora10g> conn / as sysdba
Connected.
sys@ora10g> alter system switch logfile;

System altered.

sys@ora10g> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
            69

2).查看新standby库,验证切换是否成功
ora10gdg@linux5 /home/oracle$ export ORACLE_SID=ora10g
ora10g@linux5 /home/oracle$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 28 08:55:09 2009

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Data Mining and Real Application Testing options

NotConnected@> alter database recover managed standby database disconnect from session;

Database altered.

NotConnected@> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
            69

NotConnected@> alter database recover managed standby database cancel;

Database altered.

NotConnected@> alter database open read only;

Database altered.

NotConnected@> conn sec/sec
Connected.
sec@ora10g> select * from test_new;

         A
----------
       100

OK!到此主备之间的switchover方式切换成功。

secooler
09.03.27

-- The End --

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/519536/viewspace-580380/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle ACE 总监,阿里云MVP,北京大学理学硕士,恩墨学院创始人,教育专家,中国区 Cloudera 首位官方授权大数据讲师,金牌培训专家,BDA大数据联盟创始人,OCM联盟创始人,ACCUG创始人、ACOUG核心专家,Blogger。

注册时间:2008-03-16

  • 博文量
    797
  • 访问量
    8059251