Oracle® Database 2 Day DBA 11g Release 1 (11.1) Part Number B28301-01 |
|
|
View PDF |
An Oracle database system consists of an Oracle database and an Oracle instance.
Oracle database—An Oracle database contains a set of operating system files that store data entered by users or applications, and structural information about the database itself called metadata. Information is stored persistently in these files.
Oracle instance—An Oracle instance (also known as a database instance) contains the set of Oracle Database background processes that operate on the stored data and the shared allocated memory that those processes use to do their work.
An instance must be started to read and write information to the database. Also, it is the instance that actually creates the database upon receipt of instructions from the Oracle Database Configuration Assistant (DBCA) utility or upon receipt of a SQL statement from the database administrator.
When the database instance is not available, your data is safe in the database, but it cannot be accessed by any user or application.
The properties of a database instance are specified using instance initialization parameters. When the instance is started, an initialization parameter file is read, and the instance is configured accordingly.
This section presents some of the concepts of an instance and its management. It contains the following topics:
Managing an Oracle instance includes configuring parameters that affect the basic operation of the Oracle instance. These parameters are called initialization parameters. The Oracle instance reads initialization parameters from a file at startup.
During installation, when you select from one of the preconfigured database workloads available in DBCA, the initialization parameters are optimized for typical use in the environment that you specified. As the number of database users increases and the workload increases, you might need to alter some initialization parameters. You can make these changes using the Initialization Parameter page in Oracle Enterprise Manager Database Control (Database Control), or by using one of the advisors provided by Oracle Database, such as the Memory Advisor. See "Using the Memory Advisors" for more information.
After being read from a file, initialization parameters are retained in memory, where the values for many of them can be changed dynamically. There are two types of files from which these parameters can be read: a text initialization parameter file and a server parameter file. The type of file used to start the instance determines if any dynamic initialization parameter changes you make are persistent across database shutdown and startup.
Server parameter file—The server parameter file is the preferred form of initialization parameter file, and is a binary file that can be written to and read by the database. It must not be edited manually. It is stored on the host computer on which Oracle Database is running. Any changes to it are persistent across database shutdown and startup. Changes are made when you use Database Control to modify one or more initialization parameters, or when Oracle Database itself makes changes for self-tuning purposes.
Note:
When changing an initialization parameter in the server parameter file, you can also specify that the in-memory value be changed, so that your change is reflected immediately in the current instance. If you do not change the in-memory value, the change does not take effect until you shut down and restart the database.Text initialization parameter file—This type of initialization parameter file can be read by the Oracle instance, but it is not written to by the instance. You can change a text initialization parameter file with a text editor, but changes do not take effect until you shut down and restart the Oracle instance. When you start the instance with this type of file, you can still change many initialization parameters dynamically with Database Control, but only for the current instance. Unless you also edit the text initialization parameter file and make the same change, the change is lost when you shut down and restart the database.
When you create the database with DBCA (as described in "Using DBCA to Create and Configure a Database"), a server parameter file is created. This file is then used each time the database is started.
SQL statements exist to create a server parameter file from a text initialization file, to create a server parameter file from the current (in-memory) values of all initialization parameters, and to create a text initialization parameter file from a server parameter file.
See Also:
Oracle Database Administrator's Guide for information about the default name and location of the server parameter file, and for commands to create a server parameter file or text initialization parameter file
The background processes of the Oracle instance manage memory structures, asynchronously perform I/O to write data to a file on a disk, and perform general maintenance tasks. The background processes consolidate functions that would otherwise be handled by multiple Oracle Database programs running for each user process. They monitor other Oracle Database processes to provide increased parallelism for better performance and reliability.
The background processes that are present depend on the features that are being used in the database. The most important background processes are described in Table 5-1.
Table 5-1 Oracle Database Background Processes
Background Process | Description |
---|---|
Database writer (DBWn) |
The database writer writes modified blocks from the database buffer cache to the files on a disk. Oracle Database allows a maximum of 20 database writer processes. |
Log writer (LGWR) |
The log writer process writes redo log entries to a disk. Redo log entries are generated in the redo log buffer of the System Global Area (SGA) and the log writer process writes the redo log entries sequentially into an online redo log file. |
Checkpoint |
At specific times, all modified database buffers in the SGA are written to the datafiles by a database writer process (DBWn). This event is called a checkpoint. The checkpoint process signals DBWn, updates the datafiles and control files of the database, and records the time of this update. |
System monitor (SMON) |
The system monitor performs instance recovery when a failed instance is restarted. |
Process monitor (PMON) |
The process monitor performs a recovery when a user process fails. It cleans up the cache and frees resources that the failed process was using. |
Archiver (ARCn) |
Archiver processes copy the redo log files to archival storage when the log files are full or a log switch occurs. The database must be in archive log mode to run archive processes. For more information, see Chapter 9, "Performing Backup and Recovery". |
Manageability monitor (MMON) |
This process performs various management-related background tasks, for example:
|
In addition to background processes, Oracle Database creates server processes that handle the connection requests of user or client processes. A user connection is composed of two distinct pieces:
A client program acting on behalf of the user, such as Oracle Enterprise Manager, SQL*Plus, or an application
A server process that handles the connection to the database on behalf of the client program, and that performs much of the work for the client program, such as parsing and running SQL statements, and retrieving and returning results to the client program
Server processes can be either dedicated or shared. When server processes are dedicated, Oracle Database is considered to be running in dedicated server mode. When server processes are shared, Oracle Database is considered to be running in shared server mode. In dedicated server mode, each client process has its own server process. Although a dedicated server process is good for long-running queries and administrative tasks, an idle process or too many dedicated processes can result in an inefficient use of resources.
Using shared server mode eliminates the need for a dedicated server process for each connection. In shared server mode, each client connection request is sent to a dispatcher, which is a process that is responsible for routing requests from connected user processes to a pool of shared server processes and returning the responses back to the appropriate user processes. An idle shared server process picks up a request from a common queue, which means a small number of shared servers can perform the same amount of processing as many dedicated servers. Because the amount of memory required for each user is relatively small, less memory and process management are required, and more users can be supported.
Shared server mode is more efficient at supporting multiple client programs making frequent short-running queries.
The sizes of the instance memory structures affect the performance of Oracle Database and are controlled by initialization parameters.
Upon installation, you can choose to let the database manage memory for you automatically, or you can configure some degree of manual memory management. If you configure manual memory management, Oracle Database provides advisors to help you determine appropriate values for memory parameters. For both manual and automatic memory management, Oracle Database sends alerts that identify memory sizing problems that require your attention.
The following sections describe the two important memory areas that you can monitor and size:
See Also:
"Memory" for information about memory management options during installation
Oracle Database Concepts for more information about Oracle Database memory architecture
The System Global Area (SGA) is a shared memory area that contains data and control information for the instance. Multiple users can share data within this memory area and avoid repeated, time-consuming access from a physical disk.
The SGA has several components, as listed in Table 5-2.
Table 5-2 SGA Components
Component | Description |
---|---|
Buffer cache |
Before any data stored in the database can be queried or modified, it must be read from a disk and stored in memory in the buffer cache. All user processes connected to the database share access to the buffer cache. For optimal performance, the buffer cache should be large enough to avoid frequent disk read and write operations. |
Shared pool |
The shared pool caches information that is shared among users:
|
Redo log buffer |
This buffer improves performance by caching redo information until it can be written to the physical redo log files stored on disk. Redo information and redo log files are discussed in "About Online Redo Log Files". |
Large pool |
This optional area is used to buffer large I/O requests for various server processes. |
Java pool |
The Java pool is an area of memory that is used for all session-specific Java code and data within the Java Virtual Machine (JVM). |
Streams pool |
The Streams pool is an area of memory that is used by the Oracle Streams feature. For more information about Oracle Streams, see Oracle Streams Concepts and Administration. |
Result cache |
The result cache buffers query results. If a query is run that already has results in the result cache, the database returns results from the result cache instead of rerunning the query. This speeds up the execution of frequently run queries. |
A Program Global Area (PGA) is a memory area used by a single Oracle Database server process. Each server process has its own PGA.
The PGA is used to process SQL statements and to hold logon and other session information. A large part of the PGA is dedicated to SQL work areas, which are working memory areas for sorts and other SQL operations.
The amount of PGA memory used and the contents of the PGA depend on whether the instance is running in dedicated server or shared server mode. See Oracle Database Concepts for details. See also "About Server and Client Processes" for more information about dedicated server and shared server modes.
The total memory used by all individual PGAs is known as the total instance PGA memory, and the collection of individual PGAs is referred to as the total instance PGA, or just instance PGA. With Oracle Enterprise Manager Database Control, you set the size of the instance PGA, not individual PGAs.
After installation, the Oracle instance is started, and the database is open for access by users with database accounts. At some point, you may want to shut down and restart the instance. This section describes the startup and shutdown processes.
The phrases "starting up and shutting down the Oracle instance" are often used interchangeably with "starting up and shutting down the database."
This section contains the following topics:
To start up or shut down the Oracle instance, you must connect to the instance with a special connection privilege. There are two of these privileges: SYSDBA
for fully empowered database administrators and SYSOPER
for users who operate the database, but have no privileges to access user objects.
When you create an Oracle database, there are two primary administrative user accounts that are automatically created: SYS
and SYSTEM
. Both of these users have full database administration privileges, but initially, only user SYS
can connect with the SYSDBA
privilege. Therefore, until you grant the SYSDBA
privilege to other users, you must connect to the Oracle instance as user SYS
to start up and shut down the instance. When connecting (logging in) as user SYS
, you must always specify that you are connecting AS
SYSDBA
.
See Also:
"About Administrative Accounts and Privileges" for more information about the SYS
and SYSTEM
users, and the SYSDBA
privilege
When you start the Oracle instance, you typically start it such that the database is open and ready for user connections. However, there are situations in which you may want to start the instance with the database mounted, but not open. An instance can also be started without the database either mounted or open. Thus, there are three stages to starting an instance:
You start the instance using one of the following methods:
Using Oracle Enterprise Manager. See "Shutting Down and Starting Up the Oracle Instance".
Using the SQL*Plus STARTUP
statement. See Oracle Database Administrator's Guide.
On Microsoft Windows, using the Services program in Control Panel to start the Oracle Database services. See "Shutting Down and Starting Up Using the Windows Services Program".
The instance reads the initialization parameter file, allocates SGA memory, and starts the background processes.
If you mount the database, the instance opens the database control file, but does not open the datafiles. The database is now considered to be in the mount state. This state enables you to perform certain administrative functions that cannot be performed when other users are accessing the database. An example of such a function is enabling or disabling redo log archiving. See "About Archived Redo Log Files" for information about redo log archiving.
If you open the database, the instance is first mounted, and then it opens the redo log files and datafiles for the database. The database is now open and available for all user access.
The default startup behavior is to complete the three stages in sequence, transparently. Unless you explicitly specify otherwise, the instance is started and the database is mounted and opened.
Instance shutdown is the reverse of instance startup. Shutdown goes through these three stages:
You shut down the database using one of the methods discussed in "About Instance Startup". Any modified data blocks cached in the SGA that have not been written to a disk are written. The contents of the redo log buffer are written to a disk, and then the redo log buffer is cleared. A checkpoint is performed on the datafiles and their headers are marked current as of the time the database was closed. Datafiles and log files are closed. Users can no longer access the database.
The Oracle instance dismounts the database and updates relevant entries in the control file to record a clean shutdown. The control file is closed. The database is now closed and dismounted, and only the instance remains.
The Oracle instance stops the background processes and deallocates the shared memory used by the SGA.