Oracle Concepts 11g 读书笔记(三)

[复制链接]
查看11 | 回复4 | 2012-1-4 11:58:44 | 显示全部楼层 |阅读模式
++[Physical Storage Structures]
+++[Introduction to Physical Storage Structures]
One characteristic of an RDBMS is the independence of logical data structures such as tables, views, and indexes from physical storage structures. Because physical and logical structures are separate, you can manage physical storage of data without affecting access to logical structures. For example, renaming a database file does not rename the tables stored in it.
关系型数据库的一个特性便是逻辑数据结构例如表,视图,索引独立于物理存储结构。因为物理和逻辑结构式分离的,你可以管理物理存储结构而不影响对逻辑结构的访问。
An Oracle database is a set of files that store Oracle data in persistent disk storage.
一个Oracle 数据库就是在持久硬盘存储器上存储Oracle数据的文件集合。
This section discusses the database files generated when you issue a CREATE DATABASE statement:
Data files and temp files

A data file is a physical file on disk that was created by Oracle Database and contains data structures such as tables and indexes. A temp file is a data file that belongs to a temporary tablespace. The data is written to these files in an Oracle proprietary format that cannot be read by other programs.
Control files

A control file is a root file that tracks the physical components of the database.
Online redo log files

The online redo log is a set of files containing records of changes made to data.

本节讨论当你发布一个 CREATE DATABASE 声明产生的数据库文件:
数据文件和临时文件。

数据文件是一个在硬盘上的物理文件,由Oracle 数据库创建,包含数据结构入表和索引。临时文件是存在于 临时表空间中的一个数据文件。数据是用Oracle专属的格式写入到这些文件中,不能被其他程序读取。
控制文件。

控制文件是一个根文件追踪数据库的物理组件。
联机重做日志文件。

联机重做日志文件是一个包含对数据更改的记录的文件集合。
A database instance is a set of memory structures that manage database files. 数据库实例是管理数据库文件的内存结构的集合。Figure 11-1 shows the relationship between the instance and the files that it manages.
++++[Mechanisms for Storing Database Files]
有很多分配和管理这些文件存储的机制,最常用的机制包括:
Oracle Automatic Storage Management (Oracle ASM)

Oracle自动存储管理包括了一个专为Oracle数据库使用设计的文件系统。
Operating system file system
大部分Oracle 数据库在文件系统中存储文件,在一个连续的硬盘地址空间中建立的数据结构。所有操作系统都有文件管理器在文件系统中来为文件分配和再分配硬盘空间。文件系统使硬盘空间分配给很多文件。每个文件有一个名称是对于应用例如Oracle数据库是一个连续地址空间。数据库可以建立读写重置大小和删除文件。文件系统一般是建立在逻辑卷上,逻辑卷是由一个叫做逻辑卷管理器的软件包创建的。逻辑卷使多个物理硬盘碎片连接成一个单一连续的地址空间对用高层次的软件好像是一个硬盘。Raw device

裸设备是没有被文件系统格式化的硬盘分区或是逻辑卷。裸设备最主要的优点是可以操作直接I/O和写较大的缓存。在直接I/O中应用使用操作系统缓冲区高速缓存直接读写存储设备。
Cluster file system

群文件系统使软件允许多个计算机共享那个文件存储并保持空间分配和文件内容一致性。在一个Oracle RAC环境中,一个群文件能使集群环境中的多个计算机共享的文件系统共享数据。通过群文件系统,一个集群中的计算机故障不会导致文件系统不可用。

A database employs a combination of the preceding storage mechanisms. For example, a database could store the control files and online redo log files in a traditional file system, some user data files on raw partitions, the remaining data files in Oracle ASM, and archived the redo log files to a cluster file system.一个数据库使用之前所有的存储机制的联合。例如,数据库可以通过传统文件系统存储控制文件和联机重做日志文件,裸设备存储一些用户数据文件,其他数据文件通过Oracle ASM,将重做日志文件归档到群文件系统。
++++[Oracle Automatic Storage Management (Oracle ASM)]
Oracle ASM is a high-performance, ease-of-management storage solution for Oracle Database files. Oracle ASM is a volume manager and provides a file system designed exclusively for use by the database.Oracle ASM是一个高性能,易管理的Oracle 数据库文件存储解决方案。Oracle ASM是一个卷管理器提供只为数据库使用设计的文件系统。Oracle ASM provides several advantages over conventional file systems and storage managers, including the following: Simplifies storage-related tasks such as creating and laying out databases and managing disk space Distributes data across physical disks to eliminate hot spots and to provide uniform performance across the disks Rebalances data automatically after storage configuration changes
Oracle ASM 相对于传统文件系统和存储管理器有以下优势:
简化了存储相关任务例如建立和部署数据库,管理磁盘空间。在物理磁盘数据分布和消除热点提供均匀性能。数据存储配置变化自动重新平衡数据。
To use Oracle ASM, you allocate partitioned disks for Oracle Database with preferences for striping and mirroring. Oracle ASM manages the disk space, distributing the I/O load across all available resources to optimize performance while removing the need for manual I/O tuning. For example, you can increase the size of the disk for the database or move parts of the database to new devices without having to shut down the database.通过使用 Oracle ASM,为Oracle 数据库分配分区磁盘更利于剥离和镜像。Oracle ASM管理磁盘空间,在所有可用的资源上分布I/O负载优化性能而不需手动I/O调优。例如你可以增加数据库的磁盘或者将一部分数据库移动到新设备上而无需关闭数据库。+++++[Oracle ASM Storage Components]Oracle Database can store a data file as an Oracle ASM file in an Oracle ASM disk group, which is a collection of disks that Oracle ASM manages as a unit. Within a disk group, Oracle ASM exposes a file system interface for database files.Oracle 数据库可以在Oracle ASM磁盘组(Oracle ASM以一个单元管理的磁盘集合)上讲一个数据文件存储为Oracle ASM 文件。 在一个磁盘组中,Oracle ASM 为数据库文件提供了文件系统接口。Figure 11–2 shows the relationships between storage components in a database that uses Oracle ASM. The diagram depicts the relationship between an Oracle ASM file and a data file, although Oracle ASM can store other types of files. The crow's foot notation represents a one-to-many relationship.图11-2说明了使用Oracle ASM的Oracle存储组件之间的关系。 图表描述了Oracle ASM 文件盒数据文件之间的关系,即使Oracle ASM 额可以存储其他类型的文件。Figure 11–2 illustrates the following Oracle ASM concepts:Oracle ASM Disks

An Oracle ASM disk is a storage device that is provisioned to an Oracle ASM disk group.

An Oracle ASM disk can be a physical disk or partition, a Logical Unit Number (LUN) from a storage array, a logical volume, or a network-attached file. Oracle ASM disks can be added or dropped from a disk group while the database is running. When you add a disk to a disk group, you either assign a disk name or the disk is given an Oracle ASM disk name automatically. Oracle ASM Disk Groups

An Oracle ASM disk group is a collection of Oracle ASM disks managed as a logical unit. The data structures in a disk group are self-contained and consume some disk space in a disk group. Within a disk group, Oracle ASM exposes a file system interface for Oracle database files. The content of files that are stored in a disk group are evenly distributed, or striped, to eliminate hot spots and to provide uniform performance across the disks. The performance is comparable to the performance of raw devices.
Oracle ASM Files

An Oracle ASM file is a file stored in an Oracle ASM disk group. Oracle Database communicates with Oracle ASM in terms of files. The database can store data files, control files, online redo log files, and other types of files as Oracle ASM files. When requested by the database, Oracle ASM creates an Oracle ASM file and assigns it a fully qualified name beginning with a plus sign (+) followed by a disk group name, as in +DISK1.
Oracle ASM Extents

An Oracle ASM extent is the raw storage used to hold the contents of an Oracle ASM file. An Oracle ASM file consists of one or more file extents. Each Oracle ASM extent consists of one or more allocation units on a specific disk. Oracle ASM Allocation Units

An allocation unit is the fundamental unit of allocation within a disk group. An allocation unit is the smallest contiguous disk space that Oracle ASM allocates. One or more allocation units form an Oracle ASM extent.+++++[Oracle ASM Instances]An Oracle ASM instance is a special Oracle instance that manages Oracle ASM disks. Both the ASM and the database instances require shared access to the disks in an ASM disk group. ASM instances manage the metadata of the disk group and provide file layout information to the database instances. Database instances direct I/O to ASM disks without going through an ASM instance.An ASM instance is built on the same technology as a database instance. For example, an ASM instance has a system global area (SGA) and background processes that are similar to those of a database instance. However, an ASM instance cannot mount a database and performs fewer tasks than a database instance.Figure 11–3 shows a single-node configuration with one Oracle ASM instance and two database instances, each associated with a different single-instance database. The ASM instance manages the metadata and provides space allocation for the ASM files storing the data for the two databases. One ASM disk group has four ASM disks and the other has two disks. Both database instances can access the disk groups. ++++[Oracle Managed Files and User-Managed Files]

+++[Overview of Data Files]
At the operating system level, Oracle Database stores database data in data files. Every database must have at least one data file. 每一个数据库至少要有一个数据文件。++++[Use of Data Files]
Each nonpartitioned schema object and each partition of an object is stored in its own segment.每一个不分区的模式对象以及对象的每个分区都存储它自己的段中。总结一下,Oracle 中的存储层次体系如下:(1) 数据库由一个或多个表空间组成。(2) 表空间由一个或多个数据文件组成。这些文件可以是文件系统中的cooked 文件、原始分区、ASM管理的数据库文件,或集群文件系统上的文件。表空间包含段。(3) 段(TABLE、INDEX 等)由一个或多个区段组成。段在表空间中,但是可以包含这个表空间中多个数据文件中的数据。(4) 区段是磁盘上一组逻辑连续的块。区段只在一个表空间中,而且总是在该表空间内的一个文件中。(5) 块是数据库中最小的分配单位,也是数据库使用的最小I/O 单位。A database must have the SYSTEM and SYSAUX tablespaces.Oracle Database automatically allocates the first data files of any database for the SYSTEM tablespace during database creation.The SYSTEM tablespace contains the data dictionary, a set of tables that contains database metadata.Typically, a database also has an undo tablespace and a temporary tablespace (usually named TEMP). ++++[Permanent and Temporary Data Files]
A permanent tablespace contains persistent schema objects. Objects in permanent tablespaces are stored in data files.持久表空间包含持久的模式对象。在持久表空间的对象存储在数据文件中。A temporary tablespace contains schema objects only for the duration of a session. Locally managed temporary tablespaces have temporary files (temp files), which are special files designed to store data in hash, sort, and other operations. Temp files also store result set data when insufficient space exists in memory.临时表空间包含只在session期间的模式对象。本地管理的临时表空间包含临时文件,一种为在hash和sort还有其他操作设计的特殊文件。临时文件也会在内存不足时存储结果集数据。Temp files are similar to permanent data files, with the following exceptions: Permanent database objects such as tables are never stored in temp files.持久数据库对象从来不会存储在临时文件中Temp files are always set to NOLOGGING mode, which means that they never have redo generated for them. Media recovery does not recognize temp files.

临时文件经常被设置为NOLOGGING模式,意味着他们从来不会产生重做。介质恢复不识别临时文件
You cannot make a temp file read-only.不能设置了临时文件为只读。 You cannot create a temp file with the ALTER DATABASE statement.不能创建临时文件通过ALTER DATABASE语句。 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.

当你创建或重设临时文件的大小,他们并不能总是保证分配磁盘空间的文件是指定大小。在linux和UNIX系统中,临时文件被创建为sparse files。这种情况下,磁盘块的分配只是在第一次被访问,而非在文件创建和调整大小时。
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.
临时文件信息在数据字典视图DBA_TEMP_FILES和动态性能视图V$TEMPFILE中展现,而不再DBA_DATA_FILES 或者V$DATAFILE视图中。
++++[Online and Offline Data Files]
Every data file is either online (available) or offline (unavailable). You can alter the availability of individual data files or temp files by taking them offline or bringing them online. Offline data files cannot be accessed until they are brought back online.每一个数据文件都或者是联机(可用)或是脱机(不可用)。Administrators may take data files offline for many reasons, including performing offline backups, renaming a data file, or block corruption. The database takes a data file offline automatically if the database cannot write to it.Like a data file, a tablespace itself is offline or online. When you take a data file offline in an online tablespace, the tablespace itself remains online. You can make all data files of a tablespace temporarily unavailable by taking the tablespace itself offline. 管理者可以使数据文件脱机出于以下的原因,包括操作脱机备份,重命名数据文件,或者数据库损坏。++++[Data File Structure]
Oracle Database creates a data file for a tablespace by allocating the specified amount of disk space plus the overhead for the data file header. The operating system under which Oracle Database runs is responsible for clearing old information and authorizations from a file before allocating it to the database.Oracle 数据库通过分配指定大小的磁盘空间加上数据文件头开支来为表空间创建一个数据文件。Oracle数据库运行的操作系统负责在把一个文件分配给数据库前清空它的过时信息和授权信息。The data file header contains metadata about the data file such as its size and checkpoint SCN. Each header contains an absolute file number and a relative file number. The absolute file number uniquely identifies the data file within the database. The relative file number uniquely identifies a data file within a tablespace.数据文件头包含数据文件元数据例如大小和检查点系统变化编号。每个头包含一个绝对文件号和相对文件号。绝对文件号在数据库中唯一标识这个数据文件。相对文件号在表空间唯一标识这个数据文件。When Oracle Database first creates a data file, the allocated disk space is formatted but contains no user data. However, the database reserves the space to hold the data for future segments of the associated tablespace. As the data grows in a tablespace, Oracle Database uses the free space in the data files to allocate extents for the segment.当数据库第一次创建数据文件时,被分配的磁盘空间被格式化不包含任何用户数据。然而,数据库保留空间来存储未来相关的表空间的数据段。当表空间的数据增长时,Oracle 数据库使用空闲空间来分配段中的区段。Figure11–5 illustrates the different types of space in a data file. Extents are either used, which means they contain segment data, or free, which means they are available for reuse. Over time, updates and deletions of objects within a tablespace can create pockets of empty space that individually are not large enough to be reused for new data. This type of empty space is referred to as fragmented free space. +++[Overview of Control Files]
The database control file is a small binary file associated with only one database. Each database has one unique control file, although it may maintain identical copies of it.数据库控制文件是一个只关联一个数据库的小的库文件。每一个数据库拥有一个唯一的控制文件,虽然它也可以有相同的备份。 ++++[Use of Control Files]
The control file is the root file that Oracle Database uses to find database files and to manage the state of the database generally. A control file contains information such as the following: The database name and database unique identifier (DBID)

数据库名称和数据库唯一标识
The time stamp of database creation

数据库创建时间点
Information about data files, online redo log files, and archived redo log files
数据文件,联机重做日志文件和归档重做日志文件的信息
Tablespace information

表空间信息
RMAN backups

RMAN恢复
The control file serves the following purposes:
It contains information about data files, online redo log files, and so on that are required to open the database.
The control file tracks structural changes to the database. For example, when an administrator adds, renames, or drops a data file or online redo log file, the database updates the control file to reflect this change. It contains metadata that must be accessible when the database is not open.

For example, the control file contains information required to recover the database, including checkpoints. A checkpoint indicates the SCN in the redo stream where instance recovery would be required to begin (see "Overview of Instance Recovery" on page13-12). 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.
它包含了当数据库不开启的时候必须可访问的元数据。例如检查点。Oracle Database reads and writes to the control file continuously during database use and must be available for writing whenever the database is open. For example, recovering a database involves reading from the control file the names of all the data files contained in the database. Other operations, such as adding a data file, update the information stored in the control file.
++++[Multiple Control Files]
多备份控制文件,可以防止单点故障,当所有控制文件都不可用时,需要介质恢复(Media Recovery)
Media recovery is not straightforward if an older backup of a control file must be used because a current copy is not available.
++++[Control File Structure]
Information about the database is stored in different sections of the control file. Each section is a set of records about an aspect of the database. For example, one section in the control file tracks data files and contains a set of records, one for each data file. Each section is stored in multiple logical control file blocks. Records can span blocks within a section.
The control file contains the following types of records: Circular reuse records 循环复用记录。
These records contain 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. Noncircular reuse records 不可循环复用记录。
These records contain 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. 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.对于控制文件块的读写不同于数据文件块。Oracle 数据库直接从磁盘读入控制文件到PGA。每个进程都为控制文件块分配一定数量的PGA内存。 +++[Overview of the Online Redo Log]
The most crucial structure for recovery is the online redo log, which consists of two or more preallocated files that store changes to the database as they occur. The online redo log records changes to the data files.对于恢复最关键的结构就是联机重做日志,包含两个或更多的提前分配的文件来存储对数据库的更改。联机重做日志记录了对数据文件的更改。 ++++[Use of the Online Redo Log]
The database maintains online redo log files to protect against data loss. Specifically, after an instance failure the online redo log files enable Oracle Database to recover committed data not yet written to the data files.数据库包含联机重做日志文件来防止数据丢失。具体来说,在一个实例故障后它使Oracle数据库恢复还没有写入到数据文件中的已提交的数据。Oracle Database writes every transaction synchronously to the redo log buffer, which is then written to the online redo logs. The contents of the log include uncommitted transactions, undo data, and schema and object management statements.Oracle 数据库将每一个事务同步写入到重做日志缓冲区,然后再写入到联机重做日志。日志内容包括未提交的事务,撤销数据和模式对象管理声明。Oracle Database uses the online redo log only for recovery. However, administrators can query online redo log files through a SQL interface in the Oracle LogMiner utility (see "Oracle LogMiner" on page 18-8). Redo log files are a useful source of historical information about database activity. Oracle 数据库联机重做日志只用来做恢复。 ++++[How Oracle Database Writes to the Online Redo Log]
The online redo log for a database instance is called a redo thread. 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, two or more 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.
An online redo log consists of two or more online redo log files. Oracle Database requires a minimum of two files to guarantee that one is always available for writing while the other is being archived (if the database is inARCHIVELOG mode).
一个联机重做日志包含至少两个重做日志文件。Oracle 数据库要求最少两个文件来保证一个对写入可用另一个存档(如果数据库在存档模式)。
++++[Structure of the Online Redo Log]
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.联机重做日志文件包含重做记录。一个重做记录是由一组变化向量组成的,每一个描述了一个数据块的更改。例如,更改表employees中的salary会产生一个重做记录描述了这个表的数据段块,撤销段数据块和撤销数据段的事务表。 SCN and time stamp of the change 改变的SCN和时间点 Transaction ID of the transaction that generated the change 产生这个变化的事务ID SCN and time stamp when the transaction committed (if it committed)事务提交的SCN和时间点 Type of operation that made the change 产生更改的操作类型 Name and type of the modified data segment 被修改的数据段的名字和类型。

回复

使用道具 举报

千问 | 2012-1-4 11:58:44 | 显示全部楼层
楼主加油啊!
回复

使用道具 举报

千问 | 2012-1-4 11:58:44 | 显示全部楼层
周应侯 发表于 2012-1-2 11:46
楼主加油啊!

恩,谢谢。一起加油


回复

使用道具 举报

千问 | 2012-1-4 11:58:44 | 显示全部楼层
xuewei198198 发表于 2012-1-2 11:56
恩,谢谢。一起加油

嗯~一起努力!
回复

使用道具 举报

千问 | 2012-1-4 11:58:44 | 显示全部楼层
本帖最后由 guogongzhou 于 2012-1-2 15:08 编辑
向楼主学习!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行