[20160222]Oracle 11G Data Guard Failover-flush redo.txt
--链接: http://blog.csdn.net/tianlesoftware/article/details/6256542
在Oracle 11g里,Data Guard 切换多了一个新的功能:flush redo。
Flush 能把没有发送的redo 从主库传送到standby库。 只要主库能启动到mount 状态,那么Flush 就可以把没有发送的归档和current
online redo 发送到备库。
Flush语法:
SQL> ALTER SYSTEM FLUSH REDO TO target_db_name;
这里的target_db_name 是我们在主库的db_unique_name 名称。 也就是在tnsnames.ora 文件配置的。 Flush 会将未发送的redo 从主库
传到备库,并且等待redo 在standby 库上apply 之后返回成功。 所以只要Flush成功,那么Failover 就没有主句丢失。
--自己测试看看:
1.主库:
SYS@test> show parameter unique
NAME TYPE VALUE
--------------- ------- -------
db_unique_name string test
--关闭数据库使用shutdown abort关闭。
SYS@test> shutdown abort ;
ORACLE instance shut down.
SYS@test> startup mount
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2228784 bytes
Variable Size 973082064 bytes
Database Buffers 620756992 bytes
Redo Buffers 7344128 bytes
Database mounted.
2.在备库执行:
SYS@testdg> ALTER SYSTEM FLUSH REDO TO 'test';
System altered.
--注意test要加引号,不然报错:
SYS@testdg> ALTER SYSTEM FLUSH REDO TO test;
ALTER SYSTEM FLUSH REDO TO test
*
ERROR at line 1:
ORA-00922: missing or invalid option
$ oerr ora 922
00922, 00000, "missing or invalid option"
// *Cause:
// *Action:
--检查alert*.log发现:
ALTER SYSTEM FLUSH REDO TO 'test' CONFIRM APPLY
Flush redo operation not allowed on a physical standby
--估计dg开在open read only模式,在active data guard状态。启动到mount状态继续测试:
SYS@testdg> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@testdg> startup mount
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2228784 bytes
Variable Size 905973200 bytes
Database Buffers 687865856 bytes
Redo Buffers 7344128 bytes
Database mounted.
SYS@testdg> ALTER SYSTEM FLUSH REDO TO 'test';
System altered.
--检查alert*.log发现:
Mon Feb 22 16:37:01 2016
ALTER SYSTEM FLUSH REDO TO 'test' CONFIRM APPLY
Flush redo operation not allowed on a physical standby
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using STANDBY_ARCHIVE_DEST parameter default value as /u01/app/oracle11g/archivelog
ALTER SYSTEM SET log_archive_trace=0 SCOPE=BOTH SID='testdg';
ALTER SYSTEM SET log_archive_format='%t_%s_%r.dbf' SCOPE=SPFILE SID='testdg';
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE THROUGH ALL SWITCHOVER DISCONNECT USING CURRENT LOGFILE
Attempt to start background Managed Standby Recovery process (testdg)
Mon Feb 22 16:37:04 2016
MRP0 started with pid=29, OS id=1006
MRP0: Background Managed Standby Recovery process started (testdg)
started logmerger process
Mon Feb 22 16:37:09 2016
Managed Standby Recovery starting Real Time Apply
Parallel Media Recovery started with 4 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Recovery of Online Redo Log: Thread 1 Group 5 Seq 4815 Reading mem 0
Mem# 0: /u01/app/oracle11g/oradata/test/redostb02.log
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE THROUGH ALL SWITCHOVER DISCONNECT USING CURRENT LOGFILE
--注意看~,感觉还是不对。
3.感觉应该在主库执行:
SYS@test> ALTER SYSTEM FLUSH REDO TO 'testdg';
System altered.
--检查备库的alert*.log:
Mon Feb 22 16:43:48 2016
Standby switchover readiness check: Checking whether recoveryapplied all redo..
Physical Standby applied all the redo from the primary.
--如果备库打开read only:
SYS@test> ALTER SYSTEM FLUSH REDO TO 'testdg';
ALTER SYSTEM FLUSH REDO TO 'testdg'
*
ERROR at line 1:
ORA-16447: Redo apply was not active at the target standby database
SYS@test> ALTER SYSTEM FLUSH REDO TO testdg;
ALTER SYSTEM FLUSH REDO TO testdg
*
ERROR at line 1:
ORA-00922: missing or invalid option
--必须加引号。
--说明原链接的介绍存在问题。