[20170215]再次理解flush redo.txt

lfree發表於2017-02-15

[20170215]再次理解flush redo.txt

--連結:
http://blog.itpub.net/267265/viewspace-1992583/
http://blog.itpub.net/267265/viewspace-1992840/

在Oracle 11g裡,Data Guard 切換多了一個新的功能:flush redo。

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 名稱。 Flush 會將未傳送的redo 從主庫
傳到備庫,並且等待redo 在standby 庫上apply 之後返回成功。 所以只要Flush成功,那麼Failover 就沒有主句丟失。

--//我前面的測試target_db_name必須加引號,只所以回頭看文件主要春節前在解決一套容災系統時,發現許多我不習慣的做法,
--//沒有fal等引數,而且db_unique_name兩邊是一樣的,感覺很不規範.我一直認為在dg中每個都應該分配一個不同的db_unique_name.

--//再仔細看這篇檔案,使用的是db_unique_name.
--//順便提一下oracle的name預設很容易混淆,特別是概念不清晰的情況下.而且許多情況下都是一樣的.

--//以後學習還是給認真看oracle 官方文件為準.

ALTER SYSTEM FLUSH REDO TO target_db_name [[NO] CONFIRM APPLY]
   
This statement flushes redo data from a primary database to a standby database and optionally waits for the flushed redo
data to be applied to a physical or logical standby database.

This statement must be issued on a mounted, but not open, primary database.

--//這裡並沒有指出target_db_name是什麼?


8.2.2 Performing a Failover to a Physical Standby Database

This section describes how to perform a failover to a physical standby database.

Step 1   Flush any unsent redo from the primary database to the target standby database.

If the primary database can be mounted, it may be possible to flush any unsent archived and current redo from the
primary database to the standby database. If this operation is successful, a zero data loss failover is possible even if
the primary database is not in a zero data loss data protection mode.

Ensure that Redo Apply is active at the target standby database.

Mount, but do not open the primary database. If the primary database cannot be mounted, go to Step 2.

Issue the following SQL statement at the primary database:

SQL> ALTER SYSTEM FLUSH REDO TO target_db_name;

For target_db_name, specify the DB_UNIQUE_NAME of the standby database that is to receive the redo flushed from the
primary database.

This statement flushes any unsent redo from the primary database to the standby database, and waits for that redo to be
applied to the standby database.

If this statement completes without any errors, go to Step 5. If the statement completes with any error, or if it must
be stopped because you cannot wait any longer for the statement to complete, continue with Step 2.

--//這裡明確的指出是DB_UNIQUE_NAME,好了現在重複測試.
1.環境:
SYS@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

--//停止備庫.
--//在主庫執行:
alter system archive log current ;
alter system archive log current ;
alter system archive log current ;
alter system archive log current ;
alter system archive log current ;
alter system archive log current ;

SYS@book> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/archivelog/book
Oldest online log sequence     613
Next log sequence to archive   615
Current log sequence           615

--//當前seq=615.關閉主庫.

2.測試flush redo前準備,主要配置不同的db_unique_name,驗證target_db_name引數.
--//備庫:
SYS@bookdg> startup nomount
ORACLE instance started.
Total System Global Area    634732544 bytes
Fixed Size                    2255792 bytes
Variable Size               197133392 bytes
Database Buffers            427819008 bytes
Redo Buffers                  7524352 bytes

SYS@bookdg> show parameter db_unique_name
NAME           TYPE   VALUE
-------------- ------ -------
db_unique_name string bookdg

--//修改db_unique_name為XXXX
SYS@bookdg> alter system set db_unique_name='XXXX' scope=spfile;
System altered.

SYS@bookdg> alter system set log_archive_config='DG_CONFIG=(book,bookdg,xxxx)';
System altered.

SYS@bookdg> alter system set log_archive_dest_1='LOCATION=/u01/app/oracle/archivelog/book MANDATORY VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=xxxx' scope=spfile;
System altered.

--//重啟備庫到mount:
SYS@bookdg> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.

SYS@bookdg> startup mount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

SYS@bookdg> show parameter db_unique_name
NAME           TYPE    VALUE
-------------- ------- -----
db_unique_name string  XXXX

--//主庫有一些引數也要修改,因為備庫的db_unique_name已經修改
--//主庫:
SYS@book> startup nomount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes

SYS@book> alter system set log_archive_config='DG_CONFIG=(book,bookdg,xxxx)';
System altered.

SYS@book> show parameter log_archive_dest_2
NAME               TYPE   VALUE
------------------ ------ ----------------------------------------------------------------------------------------------------
log_archive_dest_2 string SERVICE=bookdg LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=bookdg
--//這裡也要修改為:
SYS@book> alter system set log_archive_dest_2='SERVICE=bookdg LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=xxxx' scope=spfile;
System altered.

--//關閉啟動到mount狀態.
SYS@book> shutdown immediate ;
ORA-01507: database not mounted
ORACLE instance shut down.

SYS@book> startup mount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

3.測試flush redo功能:
SYS@book> ALTER SYSTEM FLUSH REDO TO bookdg;
ALTER SYSTEM FLUSH REDO TO bookdg
                           *
ERROR at line 1:
ORA-00922: missing or invalid option


SYS@book> ALTER SYSTEM FLUSH REDO TO XXXX;
ALTER SYSTEM FLUSH REDO TO XXXX
                           *
ERROR at line 1:
ORA-00922: missing or invalid option
--//oracle 官方並沒有提到這裡要使用引號.^_^.我估計這裡如果dg存在多個,應該這樣寫:ALTER SYSTEM FLUSH REDO TO 'dg1,dg2';

SYS@book> ALTER SYSTEM FLUSH REDO TO 'bookdg';
ALTER SYSTEM FLUSH REDO TO 'bookdg'
*
ERROR at line 1:
ORA-16053: DB_UNIQUE_NAME  is not in the Data Guard Configuration
=========================================
$ oerr ora 16053
16053, 00000, "DB_UNIQUE_NAME %s is not in the Data Guard Configuration"
// *Cause:  The specified DB_UNIQUE_NAME is not in the Data Guard
//          Configuration.
// *Action: If the DG_CONFIG attribute of the LOG_ARCHIVE_CONFIG parameter
//          is enabled, you must specify a valid DB_UNIQUE_NAME.  The list
//          of valid DB_UNIQUE_NAMEs can be seen with the V$DATAGUARD_CONFIG
//          view.  This problem can also occur when specifying a non-standby
//          destination with an DB_UNIQUE_NAME attribute that does not match
//          the DB_UNIQUE_NAME initialization parameter for the current
//          instance.
=========================================
--//因為找到合適的log_archive_dest_N,執行失敗.

SYS@book> ALTER SYSTEM FLUSH REDO TO 'xxxx';
ALTER SYSTEM FLUSH REDO TO 'xxxx'
*
ERROR at line 1:
ORA-16447: Redo apply was not active at the target standby database

$ oerr ora 16447
16447, 00000, "Redo apply was not active at the target standby database"
// *Cause:  ALTER SYSTEM FLUSH REDO TO STANDBY failed because redo apply
//          is not active at the target database.
// *Action: Start redo apply at the standby database and reissue the
//          ALTER SYSTEM FLUSH REDO TO STANDBY statement, or reissue the
//          ALTER SYSTEM FLUSH REDO TO STANDBY statement with the
//          NO CONFIRM APPLY clause.

--//檢查主庫alert日誌:
Wed Feb 15 15:33:34 2017
ALTER SYSTEM FLUSH REDO TO 'xxxx' CONFIRM APPLY
ALTER SYSTEM FLUSH REDO TO xxxx CONFIRM APPLY [Process Id: 28538] (book)
Flush redo: No wait for non-current ORLs to be archived
Waiting for all FAL entries to be archived...
All FAL entries have been archived.
Waiting for dest_id 2 to become synchronized...
Wed Feb 15 15:33:37 2017
ARC0: Standby redo logfile selected for thread 1 sequence 607 for destination LOG_ARCHIVE_DEST_2
Active, synchronized flush redo target has been identified
Recovery is not running at physical standby 'LOG_ARCHIVE_DEST_2'.
If this standby is the target, please startmanaged standby recovery at the target and re-issueFLUSH REDO command

--//檢查備庫日誌
Wed Feb 15 15:33:37 2017
RFS[1]: Assigned to RFS process 19369
RFS[1]: Selected log 4 for thread 1 sequence 607 dbid 1337401710 branch 896605872
RFS[1]: Opened log for thread 1 sequence 608 dbid 1337401710 branch 896605872
Wed Feb 15 15:33:38 2017
Archived Log entry 445 added for thread 1 sequence 607 ID 0x4fb7d86e dest 1:
Archived Log entry 446 added for thread 1 sequence 608 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 609 dbid 1337401710 branch 896605872
Archived Log entry 447 added for thread 1 sequence 609 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 610 dbid 1337401710 branch 896605872
Archived Log entry 448 added for thread 1 sequence 610 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 611 dbid 1337401710 branch 896605872
Archived Log entry 449 added for thread 1 sequence 611 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 612 dbid 1337401710 branch 896605872
Archived Log entry 450 added for thread 1 sequence 612 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 613 dbid 1337401710 branch 896605872
Archived Log entry 451 added for thread 1 sequence 613 rlc 896605872 ID 0x4fb7d86e dest 2:
RFS[1]: Opened log for thread 1 sequence 614 dbid 1337401710 branch 896605872
Archived Log entry 452 added for thread 1 sequence 614 rlc 896605872 ID 0x4fb7d86e dest 2:

--//說明:最後seq=614,歸檔的日誌已經傳輸到備庫.而online redo沒有傳輸,從主庫的alert提示看,沒有開啟傳輸設定.
--//備註:我以前的測試成功是因為使用dgmgrl管理dg.

--//在備庫執行,開啟傳輸與應用日誌模式:
SYS@bookdg> alter database recover managed standby database using current logfile disconnect ;
Database altered.

--//檢查備庫日誌
Wed Feb 15 15:37:45 2017
alter database recover managed standby database using current logfile disconnect
Attempt to start background Managed Standby Recovery process (bookdg)
Wed Feb 15 15:37:46 2017
MRP0 started with pid=24, OS id=19373
MRP0: Background Managed Standby Recovery process started (bookdg)
started logmerger process
Wed Feb 15 15:37:52 2017
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.
Completed: alter database recover managed standby database using current logfile disconnect
Media Recovery Log /u01/app/oracle/archivelog/book/1_607_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_608_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_609_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_610_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_611_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_612_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_613_896605872.dbf
Media Recovery Log /u01/app/oracle/archivelog/book/1_614_896605872.dbf
Media Recovery Waiting for thread 1 sequence 615
--//等待主庫傳輸seq=615.

--//在主庫執行:
SYS@book> ALTER SYSTEM FLUSH REDO TO 'XXxX';
System altered.

--//注意:引號裡面大小寫混用,也是ok的,說明db_unique_name可以大小寫混用的,雖然不提倡.

--//檢查備庫日誌
Wed Feb 15 15:40:16 2017
RFS[2]: Assigned to RFS process 19393
RFS[2]: Selected log 4 for thread 1 sequence 615 dbid 1337401710 branch 896605872
Wed Feb 15 15:40:16 2017
Archived Log entry 453 added for thread 1 sequence 615 ID 0x4fb7d86e dest 1:
Wed Feb 15 15:40:17 2017
Media Recovery Log /u01/app/oracle/archivelog/book/1_615_896605872.dbf
Wed Feb 15 15:40:17 2017
Standby switchover readiness check: Checking whether recoveryapplied all redo..
Identified End-Of-Redo (move redo) for thread 1 sequence 615 at SCN 0x3.1756ba81
Database not available for switchover
  End-Of-REDO archived log file has not been recovered
  Incomplete recovery SCN:3:391538419 archive SCN:3:391559809
Physical Standby did not apply all the redo from the primary.
Resetting standby activation ID 1337448558 (0x4fb7d86e)
Media Recovery Waiting for thread 1 sequence 616
Wed Feb 15 15:40:19 2017
Standby switchover readiness check: Checking whether recoveryapplied all redo..
Physical Standby applied all the redo from the primary.

SYS@bookdg> @ &r/dg/dg
PROCESS       PID STATUS       CLIENT_P GROUP# THREAD#  SEQUENCE#     BLOCK#     BLOCKS DELAY_MINS
--------- ------- ------------ -------- ------ ------- ---------- ---------- ---------- ----------
RFS         19391 IDLE         ARCH     N/A          0          0          0          0          0
ARCH        19325 CLOSING      ARCH     4            1        615          1       1498          0
MRP0        19373 WAIT_FOR_LOG N/A      N/A          1        616          0          0          0

4.驗證是否傳輸正確:
--//主庫上執行:
SYS@book> set numw 12
SYS@book> @ &r/logfile ;
GROUP# STATUS     TYPE       MEMBER                           IS_ GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ---------- ---------- -------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
     1            ONLINE     /mnt/ramdisk/book/redo01.log     NO       1       1       614    52428800       512       1 YES INACTIVE     13276440300 2017-02-15 15:06:03  13276440307 2017-02-15 15:06:06
     2            ONLINE     /mnt/ramdisk/book/redo02.log     NO       2       1       615    52428800       512       1 YES CURRENT      13276440307 2017-02-15 15:06:06  13276461697 2017-02-15 15:40:15
     3            ONLINE     /mnt/ramdisk/book/redo03.log     NO       3       1       613    52428800       512       1 YES INACTIVE     13276440283 2017-02-15 15:05:50  13276440300 2017-02-15 15:06:03
     4            STANDBY    /mnt/ramdisk/book/redostb01.log  NO
     5            STANDBY    /mnt/ramdisk/book/redostb02.log  NO
     6            STANDBY    /mnt/ramdisk/book/redostb03.log  NO
     7            STANDBY    /mnt/ramdisk/book/redostb04.log  NO
7 rows selected.

SYS@book> alter system dump logfile '/mnt/ramdisk/book/redo02.log' validate;
System altered.

--//轉儲內容:
DUMP OF REDO FROM FILE '/mnt/ramdisk/book/redo02.log'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
VALIDATE ONLY
FILE HEADER:
    Compatibility Vsn = 186647552=0xb200400
    Db ID=1337401710=0x4fb7216e, Db Name='BOOK'
    Activation ID=1337448558=0x4fb7d86e
    Control Seq=33442=0x82a2, File size=102400=0x19000
    File Number=2, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000615, SCN 0x0003175666f3-0xffffffffffff"
thread: 1 nab: 0x5db seq: 0x00000267 hws: 0x4 eot: 3 dis: 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
resetlogs count: 0x35711eb0 scn: 0x0000.000e2006 (925702)
prev resetlogs count: 0x3121c97a scn: 0x0000.00000001 (1)
Low  scn: 0x0003.175666f3 (13276440307) 02/15/2017 15:06:06
Next scn: 0xffff.ffffffff 01/01/1988 00:00:00
Enabled scn: 0x0000.000e2006 (925702) 11/24/2015 09:11:12
Thread closed scn: 0x0003.17566c5e (13276441694) 02/15/2017 15:23:11
Disk cksum: 0x184 Calc cksum: 0x184
Terminal recovery stop scn: 0x0000.00000000
Terminal recovery  01/01/1988 00:00:00
Most recent redo scn: 0x0000.00000000
Largest LWN: 17 blocks
End-of-redo stream : Yes
Unprotected mode
Miscellaneous flags: 0x4800008
Thread internal enable indicator: thr: 0, seq: 0 scn: 0x0000.00000000
Zero blocks: 8
Format ID is 2
redo log key is a7f8a15237d6b5e7fe61cb4acdc6227b
redo log key flag is 5
Enabled redo threads: 1
END OF REDO DUMP
----- Redo read statistics for thread 1 -----
Read rate (SYNC): 748Kb in 0.01s => 73.10 Mb/sec
Total redo bytes: 748Kb Longest record: 2Kb, moves: 0/617 moved: 0Mb (0%)
Longest LWN: 8Kb, reads: 1192
Last redo scn: 0x0003.17566c5b (13276441691)
Change vector header moves = 103/1210 (8%)
----------------------------------------------

--//備庫上執行:
SYS@bookdg> alter system dump logfile '/u01/app/oracle/archivelog/book/1_615_896605872.dbf' validate;
System altered.

--//轉儲內容:
DUMP OF REDO FROM FILE '/u01/app/oracle/archivelog/book/1_615_896605872.dbf'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
VALIDATE ONLY
FILE HEADER:
    Compatibility Vsn = 186647552=0xb200400
    Db ID=1337401710=0x4fb7216e, Db Name='BOOK'
    Activation ID=1337448558=0x4fb7d86e
    Control Seq=44808=0xaf08, File size=102400=0x19000
    File Number=4, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000615, SCN 0x0003175666f3-0x00031756ba81"
thread: 1 nab: 0x5db seq: 0x00000267 hws: 0x5 eot: 0 dis: 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
resetlogs count: 0x35711eb0 scn: 0x0000.000e2006 (925702)
prev resetlogs count: 0x3121c97a scn: 0x0000.00000001 (1)
Low  scn: 0x0003.175666f3 (13276440307) 02/15/2017 15:06:06
Next scn: 0x0003.1756ba81 (13276461697) 02/15/2017 15:40:15
Enabled scn: 0x0000.000e2006 (925702) 11/24/2015 09:11:12
Thread closed scn: 0x0003.17566c5e (13276441694) 02/15/2017 15:23:11
Disk cksum: 0x1f22 Calc cksum: 0x1f22
Terminal recovery stop scn: 0x0000.00000000
Terminal recovery  01/01/1988 00:00:00
Most recent redo scn: 0x0003.1756ba80 (13276461696)
Largest LWN: 17 blocks
End-of-redo stream : Yes
Unprotected mode
Miscellaneous flags: 0x48000b9
Thread internal enable indicator: thr: 0, seq: 0 scn: 0x0000.00000000
Zero blocks: 8
Format ID is 2
redo log key is a7f8a15237d6b5e7fe61cb4acdc6227b
redo log key flag is 5
Enabled redo threads: 1
END OF REDO DUMP
----- Redo read statistics for thread 1 -----
Read rate (SYNC): 748Kb in 0.01s => 73.10 Mb/sec
Total redo bytes: 748Kb Longest record: 2Kb, moves: 0/617 moved: 0Mb (0%)
Longest LWN: 8Kb, reads: 1192
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Last redo scn: 0x0003.17566c5b (13276441691)
Change vector header moves = 103/1210 (8%)
----------------------------------------------

--//因為主庫還沒有歸檔,從~內容看,應該沒有問題.

5.總結:
1.寫的有點長^_^.
2.ALTER SYSTEM FLUSH REDO TO target_db_name;中引數target_db_name裡面是db_unique_name.並且要使用引號,另外我估計多個要寫成類似
  ALTER SYSTEM FLUSH REDO TO 'xxxdg1,xxxdg2' 格式.
3.備庫要設定在傳輸模式:
  alter database recover managed standby database using current logfile nt logfile disconnect ;
  或者
  alter database recover managed standby database disconnect from session ;
4.要好好看官方文件,比如fal*引數對應的是Oracle Net service name,開始不看文件我以為也是db_unique_name.
 
  而引數LOG_ARCHIVE_CONFIG裡面的DG_CONFIG實際上DB_UNIQUE_NAME
  Specifies a list of up to 30 unique database names (defined with the DB_UNIQUE_NAME initialization parameter) for all
  of the databases in the Data Guard configuration.
 
5.我感覺oracle不如把這個命令改寫為:
  ALTER SYSTEM FLUSH REDO TO log_archive_dest_N;
  這樣好理解.不容易錯誤.^_^.
6.實際上測試中總是磕磕絆絆,還遇到一個問題就是備庫引數log_archive_dest_1中.如果最後的DB_UNIQUE_NAME=bookdg(與配置不一致)
  在啟動備庫時alert提示:
Wed Feb 15 11:37:49 2017
Using STANDBY_ARCHIVE_DEST parameter default value as ?/dbs/arch

--//這樣傳輸的歸檔實際上在dbs目錄
$ ls -l /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch*
-rw-r-----  1 oracle oinstall 4608 2017-02-15 11:43:18 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch1_593_896605872.dbf
-rw-r-----  1 oracle oinstall 3584 2017-02-15 11:43:18 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch1_594_896605872.dbf
-rw-r-----  1 oracle oinstall 1024 2017-02-15 11:43:18 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch1_595_896605872.dbf
--//配置本地歸檔可以不使用最後的DB_UNIQUE_NAME=XXXX.

7.最後我的觀點,在配置dg中每個資料庫配置不同的DB_UNIQUE_NAME有必要的.無論是備份還是管理都很有必要.
  而且規範的命令風格也很重要,像我們的災備系統主庫net 服務名xxxx,備庫net 服務名yyyy,非常容易亂.
  而如果主庫net服務名xxxx,備庫net 服務名xxxxdg,不是很清晰明瞭.
  我一般建議配置資料庫的ORACLE_SID不要超過6個字元,這樣備庫存在多個,我習慣的備庫命令ORACLE_SID命名風格是xxxxxxd1,xxxxxxd2.
8.還原相關設定:

--//備庫:
SYS@bookdg> alter system set log_archive_config='DG_CONFIG=(book,bookdg)';
System altered.

SYS@bookdg> alter system set log_archive_dest_1='LOCATION=/u01/app/oracle/archivelog/book MANDATORY VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=bookdg' scope=spfile;
System altered.

SYS@bookdg> alter system set db_unique_name='bookdg' scope=spfile;
System altered.

--//主庫:
SYS@book> alter system set log_archive_config='DG_CONFIG=(book,bookdg)';
System altered.

SYS@book> alter system set log_archive_dest_2='SERVICE=bookdg LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=bookdg' ;
System altered.

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

相關文章