文章目录
6 Managing Database Storage Structures
This chapter discusses using Oracle Enterprise Manager Database Control (Database Control) to view and manage the storage structures of your database. This chapter contains the following sections:
这一章讨论使用EM查看和管理你的数据库存储结构,这一章包含一下内容
•About Database Storage Structures
关于数据库存储结构
•Viewing Database Storage Structure Information
查看数据库存储结构信息
•Performing Common Database Storage Tasks
执行通用数据库存储任务
•Managing the Online Redo Log
管理在线redo日志
•Managing Undo Data
管理undo数据
•Storage: Oracle By Example Series
About Database Storage Structures
关于数据库存储结构
An Oracle database is made up of physical and logical structures. Physical structures can be seen and operated on from the operating system, such as the physical files that store data on a disk.
oracle数据库是由物理结构和逻辑结构组成的,物理结构可以从操作中看到,比如物理文件存储数据
Logical structures are created and recognized by Oracle Database and are not known to the operating system. The primary logical structure in a database, a tablespace, contains physical files. The applications developer or user may be aware of the logical structure, but is not usually aware of this physical structure. The database administrator (DBA) must understand the relationship between the physical and logical structures of a database.
逻辑结构是被oracle 创建和管理的,而且在操作系统并不能看到,最基础的逻辑结构是表空间,包含物理文件。应用程序开发人员或用户可能知道逻辑结构,但通常不知道这种物理结构。DBA必须清楚逻辑结构和物理结构直接的关系
Figure 6-1 shows the relationships between logical and physical structures. This figure also shows recovery-related structures that are optionally kept in the fast recovery area. See “Fast Recovery Area” for more information.
Figure 6-1 Oracle Database Storage Structures
Oracle Database can automate much of the management of its structure. Oracle Enterprise Manager Database Control (Database Control) provides a Web-based graphical user interface (GUI) to enable easier management and monitoring of your database.
数据库可以自动的管理结构,EM提供了一个web页面更容易的管理和监控你的数据库
To view a database storage structure, go to the Storage section of the Server subpage and click on any of the links to access the storage pages.
This section provides background information about the various database storage structures. It contains the following topics:
•About Control Files
•About Online Redo Log Files
•About Archived Redo Log Files
•About Rollback Segments
•About Data Files
•About Tablespaces
•About Other Storage Structures
About Control Files
关于控制文件
A control file tracks the physical components of the database. It is the root file that the database uses to find all the other files used by the database. Because of the importance of the control file, Oracle recommends that the control file be multiplexed, or have multiple identical copies. For databases created with Oracle Database Configuration Assistant (DBCA), three copies of the control file are automatically created and kept synchronized with each other.
控制文件跟踪数据库的物理组件。它是数据库用来查找数据库使用的所有其他文件的根文件。由于控制文件的重要性,Oracle建议对控制文件进行多路复用,或具有多个相同的副本。对于使用Oracle数据库配置助手(DBCA)创建的数据库,将自动创建控制文件的三个副本,并保持相互同步。
If any control file fails, then your database becomes unavailable. If you have a control file copy, however, you can shut down your database and re-create the failed control file from the copy, then restart your database. Another option is to delete the failed control file from the CONTROL_FILES initialization parameter and restart your database using the remaining control files.
如果任何控制文件失败,则数据库将不可用。但是,如果有控制文件副本,则可以关闭数据库并从副本中重新创建失败的控制文件,然后重新启动数据库。另一个选项是从控制文件初始化参数中删除失败的控制文件,然后使用其余的控制文件重新启动数据库。
About Online Redo Log Files
关于在线redo日志文件
Every Oracle database has a set of two or more online redo log files. The set of online redo log files is collectively known as the redo log for the database. A redo log is made up of redo entries, which are also called redo records.
每个Oracle数据库都有一组两个或多个联机重做日志文件。联机重做日志文件集合称为数据库的重做日志。重做日志由重做条目组成,这些条目也称为重做记录。
The online redo log stores a copy of the changes made to data. If a failure requires a data file to be restored from backup, then the recent data changes that are missing from the restored data file can be obtained from the online redo log files, so work is never lost. The online redo log files are used to recover a database after hardware, software, or media failure. To protect against a failure involving the online redo log file itself, Oracle Database can multiplex the online redo log file so that two or more identical copies of the online redo log file can be maintained on different disks.
联机重做日志存储对数据所做更改的副本。如果失败需要从备份中还原数据文件,则可以从联机重做日志文件中获取从已还原数据文件中丢失的最近数据更改,因此不会丢失工作。联机重做日志文件用于在硬件、软件或媒体故障后恢复数据库。为了防止在线重做日志文件本身出现故障,Oracle数据库可以多路复用在线重做日志文件,以便在不同的磁盘上维护两个或多个相同的在线重做日志文件副本。
The online redo log for a database consists of groups of online redo log files. A group consists of an online redo log file and its multiplexed copies. Each identical copy is considered to be a member of that group. Each group is defined by a number, such as Group 1.
数据库的联机重做日志由联机重做日志文件组组成。一个组由一个在线重做日志文件及其多路复用副本组成。每个相同的副本都被视为该组的成员。每个组由一个数字定义,如组1
Figure 6-2 shows the configuration of a database that has three online redo log groups and two members in each group. For each group, the members are stored on separate disks for maximum availability. For example, the members of Group 1 are the redo log files A_LOG1 and B_LOG1.
图6-2显示了一个数据库的配置,该数据库有三个在线重做日志组,每个组中有两个成员。对于每个组,成员存储在单独的磁盘上以获得最大的可用性。例如,组1的成员是重做日志文件a_log1和b_log1。
The database log writer process (LGWR) writes redo records from the memory buffer to a redo log group until the log files in that group reach their storage size limit, or until you request a log switch operation. The LGWR process then writes to the next log group. The LGWR process performs this action in a circular fashion so that the oldest group is overwritten by the most recent redo records.
数据库日志编写器进程(lgwr)将重做记录从内存缓冲区写入重做日志组,直到该组中的日志文件达到其存储大小限制,或者直到请求日志切换操作。然后lgwr进程写入下一个日志组。lgwr进程以循环方式执行此操作,以便最旧的组被最新的重做记录覆盖。
About Archived Redo Log Files
关于归档重做日志文件
When you enable archiving of the online redo logs, Oracle Database copies the online redo log files to another location before they are overwritten. These copied files are referred to as archived redo log files. You can archive to multiple locations.
当启用联机重做日志的存档时,Oracle数据库会将联机重做日志文件复制到另一个位置,然后再覆盖它们。这些复制的文件称为存档的重做日志文件。您可以存档到多个位置
These archived redo log files extend the amount of redo data that can be saved and are used for recovery. Archived redo log files are required to recover a backup of the database from the time of the backup to the current time. Archiving can be either enabled or disabled for the database, but Oracle strongly recommends that you enable archiving. Oracle also recommends that you configure the database to write archived redo log files to the fast recovery area.
这些存档的重做日志文件扩展了可以保存并用于恢复的重做数据量。需要存档的重做日志文件才能将数据库的备份从备份时间恢复到当前时间。可以为数据库启用或禁用存档,但Oracle强烈建议您启用存档。Oracle还建议您将数据库配置为将存档的重做日志文件写入快速恢复区域。
About Rollback Segments
关于回滚段
Rollback segments were database structures used to track undo information for the database in earlier releases of Oracle Database. Now, the preferred way of managing undo information is with the undo tablespace. For more information, see “Managing Undo Data”.
回滚段是数据库结构,用于跟踪Oracle数据库早期版本中数据库的撤消信息。现在,管理撤消信息的首选方法是使用撤消表空间。有关详细信息,请参见“管理撤消数据”。
About Data Files
Data files are the operating system files that store the data within the database. The data is written to these files in an Oracle proprietary format that cannot be read by other programs. Tempfiles are a special class of data files that are associated only with temporary tablespaces.
数据文件是在数据库中存储数据的操作系统文件。数据以Oracle专有格式写入这些文件,其他程序无法读取这些文件。tempfiles是一类特殊的数据文件,只与临时表空间相关联。
Data files can be broken down into the following components:
数据文件可以分解为以下组件:
•Segment
段
A segment contains a specific type of database object. For example, a table is stored in a table segment, and an index is stored in an index segment. A data file can contain many segments.
段包含特定类型的数据库对象。例如,表存储在表段中,索引存储在索引段中。数据文件可以包含多个段
•Extent区
An extent is a contiguous set of data blocks within a segment. Oracle Database allocates space for segments in units of one extent. When the existing extents of a segment are full, the database allocates another extent for that segment.
数据块是一个段内的一组连续数据块。Oracle数据库以一个区段为单位为区段分配空间。当一个段的现有扩展数据块已满时,数据库将为该段分配另一个扩展数据块。
•Data block
A data block, also called a database block, is the smallest unit of I/O to database storage. An extent consists of several contiguous data blocks. The database uses a default block size at database creation.
数据块,也称为数据库块,是数据库存储I/O的最小单位。一个数据块由几个连续的数据块组成。数据库在创建数据库时使用默认块大小
After the database has been created, it is not possible to change the default block size without re-creating the database. It is possible, however, to create a tablespace with a block size different than the default block size.
创建数据库后,如果不重新创建数据库,就无法更改默认块大小。但是,可以创建块大小与默认块大小不同的表空间。
Segments, extents, and data blocks are all logical structures. Only Oracle Database can determine how many data blocks are in a file. The operating system recognizes only files and operating system blocks, not the number of data blocks in an Oracle Database file. Each data block maps to one or more operating system blocks.
段、扩展数据块和数据块都是逻辑结构。只有Oracle数据库才能确定文件中有多少数据块。操作系统只识别文件和操作系统块,而不识别Oracle数据库文件中的数据块数量。每个数据块映射到一个或多个操作系统块
About Tablespaces
A database is divided into logical storage units called tablespaces, which group related logical structures (such as tables, views, and other database objects). For example, all application objects can be grouped into a single tablespace to simplify maintenance operations.
数据库分为称为表空间的逻辑存储单元,表空间对相关逻辑结构(如表、视图和其他数据库对象)进行分组。例如,可以将所有应用程序对象分组到一个表空间中,以简化维护操作。
A tablespace consists of one or more physical data files. Database objects assigned to a tablespace are stored in the physical data files of that tablespace.
表空间由一个或多个物理数据文件组成。分配给表空间的数据库对象存储在该表空间的物理数据文件中。
When you create an Oracle database, some tablespaces already exist, such as SYSTEM and SYSAUX.
创建Oracle数据库时,某些表空间已经存在,例如System和SysAux
Tablespaces provide a means to physically locate data on storage. When you define the data files that comprise a tablespace, you specify a storage location for these files. For example, you might specify a data file location for a certain tablespace as a designated host directory (implying a certain disk volume) or designated Oracle Automatic Storage Management disk group. Any schema objects assigned to that tablespace then get located in the specified storage location. Tablespaces also provide a unit of backup and recovery. The backup and recovery features of Oracle Database enable you to back up or recover at the tablespace level.
表空间提供了一种在存储中物理定位数据的方法。定义组成表空间的数据文件时,可以为这些文件指定存储位置。例如,可以将某个表空间的数据文件位置指定为指定的主机目录(表示某个磁盘卷)或指定的Oracle自动存储管理磁盘组。然后将分配给该表空间的任何模式对象定位到指定的存储位置。表空间还提供一个备份和恢复单元。Oracle数据库的备份和恢复功能使您能够在表空间级别进行备份或恢复。
Table 6-1 describes some tablespaces included in the database.
Table 6-1 Tablespaces and Descriptions
You can create new tablespaces to support your user and application data requirements. During tablespace creation, you set the following parameters:
•Locally Managed Tablespaces
本地化管理的表空间
•Tablespace Types
表空间类型
•Tablespace Status
表空间状态
•Autoextend Tablespace
自动扩展表空间
•Encrypted Tablespaces
表空间的加密
Locally Managed Tablespaces
本地化管理的表空间
Space management within a tablespace involves keeping track of available (free) and used space, so that space is allocated efficiently during data insertion and deletion. Locally managed tablespaces keep the space allocation information within the tablespace, not in the data dictionary, thus offering better performance. By default, Oracle Database sets all