DB Creation   «Prev  Next»

Lesson 3Optimal Flexible Architecture
ObjectiveUnderstand Oracle's recommendations for placing Oracle software and database files.

Optimal Flexible Architecture while preparing to create Database

Reasons for Using OFA
Oracle Corporation offers specific recommendations on the naming and placement of database files to help you separate the different types of files in an Oracle installation.
This eases administration and spreads I/O across as many devices as possible. The Oracle database software, the control files and the datafiles, and the administrative files are all stored in separate directory trees and can be moved around independently of each other. Oracle refers to their recommendations as the Optimal Flexible Architecture (OFA). Following OFA creates a directory structure like the one below. Move your mouse over the following diagram for more explanations.

/oracle --> product
  1. oracle: The top-level directory is called the Oracle Base directory. On UNIX systems, the ORACLE_BASE environment variable will point to this. Windows uses a registry entry named ORACLE_BASE to point to this directory.
  2. product: Software for Oracle products is installed under this directory.
  3. 815: Multiple releases of Oracle may be installed on the same machine. The first three digits of the release number form the directory name. This directory contains the Oraclei 8.1.5 release. Using separate directories for each release enables you to install a new release, or delete an old one, without affecting the others. These directories are referred to as Oracle Homes.
  4. 734: This directory would contain the 7.3.4 release of Oracle, and would also contain subdirectories named bin, rdbms, orainst, and so forth.
  5. bin, rdbms, orainst, etc.: A number of different directories are used to contain various elements of the Oracle database software.
  6. admin: This directory tree contains administrative files such as scripts, parameter files, and database alert logs.
  7. prod, devl, test: Each Oracle database gets its own subdirectory underneath the admin directory.
  8. pfile: Contains parameter files for the prod database.
  9. create: Contains database creation scripts for the prod database.
  10. bdump: Contains the alert log and trace files for the prod database.
  11. data: Under UNIX, you can place all the mount points used for data files under the data directory. Not all sites do this however. Under Windows NT you can't do it at all, because that would force you to put all database files on the same physical disk.
  12. ora01, ora02: Mount points used for database files are usually numbered, and are also named to make it obvious that they contain Oracle database files.
  13. prod: This directory contains files for the production database.
  14. devl: This directory contains files for the development database.
  15. test: This directory contains files for the test database.

Using Oracle Managed Files

The Oracle Managed File (OMF) feature automates many aspects of tablespace management, such as file placement, naming, and sizing. You control OMF by setting the following initialization parameters:
  1. DB_CREATE_FILE_DEST
  2. DB_CREATE_ONLINE_LOG_DEST_N
  3. DB_RECOVERY_FILE_DEST
If you set these parameters before you create the database, Oracle uses them for the placement of the data files, control files, and online redo logs. You can also enable OMF after your database has been created. Oracle uses the values of the initialization parameters for the locations of any newly added files. Oracle also determines the name of the newly added file. The advantage of using OMF is that creating tablespaces is simplified. For example, the CREATE TABLESPACE statement does not need to specify anything other than the tablespace name.
First, enable the OMF feature by setting the DB_CREATE_FILE_DEST parameter:
SQL> alter system set db_create_file_dest='/u01';
Now, issue the CREATE TABLESPACE statement:
SQL> create tablespace inv1;

This statement creates a tablespace named INV1, with a default data file size of 100MB. Keep in mind that you can override the default size of 100MB by specifying a size:
SQL> create tablespace inv2 datafile size 20m;

To view the details of the associated data files, query the V$DATAFILE view, and note that Oracle has created subdirectories beneath the /u01 directory and named the file with the OMF format:
SQL> select name from v$datafile where name like '%inv%';
NAME
------------------------------------------------------------
/u01/O12C/datafile/o1_mf_inv1_8b5l63q6_.dbf
/u01/O12C/datafile/o1_mf_inv2_8b5lflfc_.dbf

One limitation of OMF is that you are limited to one directory for the placement of data files. If you want to add data files to a different directory, you can alter the location dynamically:
SQL> alter system set db_create_file_dest='/u02';

Although this procedure is not a huge deal, I find it easier not to use OMF. Most of the environments I have worked in have many mount points assigned for database use.
You do not want to have to modify an initialization parameter every time you need a data file added to a directory that is not in the current definition of DB_CREATE_FILE_DEST.
It is easier to issue a CREATE TABLESPACE statement or ALTER TABLESPACE statement that has the file location and storage parameters in the script. It is not cumbersome to provide directory names and file names to the tablespace-management statements.

Oracle Base Directory
There is more to the Optimal Flexible Architecture than just the directory structure shown here. We will be following the OFA guidelines as we create the course database, and I'll be pointing out other features of the OFA as we go along.