![]() |
Creating
Oracle database that uses Raw Device option for Storing database
files
(For RHEL 4 / 3 / 2.1/ CentOS 4 / 3 / 2) By Bhavin Hingu |
Raw Devices are disk partitions or
logical volumes that have not been formatted with file system. When you
use raw devices for database file storage, Oracle writes data directly
to the partition or
volume, bypassing the operating system file layer. For this reason, you
can sometimes achieve performance gains by using raw
devices. However, because raw devices can be difficult to create and
administer, and because the performance gains over the
modern are minimal, Oracle recommends that you choose Automatic Storage
Management (ASM) or file system storage in preference
to raw devices.
Tasks covered:
Please goto "creating
paritions" to create the partitions. It is preferable to use single-whole
disk partition (e.g /dev/sda)
instead of multi-partitioned disk (e.g, /dev/sda3)
Creating
Volume Group oracle_vg
and
Logical Volumes under this group:
The
partition table
looks like below. I have used /dev/sda3
partition where Logival Volumes will be created using LVM
(Logical Volume Manager).
we need to stamp the raw disk or partition
(In our example /dev/sda3) to be recognised as Volume Group disk.
We execute the pvcreate command as root to stamp the disk.
[root@shree
~]# pvcreate -d /dev/sda3
Number | Partition Size (MB) | Purpose |
---|---|---|
1 | 500 | SYSTEM tablespace |
1 | 500 | SYSAUX tablespace |
1 | 500 | UNDOTBS1 tablespace |
1 | 250 | TEMP tablespace |
1 | 160 | EXAMPLE tablespace |
1 | 120 | USERS tablespace |
3 | 120 | Three online redo log files |
3 | 110 | First and third control files |
1 | 5 | Server parameter file (SPFILE) |
1 | 5 | Password file |
/usr/bin/raw /dev/raw/raw11 oracle_vg/lvol0 # test db -- SYSAUX Tablespace
/usr/bin/raw /dev/raw/raw12 oracle_vg/lvol1 # test db -- UNDOTBS1
/usr/bin/raw /dev/raw/raw13 oracle_vg/lvol2 # test db -- TEMP tablespace
/usr/bin/raw /dev/raw/raw14 oracle_vg/lvol3 # test db -- EXAMPLE tablespace
/usr/bin/raw /dev/raw/raw15 oracle_vg/lvol4 # test db -- USERS tablespace
/usr/bin/raw /dev/raw/raw16 oracle_vg/lvol5 # test db -- redo1_1.log
/usr/bin/raw /dev/raw/raw17 oracle_vg/lvol6 # test db -- redo1_2.log
/usr/bin/raw /dev/raw/raw18 oracle_vg/lvol7 # test db -- redo1_3.log
/usr/bin/raw /dev/raw/raw19 oracle_vg/lvol8 # test db -- control1
/usr/bin/raw /dev/raw/raw20 oracle_vg/lvol9 # test db -- control2
/usr/bin/raw /dev/raw/raw21 oracle_vg/lvol10 # test db -- control2
/usr/bin/raw /dev/raw/raw22 oracle_vg/lvol11 # test db -- spfile
/usr/bin/raw /dev/raw/raw23 oracle_vg/lvol12 # test db -- pwfile
/usr/bin/raw /dev/raw/raw24 oracle_vg/lvol13 # test db -- SYSTEM Tablespace
Also,
you need to change the ownership of these devices to oracle user. Raw
devices are refreshed with the default
permissions
and ownership every time you reboot your system. For this reason, I
add these lines to the /etc/rc.local so
that
every time machine reboots, this devices are assigned correct
ownership/permissionsPlease
add the below lines
to the /etc/rc.local
for
i in `seq 1 25`
do
chown
oracle:dba /dev/raw/raw$i
chmod
600 /dev/raw/raw$i
done
Creating dbca Raw Device Mapping File:
Creating Required
directories:
Create a database file subdirectory
under the Oracle base directory and set the appropriate owner, group
and permissions on it.
[oracle@shree
~]$ mkdir -p $ORACLE_BASE/oradata/test
[oracle@shree
~]$ chown -R orcale:oinstall $ORACLE_BASE/oradata
[oracle@shree
~]$ chmod -R 755 $ORACLE_BASE/oradata
[oracle@shree
~]$ cd $ORACLE_BASE/oradata/test
Creating
config file:
Create
the test_raw.conf file
under $ORACLE_BASE/oradata/test directory and add the below
lines in it. This file is required by dbca when you
create the data using that. Manual method of creating database does not
require this file.
system=/dev/raw/raw24
sysaux=/dev/raw/raw11
undotbs1=/dev/raw/raw12
temp=/dev/raw/raw13
example=/dev/raw/raw14
users=/dev/raw/raw15
redo1_1=/dev/raw/raw16
redo1_2=/dev/raw/raw17
redo1_3=/dev/raw/raw18
control1=/dev/raw/raw19
control2=/dev/raw/raw20
control3=/dev/raw/raw21
spfile=/dev/raw/raw22
pwdfile=/dev/raw/raw23
Linking raw devices: --
This is an OPTIONAL STEP
Optionally,
You can create the
softlink to the raw devices (e.g /dev/raw/raw10) to make this file
recognize easily.
With the softlink created, file
name as well as size can easily be guessed by looking at the link
itself. Follow the
below steps to
create the softlink and use them instead of device name.
[oracle@shree
~]$ ln -s /dev/raw/raw11 $ORACLE_BASE/oradata/test/test_sysaux_raw_520m
[oracle@shree
~]$ ln -s /dev/raw/raw12
$ORACLE_BASE/oradata/test/test_undotbs1_raw_520m
[oracle@shree
~]$ ln -s /dev/raw/raw13 $ORACLE_BASE/oradata/test/test_temp_raw_270m
[oracle@shree
~]$ ln -s /dev/raw/raw14 $ORACLE_BASE/oradata/test/test_example_raw_170m
[oracle@shree
~]$ ln -s /dev/raw/raw15 $ORACLE_BASE/oradata/test/test_users_raw_130m
[oracle@shree
~]$ ln -s /dev/raw/raw16 $ORACLE_BASE/oradata/test/test_redo1_1_raw_130m
[oracle@shree
~]$ ln -s /dev/raw/raw17 $ORACLE_BASE/oradata/test/test_redo1_2_raw_130m
[oracle@shree
~]$ ln -s /dev/raw/raw18 $ORACLE_BASE/oradata/test/test_redo1_3_raw_130m
[oracle@shree
~]$ ln -s /dev/raw/raw19
$ORACLE_BASE/oradata/test/test_control1_raw_130m
[oracle@shree
~]$ ln -s /dev/raw/raw20 $ORACLE_BASE/oradata/test/test_control2_raw_130m
[oracle@shree
~]$ ln -s /dev/raw/raw21 $ORACLE_BASE/oradata/test/test_control3_raw_130m
[oracle@shree
~]$ ln -s /dev/raw/raw22 $ORACLE_BASE/oradata/test/test_spfile_raw_8m
[oracle@shree
~]$ ln -s /dev/raw/raw23 $ORACLE_BASE/oradata/test/test_pwdfile_raw_8m
[oracle@shree
~]$ ln -s /dev/raw/raw24 $ORACLE_BASE/oradata/test/test_system_raw_520m
Now create the test_raw.conf
file under $ORACLE_BASE/oradata/test directory and add the below
lines in it.
system=/u01/app/oradata/test/test_system_raw_520m
sysaux=/u01/app/oradata/test/test_sysaux_raw_520m
undotbs1=/u01/app/oradata/test/test_undotbs1_raw_520m
temp=/u01/app/oradata/test/test_temp_raw_270m
example=/u01/app/oradata/test/test_example_raw_170m
users=/u01/app/oradata/test/test_users_raw_130m
redo1_1=/u01/app/oradata/test/test_redo1_1_raw_130m
redo1_2=/u01/app/oradata/test/test_redo1_2_raw_130m
redo1_3=/u01/app/oradata/test/test_redo1_3_raw_130m
control1=/u01/app/oradata/test/test_control1_raw_130m
control2=/u01/app/oradata/test/test_control2_raw_130m
control3=/u01/app/oradata/test/test_control3_raw_130m
spfile=/u01/app/oradata/test/test_spfile_raw_8m
pwdfile=/u01/app/oradata/test/test_pwdfile_raw_8m
Connect as a oracle user andf update
the .bash_profile file with the new variable DBCA_RAW_CONFIG added into
this. Again, this parameter is required
if you create the database through
dbca.
The updated file should look like
this:
Once you complete the former steps
(except creating config file and creating links), you are ready to
create database manually.
Please follow the below steps.
[oracle@shree
~]$ mkdir -p $ORACLE_BASE/admin/test
[oracle@shree
~]$ cd $ORACLE_BASE/admin/test
[oracle@shree test]$ mkdir bdump
[oracle@shree test]$ mkdir udump
[oracle@shree test]$ mkdir cdump
[oracle@shree test]$ mkdir pfile
Using
vi editor or any other editor you like, create the init+test.ora file
under the $ORACLE_HOME/dbs
directory
and add the below lines into this file.
db_cache_size=88080384
java_pool_size=4194304
large_pool_size=4194304
shared_pool_size=67108864
streams_pool_size=0
audit_file_dest='/u01/app/admin/test/adump'
background_dump_dest='/u01/app/admin/test/bdump'
compatible='10.2.0.1.0'
control_files='/dev/raw/raw19','/dev/raw/raw20','/dev/raw/raw21'
core_dump_dest='/u01/app/admin/test/cdump'
db_block_size=8192
db_domain=''
db_file_multiblock_read_count=16
db_name='test'
db_recovery_file_dest='/u01/app/flash_recovery_area'
db_recovery_file_dest_size=2147483648
dispatchers='(PROTOCOL=TCP) (SERVICE=testXDB)'
job_queue_processes=10
open_cursors=300
pga_aggregate_target=16777216
processes=150
remote_login_passwordfile='EXCLUSIVE'
sga_target=167772160
undo_management='AUTO'
undo_tablespace='UNDOTBS1'
user_dump_dest='/u01/app/admin/test/udump'
[oracle@shree
~]$ export ORACLE_SID=test
[oracle@shree
~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 8 22:06:29 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> create spfile from pfile;
File created.
Now ruu the $ORACLE_HOME/rdbms/admin/catalog.sql and $ORACLE_HOME/rdbms/admin/catproc.sql.