In Chapter 10, we introduced the Oracle instance, and explained that the terms instance and database are often used interchangeably. This chapter provides information about the physical structures that make up an Oracle database, which is accessed by means of the Oracle instance. 11.1. Types of Database FilesThe Oracle database consists of a number of physical files, often referred to as operating system files, since they are usually created and maintained by the host operating system. These physical files are used by Oracle for parameter storage, database coordination, and data storage. The files shown in the following list, which are described in the following sections, are unique to a particular database; that is, each mounted and opened database must have all of these files, and the files are not shared across instances except in the special case of the Oracle Parallel Server, whose purpose is to share datafiles.
11.1.1. Parameter Storage FilesTwo types of parameter storage files are used by Oracle: the INIT.ORA file and the optional CONFIG.ORA file. These files, described in the following sections, collectively contain information provided by the DBA to configure and tune a particular Oracle instance. 11.1.1.1. Initialization fileThe initialization file, usually referred to as the INIT.ORA file, is the primary file that contains configuration and tuning parameters. For detailed information on these parameters, see Chapter 12. An INIT.ORA file must exist for each Oracle instance. This file is used by Oracle when starting the database, and therefore must be located in a known location, or Oracle must be told where it is located through the use of a command-line parameter to Server Manager. In Unix systems, this file is found in the $ORACLE_HOME/dbs directory. The INIT.ORA file is one of only two Oracle files (the other is the CONFIG.ORA file) that can be directly read and manipulated by a user—in this case, by the DBA. The INIT.ORA file is stored as plain text—ASCII on most systems—and is typically edited by the DBA, using a text editor. The file format is straightforward: it consists of multiple lines, each of which specifies a parameter in the following format: parameter_name = parameter_value
The following rules apply to entries in the INIT.ORA table:
Because the INIT.ORA file is a plain text file, it should not contain any special formatting, graphic, or control characters other than the newline character. Do not edit the INIT.ORA file with a word processing program, since these programs usually store extra control characters that will prevent the INIT.ORA file from being read properly by Oracle. Note that any error in the INIT.ORA file will prevent the database from being started.
11.1.1.2. Configuration fileThe configuration file, usually referred to as the CONFIG.ORA file, is an optional file that contains parameters, just like the INIT.ORA file. In fact, the CONFIG.ORA file is a subset of the INIT.ORA file, and can only be used if the INIT.ORA file contains an "include" line specifying the name of the CONFIG.ORA file. Since the CONFIG.ORA file is actually merged into the INIT.ORA file prior to processing by Oracle, all of the same syntax rules apply. The CONFIG.ORA file is primarily used to segregate a particular set of standard initialization parameters. For example, when running the Oracle Parallel Server, there are many initialization parameters that must be set identically for each instance, and these are stored in a separate CONFIG.ORA file. Similarly, several Oracle instances running on the same host may share a common subset of parameters that is stored in a single CONFIG.ORA file, while each instance also has a set of specific initialization parameters stored in its INIT.ORA file. 11.1.2. Database Coordination FilesTwo types of database coordination files must exist for every Oracle instance: control files and redo log files. These files are critical to the operation of Oracle, and the loss of or damage to either file could have catastrophic effects on the database. 11.1.2.1. Control filesEvery Oracle instance must have one or more control files. The control file is a binary file that is critical to Oracle, but is not directly readable by a user, nor is it editable by a text editor. The control file can be thought of as a software "bootstrap" file; it contains information that Oracle requires to start. Information stored in the control file includes:
The information stored in the control file is so critical that if the control file is lost or damaged, the only options available for recovery are either to create a new control file (assuming that the DBA has access to all pertinent information required) or to rebuild the database and restore from a backup. Because of the critical nature of the control file, Oracle allows the DBA to maintain multiple mirrored control files, as specified by the CONTROL_FILES parameter in the INIT.ORA file. For example, the following line from INIT.ORA specifies two control files: CONTROL_FILES = (/disk00/oracle/control01.ctl,/disk02/oracle/control02.ctl)
Since the control file is not human readable, and is used only by Oracle itself, we recommend that, for operating systems with file protection, the control file be made readable only by the Oracle owner. In Unix, control files should be owned by Oracle, be assigned to group DBA, and have a protection of 600, which gives read/write access to the owner, but no access to the group or world. Although the control file is in a binary format and is readable only by Oracle, a method is provided to create a script containing SQL statements that can be used to recreate a control file. This text version may be edited and used to create a new control file with modified values. To create a text version of the control file, the DBA may use this command: ALTER DATABASE BACKUP CONTROLFILE TO TRACE NORESETLOGS; After execution of this command, a trace file will be created in a directory specified by the INIT.ORA parameter BACKGROUND_DUMP_DEST; by default, this will usually be $ORACLE_HOME/rdbms/log. You must go to the directory containing trace files and look for a file with an extension of .trc and a date/time stamp at the time you executed the ALTER DATABASE command. This trace file will be similar to the one shown in the following sample, which was created with Oracle Version 7.3.4 on an HP platform, and will contain the SQL statements required to create a new control file and restart the database.
Code View:
Scroll
/
Show All
Dump file /disk00/oracle/product/7.3.4/rdbms/log/DW1/ora_13607.trc This SQL text file may then be edited (carefully!) by the DBA. You might change the value of one of the configuration parameters (MAXDATAFILES, for example), or perhaps change the name or location of a LOGFILE. To replace a control file, perform the following steps:
Since this is a critical operation and an error may result in a database that cannot be opened, we highly recommend that you back up the database prior to creating a new control file. 11.1.2.2. Redo log filesRedo log files are operating system files used by Oracle to maintain logs of all transactions performed against the database. The primary purpose of these log files is to allow Oracle to recover changes made to the database in the case of a failure. An Oracle database must have at least two redo log files, and most databases have more than two. These files are written by the LGWR process in a circular fashion; that is, when the last log file is filled, the first log file is reused. For example, if a database has three redo log files, blocks will be written to file1 until it is filled; then that file is closed, and LGWR begins writing to file2 (this is called a log switch). When file2 is filled, LGWR switches to file3. When file3 is filled, file1 is reused, and so on. If the database is being operated in archivelog mode, then at the time of a log switch, the ARCH process copies the contents of the log file just filled to the ARCHIVE_LOG_DEST directory, giving the archived log file a unique name using a sequential number. These archived log files may be used during a database recovery to restore transactions made after the last complete backup of the database. If the ARCH process cannot finish copying before Oracle needs to use the log file again, all database activity stops until archiving is finished. Since this can have a significant effect on performance, make sure to create enough log files to prevent this from happening. Because redo log files are so critical to database recovery, you must protect redo log files from loss due to a hardware failure. There are two ways this can be accomplished. One method is to replace redo log files with mirrored devices; with this method, the hardware or operating system (or both) ensures that redundant copies of the files are written simultaneously. The other method is to use redo log groups, a mechanism provided by Oracle. With redo log groups, the LGWR process writes to each member of the current redo log group at the same time, without incurring a significant amount of operating system overhead or degradation of overall performance. Place members of redo log groups on separate disks in order to avoid loss due to failure of a single disk device and to reduce I/O contention, since redo log files are written to sequentially. 11.1.3. Data Storage FilesThe bulk of the storage allocated to any Oracle database is dedicated to (no surprise here) data. Data storage is arguably the most important component of the Oracle database, and it may be the most complex as well. Oracle differs from other database management systems in many ways: one of the most important differences is the way Oracle allocates and manages data storage. In many systems, storage is maintained by the operating system and allocated to a database as required. In an Oracle database, the DBA allocates one or more blocks of storage to Oracle in the form of one or more operating system files, and Oracle itself then manages the allocation of this storage. In fact, the physical operating system files that make up the database are invisible to database user—only the DBA knows the physical makeup of the database. In order to control storage allocation, Oracle manages the physical disk space by dividing it into Oracle blocks , and uses logical constructs called tablespaces, described in some detail in the next section. Figure 11.1 illustrates the relationships within Oracle's data storage structure. |
|