CONTROL_FILE_RECORD_KEEP_TIME和MAXLOGHISTORY引數詳解
開始前我們先看看官方文件對CONTROL_FILE_RECORD_KEEP_TIME和MAXLOGHISTORY說明
CONTROL_FILE_RECORD_KEEP_TIME
Property | Description |
---|---|
Parameter type | Integer |
Default value | 7 (days) |
Modifiable | ALTER SYSTEM |
Range of values | 0 to 365 (days) |
Basic | No |
CONTROL_FILE_RECORD_KEEP_TIME specifies the minimum number of days before a reusable record in the control file can be reused. In the event a new record needs to be added to a reusable section and the oldest record has not aged enough, the record section expands. If this parameter is set to 0, then reusable sections never expand, and records are reused as needed.
If the number of reusable records in the control file exceeds the circular reuse record limit UB4MAXVAL, then reusable records will be overwritten even if CONTROL_FILE_RECORD_KEEP_TIME has not elapsed. UB4MAXVAL is defined in the oratypes.h header file, which is found in the public directory. Its value may vary according to the operating system you are using.
大致意思是說:CONTROL_FILE_RECORD_KEEP_TIME 引數指明control file中reusable record最小保留天數
官方文件SQL Language Reference/CREATE
CONTROLFILE章這樣介紹MAXLOGHISTORY:
MAXLOGHISTORY Clause
This parameter is useful only if you are using Oracle Database in ARCHIVELOG mode. Specify your current estimate of the maximum number of archived redo log file groups needed for automatic media recovery of the database. The database uses this value to determine how much space to allocate in the control file for the names of archived redo log files.
The minimum value is 0. The default
value is a multiple of the MAXINSTANCES value and depends on your
operating system. The maximum value is limited only by the maximum size of the
control file. The database will continue to add additional space to the
appropriate section of the control file as needed, so that you do not need to
re-create the control file if your your original configuration is no longer
adequate. As a result, the actual value of this parameter can eventually exceed
the value you specify.
看到這裡覺得有點凌亂了,如:v$log_history 中的儲存條目數到底是哪個引數決定的呢?
一下說CONTROL_FILE_RECORD_KEEP_TIME 指明control file中reusable record最小保留天數
一下說由CONTROL FILE中MAXLOGHISTORY引數決定
官方文件中又查到了一個相關的view: V$CONTROLFILE_RECORD_SECTION
displays information about the control file record sections.
檢視一臺新裝不久的DB(archive mode):
SELECT * FROM V$CONTROLFILE_RECORD_SECTION WHERE TYPE in('LOG HISTORY');
TYPE RECORD_SIZE RECORDS_TOTAL RECORDS_USED FIRST_INDEX LAST_INDEX LAST_RECID
LOG HISTORY 56 292 126 1 126 126
解釋:
RECORD_SIZE:56 每條log history record是佔56 byte
RECORDS_TOTAL:292 當前分配可儲存292條log history record
RECORDS_USED:126 當前儲存了126條log history record
為什麼RECORDS_TOTAL是292?
CONTROL FILE中LOG HISTORY分配總大小= RECORD_SIZE* RECORDS_TOTAL=292*56 byte=16352 byte ≈16384=16K 細心的人可以發現這個值約等於16KB,而CONTROL FILE一個BLOCK SIZE正是16KB,查詢V$CONTROLFILE可以看到CONTROL FILE BLOCK SIZE:
SELECT NAME,BLOCK_SIZE FROM V$CONTROLFILE
NAME BLOCK_SIZE
/data/lenovo/control01.ctl 16384
因為一個CONTROL FILE中保留資訊最小的單位是16KB, RECORD_SIZE:56
16384沒法整除56,不可能保留0.5條RECORD,所以擷取:
SELECT TRUNC(16384/56) FROM DUAL
292 --擷取後正好為292和RECORDS_TOTAL一致,說明CONTROLFILE初始分配了一個BLOCK記錄LOG HISTORY
此塊演算法:MOS中有說明,但應該是針對早期版本,RECORD_SIZE,CONTROLFILE BLOCK SIZE不一致,但演算法一樣
Why is the MAXLOGHISTORY Parameter Ignored When Creating a Controlfile? (文件 ID 217718.1) |
||
fix: When a controlfile is created, it is not obvious how the MAXLOGHISTORY parameter relates to the number of records created in the Log History section.
For example, creating a controlfile with MAXLOGHISTORY parameter set to 100 may result in the controlfile being created with 227 records in the Log History section. This is an expected behaviour.
When controlfile is created, each section of it is sized initially and space allocated accordingly. The space for each section is in terms of Oracle blocks and not records. The size of a single record in each of the controlfile section is fixed. In case of log history records, the size is 36 bytes. So, 100 records (MAXLOGHISTORY) would need 3600 bytes. Depending on the size of the Oracle block size - the controlfile block size is the same as DB_BLOCK_SIZE parameter, a certain number of blocks wold be allocated to the log history record section. For example, if the DB_BLOCK_SIZE is 8192, then one block will be sufficient and accordingly will be allocated. In one block, we can have 8192/36 ~ 227 records. If the DB_BLOCK_SIZE parameter was 2048, then 2 blocks would have been needed but only 113 records would have been created. |
|
檢視v$log_history:
select count(1) from v$log_history
COUNT(1)
126 --和V$CONTROLFILE_RECORD_SECTION.RECORDS_USED 數量一致
檢視建立資料庫DBCA開始的alert.log:
Thu Nov 23 15:07:06 2017
QMNC started with pid=22, OS id=14684
Completed: CREATE DATABASE "lenovo"
MAXINSTANCES 8
MAXLOGHISTORY 1 --這裡LOG HISTORY RECORD為1,我理解是雖然是1但還是要分配一個CONTROLFILE BLOCK存放,既然分配了一個BLOCK就可以全部使用292條RECORD
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1000
DATAFILE '/data/lenovo/system01.dbf' SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
……
目前,基本可以理解dbca建庫後預設分配1個CONTROLFILE BLOCK存放292條LOG HISTORY RECORD。但後續發現業務增加後V$CONTROLFILE_RECORD_SECTION.RECORDS_TOTAL增加是為什麼呢?
查到MOS另一篇文件:Master Note: Overview of
Database ControlFiles (文件 ID 1493674.1) 提到:
http://blog.itpub.net/25583515/viewspace-2150930/
- You want to change the parameters from the CREATE DATABASE or CREATE CONTROLFILE commands: MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, and MAXINSTANCES, when the compatibility is earlier than 10.2.0. If compatibility is 10.2.0 or later, you do not have to create new control files when you make such a change; the control files automatically expand, if necessary, to accommodate the new configuration information.
至此,個人理解:
CONTROL FILE中類似MAXLOGHISTORY引數再10.2之後版本意義已經不大,record保留完全透過control_file_record_keep_time控制
control_file_record_keep_time:是一個guarantee值,意思是說重用部分最起碼可以被保留7天,而不是到了7天就一定被覆蓋。
使用用大致分為三種情況:
1. 在controlfile空間有富餘時,不會重用覆蓋7天前的record
2. 在controlfile空間不足時,但沒有7天前可重用覆蓋的record,就會自動擴充套件controlfile空間,以滿足新record需要的空間
3. 在controlfile空間不足時,會重用覆蓋7天前的record,並不會自動擴充套件controlfile空間
如果你想確保備份一定可以保留15天,就設定control_file_record_keep_time=16
這樣才是保險的。
參考:
http://blog.itpub.net/25583515/viewspace-2150930/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25583515/viewspace-2150933/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle中control_file_record_keep_time和MAXLOGHISTORY引數Oracle
- 控制檔案相關 -- MAXLOGHISTORY ,control_file_record_keep_time
- 26、控制檔案相關 -- MAXLOGHISTORY ,control_file_record_keep_time
- Redis 主從配置和引數詳解Redis
- ajax 引數詳解
- DockerFile引數詳解Docker
- dd引數詳解
- Mysqldump引數詳解MySql
- vmstat 引數詳解
- OGG引數詳解
- tar命令引數詳解
- 函式引數詳解函式
- Oracle UNDO引數詳解Oracle
- jqGrid引數詳解
- $.ajax()方法引數詳解
- DataGuard引數配置詳解
- redis info引數詳解Redis
- ES常用引數詳解
- struts配置引數詳解
- 【轉】Cmd引數詳解
- flash wmode引數詳解
- GCC引數詳解(轉)GC
- fstab引數詳解(轉)
- lsblk命令引數詳解
- Dockerfile - 引數與詳解Docker
- FAL_CLIENT和FAL_SERVER引數詳解clientServer
- 建立表時引數PCTFREE和PCTUSED詳解
- CONTROL_FILE_RECORD_KEEP_TIME引數 和 retention policy 的關係 (轉郝總)
- 選購交換機的引數依據和主要的引數指標詳解指標
- variables_order引數詳解
- oracle rac 核心引數詳解Oracle
- Flink Checkpoint 引數詳解
- find 命令的引數詳解
- Mysql配置引數詳解(一)MySql
- Prometheus hashmod 配置引數詳解Prometheus
- SQL*Plus Set引數詳解SQL
- ntpq –p 各引數詳解
- oracle RMAN引數配置詳解Oracle