log_archive_dest_n裡的alternate屬性使用須知
log_archive_dest_n裡的alternate屬性主要用於指定當前主歸檔目錄的備用目錄
下面的設定表示如果/oradata06目錄無法寫入,那麼嘗試將歸檔寫入到/oradata01目錄
log_archive_dest_5='location=/oradata06'
log_archive_dest_state_5=enable
log_archive_dest_1='location=/oradata01 alternate=log_archive_dest_5';
log_archive_dest_state_1=alternate
實際在使用alternate屬性的時候有些trick,不注意的話你會發現alternate目錄始終無法用上,看下面測試就明白了
<<<設定reopen=10,alternate=log_archive_dest_5>>>
SYS@tstdb1-SQL> alter system set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST reopen=10 alternate=log_archive_dest_5 valid_for=(all_logfiles,all_roles) db_unique_name=tstdb1';
System altered.
select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');SYS@tstdb1-SQL>
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 VALID USE_DB_RECOVERY_FILE_DEST 10 0 0
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
###修改LOG_ARCHIVE_DEST_1對應目錄的許可權為root
chown root.system /oradata06/fra/TSTDB1/archivelog/2015_09_22
###第一次Switch logfile
alter system switch logfile;
###歸檔並沒有生成到LOG_ARCHIVE_DEST_5指定的目錄
select name,sequence# from v$archived_log where sequence#>=190;
no rows selected
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 VALID USE_DB_RECOVERY_FILE_DEST 10 1 0
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
###第二次Switch logfile 歸檔依然沒有生成到LOG_ARCHIVE_DEST_5指定的目錄
alter system switch logfile;
select name,sequence# from v$archived_log where sequence#>=190;
no rows selected
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 VALID USE_DB_RECOVERY_FILE_DEST 10 1 0
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
###之後每過5分鐘後failure_count往上增1,15分鐘後,沒有定義max_failure,所以不停的嘗試訪問LOG_ARCHIVE_DEST_1,導致無法使用到備用目錄
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 VALID USE_DB_RECOVERY_FILE_DEST 10 4 0
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
<<<設定reopen=10,max_failure=1,alternate=log_archive_dest_5>>>
###重新設定LOG_ARCHIVE_DEST_1,將failure_count清零,這次加上了max_failure=1
SYS@tstdb1-SQL> alter system set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST reopen=10 max_failure=1 alternate=log_archive_dest_5 valid_for=(all_logfiles,all_roles) db_unique_name=tstdb1';
System altered.
###注意此時的LOG_ARCHIVE_DEST_1狀態從VALID變為了ALTERNATE
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 ALTERNATE USE_DB_RECOVERY_FILE_DEST 10 0 1
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
###過了大約82秒,log_archive_dest_1再一次歸檔失敗狀態被置為DISABLED,failure_count=1,同時我們看到LOG_ARCHIVE_DEST_5=VALID,之前沒有能歸檔的seq# 190~192都生成到了LOG_ARCHIVE_DEST_5目錄
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 DISABLED USE_DB_RECOVERY_FILE_DEST 10 1 1
5 LOG_ARCHIVE_DEST_5 VALID /oradata06 300 0 0
SYS@tstdb1-SQL> select name,sequence# from v$archived_log where sequence#>=190;
NAME SEQUENCE#
-------------------------------------------------- ----------
/oradata06/1_190_884446916.dbf 190
/oradata06/1_191_884446916.dbf 191
/oradata06/1_192_884446916.dbf 192
select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
###恢復LOG_ARCHIVE_DEST_1對應目錄的許可權
chown oracle.oinstall /oradata06/fra/TSTDB1/archivelog/2015_09_22
###switch logfile
alter system switch logfile;
###雖然LOG_ARCHIVE_DEST_1許可權已恢復,因其狀態還處於DISABLED,所以seq# 193這個log還是生成在了LOG_ARCHIVE_DEST_5對應目錄下
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 DISABLED USE_DB_RECOVERY_FILE_DEST 10 1 1
5 LOG_ARCHIVE_DEST_5 VALID /oradata06 300 0 0
SYS@tstdb1-SQL> select name,sequence# from v$archived_log where sequence#>=190;
NAME SEQUENCE#
-------------------------------------------------- ----------
/oradata06/1_190_884446916.dbf 190
/oradata06/1_191_884446916.dbf 191
/oradata06/1_192_884446916.dbf 192
/oradata06/1_193_884446916.dbf 193
###這時如果要強制讓後面生成的archivelog寫入LOG_ARCHIVE_DEST_1目錄,必須作如下設定
SYS@tstdb1-SQL> show parameter LOG_ARCHIVE_DEST_STATE_1
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_1 string ENABLE
SYS@tstdb1-SQL> show parameter LOG_ARCHIVE_DEST_STATE_5
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_5 string ALTERNATE
alter system set LOG_ARCHIVE_DEST_STATE_1=enable; <---重新設定一邊雖然設定前後的值是一樣的
alter system set log_archive_dest_state_5=ALTERNATE; <---重新設定一邊雖然設定前後的值是一樣的
###確認LOG_ARCHIVE_DEST_1、LOG_ARCHIVE_DEST_5的狀態已分別恢復為VALID、ALTERNATE
select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 VALID USE_DB_RECOVERY_FILE_DEST 10 0 1
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
###接下來switch logfile產生的歸檔就生成到了LOG_ARCHIVE_DEST_1目錄下
SYS@tstdb1-SQL> select name,sequence# from v$archived_log where sequence#>=190;
NAME SEQUENCE#
-------------------------------------------------- ----------
/oradata06/1_190_884446916.dbf 190
/oradata06/1_191_884446916.dbf 191
/oradata06/1_192_884446916.dbf 192
/oradata06/1_193_884446916.dbf 193
/oradata06/fra/TSTDB1/archivelog/2015_09_22/o1_mf_ 194 <---新的歸檔
1_194_1mEKL8nn4_.arc
所以使用log_archive_dest_n裡alternative屬性時一定要設定好max_failure
下面的設定表示如果/oradata06目錄無法寫入,那麼嘗試將歸檔寫入到/oradata01目錄
log_archive_dest_5='location=/oradata06'
log_archive_dest_state_5=enable
log_archive_dest_1='location=/oradata01 alternate=log_archive_dest_5';
log_archive_dest_state_1=alternate
實際在使用alternate屬性的時候有些trick,不注意的話你會發現alternate目錄始終無法用上,看下面測試就明白了
<<<設定reopen=10,alternate=log_archive_dest_5>>>
SYS@tstdb1-SQL> alter system set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST reopen=10 alternate=log_archive_dest_5 valid_for=(all_logfiles,all_roles) db_unique_name=tstdb1';
System altered.
select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');SYS@tstdb1-SQL>
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 VALID USE_DB_RECOVERY_FILE_DEST 10 0 0
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
###修改LOG_ARCHIVE_DEST_1對應目錄的許可權為root
chown root.system /oradata06/fra/TSTDB1/archivelog/2015_09_22
###第一次Switch logfile
alter system switch logfile;
###歸檔並沒有生成到LOG_ARCHIVE_DEST_5指定的目錄
select name,sequence# from v$archived_log where sequence#>=190;
no rows selected
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 VALID USE_DB_RECOVERY_FILE_DEST 10 1 0
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
###第二次Switch logfile 歸檔依然沒有生成到LOG_ARCHIVE_DEST_5指定的目錄
alter system switch logfile;
select name,sequence# from v$archived_log where sequence#>=190;
no rows selected
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 VALID USE_DB_RECOVERY_FILE_DEST 10 1 0
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
###之後每過5分鐘後failure_count往上增1,15分鐘後,沒有定義max_failure,所以不停的嘗試訪問LOG_ARCHIVE_DEST_1,導致無法使用到備用目錄
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 VALID USE_DB_RECOVERY_FILE_DEST 10 4 0
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
<<<設定reopen=10,max_failure=1,alternate=log_archive_dest_5>>>
###重新設定LOG_ARCHIVE_DEST_1,將failure_count清零,這次加上了max_failure=1
SYS@tstdb1-SQL> alter system set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST reopen=10 max_failure=1 alternate=log_archive_dest_5 valid_for=(all_logfiles,all_roles) db_unique_name=tstdb1';
System altered.
###注意此時的LOG_ARCHIVE_DEST_1狀態從VALID變為了ALTERNATE
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 ALTERNATE USE_DB_RECOVERY_FILE_DEST 10 0 1
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
###過了大約82秒,log_archive_dest_1再一次歸檔失敗狀態被置為DISABLED,failure_count=1,同時我們看到LOG_ARCHIVE_DEST_5=VALID,之前沒有能歸檔的seq# 190~192都生成到了LOG_ARCHIVE_DEST_5目錄
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 DISABLED USE_DB_RECOVERY_FILE_DEST 10 1 1
5 LOG_ARCHIVE_DEST_5 VALID /oradata06 300 0 0
SYS@tstdb1-SQL> select name,sequence# from v$archived_log where sequence#>=190;
NAME SEQUENCE#
-------------------------------------------------- ----------
/oradata06/1_190_884446916.dbf 190
/oradata06/1_191_884446916.dbf 191
/oradata06/1_192_884446916.dbf 192
select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
###恢復LOG_ARCHIVE_DEST_1對應目錄的許可權
chown oracle.oinstall /oradata06/fra/TSTDB1/archivelog/2015_09_22
###switch logfile
alter system switch logfile;
###雖然LOG_ARCHIVE_DEST_1許可權已恢復,因其狀態還處於DISABLED,所以seq# 193這個log還是生成在了LOG_ARCHIVE_DEST_5對應目錄下
SYS@tstdb1-SQL> select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 DISABLED USE_DB_RECOVERY_FILE_DEST 10 1 1
5 LOG_ARCHIVE_DEST_5 VALID /oradata06 300 0 0
SYS@tstdb1-SQL> select name,sequence# from v$archived_log where sequence#>=190;
NAME SEQUENCE#
-------------------------------------------------- ----------
/oradata06/1_190_884446916.dbf 190
/oradata06/1_191_884446916.dbf 191
/oradata06/1_192_884446916.dbf 192
/oradata06/1_193_884446916.dbf 193
###這時如果要強制讓後面生成的archivelog寫入LOG_ARCHIVE_DEST_1目錄,必須作如下設定
SYS@tstdb1-SQL> show parameter LOG_ARCHIVE_DEST_STATE_1
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_1 string ENABLE
SYS@tstdb1-SQL> show parameter LOG_ARCHIVE_DEST_STATE_5
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_5 string ALTERNATE
alter system set LOG_ARCHIVE_DEST_STATE_1=enable; <---重新設定一邊雖然設定前後的值是一樣的
alter system set log_archive_dest_state_5=ALTERNATE; <---重新設定一邊雖然設定前後的值是一樣的
###確認LOG_ARCHIVE_DEST_1、LOG_ARCHIVE_DEST_5的狀態已分別恢復為VALID、ALTERNATE
select dest_id,dest_name,status,destination,REOPEN_SECS,failure_count,max_failure from v$archive_dest where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_5');
DEST_ID DEST_NAME STATUS DESTINATION REOPEN_SECS FAILURE_COUNT MAX_FAILURE
---------- -------------------- --------- ------------------------------------------------------------ ----------- ------------- -----------
1 LOG_ARCHIVE_DEST_1 VALID USE_DB_RECOVERY_FILE_DEST 10 0 1
5 LOG_ARCHIVE_DEST_5 ALTERNATE /oradata06 300 0 0
###接下來switch logfile產生的歸檔就生成到了LOG_ARCHIVE_DEST_1目錄下
SYS@tstdb1-SQL> select name,sequence# from v$archived_log where sequence#>=190;
NAME SEQUENCE#
-------------------------------------------------- ----------
/oradata06/1_190_884446916.dbf 190
/oradata06/1_191_884446916.dbf 191
/oradata06/1_192_884446916.dbf 192
/oradata06/1_193_884446916.dbf 193
/oradata06/fra/TSTDB1/archivelog/2015_09_22/o1_mf_ 194 <---新的歸檔
1_194_1mEKL8nn4_.arc
所以使用log_archive_dest_n裡alternative屬性時一定要設定好max_failure
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/53956/viewspace-1806642/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 17 LOG_ARCHIVE_DEST_n 引數屬性Hive
- Oracle Data Guard LOG_ARCHIVE_DEST_n引數的可選屬性OracleHive
- LOG_ARCHIVE_DEST_n 中的各屬性 (包括valid_for等)Hive
- LOG_ARCHIVE_DEST_n引數屬性——DATA GUARD概念和管理Hive
- name屬性是表單元素必須的
- DG學習筆記(6)_LOG_ARCHIVE_DEST_N引數的各個屬性筆記Hive
- JSON 屬性必須用雙引號JSON
- 【Swift】在extension裡面新增屬性Swift
- C#裡面標籤的屬性和事件C#事件
- ACFS Security & Encryption特性使用須知
- CLOI 公用賬號使用須知
- Glide 使用必須知道的基礎屬性——Google推薦的圖片載入庫IDEGo
- CSS grid屬性的使用CSS
- 【後知後覺系列】css position: sticky 屬性以及某些場景的使用CSS
- 知識點:可變陣列的屬性使用copy修飾的後果陣列
- win10桌面屬性在哪裡_win10開啟桌面屬性的兩種方法Win10
- js知識梳理1:理解物件的屬性特性JS物件
- Web 前端開發者必知的9 個CSS屬性Web前端CSS
- java 只列印實體類裡的 非 null 屬性JavaNull
- 獲取json串裡的某個屬性值JSON
- win10系統屬性在哪裡 快速開啟win10系統屬性的方法Win10
- Android 相容性 | NDK 工具集更新須知Android
- SAP SEGW 事物碼裡的導航屬性(Navigation Property) 和 EntitySet 使用方法Navigation
- Android動畫:這裡有一份很詳細的 屬性動畫 使用攻略Android動畫
- Android 樣式屬性的使用Android
- CSS pointer-events屬性的使用CSS
- vue元件使用的細節 is 屬性Vue元件
- display的flex屬性使用詳解Flex
- Maven屬性(properties)標籤的使用Maven
- 使用windbg檢視DependencyObject的屬性Object
- [JAVA] 只知物件屬性,不知類屬性?就算類答應,static都不答應Java物件
- Struts FormBean 裡 Long型屬性取不到null嗎?ORMBeanNull
- flash 元件修改父級介面裡面的元件屬性元件
- Kotlin 知識梳理(9) 委託屬性Kotlin
- 人人須知的 jQuery 技巧jQuery
- 前端須知的 Cookie 知識小結前端Cookie
- JSON格式資料屬性必須用雙引號包裹JSON
- vue例項中watch屬性的使用Vue