In Oracle 10g, there are 3 options to storage datafiles:
1. Filesystem
2. RAW disk
3. Automatic Storage Management (ASM)
ASM is a new feature that has be introduced in Oracle 10g to simplify the storage of Oracle datafiles, log files and control files. Oracle Managed Files (OMF) will be use if ASM is chosen as storage method.
But, how to prepare the disk from scratch? In this example, I assumed that disk already can be detect using fdisk command in OS level. I am using VMWare to prepare this example.
How many hard disk am I used?
2 hard disk (virtual) :
/dev/sda – 30GB for OS
/dev/sdb – 20GB for ASM; I will slice this disk to 4 parts (sdb1, sdb2, sdb3, sdb4). Yes I know this is not the best practice for production purpose. In production should have at least 2 different disk (sdb1, sdb2 and sdc1, sdc2) for normal redundancy. But for example purpose, should be okay.
Prepare the disks
1. As root user, list disks using fdisk command to identify which disk will be used.
# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3916 31350847+ 8e Linux LVM
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
So, I used /dev/sdb to create ASM
2. Then, format and slice disk to 4 parts. So each part will have 5 GB.
# fdisk /dev/sdb
3. Then press m to list the menus
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
4. Then press n to create new partition and choose p for primary partition (1 disk can create up to 4 primary partitions)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
5. Put +5000M (5.0GB) for the first partition
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +5000M
Command (m for help): p
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 609 4891761 83 Linux
6. Repeat step 4 and 5 with different partition number in step 4. Make sure the result as show below:
Command (m for help): p
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 609 4891761 83 Linux
/dev/sdb2 610 1218 4891792+ 83 Linux
/dev/sdb3 1219 1827 4891792+ 83 Linux
/dev/sdb4 1828 2610 6289447+ 83 Linux
Alternatively, can use cylinder number in step 5 instead of entering the size in Megabytes. If use cylinder number instead of Megabytes, the result is like:
Command (m for help): p
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 652 5237158+ 83 Linux
/dev/sdb2 653 1305 5245222+ 83 Linux
/dev/sdb3 1306 1958 5245222+ 83 Linux
/dev/sdb4 1959 2610 5237190 83 Linux
7. Then, if everything goes fine, press w to write the partition table
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Create Disk for ASM Usage by Using oracleasm
1. Configure the oracleasm
/etc/init.d/oracleasm configure
2. Answer the questions with the following answer
Default user to own the driver interface []: oracle (or equivalent user)
Default group to own the driver interface []: oinstall (or equivalent group)
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
3. Then create the disk for ASM usage. I used “ASMDISK<number>” as the disk naming, but actually can be any name instead of “ASMDISK01″, “ASMDISK02″,…. It can be “MYDISK01″ or “DATA01″ or anything else.
# /etc/init.d/oracleasm createdisk ASMDISK01 /dev/sdb1
Marking disk "ASMDISK01" as an ASM disk: [ OK ]
#
# /etc/init.d/oracleasm createdisk ASMDISK02 /dev/sdb2
Marking disk "ASMDISK02" as an ASM disk: [ OK ]
#
# /etc/init.d/oracleasm createdisk ASMDISK03 /dev/sdb3
Marking disk "ASMDISK03" as an ASM disk: [ OK ]
#
# /etc/init.d/oracleasm createdisk ASMDISK04 /dev/sdb4
Marking disk "ASMDISK04" as an ASM disk: [ OK ]
4. Check the disk
# oracleasm listdisks
ASMDISK01
ASMDISK02
ASMDISK03
ASMDISK04
5. If the ASM is for the Oracle Real Application Cluster (RAC) purpose, there are additional steps to do on each node
# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
Instantiating disk "ASMDISK01"
Instantiating disk "ASMDISK02"
Instantiating disk "ASMDISK03"
Instantiating disk "ASMDISK04"
Okay, that’s a bit about how to prepare the disk for ASM usage. I don’t really care if you guys understand or not..muahahaha..:D
linux, Oracle, Red Hat Enterprise Linux 5, RHEL5, Technology, vmware Oracle, Software, Technology