Physical Storage Structures

Oracle分为Logical Storage Structures与Physical Storage Structures,逻辑存储结构包含block, extent, segment, tablespace; 物理存储结构包含数据文件,控制文件,REDO LOG, 归档文件

The following figure is an entity-relationship diagram for physical and logical storage. The crow's foot notation represents a one-to-many relationship.

Note:

  1. A segment can span one or more data files, but it cannot span multiple tablespaces
  2. An extent is a set of logically contiguous data blocks allocated for storing a specific type of information. A single extent can never span data files. 注逻辑连续的blocks不是物理连续

Data File

The data file header contains metadata about the data file such as its size and checkpoint SCN. Each header contains an absolute file number, which uniquely identifies the data file within the database, and a relative file number, which uniquely identifies a data file within a tablespace.

(二)Temp File

When you create or resize temp files, they are not always guaranteed allocation of disk space for the file size specified. On file systems such as Linux and UNIX, temp files are created as sparse files. In this case, disk blocks are allocated not at file creation or resizing, but as the blocks are accessed for the first time. Sparse files enable fast temp file creation and resizing; however, the disk could run out of space later when the temp files are accessed.

Temp file information is shown in the data dictionary view DBA_TEMP_FILES and the dynamic performance view V$TEMPFILE, but not in DBA_DATA_FILES or the V$DATAFILE view.

Control Files

控制文件是一个很小但IO很频繁的二进制文件,它分保存checkpoint scn, 它表示实例恢复时需要从此SCN开始,此SCN之前提交的事务均已写入磁盘,因为DBWR会最少3秒落一次盘,所以checkpoint process也是每3秒把日志中的checkpoint scn写入controlfile的

checkpoint indicates the SCN in the redo stream where instance recovery would be required to begin. Every committed change before a checkpoint SCN is guaranteed to be saved on disk in the data files. At least every three seconds the checkpoint process records information in the control file about the checkpoint position in the online redo log.

控制文件包括以下信息:

  1. The database name and database unique identifier (DBID)
  2. The time stamp of database creation
  3. Information about data files, online redo log files, and archived redo log files
  4. Tablespace information
  5. RMAN backups

读写控制文件块也不同于datafile, 它不会存于SGA而是直接使用PGA

Reading and writing the control file blocks is different from reading and writing data blocks. For the control file, Oracle Database reads and writes directly from the disk to the program global area (PGA). Each process allocates a certain amount of its PGA memory for control file blocks.

Information about the database is stored in different sections of the control file,查看:

Select * from v$controlfile;

RECORD_SIZE: Record size in bytes

RECORDS_TOTAL: Number of records allocated for the section

RECORDS_USED: Number of records used in the section

The control file contains the following types of records:

  1. Circular reuse records

circular reuse record contains noncritical information that is eligible to be overwritten if needed. When all available record slots are full, the database either expands the control file to make room for a new record or overwrites the oldest record. Examples include records about archived redo log files and RMAN backups.

设置控制文件循环使用区域最小保持天数(默认7天),如果此部分空间不够且没有过期可重用数据将扩展此section大小,设置为0表示从不扩展大小,在需要时reuse

ALTER SYSTEM SET CONTROL_FILE_RECORD_KEEP_TIME=0;  

Note: 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.

  1. Noncircular reuse records

noncircular reuse record contains critical information that does not change often and cannot be overwritten. Examples of information include tablespaces, data files, online redo log files, and redo threads. Oracle Database never reuses these records unless the corresponding object is dropped from the tablespace.

Online Redo Log

不能多进程并发写日志,只能设置一个LGWR进程. Oracle要求最少2个日志组

In single-instance configurations, only one instance accesses a database, so only one redo thread is present. In an Oracle Real Application Clusters (Oracle RAC) configuration, however, multiple instances concurrently access a database, with each instance having its own redo thread. A separate redo thread for each instance avoids contention for a single set of online redo log files.

Oracle Database requires a minimum of two files to guarantee that one file is always available for writing in case the other file is in the process of being cleared or archived.

是否可以写入下个日志要求是相关数据的checkpoint操作是否完成以及是否归档完成,日志的三个状态: current, active(相关数据未落盘或未完成归档),inactive(可重用)

Filled online redo log files are available for reuse depending on the archiving mode:

  1. If archiving is disabled, then a filled online redo log file is available after the changes recorded in it have been checkpointed (written) to disk by database writer (DBW).
  2. If archiving is enabled, which means that the database is in ARCHIVELOG mode, then a filled online redo log file is available to log writer after the changes have been written to the data files and the file has been archived.

Structure of the Online Redo Log:

一个redo record对应一个block的更改,一个事务可以包含多个数据块的更改,所以可能有多个redo record

Online redo log files contain redo records. A redo record is made up of a group of change vectors, each of which describes a change to a data block. For example, an update to a salary in the employees table generates a redo record that describes changes to the data segment block for the table, the undo segment data block, and the transaction table of the undo segments.

The redo records have all relevant metadata for the change, including the following:

  1. SCN and time stamp of the change
  2. Transaction ID of the transaction that generated the change
  3. SCN and time stamp when the transaction committed (if it committed)
  4. Type of operation that made the change
  5. Name and type of the modified data segment

Archived Log

Archive log只是redo log的copy

In "Multiple Copies of Online Redo Log Files", files A_LOG1 and B_LOG1 are identical members of Group 1. If the database is in ARCHIVELOG mode, and if automatic archiving is enabled, then the archiver process (ARCn) will archive one of these files. If A_LOG1 is corrupted, then the process can archive B_LOG1. The archived redo log contains a copy of every redo log group that existed starting from the time that you enabled archiving.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值