Configurando RAWDEVICES para Oracle ASM non-RAC

O objetivo deste artigo é explicar como criar o ASM pelo rawdevices com partições de um único disco.
Podemos criar várias partições com vários discos, porém estarei utilizando apenas um disco.
OBS: O recomendado é que se tenha vários discos para o uso do ASM para a alta disponibilidade dos dados.

Vamos criar no linux as partições para definirmos os rawdevices para o uso do Oracle ASM.
OBS: No fdisk do linux para criar uma partição entre com a letra “n” e após criar as mesmas digite “w” para atualizar a tabela das partições.
Para ver a lista completa dos comandos do fdisk digite a letra “m” para ajuda.

[root@serveroracle ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 5221.
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)

Command (m for help): p

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          16      128488+  83  Linux
/dev/sda2              17        1321    10482412+  83  Linux
/dev/sda3            1322        2365     8385930   83  Linux
/dev/sda4            2366        5221    22940820    5  Extended
/dev/sda5            2366        2757     3148708+  82  Linux swap / Solaris

Command (m for help): n
First cylinder (2758-5221, default 2758):
Using default value 2758
Last cylinder or +size or +sizeM or +sizeK (2758-5221, default 5221): 3408

Command (m for help): n
First cylinder (3409-5221, default 3409):
Using default value 3409
Last cylinder or +size or +sizeM or +sizeK (3409-5221, default 5221): 4059

Command (m for help): n
First cylinder (4060-5221, default 4060):
Using default value 4060
Last cylinder or +size or +sizeM or +sizeK (4060-5221, default 5221): 4710

Command (m for help): n
First cylinder (4711-5221, default 4711):
Using default value 4711
Last cylinder or +size or +sizeM or +sizeK (4711-5221, default 5221):
Using default value 5221

Command (m for help): p

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          16      128488+  83  Linux
/dev/sda2              17        1321    10482412+  83  Linux
/dev/sda3            1322        2365     8385930   83  Linux
/dev/sda4            2366        5221    22940820    5  Extended
/dev/sda5            2366        2757     3148708+  82  Linux swap / Solaris
/dev/sda6            2758        3408     5229126   83  Linux
/dev/sda7            3409        4059     5229126   83  Linux
/dev/sda8            4060        4710     5229126   83  Linux
/dev/sda9            4711        5221     4104576   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@serveroracle ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          16      128488+  83  Linux
/dev/sda2              17        1321    10482412+  83  Linux
/dev/sda3            1322        2365     8385930   83  Linux
/dev/sda4            2366        5221    22940820    5  Extended
/dev/sda5            2366        2757     3148708+  82  Linux swap / Solaris
/dev/sda6            2758        3408     5229126   83  Linux
/dev/sda7            3409        4059     5229126   83  Linux
/dev/sda8            4060        4710     5229126   83  Linux
/dev/sda9            4711        5221     4104576   83  Linux
[root@serveroracle ~]# cat /proc/partitions
major minor  #blocks  name

   8     0   41943040 sda
   8     1     128488 sda1
   8     2   10482412 sda2
   8     3    8385930 sda3
   8     4          1 sda4
   8     5    3148708 sda5
[root@serveroracle ~]#

Vamos agora reinicializar o Linux para que as partições criadas façam efeitos.

[root@serveroracle ~]# reboot

Broadcast message from root (pts/2) (Sat Oct 15 11:53:30 2011):

The system is going down for reboot NOW!
[root@serveroracle ~]#
login as: root
root@192.168.56.102's password:
Last login: Sat Oct 15 11:36:05 2011 from 192.168.56.101
[root@serveroracle ~]# cat /proc/partitions
major minor  #blocks  name

   8     0   41943040 sda
   8     1     128488 sda1
   8     2   10482412 sda2
   8     3    8385930 sda3
   8     4          1 sda4
   8     5    3148708 sda5
   8     6    5229126 sda6
   8     7    5229126 sda7
   8     8    5229126 sda8
   8     9    4104576 sda9
[root@serveroracle ~]#

Pronto criamos as partições no linux. Agora vamos criar os rawdevices de tais partições para implementarmos o Oracle ASM.
Vamos ver novamente as partições e vamos utilizar as partições criadas para usar nas rawdevices.

[root@serveroracle ~]# cat /proc/partitions
major minor  #blocks  name

   8     0   41943040 sda
   8     1     128488 sda1
   8     2   10482412 sda2
   8     3    8385930 sda3
   8     4          1 sda4
   8     5    3148708 sda5
   8     6    5229126 sda6
   8     7    5229126 sda7
   8     8    5229126 sda8
   8     9    4104576 sda9
[root@serveroracle ~]# vi /etc/sysconfig/rawdevices
[root@serveroracle ~]# cat /etc/sysconfig/rawdevices
# raw device bindings
# format:  <rawdev> <major> <minor>
#          <rawdev> <blockdev>
# example: /dev/raw/raw1 /dev/sda1
#          /dev/raw/raw2 8 5
/dev/raw/raw1 /dev/sda6
/dev/raw/raw2 /dev/sda7
/dev/raw/raw3 /dev/sda8
/dev/raw/raw4 /dev/sda9
[root@serveroracle ~]#

Vamos reiniciar o serviço “rawdevices”.

[root@serveroracle ~]# service rawdevices restart
Assigning devices:
           /dev/raw/raw1  -->   /dev/sda6
/dev/raw/raw1:  bound to major 8, minor 6
           /dev/raw/raw2  -->   /dev/sda7
/dev/raw/raw2:  bound to major 8, minor 7
           /dev/raw/raw3  -->   /dev/sda8
/dev/raw/raw3:  bound to major 8, minor 8
           /dev/raw/raw4  -->   /dev/sda9
/dev/raw/raw4:  bound to major 8, minor 9
done
[root@serveroracle ~]#

Vamos agora dar permissões para uso das rawdevices para o usuário “ORACLE”.
OBS: Todas as vezes que iniciar o Linux, será carregado já as permissões para as rawdevices do usuário “ORACLE”.

[root@serveroracle ~]# vi  /etc/rc.local
[root@serveroracle ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
chown oracle:dba /dev/raw/raw1
chown oracle:dba /dev/raw/raw2
chown oracle:dba /dev/raw/raw3
chown oracle:dba /dev/raw/raw4
chmod 600 /dev/raw/raw1
chmod 600 /dev/raw/raw2
chmod 600 /dev/raw/raw3
chmod 600 /dev/raw/raw4
[root@serveroracle ~]#

Vamos criar o serviço Oracle CSS para utilizarmos o Oracle ASM. Na figura 3 abaixo caso o serviço não esteja criado, ocorre erro ao criar o ASM.

[root@serveroracle ~]# /u01/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 90 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.
        serveroracle
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
[root@serveroracle ~]# 

Vamos listar as rawdevices.

[root@serveroracle ~]# ls -l /dev/raw/raw*
crw------- 1 root root 162, 1 Oct 15 12:55 /dev/raw/raw1
crw------- 1 root root 162, 2 Oct 15 12:55 /dev/raw/raw2
crw------- 1 root root 162, 3 Oct 15 12:55 /dev/raw/raw3
crw------- 1 root root 162, 4 Oct 15 12:55 /dev/raw/raw4
[root@serveroracle ~]# su - oracle
[oracle@serveroracle ~]$ ls -l /dev/raw/raw*
crw------- 1 oracle dba 162, 1 Oct 15 12:59 /dev/raw/raw1
crw------- 1 oracle dba 162, 2 Oct 15 12:59 /dev/raw/raw2
crw------- 1 oracle dba 162, 3 Oct 15 12:59 /dev/raw/raw3
crw------- 1 oracle dba 162, 4 Oct 15 12:59 /dev/raw/raw4
[oracle@serveroracle ~]$

Agora vamos criar a Instância ASM com as rawdevices configuradas.

%name Configurando RAWDEVICES para Oracle ASM non RAC

Autor: Maycon Tomiasi

Formado em Tecnologia da Informação na FIPP (Faculdade de Informática de Presidente Prudente), Analista DBA Oracle pela Teiko Soluções em Tecnologia da Informação, residente em Blumenau/ SC, Certificado OCP 10g/11g/12c, OCS 11g Implementation, OCE 11g Performance Tuning, OCE 11g RAC & GRID e OPN Specialist. Conhecimentos em PHP.