Raw Partitions and Windows NT
1.0 What is a Raw Partition?
2.0 When to use Raw Partitions
2.1 I/O Bound Application
2.2 Oracle Parallel Server
2.3 Asynchronous I/O (Overlapped I/O)
3.0 Advantages and drawbacks of Raw Partitions compared to File Systems
3.1 Advantages
3.2 Drawbacks
4.0 Setting Up
4.1 Calculating The Size of the Partition
4.2 Creating the partitions
4.3 Specifying in a create tablespace command
4.4 Symbolic Links
A) Creating Symbolic Links
B) Removing Symbolic Links
5.0 Backup Strategies
5.1 OCOPY80.EXE
5.2 RMAN
6.0 Raw Devices and Export/Import
7.0 How to switch files from a File System to Raw Device or from a Raw
Device to a File System.
8.0 Remarks
1.0 What is a Raw Partition?
-----------------------------
Raw partitions or devices are disk partitions that are not mounted and written
to as a file system, but are accessed via a character device driver. It is the
responsibility of the application to organize how the data is written to the
disk partition. So a Raw Partition is a segment of disk space pointed by the
partition table. There is no file system out there, no directories (no DIR or
NT Explorer).
Disk Naming
-----------
At startup, Windows NT names each found disk drives following this naming
convention:
\Device\Harddisk\Partition
where: : the number of the physical drive - starts with 0
: the number of the logical number as show in the NT Disk
Adminstrator - starts with 1
\Device\Harddisk0\Partition1 would typically be the C drive
Raw Partition Definition
------------------------
There are two different types (definition methods) of Raw Partitions
a) physical disk
b) logical disk
TIP:
Although you actualy could you the physical disk approach, its
strongly recommended to use the logical disk approach.
a) Physical disk:
A physical disk or Partition0 actualy refers to the whole disk
\Device\Harddisk\Partition0
When using the Setlinks command on a Dos prompt you will notice that Windows
NT by default creates a symbolic link for each Partition0:
harddisk ==> symbolic link Phys
For example (only 1 physical disk):
C:\>setlinks /D │grep -i Harddisk
D: = \Device\Harddisk0\Partition3
O: = \Device\Harddisk0\Partition2
C: = \Device\Harddisk0\Partition1
==> PhysicalDrive0 = \Device\Harddisk0\Partition0
Symbolic links are referenced as \\.\. In our example,
the symbolic link reference is \\.\PhysicalDrive0.
b) Logical Partition
Logical Partitions are created by the "NT Disk Administrator" utility.
There can be a drive letter assigned to logical partitions, but this is not
necessary. When there is a drive letter assigned, this is automatically a
symbolic link
For example (only 1 physical disk):
C:\>setlinks /D │grep -i Harddisk
D: = \Device\Harddisk0\Partition3
==> O: = \Device\Harddisk0\Partition2
C: = \Device\Harddisk0\Partition1
Partition O is a logical partition, with O as assigned drive letter;
the logical partition is visible in the Windows NT Explorer as drive O:.
So in this case the symbolic link reference is \\.\O:
Note: Oracle does not skip the first block of a logical partition used for
an Oracle Data file.
Using an entire disk (Partition0) for an Oracle datafile and using a logical
partition that occupies the entire disk for an Oracle datafile is not the same
thing. Even when a partition occupies the entire disk, there is still a small
place on the disk that is not part of the partition.
Never use the reference Partition0, because this might lead to data loss and/or
corruption.
2.0 When to use Raw Partitions
------------------------------
2.1 I/O Bound Applications
---------------------------
Raw devices are used in circumstances where an application is seen to be I/O
bound. To see if this is the case there are you could use:
1. UTLBstat UTLEstat utility ( Provided by Oracle in %OH%\RDBMS80\ADMIN )
2. NT Performance Monitor: for monitoring disk I/O on NT with the
Performance Monitor you have to activate the diskcounters
Not fault-tolerant : diskperf -y
Fault-tolerant (RAID): diskperf -ye
Remark: activating the I/O counters on NT
1) requires rebooting the server
2) imposes a (small) overhead/load ( < 5% )
Using these tools along with your knowledge of the application you should be
able to identify I/O Hot Spots.
Having done this and identified an I/O problem, there are several options that
should be considered BEFORE deciding to implement raw disk partitions.
To summarize these options :
1. Use more database buffers to reduce the need for Disk I/O.
2. Organize objects that are heavily accesses such that they are on separate
disks.
3. Separate indexes from tables place into different tablespaces and split
these tablespaces onto different disks.
4. Stripe heavily accessed objects over multiple disks.
5. Separate redo logs onto a lightly loaded disk drive.
**Note: Raid 5 based disks are NOT a good location for redo logs!**
6. Place rollback segments into to separate tablespaces and then by the
listing order in the init.ora interleaf the access between the two
tablespaces.
7. Use the Explain plan utility to check the most common SQL statements that
are used. From this it may be possible to utilize indexes that will
prevent sorting and hence reduce I/O to the temporary tablespace.
If having done all these you are still identifying an I/O problem, then now is
the time to implement Raw Partitions.
2.2 Oracle Parallel Server
---------------------------
The implementations of Oracle Parallel Server on NT requires that all data
files, log files, and control files are placed onto Raw Partitions so that the
all nodes of the parallel server environment are all able to see and access the
files. This is necessary because NT file system (and most UNIX files systems)
does not allow multiple nodes to share control of files.
2.3 Asynchronous I/O (Overlapped I/O)
--------------------------------------
NT supports Async I/O: threads can continue to work while I/O for that
thread complete: its possible for a specific thread to have multiple
I/Os at the same time. Oracle RDBMS on NT uses by default Asynchronous I/O
3.0 Advantages and Drawbacks of Raw Partitions Compared to File Systems
------------------------------------------------------------------------
3.1 Advantages
---------------
a) The absence of a filesystem eliminates all storage overhead that
comes along with a filesystem.
b) No fragmentation on filesystem-level: disk fragmentation is typical
for filesystems (NTFS & FAT).
c) On most platforms I/O against a file system (cache) creates a rather
large bottleneck.
(*) Oracle on NT bypasses the filesystem buffer cache completely by
using the FILE_FLAG_NO_BUFFERING option on opening files with
CreateFile(). Oracle also uses the FILE_FLAG_WRITE_THROUGH option.
So there is no real caching difference between raw I/O and NTFS I/O.
Because of this implementation (b & c), the performance of Oracle on NT is
rather small (5% to 10%) and is mainly due to the absence of fragmentation (b).
3.2 Drawbacks
-------------
a) Manageability & security: when there is no filesystem, we lose all the
manipulation possibilities offered by a filesystem: no space allocation
control, no good security, difficult to maintain.
b) Only 1 file per Raw Partition is possible.
4.0 Setting Up
--------------
4.1 Calculating The Size of the Partition
-----------------------------------------
When creating the Oracle tablespace on the Raw Partition, a slightly smaller
size than the actual partition size needs to be specified. This size can be
calculated as follows:
Size of Redo Log = Raw Partition Size - 1*512 byte block
Size of Data File = Raw Partition Size - 2* Oracle Block Size
Oracle typically recommends a spare megabyte. If you want to have an exactly
50 MB datafile on a Raw Partition, Oracle advises to create a Raw Partition
of 51 MB.
ORA-19502 ORA-27072 OSD-4008; NT ERROR: 87 CREATING
TABLESPACE ON RAW PARTITION
4.2 Creating the partitions
---------------------------
The number of partitions on 1 disk is limited at 4: you can have a maximum of
4 primary partitions, or a maximum of 3 primary partitions and 1 extended
partition.
A primary partition cannot be split into smaller partitions. An extended
partition can be split into many Logical Partitions. You could assign a
drive letter to Logical Partitions and Primary Partitions. Its better
to use extended partitions because it enables you to have more than 4 drives
per disk.
1) Start the NT Disk Administrator in the Administrative Tools program group.
2) If you dont have any free space left you need to free up some by
deleting an existing partition that you dont need anymore. To do so,
select the drive that you want to suppress by clicking on it, then select
"Delete", under the "Partition" menu.
or
3) Primary Partition
Select the "Free Space" by clicking on it. Go to the
"Partition"-menu and select "Create". In the "Create Primary
Partition" screen, you define the Raw Partition Size (i.e.
desired filesize + 1 MB).
Click OK.
or
3) Extended Partition
3.a If no Extended Partition is already present on the disk.
Select the "Free Space" by clicking on it. Go to the "Partition"
Menu and choose "Create Extended ...". Choose the size of the
extended partition, you want to create. When youre initiating a
new disk, Oracle recommends to use the entire disk to create the
extended partition.
3.b If you already have an Extended Partition or you created one.
Select the extended partition that you want to split up. Go to
the "Partition"-menu and select "Create ...". In the popup screen
you fill in the size of the logical partition
4) Repeat step 3) for each Raw Partition you would like to create.
5) You could change the drive letter assigned by default to a new
not already in use letter: select the partition, choose in the
"Tools"-menu "Assign Drive Letter" and pick the one you want.
In the same way you could also choose not to assign a drive
letter.
(See 4.4. Symbolic Links)
6) After all changes have been done, go to the "Partition"-menu and
click on "Commit Changes Now...", to save the changes.
4.3 Specifying in a create tablespace command
Once the Raw Partition has been created and the required calculated,
it may be referenced in a create tablespace command as follows:
There is 1 Raw Partition present on the system q:
CREATE TABLESPACE rauw DATAFILE \\.\q: SIZE 7 M,
D:\TEMP\REST.DBF size 7M;
or
ALTER DATABASE ADD LOGFILE GROUP 3 (\\.\q:) size 7M;
4.4 Symbolic Links
A) Creating Symbolic Links
--------------------------
Assigning Symbolic Links to Each Logical Partition:
If you dont want to use the drive letters assigned to logical
partitions or you need to use more Raw Partitions than there are drive
letters available, use the SETLINKS utility to create symbolic links to
Raw Logical Partitions.
Create a ASCII file with the partitions and link names you intend to use.
Its content is
"Symbolic Link 1" "\Device\Physical Drive Number x1\Partition Number y1"
"Symbolic Link 2" "\Device\Physical Drive Number x2\Partition Number y2"
"Symbolic Link 3" "\Device\Physical Drive Number x3\Partition Number y3"
...
Dont forget to end the parameter file with a Carriage Return.
Note.104093.1: Setlinks does not update symbolic link list
Below are a few lines from a sample file called DATABASE.TBL:
DATABASE.TBL
------------
RAW_CTL01 \Device\Harddisk4\Partition3
RAW_LOG01 \Device\Harddisk1\Partition2
RAW_IDX01 \Device\Harddisk2\Partition1
Run the DATABASE.TBL file through Setlinks from
a DOS Command prompt:
C:\>SETLINKS /F:DATABASE.TBL
Symbolic Links are accessed using the convention \\.\.
Above, we created a symbolic link for the control file on the third
partition of the 5th Device called RAW_CTL01. You would reference
the file in init.ora like this:
CONTROL_FILES = \\.\RAW_CTL01
or to create a tablespace with a datafile in a raw partition:
CREATE TABLESPACE CBAT
DATAFILE \\.\RAW_IDX01 SIZE 10M;
SVRMGR> select name from v$datafile;
NAME
------------------------------------------------
D:\DATABASES\OR85\DATAFILES\SYS1OR85.ORA
D:\DATABASES\OR85\DATAFILES\RBS1OR85.ORA
D:\DATABASES\OR85\DATAFILES\USR1OR85.ORA
D:\DATABASES\OR85\DATAFILES\TMP1OR85.ORA
D:\DATABASES\OR85\DATAFILES\INDX1OR85.ORA
\\.\\\.\RAW_IDX01
You can verify which Symbolic Links are currently defined by
executing from a DOS Command prompt:
C:\>SETLINKS /D
B) Removing Symbolic Links
--------------------------
Removing the created Symbolic Links can be done by creating a new
parameter file (ASCII):
If you want to remove "Symbolic Link 1", you create the file
that mention the name of the link but no Logical Partition name
following it
Lets remove the RAW_CTL01 Dynamic Link
REMOVE_LINKS.TBL
----------------
RAW_CTL01
Run the REMOVE_LINKS.TBL file through Setlinks from
a DOS Command prompt:
C:\>SETLINKS /F:REMOVE_LINKS.TBL
5.0 Backup Strategies
5.1 OCOPY80.EXE
To backup raw partitions you will need to use the utility delivered by
Oracle the ocopy-command. OCOPY copies files :
from Raw Partitions to either Raw Partitions or File Systems Files,
or from File System Files to either Raw Partitions or File Systems Files.
Utilities like the NT-commands copy, xcopy CANNOT be used to back up Raw
partitions.
5.2 RMAN
Another possibility is to use the Oracle tool RMAN.
6.0 Raw Devices and Export/Import
If you are performing a full database import to a database on the same
machine as the exported database, and the original datafiles were
on a raw device, the files will be reused even if you specify
DESTROY=N.
This will crash the original database from which the export was taken.
7.0 How to switch files from a File System to Raw Device or from a Raw
Device to a File System.
This can only be done through export and import.
for example: you have a tablespace with 1 file on a File System and you
want to switch that tablespace to a Raw Partition
1. export all data from that tablespace
2. drop all objects from that tablespace
3. drop the tablespace itself
4. recreate the tablespace with a Raw Partition
5. reimport the exported objects.
8.0 Remarks
8.1 When placing control files (as from Oracle8) on Raw Partition
keep in mind that control files can grow in size overtime and that
there must be sufficient space in the Raw Partition to cope with
this growth.
The growth of the controlfile, amongst many aspect, is mainly
influenced by the init.ora parameter CONTROL_FILE_RECORD_KEEP_TIME.
8.2 Think about standardization of the size of Raw Partitions; One, two
or three different size make it much easier to administrate than 20
different sizes. It will allow easy reuse anf avoids repeated
partitioning.