ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 10g_dataguard_failover

10g_dataguard_failover

原创 Linux操作系统 作者:oracle_mao 时间:2012-05-11 10:44:26 0 删除 编辑

大体步骤:
1、启动failover
SQL> alter database recover managed standby database finish force;

FORCE 关键字将会停止当前活动的RFS 进程,以便立刻执行failover。
剩下的步骤就与前面switchover 很相似了

2、切换物理standby 角色为primary
SQL> alter database commit to switchover to primary;

3、启动新的primary 数据库。
SQL> alter database open;

这样就可以了,不需要在主库上做啥操作。

如果想再将已经切换的系统变回原形,那就需要重新配置dg,因为在failover之后,原来的主库就不是dg的一部分了。如果重新配置dg,那就要以原来的备库(现在的主库)作为主库了,因为他在后续有很多操作了已经(无论是测试还是真正的火灾他必定是已经当了很久的主库了),待重新配置完dg之后,再做一次switchover切换,就可以将dg完完全全的恢复到我们所有测试之前的角色模式了。

实验:
环境:
主库:150-----因为是failover,所以在切换角色时150不需要做任何操作
备库:200
1、200上:
SQL> alter database recover managed standby database finish force;
SQL> alter database commit to switchover to primary;
SQL> alter database open;
SQL> select switchover_status from v$database;
 
2、此时查看原来的主库150的状态
 
解析:如果想再将已经切换的系统变回原形,那就需要重新配置dg,因为在failover之后,原来的主库就不是dg的一部分了。如果重新配置dg,那就要以原来的备库(现在的主库)作为主库了,因为他在后续有很多操作了已经(无论是测试还是真正的火灾他必定是已经当了很久的主库了),待重新配置完dg之后,再做一次switchover切换,就可以将dg完完全全的恢复到我们所有测试之前的角色模式了

3、重新配置DG以便将所有角色切换到最开始的状态(150主库,200备库)

3.1 参数文件不需要改变
3.2 在200(此时主库)创建备库控制文件并scp到150
[oracle@stream dbs]$ sqlplus / as sysdba
SQL> create spfile from pfile;
SQL> startup mount
SQL> alter database create standby controlfile as '/u01/control01.dbf';
SQL> exit
[oracle@stream dbs]$ cd /u01
[oracle@stream u01]$ scp control01.dbf 192.168.249.150:/u01/app/oracle/oradata/ora10g/ 
3.3 将200(此时主库)的数据文件和日志文件传到150上
[oracle@stream u01]$ cd app/oracle/oradata/ora10g/
[oracle@stream ora10g]$ scp *.dbf *.log 192.168.249.150:/u01/app/oracle/oradata/ora10g/
3.4 在200上将主库启动到open状态
[oracle@stream ora10g]$ sqlplus / as sysdba
SQL> alter database open;
SQL>  select name,database_role,open_mode,protection_mode from v$database;

NAME      DATABASE_ROLE    OPEN_MODE  PROTECTION_MODE
--------- ---------------- ---------- --------------------
ORA10G    PRIMARY          READ WRITE MAXIMUM PERFORMANCE
SQL> select switchover_status from v$database;

SWITCHOVER_STATUS---状态不正常应该是因为150(备库)还没有mount,也没应用redo
--------------------
NOT ALLOWED
3.5 启动此时的备库150到mount
SQL> startup mount
ORACLE instance started.

Total System Global Area  373293056 bytes
Fixed Size                  1273780 bytes
Variable Size             113246284 bytes
Database Buffers          255852544 bytes
Redo Buffers                2920448 bytes
Database mounted.
SQL> select switchover_status from v$database;

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

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /arch/log
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /arch/log
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2
3.6 备库应用redo

SQL> alter database recover managed standby database disconnect from session;

Database altered.

3.7 在200上切换日志
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /arch/log
Oldest online log sequence     3
Next log sequence to archive   5
Current log sequence           5
SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> select switchover_status from v$database;

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

SQL> !date
Fri May 11 00:41:35 CST 2012

3.8 备库查看归档是否已经传递过来

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /arch/log
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /arch/log
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /arch/log
Oldest online log sequence     1
Next log sequence to archive   0
Current log sequence           8
SQL> select switchover_status from v$database;

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

待DG重新搭建好以后(200为主库,150为备库),现在再将150变为主库,200变为备库
4、 切换
4.1 200上
SQL> select switchover_status from v$database;

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

SQL> !date
Fri May 11 00:41:35 CST 2012

SQL> alter database commit to switchover to physical standby;

Database altered.

SQL> shutdown immediate
ORA-01507: database not mounted


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

Total System Global Area  373293056 bytes
Fixed Size                  1273780 bytes
Variable Size             113246284 bytes
Database Buffers          255852544 bytes
Redo Buffers                2920448 bytes
Database mounted.
SQL> alter database recover managed standby database disconnect from session;

Database altered.

SQL>  select switchover_status from v$database;

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

SQL>  select name,database_role,open_mode,protection_mode from v$database;

NAME      DATABASE_ROLE    OPEN_MODE  PROTECTION_MODE
--------- ---------------- ---------- --------------------
ORA10G    PHYSICAL STANDBY MOUNTED    MAXIMUM PERFORMANCE

4.2 150上:
SQL> select switchover_status from v$database;

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

SQL>  select switchover_status from v$database;

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

SQL>  alter database commit to switchover to primary;

Database altered.

SQL> alter database open;

Database altered.

SQL>   select name,database_role,open_mode,protection_mode from v$database;

NAME      DATABASE_ROLE    OPEN_MODE  PROTECTION_MODE
--------- ---------------- ---------- --------------------
ORA10G    PRIMARY          READ WRITE MAXIMUM PERFORMANCE

SQL>  select switchover_status from v$database;

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

5、此时已经完全恢复到我们所做测试前的状态

测试完毕!!

 


 

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

请登录后发表评论 登录
全部评论

注册时间:2011-03-28

  • 博文量
    94
  • 访问量
    753990