[20160222]Oracle 11G Data Guard Failover

lfree發表於2016-02-22

[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
--必須加引號。

--說明原連結的介紹存在問題。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1992583/,如需轉載,請註明出處,否則將追究法律責任。

相關文章