Oracle資料庫的閃回恢復區及多歸檔路徑的設定
9i開始提供閃回查詢,以便能在需要的時候查到過去某個時刻的一致性資料,這是透過Undo實現的。這個功能有很大的限制,就是相關事務的undo不能被覆蓋,否則就無力迴天了。oracle10g大大的增強了閃回查詢的功能,並且提供了將整個資料庫回退到過去某個時刻的能力,這是透過引入一種新的flashback log實現的。flashback log有點類似redo log,只不過redo log將資料庫往前滾,flashback log則將資料庫往後滾。為了儲存管理和備份恢復相關的檔案,oracle10g提供了一個叫做閃回恢復區(Flashback recovery area)的新特性,可以將所有恢復相關的檔案,比如flashback log,archive log,backup set等,放到這個區域集中管理。
1.設定閃回恢復區
閃回恢復區主要透過3個初始化引數來設定和管理
db_recovery_file_dest:指定閃回恢復區的位置
db_recovery_file_dest_size:指定閃回恢復區的可用空間大小
db_flashback_retention_target:指定資料庫可以回退的時間,單位為分鐘,預設1440分鐘,也就是一天。當然,實際上可回退的時間還決定於閃回恢復區的大小,因為裡面儲存了回退所需要的
flash log。所以這個引數要和db_recovery_file_dest_size配合修改。
2.啟動flashback database
設定了閃回恢復區後,可以啟動閃回資料庫功能。
首先,資料庫必須已經處於歸檔模式
那麼如何設定歸檔呢?很簡單的步驟
1.關閉資料庫
SQL> shutdown immediate;
2.啟動資料庫為mount模式
SQL> startup mount
3.顯示和修改歸檔模式
SQL> archive log list
SQL> alter database archivelog;
SQL> alter database open
4.設定歸檔日誌的格式
SQL>alter system set log_archive_format='ARC%s%t%r.log' scope=spfile;
5.設定歸檔日誌的存放路徑
SQL>alter system set log_archive_dest='+data/arcl' scope=spfile;
SQL>shutdown immediate
SQL>startup
6.強制切換歸檔日至
SQL>alter system switch logfile;
7.取消歸檔
SQL>alter database noarchivelog;
引數
1.格式引數
%s 日誌序列號
%S 日誌序列號(帶前導的0)
%t 重做執行緒編號
%a 活動的ID號
%d 資料庫ID號
%r RESELOGS的iD值
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 156
Next log sequence to archive 158
Current log sequence 158
然後,啟動資料庫到mount狀態
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 75499088 bytes
Database Buffers 205520896 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL>alter database flashback on;
資料庫已更改。
SQL> alter database open;
資料庫已更改。
SQL>selectFLASHBACK_ONfrom v$database;
FLASHBACK_ON
------------------------------------
YES
3.取消閃回恢復區
將db_recovery_file_dest引數設定為空,可以停用閃回恢復區。
如果已經啟用flashback database,則不能取消閃回恢復區。
SQL> alter system set db_recovery_file_dest='';
alter system set db_recovery_file_dest=''
*
第 1 行出現錯誤:
ORA-02097: 無法修改引數, 因為指定的值無效
ORA-38775: 無法禁用快速恢復區 - 閃回資料庫已啟用
所以,必須先禁用flashback database,才能取消閃回恢復區
SQL> shutdown immediate;
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。
SQL> startup mount;
ORACLE 例程已經啟動。
Total System Global Area 142606336 bytes
Fixed Size 1247732 bytes
Variable Size 83887628 bytes
Database Buffers 50331648 bytes
Redo Buffers 7139328 bytes
資料庫裝載完畢。
SQL>alter database flashback off;
資料庫已更改。
SQL> alter database open;
資料庫已更改。
SQL> alter system set db_recovery_file_dest='';
系統已更改。
4.閃回恢復區的內容
所有和恢復相關的檔案都可以存放到閃回恢復區
SQL>select file_type from v$flash_recovery_area_usage;
FILE_TYPE
------------------------
CONTROLFILE
ONLINELOG
ARCHIVELOG
BACKUPPIECE
IMAGECOPY
FLASHBACKLOG
已選擇6行。
上面的檢視中可以看出,包括controfile,online redo logfile,archive logfile,rman backup
piece,rman image copy, flashback log等,都可以利用閃回恢復區來存放、管理。
5.閃回恢復區的一些限制
如果設定了閃回恢復區,則log_archive_dest和log_archive_duplex_dest將不可用
alter system set log_archive_dest='e:/'
*
第 1 行出現錯誤:
ORA-02097: 無法修改引數, 因為指定的值無效
ORA-16018: 無法將 LOG_ARCHIVE_DEST 與 LOG_ARCHIVE_DEST_n 或
DB_RECOVERY_FILE_DEST 一起使用
SQL> alter system set log_archive_duplex_dest='e:/';
alter system set log_archive_duplex_dest='e:/'
*
第 1 行出現錯誤:
ORA-02097: 無法修改引數, 因為指定的值無效
ORA-16018: 無法將 LOG_ARCHIVE_DUPLEX_DEST 與 LOG_ARCHIVE_DEST_n 或
DB_RECOVERY_FILE_DEST 一起使用
設定閃回恢復區後,如果沒有設定過log_archive_dest_n引數,則歸檔日誌預設是儲存到該區域的
SQL> archive log list
資料庫日誌模式 存檔模式
自動存檔 啟用
存檔終點 USE_DB_RECOVERY_FILE_DEST
最早的聯機日誌序列 245
下一個存檔日誌序列 247
當前日誌序列 247
實際上,是透過隱式的設定log_archive_dest_10='location= USE_DB_RECOVERY_FILE_DEST'來實現的。所以,如果之後你修改過log_archive_dest_n將歸檔日誌儲存到其他位置,也可以修改該引數繼續使用閃回恢復區。
多個資料庫的閃回恢復區可以指定到同一個位置,但是db_name不能一樣,或者db_unique_name不一樣。
RAC的閃回恢復區必須位於共享磁碟上,能被所有例項訪問。
6.閃回恢復區的空間管理
當閃回恢復區空間不足(使用超過85%)時,alert中會有警告記錄
Tue Dec 19 10:45:41 2006
Errors in file e:/oracle/ora10/admin/ning/bdump/ning_rvwr_31968.trc:
ORA-19815: 警告: db_recovery_file_dest_size 位元組 (共 52428800 位元組) 已使用 87.29%, 尚有6665216 位元組可用。
同時,oracle在alert中還會給出解決該問題的建議
Tue Dec 19 10:45:41 2006
************************************************************************
You have following choices to free up space from flash recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
system command was used to delete files, then use RMAN CROSSCHECK and
DELETE EXPIRED commands.
************************************************************************
如果閃回恢復區空間耗盡,且歸檔路徑設定到了閃回恢復區中,則由於日誌無法歸檔,資料庫會hang住。
Tue Dec 19 10:45:57 2006
Errors in file e:/oracle/ora10/admin/ning/bdump/ning_arc0_32372.trc:
ORA-19815: 警告: db_recovery_file_dest_size 位元組 (共 52428800 位元組) 已使用 100.00%, 尚有 0 位元組可用。
Tue Dec 19 10:45:57 2006
Errors in file e:/oracle/ora10/admin/ning/bdump/ning_arc0_32372.trc:
ORA-19809: 超出了恢復檔案數的限制
ORA-19804: 無法回收 6836224 位元組磁碟空間 (從 52428800 限制中)
ARC0: Error 19809 Creating archive log file to
'E:/ORACLE/ORA10/FLASH_RECOVERY_AREA/NING/ARCHIVELOG/2006_12_19/O1_MF_1_250_U_.ARC'
ARC0: Failed to archive thread 1 sequence 250 (19809)
ARCH: Archival stopped, error occurred. Will continue retrying
Tue Dec 19 10:45:58 2006
Errors in file e:/oracle/ora10/admin/ning/bdump/ning_arc0_32372.trc:
ORA-16038: 日誌 1 序列號 250 無法歸檔
ORA-19809: 超出了恢復檔案數的限制
ORA-00312: 聯機日誌 1 執行緒 1: 'E:/ORACLE/ORA10/ORADATA/NING/REDO01.LOG'
所以,對於生產庫,如果將歸檔放到閃回恢復區中,需要密切關注閃回恢復區的空間使用情況,否則一旦閃回恢復區的空間用盡,將導致資料庫無法提供服務。
透過查詢檢視v$flash_recovery_area_usage,可以獲得當前閃回恢復區的空間使用情況,並且可以知道
是哪些檔案佔中了空間,據此可以做出相應的處理,或者加大閃回恢復區,或者移走相應的檔案。
PHP code:--------------------------------------------------------------------------------
SQL> select * from v$flash_recovery_area_usage;
FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
------------------------ ------------------ ------------------------- ---------------
CONTROLFILE 0 0 0
ONLINELOG 0 0 0
ARCHIVELOG 91 0 16
BACKUPPIECE 0 0 0
IMAGECOPY 0 0 0
FLASHBACKLOG 8 4 2
已選擇6行。
----------------------------------------------------------------------------------
另外,v$recovery_file_dest檢視也提供了閃回恢復區的概要資訊。
SQL> select * from v$recovery_file_dest;
NAME SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES
----------------------------------- ----------- ---------- ----------------- ---------------
Eracleora10flash_recovery_area 104857600 101835264 0 17
資料庫現在用的是spfile引數,並且歸檔格式為:
SQL> show parameter log_archive
NAME TYPE value
------------------------------------ ----------- ------------------------------
log_archive_dest string /opt/oracle/product/9.2.0/dbs/arch
現在想修改歸檔路徑為多路徑模式,也就是要使用log_archive_dest_n,那麼該怎麼操作?
解釋如下:
1:首先檢視oracle的版本,oracle標準版不支援standby database,如果設了log_archive_dest_n,就意味著有可能使用standby database,所以前提是你的資料庫要是企業版本。
IXDBA.NET社群論壇
2: oracle中log_archive_dest_n和log_archive_dest不能共存,也就是隻能使用其一,
如果同時使用,會報錯如下資訊:
ORA-16019: cannot use LOG_ARCHIVE_DEST_1 with LOG_ARCHIVE_DEST or LOG_ARCHIVE_DUPLEX_DEST
log_archive_dest_n可以設定10個歸檔路徑,也就是n可以是1-10,接下來要作的是去除db現在的log_archive_dest引數設定,可以執行如下命令清除:
SQL> alter system reset log_archive_dest scope=spfile sid='*';
也可以這樣操作:
SQL> alter system set log_archive_dest='' scope=spfile;
然後重新啟動資料庫。
3: 執行命令:
SQL> alter system set log_archive_dest_n="location=F:/oracle/product/10.2.0/db_1
/database/arch" scope=spfile;
n可以是1-10,最多可以設定10個歸檔路徑。
4:重新啟動資料庫,使設定生效。
檢視設定資訊:
SQL> show parameter log_archive
NAME TYPE value
------------------------------------ ----------- ------------------------------
log_archive_config string
log_archive_dest string
log_archive_dest_1 string location=F:/oracle/product/10.
2.0/db_1/database/archive
log_archive_dest_10 string
log_archive_dest_2 string location=F:/oracle/product/10.
2.0/db_1/database/arch
看到設定已經生效了。
下面看一個例子
〖環境(Environment)〗
OS:LINUX
DB:ORACLE10G
〖現象(Symptom)〗
以普通使用者登入資料庫時,報告錯誤:ORA-00257 : archiver error. Connect internal only, until freed。
用ALTER SYSTEM ARCHIVE LOG CURRENT執行手工歸檔也不行。
〖原理(Cause) 〗
Step01:用ps -ef|grep oracle檢視歸檔程式,歸檔程式執行正常。
oracle 524 1 1 15:50:30 0:14 ora_arc0_nbo
oracle 518 1 0 15:50:23 0:01 ora_arc1_nbo
。。。
Step02:檢視歸檔路徑。
SQL> show parameter LOG_ARCHIVE_DEST_
NAME TYPE VALUE
------------------------------------ ----------- ----------------
log_archive_dest_1 string
log_archive_dest_10 string
log_archive_dest_2 string
log_archive_dest_3 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string
log_archive_dest_8 string
log_archive_dest_9 string
log_archive_dest_state_1 string enable
。。。
從資料可以看出,歸檔路徑LOG_ARCHIVE_DEST_n為空,沒有設定歸檔路徑。如果沒有設定歸檔路徑的時候,ORALCE預設會把歸檔檔案(archived logs)放到閃回區(Flash Recovery Area)。
Step03:得到閃回區(flash recovery area)的路徑。
SQL> show parameter DB_RECOVERY_FILE_DEST
NAME TYPE VALUE
------------------------------------ ----------- --------------------------
db_recovery_file_dest string /wxxrdata/flash_recovery_area
閃回區(flash recovery area)的路徑是/wxxrdata/flash_recovery_area。
Step04:檢視閃回區(Flash Recovery Area)的使用情況。
SQL> SELECT * FROM V$FLASH_RECOVERY_AREA_USAGE;
FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
------------ ------------------ ------------------------- ---------------
CONTROLFILE 0 0 0
ONLINELOG 0 0 0
ARCHIVELOG 74.05 0 31
BACKUPPIECE 10.95 0 8
IMAGECOPY 15 0 66
FLASHBACKLOG 0 0 0
從查詢結果可以看出,在閃回區中,歸檔日誌(ARCHIVELOG)佔用74.05%的空間,備份(BACKUPPIECE)佔用10.95%的空間,檔案複製(IMAGECOPY)佔用15%的空間。閃回區中已經沒有空餘的磁碟空間。
〖方法(Action)〗
方法一:重新指定歸檔路徑。
●如果使用SPFILE啟動資料庫,則可以動態改變歸檔路徑。
SQL>alter system set log_archive_dest_1='location=/proddata' scope=both;
這裡指定一個新的歸檔路徑。
●如果使用PFILE啟動資料庫,則需要執行下面的過程。
Step01:進入初始化引數檔案所在的目錄
$ cd $_HOME/dbs(這是預設路徑)
本例中的PFILE是initnbo.ora。
Step02:編輯初始化引數檔案
$vi initnbo.ora
新增引數:
log_archive_dest_1='location=/proddata'。
這裡指定一個新的歸檔路徑,這個路徑要有足夠的空間。
Step03:關閉資料庫
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
Step04:重啟資料庫。
SQL> startup PFILE='/oracle/app/oracle/product/10.1.0/Db_1/dbs/initnbo.ora';
ORACLE instance started.
Total System Global Area 289406976 bytes
Fixed Size 1248600 bytes
Variable Size 100663976 bytes
Database Buffers 184549376 bytes
Redo Buffers 2945024 bytes
Database mounted.
Database opened.
從此以後,資料庫的歸檔日誌將被寫到/proddata下。
方法二:增加閃回區(Flash Recovery Area)的大小。
SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE =20GSCOPE=BOTH SID='*';
System altered.
閃回區的大小被提到20G。
方法三:刪除閃回區(Flash Recovery Area)中多餘的歸檔日誌檔案。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29209863/viewspace-2128249/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 歸檔路徑更改後,如何對資料庫進行恢復(轉)資料庫
- Oracle閃回功能恢復偶然丟失的資料(轉)Oracle
- Oracle資料庫閃回Oracle資料庫
- Oracle資料庫閃回區空間不足Oracle資料庫
- Rman在run命令塊裡臨時設定歸檔目錄,歸檔日誌能否恢復主要看預設的歸檔路徑
- Oracle閃回技術 為Oracle閃回配置資料庫Oracle資料庫
- 【Oracle】歸檔日誌管理-設定歸檔日誌路徑以及歸檔日誌冗餘Oracle
- Orcale利用閃回功能恢復資料
- 【資料庫資料恢復】如何恢復Oracle資料庫truncate表的資料資料庫資料恢復Oracle
- Oracle設定多個歸檔路徑生成多份歸檔日誌,Rman備份時也只備份其中的一份歸檔日誌Oracle
- 【資料庫資料恢復】Oracle資料庫檔案出現壞塊報錯的資料恢復案例資料庫資料恢復Oracle
- Oracle 閃回資料庫測試Oracle資料庫
- 詳解oracle資料庫閃回Oracle資料庫
- 【資料庫資料恢復】Oracle資料庫誤truncate table的資料恢復案例資料庫資料恢復Oracle
- 【資料庫資料恢復】誤truncate table的Oracle資料庫資料恢復方案資料庫資料恢復Oracle
- rac使用預設閃回區歸檔空間滿
- 修改Oracle資料檔名及資料檔案存放路徑Oracle
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- 【資料庫資料恢復】ASM磁碟組掉線的Oracle資料庫資料恢復案例資料庫資料恢復ASMOracle
- DM7使用dmrestore工具利用不同資料庫的歸檔恢復資料庫REST資料庫
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- 對歸檔模式下CLEAR 未歸檔日誌後恢復資料庫的一點看法模式資料庫
- 【資料庫資料恢復】ASM例項不能掛載的Oracle資料庫資料恢復案例資料庫資料恢復ASMOracle
- 【資料庫資料恢復】LINUX環境下ORACLE資料庫誤刪除的資料恢復資料庫資料恢復LinuxOracle
- 【oracle資料庫資料恢復】誤操作導致的資料庫誤刪除的資料恢復案例Oracle資料庫資料恢復
- 【資料庫資料恢復】斷電導致Oracle資料庫資料丟失的資料恢復案例資料庫資料恢復Oracle
- 【資料庫資料恢復】oracle資料庫誤truncate table怎麼恢復資料?資料庫資料恢復Oracle
- 【資料庫資料恢復】Sql Server資料庫檔案丟失的資料恢復過程資料庫資料恢復SQLServer
- 【北亞資料恢復】異常斷電導致Oracle資料庫報錯的oracle資料恢復資料恢復Oracle資料庫
- office for mac的自動恢復檔案的路徑Mac
- Oracle資料庫恢復之resetlogsOracle資料庫
- Oracle資料庫歸檔模式的切換ELOracle資料庫模式
- 資料庫資料恢復-ORACLE資料庫的常見故障&各種故障下的資料恢復可能性資料庫資料恢復Oracle
- 【資料庫資料恢復】HP-UX系統ORACLE資料庫被誤刪除的資料恢復資料庫資料恢復UXOracle
- 【資料庫資料恢復】Oracle ASM例項無法掛載的資料恢復案例資料庫資料恢復OracleASM
- 【資料庫資料恢復】Oracle資料庫ASM磁碟組掉線如何恢復資料?資料庫資料恢復OracleASM
- 資料庫資料恢復-SQL SERVER資料庫檔案大小變為“0”的資料恢復方案資料庫資料恢復SQLServer
- 恢復Oracle資料庫誤刪除資料的語句Oracle資料庫
- oracle dg 歸檔日誌恢復情況Oracle