Oracle学习笔记:redo重做日志
?
redo重做日志對于oracle來說猶如 肝臟 那么重要,是oracle機能中的排毒恢復健康的重要部件!!
相關的基本概念:
1.scn
2.日志序列號
3.日志組 和 日志 成員,尤其是日志文件的尺寸(影響ckpt自動發出);日志寫入等待;
4.lgwr
5.ckpt
6.dbwr
7.log_buffer、fast_start_mttr_target、log_checkpoint_interval、log_checkpoit_timeout 初始化參數
?
基本管理
1.切換日志:alter system switch logfile;
2.手工發出檢查點:alter sysem checkpoit;
3.增加日志組:alter database add logfile [group n] file-spec?
4.增加日志組成員:alter database add logfile member file-spec to group n
5.刪除日志組:alter database drop logfile group n
6.刪除日志組成員:alter database drop logfile member file-spec
7.重新初始化日志組或日志組成員:alter database clear logfile {group n|file-spec|(file-spec,file-spec...)}
8.查看當前的日志文件組及成員:select * from v$logfile;? select * from v$log;
9.移動或|和重命名日志組成員文件:alter database rename file file-spec to file-spec
?
archivelog和noarchivelog模式
noarchivelog模式是oracle的默認模式,相當于sqlserver恢復模型的“簡單”模式,只能用于防止例程失效 和 smon的啟動恢復
noarchivelog的特點:
1.簡單,redo日志組不歸檔,只要要足夠的size,完全不用考慮redo日志空間的占用問題
2.備份數據庫有要求:必須保證數據庫的一致性,不能使用shutdown abort模式;而且必須和控制文件一并備份
3.數據庫無法還原到某個scn、time或日志序列
archivelog模式是最重要、主要的模式,一般的情況下,我們應該采用該種模式。
archivelog的特點:
1.具有額外的歸檔進程,需要相應的歸檔目錄和磁盤空間
2.具有完全的數據庫保護功能:只要有備份和之后的redo歸檔日志,可以還原到某個scn、time或日志序列
3.管理方便:在數據庫處于open狀態時,可以備份、還原!!!
archivelog和noarchivelog模式的切換:mount狀態下,alter database {archivelog|noarchivelog}
配置archivelog歸檔日志的位置
默認的位置是:%oracle_home%\rdbms
默認的文件格式為:ARC%S_%R.%T(格式符合的意思分別是:日志序列號、resetlogs的id號、arch線程號)
可以通過修改初始化參數來自定義本地歸檔日志的位置:log_archive_dest、log_archive_duplex_dest
可以通過修改初始化參數來自定義本地或遠程歸檔日志的位置:log_archive_dest_n(1-10)。注意和上面的配置方式是互斥的!
特別的:這種配置在設置的字符串值里需要指定是location還是service:{ LOCATION=path_name | SERVICE=service_name }
而且還有一大堆的選項
LOG_ARCHIVE_DEST_[1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10] =
?{ null_string | LOCATION=path_name | SERVICE=service_name } --path_name可以設置成USE_DB_RECOVERY_FILE_DEST
?[ { MANDATORY | OPTIONAL } ] --通過使用MANDATORY可以強制rts服務進程必須等待目標standby歸檔日志傳輸成功才可切換日志
?[ REOPEN[=seconds] ] --Specifies the minimum number of seconds before the archiver processes (ARCn) or the log writer process (LGWR) should try again to access a previously failed destination. The default is 300 seconds.
?[ DELAY[=minutes] ] --cannot set the DELAY attribute for a logical standby database destination,default is 30 minutes
?[ NOREGISTER ]
?[ TEMPLATE=template] ]
?[ ALTERNATE=destination ] --格式LOG_ARCHIVE_DEST_n
?[ DEPENDENCY=destination ] ----格式LOG_ARCHIVE_DEST_n
?[ MAX_FAILURE=count ]
?[ ARCH | LGWR ]
?[ SYNC | ASYNC ] --network I/O is to be done synchronously or asynchronously when archival is performed using the log writer process (LGWR) and the network server (LNSn) processes.
?[ AFFIRM | NOAFFIRM ] --synchronous or asynchronous disk I/O
?[ NET_TIMEOUT=seconds ] --The default is 180 seconds.
?[ VALID_FOR=(redo_log_type,database_role) ]
?[{ DB_UNIQUE_NAME }] --Speci?es a unique name for the database at this destination.
?[ VERIFY ] --Indicates if an archiver (ARCn) process should scan and verify the correctness of the contents of a completed archived redo log file, either local or remote, after successfully completing the archival operation. By default, archived redo log files are not verified.
?}
?
與log_archive_dest_n配合的log_archive_dest_state_n用來決定歸檔位置的可用性:enable(可用)、defer(不可用)、alternate(候補)
我們可以通過log_archive_config初始化參數配置oracle是否發送、接受遠程oracle服務器的事務日志,定義data guard。這個參數可能影響服務器的性能!
LOG_ARCHIVE_CONFIG =
?{
?[ SEND | NOSEND ]
?[ RECEIVE | NORECEIVE ]
?[ DG_CONFIG=(remote_db_unique_name1 [, ... remote_db_unique_name9) | NODG_CONFIG ]
?}
?
查看archivelog模式的相關信息
1.在sqlplus下: archive log list
2.顯示歸檔歷史:select * from v$archived_log; select * from v$loghist;
3.顯示歸檔日志的位置:select * from v$archive_dest; 其他可以使用show parameters log_archive;
?
?
?
?
轉載于:https://www.cnblogs.com/jinzhenshui/archive/2009/02/24/1397364.html
總結
以上是生活随笔為你收集整理的Oracle学习笔记:redo重做日志的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: log4net简介(三)之无法写入日志
- 下一篇: 一步步构建多层架构系列二之设计模式运用篇