A raw device is simply a disk. Raw files are unformatted disk partitions that can be used
as one large file. It does NOT contain any File System it can still be partitioned.
Raw files have the benefit of no File-System overhead (in order to bypass a File System
overhead or File-System cache) because they are unformatted partitions.
More efficient than cooked files because 10% to 15% we can get performance gain.
It creates all Oracle database files on RAW BLOCK DEVICES managed by ASM using ASMLib
calls. RAW devices are NOT required with this method as ASMLib works with block devices.
ASM WITH STANDARD UNIX I/O
This method creates all Oracle database files on RAW CHARACTER DEVICES managed by ASM using
Standard Linux I/O system calls. You will be required to create RAW devices for all disk
partitions used by ASM.
When we choose RAW devices (for database files) that ASM needs DIRECT access to the device
(it opens the device with a direct I/O flag enabled). No other s/w driver layer involves
that prevents direct I/O and provides some kind of write-through and buffering feature.
In this article, we are going to implement ASM using UNIX IO. Oracle recommends that you
create a Single whole-disk Partition on each disk that you want to use.
DEVICE NAME BASED ON TYPE OF THE DISK
DISK TYPE
DESCRIPTION
SCSI Disk
/dev/sdxn
IDE disk
/dev/hdxn
I am adding 4 virtual disks size of size 10G each and all on different SCSI disk controller.
On VMWare Work Station you can see EDIT VIRTUAL MACHINE SETTINGS (Click it and add hardware
wizard will open). Demo shown for adding 1st disk. Follow same procedure for other 3 disks.
Now you can create remaining 3 disks in the same way as shown in figure above steps.
Once we created required disks, then power on your Virtual machine just above left side of
the VMWARE WORK STATION and login as root # user.
# ls /dev/sd*
/dev/sda
/dev/sda2
/dev/sda4
/dev/sda6
/dev/sda8
/dev/sdc
/dev/sda1
/dev/sda3
/dev/sda5
/dev/sda7
/dev/sdb
/dev/sdd
/dev/sde
sda is our main disk where OS and other apps are installed and sda1 to sda6 are its
partitions. The output from 'cat /proc/partitions' shows they are not partitioned yet.
# cat /proc/partitions
major minor
#blocks
name
85983232 sda
112423 sda1
32764567 sda2
22531162 sda3
1 sda4
10546641 sda5
6144831 sda6
3068383 sda7
10811713 sda8
16
10485760 sdb
32
10485760 sdc
48
10485760 sdd
64
10485760 sde
# fdisk -l |
grep ^Disk
4 disks (sdb, sdc, sdd, sde) are the raw disks that I just added. As of now no partitions,
I would like to create at-least one partition one each disk. Creating single partition on
the whole device is really good because the reason is you have one controller per disk in
this case so as faster IO.
For production environment it is recommended to spread the data over different Physical
disks, to keep IO low for a Single disk. Just spreading data over different mount points
(on the same Physical disk) has no effect. At the end all IO gets to the same disk multiple
partitions on the same Physical spindle will NOT increase your I/O.
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Start
End
Blocks
Id
System
extended
<-----
Primary Partition
<-----
Start
End
Blocks
Id
System
1305
10482381
83
Linux
/dev/sdb1
Command (m for help): w
# fdisk /dev/sdc
# fdisk /dev/sdd
# fdisk /dev/sde
Once you created new partition using fdisk then you need to reboot LINUX based systems to
get partition recognized. The new table will be used at the next reboot. However you can
use partition table changes, by requesting that the operating system re-read the partition
table without reboot by partprobe command.
# partprobe
or
# partprobe /dev/sdb
# partprobe /dev/sdc
# partprobe /dev/sdd
# partprobe /dev/sde
After I partitioned all attached disks, now all attached disks are ready to configure.
Following output shows that i have one partition for every disk.
# cat /proc/partitions
major minor
#blocks
name
85983232 sda
112423 sda1
32764567 sda2
22531162 sda3
1 sda4
10546641 sda5
6144831 sda6
3068383 sda7
10811713 sda8
16
10485760 sdb
17
10482381 sdb1
32
10485760 sdc
33
10482381 sdc1
48
10485760 sdd
49
10482381 sdd1
64
10485760 sde
65
10482381 sde1
We need to bind this partitions with the raw devices on the Linux System. A raw device can
be assigned or bound to block devices such as disk or disk partitions. When a raw device
is bound to a disk, any read or write access to the raw device will perform a raw I/O with
the disk. A raw I/O through the /dev/raw interface bypasses the kernel's block buffer cache
entirely that is normally associated with block devices.
By bypassing the cache it accesses a physical device directly which allows applications
such as Oracle databases to have more control over the I/O to the physical device.
A utility called raw can be used to bind a raw device to an existing block device.The
rawdevices service can only initialize devices named according to the /dev/raw/rawN format.
The service rawdevices allows us to create raw devices in Linux.
# ntsysv
# raw
Usage:
raw /dev/raw/rawN /dev/<blockdev>
# raw /dev/raw/raw1 /dev/sdb1
/dev/raw/raw1:
# raw a
/dev/raw/raw1:
/dev/raw/raw2:
/dev/raw/raw3:
/dev/raw/raw4:
# ls -l /dev/raw/raw*
crw-rw----
crw-rw----
crw-rw----
crw-rw----
brw-rw----
brw-rw----
brw-rw----
/dev/sdb1
We bound raw device with block device via a process called Binding.
SETTING PERMISSIONS
However, raw devices do not have the correct ownership or permissions for an Oracle database
files by default. We have change from root to oracle user (who is going to mange ASM).
crw-rw----
crw-rw----
crw-rw----
Once required raw devices are established, there is a problem every time I restart the
machine 2 things would happen.
1) The binding will disappear; e.g /dev/raw/raw*
2) Even I recreate that binding again default ownership and permissions will be set.
Because these device names are owned by the dev package, each time the package is updated
(for example, as part of an operating system update), all devices are recreated with the
default ownership and permissions at boot. It is therefore necessary to set ownership and
permissions each time the dev package is updated.
To make it persistent after the reboot
1) The raw device(s) binding should auto create itself.
2) The ownership should reset back to oracle:dba for /dev/raw/raw*
For a kernel release (2.6.9), use the /etc/sysconfig/rawdevices file to define the set of
raw device mappings automatically created during the system startup sequence. The format
of the file is the same used in the command line with the exception that the "raw" command
itself is omitted. So I have to map and bind raw partitions to raw device files into the
/etc/sysconfig/rawdevices file and restart the rawdevices service.
# cat /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 8)
# uname -r
2.6.9-89.EL
# vi /etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdc1
/dev/raw/raw3 /dev/sdd1
/dev/raw/raw4 /dev/sde1
/dev/sdc1
-->
/dev/sdd1
/dev/raw/raw4
/dev/raw/raw4:
-->
/dev/raw/raw3
/dev/raw/raw3:
/dev/sdb1
/dev/raw/raw2
/dev/raw/raw2:
-->
-->
/dev/sde1
done
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 have to add following lines into the /etc/rc.local file so that every
time machine reboots, this devices are assigned correct ownership/permissions. First execute
the following commands to set access and ownership on the raw disks for user oracle.
CHANGING OWNER AND PERMISSIONS
# ls -l /dev/raw/raw1 /dev/sdb1
crw-rw----
1 oracle dba
brw-rw----
1 root
disk
162,
# ls -l /dev/raw/raw2 /dev/sdc1
crw-rw----
1 oracle dba
brw-rw----
1 root
disk
162,
# ls -l /dev/raw/raw3 /dev/sdd1
crw-rw----
1 oracle dba
brw-rw----
1 root
162,
disk
# ls -l /dev/raw/raw4 /dev/sde1
crw-rw----
1 oracle dba
brw-rw----
1 root
162,
disk
You can verify newly created partitions using major and minor device number.
# ls -l /dev/* |grep
brw-rw----
'8,
17'
1 root disk
8,
1 root disk
8,
brw-rw----
1 root disk
8,
brw-rw----
1 root disk
8,
brw-rw----
1 root disk
8,
$ cat ora10.env
export ORACLE_BASE=/u02/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl
$ cat asm.env
export ORACLE_BASE=/u02/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=+ASM
Before creating and starting +ASM instance, CSS service must be up and running so in order
to get your CSS service up and running just login as super user (root) run the localconfig
utility from $ORACLE_HOME/bin to start CSS service.
CSS DEAMON
# cd /u02/app/oracle/product/10.2.0/db_1/bin/
# ./localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized
Adding to inittab
Startup will be queued to init within 30 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
rac-server1
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
$ cd /etc/oracle/
[oracle@RAC-SERVER1 oracle]$ ls -l
total 12
-rw-r--r--
1 oracle oinstall
92 Feb
1 01:27 ocr.loc
drwxrwxr-x
5 root
root
4096 Feb
1 01:27 oprocd
drwxr-xr-x
3 root
root
4096 Feb
1 01:27 scls_scr
ocrconfig_loc parameter says the location of the Oracle Cluster Registry (OCR) used by CSS.
local_only = TRUE Means Single node Oracle Instance and FALSE means RAC
2348
2080
0 03:25 ?
00:00:03
/u02/app/oracle/product/10.2.0/db_1/bin/ocssd.bin
CSS is completely ASM dependency. For 10g versions of oracle ASM binaries are shipped
with RDBMS binaries so that CSS is started and running from the $ORACLE_HOME by default.
Running localconfig from $ORACLE_HOME will create a CSS deamon and will work well since
ORACLE_HOME is the same release as ASM_HOME where ASM Instance was configured.
We can configure the CSS to be run from the ASM home too.
To Setup/Remove/Modify a Cluster Synchronization Service daemon docid 369824.1
$ . ./asm.env
Now you can see +ASM Instance has been setup successfully and running.
$ ps -ef | grep asm
oracle
21381
0 16:16 ?
00:00:00 asm_pmon_+ASM
oracle
21383
0 16:16 ?
00:00:00 asm_psp0_+ASM
oracle
21385
0 16:16 ?
00:00:00 asm_mman_+ASM
oracle
21387
0 16:16 ?
00:00:00 asm_dbw0_+ASM
oracle
21389
0 16:16 ?
00:00:00 asm_lgwr_+ASM
oracle
21391
0 16:16 ?
00:00:00 asm_ckpt_+ASM
oracle
21393
0 16:16 ?
00:00:00 asm_smon_+ASM
oracle
21395
0 16:16 ?
00:00:00 asm_rbal_+ASM
oracle
21397
0 16:16 ?
00:00:00 asm_gmon_+ASM
oracle
21438 21434
1 16:20 pts/1
00:00:27
21846 21632
0 17:02 pts/2
$ dbca
21381
0 16:16 ?
00:00:00 asm_pmon_+ASM
oracle
21383
0 16:16 ?
00:00:00 asm_psp0_+ASM
oracle
21385
0 16:16 ?
00:00:00 asm_mman_+ASM
oracle
21387
0 16:16 ?
00:00:00 asm_dbw0_+ASM
oracle
21389
0 16:16 ?
00:00:00 asm_lgwr_+ASM
oracle
21391
0 16:16 ?
00:00:00 asm_ckpt_+ASM
oracle
21393
0 16:16 ?
00:00:00 asm_smon_+ASM
oracle
21395
0 16:16 ?
00:00:00 asm_rbal_+ASM
oracle
21397
0 16:16 ?
00:00:00 asm_gmon_+ASM
oracle
22227
0 17:10 ?
00:00:00 asm_o000_+ASM
oracle
22259
0 17:10 ?
00:00:00 ora_asmb_orcl
oracle
26655 21632
0 17:15 pts/2
21381
0 18:29 ?
00:00:00 asm_pmon_+ASM
oracle
22231
0 19:22 ?
00:00:00 ora_pmon_orcl
oracle
29916 21333
0 20:29 pts/1
$ . ./ora10.env
ORACLE_SID = [oracle] ? orcl
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Feb 1 20:41:55 2016
Copyright (c) 1982, 2010, Oracle.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name from v$datafile;
NAME
-------------------------------------------------------------------------------+ASM_DG_DATA/orcl/datafile/system.256.902682117
+ASM_DG_DATA/orcl/datafile/undotbs1.258.902682117
+ASM_DG_DATA/orcl/datafile/sysaux.257.902682117
+ASM_DG_DATA/orcl/datafile/users.259.902682119
+ASM_DG_DATA/orcl/datafile/example.265.902682395
SQL> select name from v$controlfile;
NAME
-------------------------------------------------------------------------------+ASM_DG_DATA/orcl/controlfile/current.260.902682293
+ASM_DG_FRA/orcl/controlfile/current.256.902682297
SQL> select member from v$logfile;
MEMBER
-------------------------------------------------------------------------------+ASM_DG_DATA/orcl/onlinelog/group_3.263.902682311
+ASM_DG_FRA/orcl/onlinelog/group_3.259.902682313
+ASM_DG_DATA/orcl/onlinelog/group_2.262.902682305
+ASM_DG_FRA/orcl/onlinelog/group_2.258.902682307
+ASM_DG_DATA/orcl/onlinelog/group_1.261.902682301
+ASM_DG_FRA/orcl/onlinelog/group_1.257.902682305
SQL> show parameter db_recovery_file_dest;
NAME
TYPE
VALUE
string
+ASM_DG_FRA
db_recovery_file_dest_size
big integer 2G
$. ./asm.env
$ echo $ORACLE_SID
+ASM
$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Feb 1 20:48:13 2016
Copyright (c) 1982, 2010, Oracle.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYSL> select status from v$instance;
STATUS
-----------STARTED
SYS> show parameter instance_type;
NAME
TYPE
VALUE
string
asm
TYPE
VALUE
string
/u02/app/oracle/product/10.2.0
/db_1/dbs/spfile+ASM.ora
$ cat /tmp/initasm.ora
+ASM.asm_diskgroups='ASM_DG_DATA','ASM_DG_FRA' #Manual Mount
*.asm_diskgroups='ASM_DG_DATA','ASM_DG_FRA'
*.background_dump_dest='/u02/app/oracle/admin/+ASM/bdump'
*.core_dump_dest='/u02/app/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/u02/app/oracle/admin/+ASM/udump'
I Hope this document would help someone to setup ASM based database.
POINTS TO REMEMBER
A raw device can be bound to an existing block device (e.g. a disk) and be used to perform
"raw" IO with that existing block device. Such "raw" IO bypasses the caching that is
normally associated with block device.
Oracle ASMLib is available for Linux; as a kernel module is needed only the supported Linux
distributions, the required RPM packages are downloadable from OTN. You need to pick exact
version that matches to your distribution based on kernel and architecture.
# cat /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 8)
Oracle ASMLib Downloads for Red Hat Enterprise Linux 4 AS
http://www.oracle.com/technetwork/server-storage/linux/downloads/rhel4-092650.html
There are 3 packages that one would normally install as part of ASM:
oracleasm + oracleasm-support + oracleasmlib
# ASM Libraries
oracleasm-support
# uname r
2.6.9-89.EL
Drivers for kernel 2.6.9-89.EL
oracleasm-2.6.9-89.ELxenU-2.0.5-1.el4.i686.rpm
oracleasm-2.6.9-89.ELsmp-2.0.5-1.el4.i686.rpm
oracleasm-2.6.9-89.ELhugemem-2.0.5-1.el4.i686.rpm
oracleasm-2.6.9-89.EL-debuginfo-2.0.5-1.el4.i686.rpm
oracleasm-2.6.9-89.EL-2.0.5-1.el4.i686.rpm
The oracleasm-2.6 package is a kernel driver that ships for various different kind of Linux
kernels that existed under EL 4. But we only need the driver for the kernel we are using
and cannot install the driver for a kernel we do not have installed.
All ASMLib installations require the oracleasmlib & oracleasm-support packages appropriate
for their machine. Library and Tools common for all.
# uname p i
i686 i386
Library and Tools
oracleasm-support-2.1.7-1.el4.i386.rpm
oracleasmlib-2.0.4-1.el4.i386.rpm
uname p
uname i
oracleasmlib-2.0.4-1.el4.i386.rpm
oracleasm-support oracleasm-support-2.1.7-1.el4.i386.rpm
oracleasm kernel driver oracleasm-2.6.9-89.EL-2.0.5-1.el4.i686.rpm
Once you download above packages using ftp upload above all in Linux Server. You need #
(root) privilege to install all downloaded rpms. Install ASMLibs in following order to
avoid package dependency errors make sure you are logged in as # (root) user.
oracleasm-support +
oracleasm + oracleasmlib
oracleasm-support-2.1.7-1.el4.i386.rpm:
V3
DSA
signature:
NOKEY,
key
b38a8516
Preparing...
########################################### [100%]
1:oracleasm-support
########################################### [100%]
########################################### [100%]
1:oracleasm-2.6.9-89.EL
########################################### [100%]
########################################### [100%]
1:oracleasmlib
########################################### [100%]
ID
# /etc/init.d/oracleasm configure -i
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver.
OK
OK
ls -lrt /dev/raw
total 0
crw-rw----
2 14:32 raw1
crw-rw----
2 14:32 raw2
crw-rw----
2 14:32 raw3
crw-rw----
2 14:32 raw4
$ . ./asm.env
$ sqlplus / as sysdba
SYS> ALTER SYSTEM SET asm_diskstring = 'ORCL:VOL*' SCOPE=SPFILE;
System altered.
SYS> shutdown immediate;
ASM diskgroups dismounted
ASM instance shutdown
# ls -lrt /dev/sd*1
brw-rw----
3 01:30 /dev/sde1
brw-rw----
3 01:30 /dev/sdd1
brw-rw----
3 01:30 /dev/sdc1
brw-rw----
3 01:30 /dev/sdb1
We cannot use reatedisk command used to stamp above disks it would fail, so we must issue
the renamedisk command as the root user for each disk.
/etc/init.d/oracleasm renamedisk /dev/sdb1 VOL1
WARNING: Changing the label of an disk marked for ASM is a very dangerous
operation.
ensure that all Oracle and ASM instances have ceased using
this disk.
If you are really sure you wish to change the label and are sure that
all of your Oracle and ASM instances have ceased using the disk,
rerun with the force-renamedisk command.
Renaming disk "/dev/sdb1" to "VOL1":
[FAILED]
We can use the force-renamedisk command (once again, ensure no databases are accessing the
diskgroup prior to doing this.
# /etc/init.d/oracleasm force-renamedisk /dev/sdb1 VOL1
Renaming disk "/dev/sdb1" to "VOL1":
OK
OK
OK
OK
# raw /dev/raw/raw1 0 0
/dev/raw/raw1:
# raw /dev/raw/raw2 0 0
/dev/raw/raw2:
# raw /dev/raw/raw3 0 0
/dev/raw/raw3:
# raw /dev/raw/raw4 0 0
/dev/raw/raw4:
# ls -lrt /dev/raw
ls: /dev/raw: No such file or directory
$ . ./asm.env
$ sqlplus / as sysdba
SYS> startup;
ASM instance started
..
...
ASM diskgroups mounted
$ . ./ora10g.env
$ sqlplus / as sysdba
SYS> startup;
ORACLE instance started.
..
...
Database opened.
SYS> select path from v$asm_disk;
PATH
----------------------------ORCL:VOL1
ORCL:VOL2
ORCL:VOL3
ORCL:VOL4
REFERENCE DOC FROM HERE.