切换之前,要插播一段小插曲。上一篇日志写到主备日志切换,是纠错之后的理想化阶段,而在这之前,还有那么点小暇疵。
起初,备节点数据库启动之后,通过命令“archive log list”校验时发现归档日志路径不对。在参数文件中指定到“/arch”,结果却变到了“/home/db/oracle/10g/dbs”。这样一来,主节点日志切换时,同步的日志文件直接到达备节点的“/home/db/oracle/10g/dbs”目录下,与预先设定的不一致,且alert日志文件中不断有报错信息。
经过很长时间的检查,最后发现是备节点上参数文件出了问题,将db_unique_name对应的“10gstandby”误写成了“10gtandby”,少写了一个字母“s”。改过来之后并重启数据库就好了,没有报错信息,但之前同步到“/home/db/oracle/10g/dbs”下的日志文件就这样永久的保留了下来,之后同步过来的日志文件就能准确到达指定的“/arch”目录下了,如下所示:
SQL> select name from v$archived_log;
NAME
--------------------------------------------------------------------------------
/home/db/oracle/10g/dbs/arch1_2_697298091.dbf
/home/db/oracle/10g/dbs/arch1_3_697298091.dbf
/home/db/oracle/10g/dbs/arch1_4_697298091.dbf
/home/db/oracle/10g/dbs/arch1_5_697298091.dbf
/home/db/oracle/10g/dbs/arch1_6_697298091.dbf
/home/db/oracle/10g/dbs/arch1_7_697298091.dbf
/home/db/oracle/10g/dbs/arch1_10_697298091.dbf
/home/db/oracle/10g/dbs/arch1_11_697298091.dbf
/home/db/oracle/10g/dbs/arch1_12_697298091.dbf
/home/db/oracle/10g/dbs/arch1_13_697298091.dbf
/home/db/oracle/10g/dbs/arch1_14_697298091.dbf
NAME
--------------------------------------------------------------------------------
/home/db/oracle/10g/dbs/arch1_15_697298091.dbf
/home/db/oracle/10g/dbs/arch1_16_697298091.dbf
/home/db/oracle/10g/dbs/arch1_17_697298091.dbf
/home/db/oracle/10g/dbs/arch1_18_697298091.dbf
/arch/1_8_697298091.dbf
/arch/1_9_697298091.dbf
/arch/1_19_697298091.dbf
18 rows selected.
从上面所显示的可以看到,一部分归档日志存在于/home/db/oracle/10g/dbs目录下,另一小部分归档日志存在于/arch目录下。
一切准备就绪,下面就要开始日志切换了,先在主节点上进行操作,其目的是将主节点的primary角色转换到standby角色:
SQL> alter database commit to switchover to physical standby with session shutdown;
Database altered.
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 1999160 bytes
Variable Size 297799368 bytes
Database Buffers 767557632 bytes
Redo Buffers 6385664 bytes
SQL> alter database mount standby database;
Database altered.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
这个时候主节点角色转换成standby,且准备完毕接受来自备节点的日志传递。
下面开始备节点的操作:
首先查看一下状态
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
RECOVERY NEEDED
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
*
ERROR at line 1:
ORA-16139: media recovery required
提示需要恢复,而不是“TO PRIMARY“状态,这个是之前参数文件出问题时造成的,可以通过以下办法来解决:
SQL> recover managed standby database finish;
Media recovery complete.
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
Database altered.
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 1999192 bytes
Variable Size 264244904 bytes
Database Buffers 805306368 bytes
Redo Buffers 2191360 bytes
Database mounted.
Database opened.
查看一下归档日志的生成情况:
SQL> select name from v$archived_log;
NAME
--------------------------------------------------------------------------------
/home/db/oracle/10g/dbs/arch1_2_697298091.dbf
/home/db/oracle/10g/dbs/arch1_3_697298091.dbf
/home/db/oracle/10g/dbs/arch1_4_697298091.dbf
/home/db/oracle/10g/dbs/arch1_5_697298091.dbf
/home/db/oracle/10g/dbs/arch1_6_697298091.dbf
/home/db/oracle/10g/dbs/arch1_7_697298091.dbf
/home/db/oracle/10g/dbs/arch1_10_697298091.dbf
/home/db/oracle/10g/dbs/arch1_11_697298091.dbf
/home/db/oracle/10g/dbs/arch1_12_697298091.dbf
/home/db/oracle/10g/dbs/arch1_13_697298091.dbf
/home/db/oracle/10g/dbs/arch1_14_697298091.dbf
NAME
--------------------------------------------------------------------------------
/home/db/oracle/10g/dbs/arch1_15_697298091.dbf
/home/db/oracle/10g/dbs/arch1_16_697298091.dbf
/home/db/oracle/10g/dbs/arch1_17_697298091.dbf
/home/db/oracle/10g/dbs/arch1_18_697298091.dbf
/arch/1_8_697298091.dbf
/arch/1_9_697298091.dbf
/arch/1_19_697298091.dbf
/arch/1_20_697298091.dbf
/arch/1_21_697298091.dbf
20 rows selected.
至此,物理方式下建立oracle data guard系列故事告一段落。
阅读(1911) | 评论(0) | 转发(0) |