Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

rekharaghuram
from rekharaghuram More from this publisher
05.11.2015 Views

CHAPTER 3 ■ FILES 89 A Brief Review of File System Mechanisms There are four file system mechanisms in which to store your data in Oracle. By your data, I mean your data dictionary, redo, undo, tables, indexes, LOBs, and so on—the data you personally care about at the end of the day. Briefly, they are • “Cooked” operating system (OS) file systems: These are files that appear in the file system just like your word processing documents do. You can see them in Windows Explorer; you can see them in UNIX as the result of an ls command. You can use simple OS utilities such as xcopy on Windows or cp on UNIX to move them around. Cooked OS files are historically the “most popular” method for storing data in Oracle, but I personally expect to see that change with the introduction of ASM (more on that in a moment). Cooked file systems are typically buffered as well, meaning that the OS will cache information for you as you read and, in some cases, write to disk. • Raw partitions: These are not files—these are raw disks. You do not ls them; you do not review their contents in Windows Explorer. They are just big sections of disk without any sort of file system on them. The entire raw partition appears to Oracle as a single large file. This is in contrast to a cooked file system, where you might have many dozens or even hundreds of database data files. Currently, only a small percentage of Oracle installations use raw partitions due to their perceived administrative overhead. Raw partitions are not buffered devices—all I/O performed on them is a direct I/O, without any OS buffering of data (which, for a database, is generally a positive attribute). • Automatic Storage Management (ASM): This is a new feature of Oracle 10g Release 1 (for both Standard and Enterprise editions). ASM is a file system designed exclusively for use by the database. An easy way to think about it is as a database file system. You won’t store your shopping list in a text file on this file system—you’ll store only databaserelated information here: your tables, indexes, backups, control files, parameter files, redo logs, archives, and more. But even in ASM, the equivalent of a data file exists; conceptually, data is still stored in files, but the file system is ASM. ASM is designed to work in either a single machine or clustered environment. • Clustered file system: This is specifically for a RAC (clustered) environment and provides for the appearance of a cooked file system that is shared by many nodes (computers) in a clustered environment. A traditional cooked file system is usable by only one computer is a clustered environment. So, while it is true that you could NFS mount or Samba share (a method of sharing disks in a Windows/UNIX environment similar to NFS) a cooked file system among many nodes in a cluster, it represents a single point of failure. In the event that the node owning the file system and performing the sharing was to fail, then that file system would be unavailable. The Oracle Cluster File System (OCFS) is Oracle’s offering in this area and is currently available for Windows and Linux only. Other third-party vendors do provide certified clustered file systems that work with Oracle as well. The clustered file system brings the comfort of a cooked file system to a clustered environment.

90 CHAPTER 3 ■ FILES The interesting thing is that a database might consist of files from any and all of the preceding file systems—you don’t need to pick just one. You could have a database whereby portions of the data were stored in conventional cooked file systems, some on raw partitions, others in ASM, and yet other components in a clustered file system. This makes it rather easy to move from technology to technology, or to just get your feet wet in a new file system type without moving the entire database into it. Now, since a full discussion of file systems and all of their detailed attributes is beyond the scope of this particular book, we’ll dive back into the Oracle file types. Regardless of whether the file is stored on cooked file systems, in raw partitions, within ASM, or on a clustered file system, the following concepts always apply. The Storage Hierarchy in an Oracle Database A database is made up of one or more tablespaces. A tablespace is a logical storage container in Oracle that comes at the top of the storage hierarchy and is made up of one or more data files. These files might be cooked files in a file system, raw partitions, ASM-managed database files, or files on a clustered file system. A tablespace contains segments, as described next. Segments We will start our examination of the storage hierarchy by looking at segments, which are the major organizational structure within a tablespace. Segments are simply your database objects that consume storage—objects such as tables, indexes, rollback segments, and so on. When you create a table, you create a table segment. When you create a partitioned table, you create a segment per partition. When you create an index, you create an index segment, and so on. Every object that consumes storage is ultimately stored in a single segment. There are rollback segments, temporary segments, cluster segments, index segments, and so on. ■Note It might be confusing to read “Every object that consumes storage is ultimately stored in a single segment.” You will find many CREATE statements that create mulitsegment objects. The confusion lies in the fact that a single CREATE statement may ultimately create objects that consist of zero, one, or more segments! For example, CREATE TABLE T ( x int primary key, y clob ) will create four segments: one for the TABLE T, one for the index that will be created in support of the primary key, and two for the CLOB (one segment for the CLOB is the LOB index and the other segment is the LOB data itself). On the other hand, CREATE TABLE T ( x int, y date ) cluster MY_CLUSTER, will create no segments. We’ll explore this concept further in Chapter 10. Extents Segments themselves consist of one or more extent. An extent is a logically contiguous allocation of space in a file (files themselves, in general, are not contiguous on disk; otherwise, we would never need a disk defragmentation tool!). Also, with disk technologies such as

CHAPTER 3 ■ FILES 89<br />

A Brief Review of File System Mechanisms<br />

There are four file system mechanisms in which to store your data in <strong>Oracle</strong>. By your data, I<br />

mean your data dictionary, redo, undo, tables, indexes, LOBs, <strong>and</strong> so on—the data you personally<br />

care about at the end of the day. Briefly, they are<br />

• “Cooked” operating system (OS) file systems: These are files that appear in the file system<br />

just like your word processing documents do. You can see them in Windows Explorer;<br />

you can see them in UNIX as the result of an ls comm<strong>and</strong>. You can use simple OS utilities<br />

such as xcopy on Windows or cp on UNIX to move them around. Cooked OS files<br />

are historically the “most popular” method for storing data in <strong>Oracle</strong>, but I personally<br />

expect to see that change with the introduction of ASM (more on that in a moment).<br />

Cooked file systems are typically buffered as well, meaning that the OS will cache information<br />

for you as you read <strong>and</strong>, in some cases, write to disk.<br />

• Raw partitions: These are not files—these are raw disks. You do not ls them; you do not<br />

review their contents in Windows Explorer. They are just big sections of disk without<br />

any sort of file system on them. The entire raw partition appears to <strong>Oracle</strong> as a single<br />

large file. This is in contrast to a cooked file system, where you might have many dozens<br />

or even hundreds of database data files. Currently, only a small percentage of <strong>Oracle</strong><br />

installations use raw partitions due to their perceived administrative overhead. Raw<br />

partitions are not buffered devices—all I/O performed on them is a direct I/O, without<br />

any OS buffering of data (which, for a database, is generally a positive attribute).<br />

• Automatic Storage Management (ASM): This is a new feature of <strong>Oracle</strong> 10g Release 1 (for<br />

both St<strong>and</strong>ard <strong>and</strong> Enterprise editions). ASM is a file system designed exclusively for<br />

use by the database. An easy way to think about it is as a database file system. You won’t<br />

store your shopping list in a text file on this file system—you’ll store only databaserelated<br />

information here: your tables, indexes, backups, control files, parameter files,<br />

redo logs, archives, <strong>and</strong> more. But even in ASM, the equivalent of a data file exists; conceptually,<br />

data is still stored in files, but the file system is ASM. ASM is designed to work<br />

in either a single machine or clustered environment.<br />

• Clustered file system: This is specifically for a RAC (clustered) environment <strong>and</strong> provides<br />

for the appearance of a cooked file system that is shared by many nodes (computers)<br />

in a clustered environment. A traditional cooked file system is usable by only one computer<br />

is a clustered environment. So, while it is true that you could NFS mount or<br />

Samba share (a method of sharing disks in a Windows/UNIX environment similar to<br />

NFS) a cooked file system among many nodes in a cluster, it represents a single point of<br />

failure. In the event that the node owning the file system <strong>and</strong> performing the sharing<br />

was to fail, then that file system would be unavailable. The <strong>Oracle</strong> Cluster File System<br />

(OCFS) is <strong>Oracle</strong>’s offering in this area <strong>and</strong> is currently available for Windows <strong>and</strong> Linux<br />

only. Other third-party vendors do provide certified clustered file systems that work<br />

with <strong>Oracle</strong> as well. The clustered file system brings the comfort of a cooked file system<br />

to a clustered environment.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!