Oracle 10g – New Features: DATAFILES – FILE_MAPPING

FMON is a background process started by the database whenever the FILE_MAPPING initialization parameter is set to TRUE.

What it does?

Building mapping information, which is stored in the SGA. This information is composed of the following structures:

(1) Files.
(2) File system extents
(3) Elements
(4) Sub-elements

Refreshing mapping information takes place when there are

(1) Changes to datafiles (size)
(2) Addition/s or deletion/s of datafiles
(3) Changes to the storage configuration (not frequent)

Saving mapping information in the data dictionary to maintain a view of the information that is persistent across startup and shutdown operations

Restoring mapping information into the SGA at instance startup. This avoids the need for a potentially expensive complete rebuild of the mapping information on every instance startup.

You help control this mapping using procedures that are invoked with the DBMS_STORAGE_MAP package

External Process (FMPUTL) – a non-oracle process spawned by Oracle Background Process

Oracle Doc says:

FMON spawns an external non-Oracle Database process called FMPUTL, which communicates directly with the vendor supplied mapping libraries. This process obtains the mapping information through all levels of the I/O stack, assuming that mapping libraries exist for all levels. On some platforms the external process requires that the SETUID bit is set to ON because root privileges are needed to map through all levels of the I/O mapping stack.

The external process is responsible for discovering the mapping libraries and dynamically loading them into its address space.

Mapping Libraries

Oracle Database uses mapping libraries to discover mapping information for the elements that are owned by a particular mapping library. Through these mapping libraries information about individual I/O stack elements is communicated. This information is used to populate dynamic performance views that can be queried by users.

Mapping libraries need to exist for all levels of the stack for the mapping to be complete, and different libraries may own their own parts of the I/O mapping stack. For example, a VERITAS VxVM library would own the stack elements related to the VERITAS Volume Manager, and an EMC library would own all EMC storage specific layers of the I/O mapping stack.

Mapping libraries are vendor supplied. However, Oracle currently supplies a mapping library for EMC storage. The mapping libraries available to a database server are identified in a special file named filemap.ora.

Mapping Structures
The mapping structures and the Oracle Database representation of these structures are described in this section. You will need to understand this information in order to interpret the information in the mapping views.

The following are the primary structures that compose the mapping information:

Files

A file mapping structure provides a set of attributes for a file, including file size, number of file system extents that the file is composed of, and the file type.

File system extents

A file system extent mapping structure describes a contiguous chunk of blocks residing on one element. This includes the device offset, the extent size, the file offset, the type (data or parity), and the name of the element where the extent resides.

Note:

File system extents are not the same as Oracle Database extents. File system extents are physical contiguous blocks of data written to a device as managed by the file system. Oracle Database extents are logical structures managed by the database, such as tablespace extents.

Elements

An element mapping structure is the abstract mapping structure that describes a storage component within the I/O stack. Elements may be mirrors, stripes, partitions, RAID5, concatenated elements, and disks. These structures are the mapping building blocks.

Subelements

A subelement mapping structure describes the link between an element and the next elements in the I/O mapping stack. This structure contains the subelement number, size, the element name where the subelement exists, and the element offset.

All of these mapping structures are illustrated in the following example.

This cannot be tested unless you have the required environment.

Enabling File Mapping

Ensure that a valid filemap.ora file exists in the $ORACLE_HOME/rdbms/filemap/etc directory.

Caution:

While the format and content of the filemap.ora file is discussed here, it is for informational reasons only. The filemap.ora file is created by the database when your system is installed. Until such time that vendors supply there own libraries, there will be only one entry in the filemap.ora file, and that is the Oracle-supplied EMC library. This file should be modified manually by uncommenting this entry only if an EMC Symmetrix array is available.

The filemap.ora file is the configuration file that describes all of the available mapping libraries. FMON requires that a filemap.ora file exists and that it points to a valid path to mapping libraries. Otherwise, it will not start successfully.

The following row needs to be included in filemap.ora for each library :

lib=vendor_name:mapping_library_path

where:

vendor_name should be Oracle for the EMC Symmetric library

mapping_library_path is the full path of the mapping library

Note that the ordering of the libraries in this file is extremely important. The libraries are queried based on their order in the configuration file.

The file mapping service can be even started even if no mapping libraries are available. The filemap.ora file still needs to be present even though it is empty. In this case, the mapping service is constrained in the sense that new mapping information cannot be discovered. Only restore and drop operations are allowed in such a configuration.

Set the FILE_MAPPING initialization parameter to TRUE.

FILE_MAPPING=TRUE

The instance does not have to be shut down to set this parameter. It can be set using an ALTER SYSTEM statement.

Invoke the appropriate DBMS_STORAGE_MAP mapping procedure. You have two options:

In a cold startup scenario, the Oracle Database is just started and no mapping operation has been invoked yet. You execute the DBMS_STORAGE_MAP.MAP_ALL procedure to build the mapping information for the entire I/O subsystem associated with the database.

In a warm start scenario where the mapping information is already built, you have the option to invoke the DBMS_STORAGE_MAP.MAP_SAVE procedure to save the mapping information in the data dictionary. (Note that this procedure is invoked in DBMS_STORAGE_MAP.MAP_ALL() by default.) This forces all of the mapping information in the SGA to be flushed to disk.

Once you restart the database, use DBMS_STORAGE_MAP.RESTORE() to restore the mapping information into the SGA. If needed, DBMS_STORAGE_MAP.MAP_ALL() can be called to refresh the mapping information.

QUERIES to view the data related to file mapping

(1) To Map All Database Files that Span a Device:

SELECT UNIQUE
me.ELEM_NAME,
mf.FILE_NAME
FROM V$MAP_FILE_IO_STACK fs,
V$MAP_FILE mf,
V$MAP_ELEMENT me
WHERE mf.FILE_MAP_IDX = fs.FILE_MAP_IDX
AND me.ELEM_IDX = fs.ELEM_IDX
AND me.ELEM_NAME = ”;

(2) To Map a File into Its Corresponding Devices:

WITH fv AS
(SELECT FILE_MAP_IDX,
FILE_NAME
FROM V$MAP_FILE
WHERE FILE_NAME = ”)
SELECT fv.FILE_NAME,
LPAD(‘ ‘, 4 * (LEVEL – 1)) || el.ELEM_NAME ELEM_NAME
FROM V$MAP_SUBELEMENT sb,
V$MAP_ELEMENT el,
fv,
(
SELECT UNIQUE
ELEM_IDX
FROM V$MAP_FILE_IO_STACK io,
fv
WHERE io.FILE_MAP_IDX = fv.FILE_MAP_IDX
) fs
WHERE el.ELEM_IDX = sb.CHILD_IDX
AND fs.ELEM_IDX = el.ELEM_IDX
START WITH sb.PARENT_IDX IN
(
SELECT DISTINCT
ELEM_IDX
FROM V$MAP_FILE_EXTENT fe,
fv
WHERE fv.FILE_MAP_IDX = fe.FILE_MAP_IDX
)
CONNECT BY PRIOR
sb.CHILD_IDX = sb.PARENT_IDX;

(3) Map a Database Object:

SELECT io.OBJECT_NAME o_name,
io.OBJECT_OWNER o_owner,
io.OBJECT_TYPE o_type,
mf.FILE_NAME,
me.ELEM_NAME,
io.DEPTH,
(SUM(io.CU_SIZE * (io.NUM_CU – DECODE(io.PARITY_PERIOD, 0, 0,
TRUNC(io.NUM_CU / io.PARITY_PERIOD)))) / 2) o_size
FROM MAP_OBJECT io,
V$MAP_ELEMENT me,
V$MAP_FILE mf
WHERE io.OBJECT_NAME = ”
AND io.OBJECT_OWNER = ”
AND io.OBJECT_TYPE = ”
AND me.ELEM_IDX = io.ELEM_IDX
AND mf.FILE_MAP_IDX = io.FILE_MAP_IDX
GROUP BY io.ELEM_IDX,
io.FILE_MAP_IDX,
me.ELEM_NAME,
mf.FILE_NAME,
io.DEPTH,
io.OBJECT_NAME,
io.OBJECT_OWNER,
io.OBJECT_TYPE
ORDER BY io.DEPTH;