VmWare Linux ASM Disk Create

Vmware üzerinde tek disk yapısında, ASM disk mimarisini oluşturmak için gerekli olan işlem sırası aşağıdaki gibidir;

1. Creating the ASM environment
To exceed the default losetup loopback limit of eight loopback devices, as OS user root, add the following line to /etc/modprobe.conf, then reboot:
options loop max_loop=32

For the initial setup of the ASM Disks, execute these commands as OS user root:
# Create the directory in which the flat files will reside

mkdir -p /u01/asmdisks

# Create the flat files which will represent disks

dd if=/dev/zero of=/u01/asmdisks/_file_disk_01 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_02 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_03 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_04 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_05 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_06 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_07 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_08 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_09 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_10 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_11 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_12 bs=1k count=2359296
dd if=/dev/zero of=/u01/asmdisks/_file_disk_13 bs=1k count=2359296

# Make the flat files available as loopback devices

losetup /dev/loop1 /u01/asmdisks/_file_disk_01
losetup /dev/loop2 /u01/asmdisks/_file_disk_02
losetup /dev/loop3 /u01/asmdisks/_file_disk_03
losetup /dev/loop4 /u01/asmdisks/_file_disk_04
losetup /dev/loop5 /u01/asmdisks/_file_disk_05
losetup /dev/loop6 /u01/asmdisks/_file_disk_06
losetup /dev/loop7 /u01/asmdisks/_file_disk_07
losetup /dev/loop8 /u01/asmdisks/_file_disk_08
losetup /dev/loop9 /u01/asmdisks/_file_disk_09
losetup /dev/loop10 /u01/asmdisks/_file_disk_10
losetup /dev/loop11 /u01/asmdisks/_file_disk_11
losetup /dev/loop12 /u01/asmdisks/_file_disk_12
losetup /dev/loop13 /u01/asmdisks/_file_disk_13

# Alias the loopback devices to make them look like virtual block devices (VBDs).
# The naming convention /dev/xvd was chosen so no course material would
# require modification when the course is eventually moved to a VM environment and
# the solution is implemented with VBDs.

ln -s /dev/loop1 /dev/xvdb
ln -s /dev/loop2 /dev/xvdc
ln -s /dev/loop3 /dev/xvdd
ln -s /dev/loop4 /dev/xvde
ln -s /dev/loop5 /dev/xvdf
ln -s /dev/loop6 /dev/xvdg
ln -s /dev/loop7 /dev/xvdh
ln -s /dev/loop8 /dev/xvdi
ln -s /dev/loop9 /dev/xvdj
ln -s /dev/loop10 /dev/xvdk
ln -s /dev/loop11 /dev/xvdl
ln -s /dev/loop12 /dev/xvdm
ln -s /dev/loop13 /dev/xvdn

# Change ownership to oracle:oinstall
# Change permissions to 666

chown -R oracle:oinstall /u01/asmdisks
chmod -R 666 /u01/asmdisks

chown oracle:oinstall /dev/loop[1-9]
chown oracle:oinstall /dev/loop1[0-3]
chmod 666 /dev/loop[1-9]
chmod 666 /dev/loop1[0-3]

2. Making the ASM environment persistent across reboot:

On startup, losetup must be executed to allocate the loopback devices. On shutdown, losetup must be executed to deallocate loopback devices. Failing to explicitly deallocate the loopback device can cause a shutdown/reboot to take longer.
A new service will be created to handle this task. Vi file /etc/init.d/losetup. In the file place the following:
#!/bin/sh
#
# chkconfig: 345 13 89
# description: Allocates the flat files in /u01/asmdisks as loopback devices.
# Creates links to those loopback devices to simulate the naming
# convention of Oracle VM Server virtaual block devices.
#
# Source function library.
. /etc/init.d/functions

PATH=/sbin:/bin:/usr/sbin:/usr/bin

RETVAL=0

start()
{

losetup /dev/loop1 /u01/asmdisks/_file_disk_01
losetup /dev/loop2 /u01/asmdisks/_file_disk_02
losetup /dev/loop3 /u01/asmdisks/_file_disk_03
losetup /dev/loop4 /u01/asmdisks/_file_disk_04
losetup /dev/loop5 /u01/asmdisks/_file_disk_05
losetup /dev/loop6 /u01/asmdisks/_file_disk_06
losetup /dev/loop7 /u01/asmdisks/_file_disk_07
losetup /dev/loop8 /u01/asmdisks/_file_disk_08
losetup /dev/loop9 /u01/asmdisks/_file_disk_09
losetup /dev/loop10 /u01/asmdisks/_file_disk_10
losetup /dev/loop11 /u01/asmdisks/_file_disk_11
losetup /dev/loop12 /u01/asmdisks/_file_disk_12
losetup /dev/loop13 /u01/asmdisks/_file_disk_13

ln -s /dev/loop1 /dev/xvdb
ln -s /dev/loop2 /dev/xvdc
ln -s /dev/loop3 /dev/xvdd
ln -s /dev/loop4 /dev/xvde
ln -s /dev/loop5 /dev/xvdf
ln -s /dev/loop6 /dev/xvdg
ln -s /dev/loop7 /dev/xvdh
ln -s /dev/loop8 /dev/xvdi
ln -s /dev/loop9 /dev/xvdj
ln -s /dev/loop10 /dev/xvdk
ln -s /dev/loop11 /dev/xvdl
ln -s /dev/loop12 /dev/xvdm
ln -s /dev/loop13 /dev/xvdn

chown oracle:oinstall /dev/loop[1-9]
chown oracle:oinstall /dev/loop1[0-3]

chmod 666 /dev/loop[1-9]
chmod 666 /dev/loop1[0-3]

success
echo
}

stop()
{

losetup -d /dev/loop1
losetup -d /dev/loop2
losetup -d /dev/loop3
losetup -d /dev/loop4
losetup -d /dev/loop5
losetup -d /dev/loop6
losetup -d /dev/loop7
losetup -d /dev/loop8
losetup -d /dev/loop9
losetup -d /dev/loop10
losetup -d /dev/loop11
losetup -d /dev/loop12
losetup -d /dev/loop13

rm -f /dev/xvd[b-n]

success
}

case “$1″ in
start)
start
;;
stop)
stop
;;
*)
echo $”Usage: $0 {start|stop}”
exit 1
esac
exit $RETVAL
After creating the file, /etc/init.d/losetup, change the permissions, then use chkconfig to enable the service. As OS user root execute:
chmod 755 /etc/init.d/losetup
chkconfig losetup –add
chkconfig losetup on
chkconfig losetup –list

3. Create a script (such as setupasm.sh) from the following commands then run the script to create the ASM Disks:
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid
oracleasm exit
oracleasm configure -i < oracle
dba
Y
Y
ENDASMCONF
oracleasm exit
oracleasm init
oracleasm createdisk ASMDISK01 /dev/xvdb
oracleasm createdisk ASMDISK02 /dev/xvdc
oracleasm createdisk ASMDISK03 /dev/xvdd
oracleasm createdisk ASMDISK04 /dev/xvde
oracleasm createdisk ASMDISK05 /dev/xvdf
oracleasm createdisk ASMDISK06 /dev/xvdg
oracleasm createdisk ASMDISK07 /dev/xvdh
oracleasm createdisk ASMDISK08 /dev/xvdi
oracleasm createdisk ASMDISK09 /dev/xvdj
oracleasm createdisk ASMDISK10 /dev/xvdk
oracleasm createdisk ASMDISK11 /dev/xvdl
oracleasm createdisk ASMDISK12 /dev/xvdm
oracleasm createdisk ASMDISK13 /dev/xvdn

oracleasm scandisks
oracleasm listdisks