Chinaunix首页 | 论坛 | 博客
  • 博客访问: 120760
  • 博文数量: 24
  • 博客积分: 32
  • 博客等级: 民兵
  • 技术积分: 109
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-28 16:23
文章分类
文章存档

2014年(6)

2013年(8)

2012年(6)

2011年(4)

分类: Oracle

2014-02-10 10:10:33

原文地址:rac环境dataguard环境切换 作者:hxl

环境:
主库:两个节点的RAC
备库:单节点的文件系统

SwitchOver切换
-------------------------------rac切换到单节点文件系统--------------------------

主库上的操作(rac环境,在其中一个节点上执行)

1.rac主库为每个节点添加standby 日志
alter database add standby logfile thread 1 group 7 ('+FRA') size 50m;
alter database add standby logfile thread 1 group 8 ('+FRA') size 50m;
alter database add standby logfile thread 1 group 9 ('+FRA') size 50m;
alter database add standby logfile thread 1 group 10 ('+FRA') size 50m;

alter database add standby logfile thread 2 group 11 ('+FRA') size 50m;
alter database add standby logfile thread 2 group 12 ('+FRA') size 50m;
alter database add standby logfile thread 2 group 13 ('+FRA') size 50m;
alter database add standby logfile thread 2 group 14 ('+FRA') size 50m;

2.查看switchover状态
SQL> select switchover_status from v$database;

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

3.切换成从库
SQL> alter database commit to switchover to physical standby with session shutdown;
alter database commit to switchover to physical standby with session shutdown
*
ERROR at line 1:
ORA-01105: mount is incompatible with mounts by other instances

原因是两外一个节点没有关闭,注意在做切换的时候,rac两外的其他节点都需要关闭,将另外一个节点shutdown后继续执行操作.


SQL> alter database commit to switchover to physical standby with session shutdown;

Database altered.

4.确保实例在mount状态下
SQL> select status from v$instance;

STATUS
------------
STARTED
SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  497995776 bytes
Fixed Size                  1337464 bytes
Variable Size             260048776 bytes
Database Buffers          230686720 bytes
Redo Buffers                5922816 bytes
Database mounted.


5.切换成从库

SQL> alter database commit to switchover to physical standby;

Database altered.


6.应用日志
SQL> alter database recover managed standby database using current logfile disconnect from session;

Database altered.

 

备库上的操作(单节点文件系统):
1.查看switchover状态
SQL> select switchover_status from v$database;

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

2.关闭所有的客户端连接后切换为主库
SQL> alter database commit to switchover to primary;

Database altered.


3.打开数据库

确认日志正常应用后,可以启动其他节点数据库
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area  497995776 bytes
Fixed Size                  1337464 bytes
Variable Size             243271560 bytes
Database Buffers          247463936 bytes
Redo Buffers                5922816 bytes
Database mounted.
Database opened.

SQL> select database_role,open_mode from v$database;

DATABASE_ROLE    OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY WITH APPLY

-------------------------------单节点文件系统切换到rac环境--------------------------

主库上的操作(单节点文件系统)
1.查看switchover状态
sql> select switchover_status from v$database;

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

2.切换成从库
alter database commit to switchover to physical standby with session shutdown;


3.确保实例在mount状态下
SQL> select status from v$instance;

STATUS
------------
STARTED

SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  422670336 bytes
Fixed Size                  1336960 bytes
Variable Size             343935360 bytes
Database Buffers           71303168 bytes
Redo Buffers                6094848 bytes
Database mounted.


5.切换成从库
SQL> alter database commit to switchover to physical standby;

Database altered.


6.应用日志
SQL> alter database recover managed standby database using current logfile disconnect from session;

Database altered.


备库上的操作(RAC环境)
步骤1到3是在节点1上执行,步骤4是在另外一个节点上执行

1.查看switchover状态
SQL> select switchover_status from v$database;

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


2.关闭所有的客户端连接后切换为主库
SQL> alter database commit to switchover to primary;

Database altered.


3.打开数据库
SQL> alter database open;

Database altered.

4.在另外一个节点上启动数据库
[oracle@node2 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Wed Feb 5 17:18:31 2014

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area  497995776 bytes
Fixed Size                  1337464 bytes
Variable Size             243271560 bytes
Database Buffers          247463936 bytes
Redo Buffers                5922816 bytes
Database mounted.
Database opened.

 

-- The End --

阅读(1560) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~