Oracle Automatic Storage Management (ASM) on Red Hat Linux (using ASMlib)

As a first step we need to install support ASM libraries to configure the ASM. This library is provided to enable ASM I/O to Linux disks without the limitations of the standard Unix I/O API.

The ASMLib software is available from the Oracle Technology Network at http://www.oracle.com/technology/tech/linux/asmlib/index.html

The oracleasmlib package provides the actual ASM library. The oracleasm-support package provides the utilities used to get the ASM driver up and running. Both of these packages need to be installed.

The remaining packages provide the kernel driver for the ASM library. Each package provides the driver for a different kernel. You must install the appropriate package for the kernel you are running. Use the “uname -r command to determine the version of the kernel. The oracleasm kerel driver package will have that version string in its name. For example, if you were running Red Hat Enterprise Linux 4 AS, and the kernel you were using was the 2.6.9-5.0.5.ELsmp kernel, you would choose the oracleasm-2.6.9-5.0.5-ELsmp package. So, to install these packages on RHEL4 on an Intel x86 machine, you might use the command:

[root@ssk ~]# rpm -Uvh oracleasm-support-2.1.3-1.el5.i386.rpm
[root@ssk ~]# rpm -Uvh oracleasm-2.6.18-53.el5PAE-2.0.4-1.el5.i686.rpm
[root@ssk ~]# rpm -Uvh oracleasmlib-2.0.4-1.el5.i386.rpm

 If you were on a different machine, the package names would be slightly different, replacing ‘i686′ with the appropriate architecture. Use the package names relevant for your distribution.

NOTE: Distributions with the Linux 2.4 kernel still use the 1.0 kernel driver, while distributions based on the Linux 2.6 kernel use the 2.0 kernel driver. All distributions use version 2.0 of the support and library packages. See the driver matrix for more information.

Once the above steps are completed, ASMLib is now installed on the system.

 Next step is to Configure the Oracle ASM library driver:

Run the /etc/init.d/oracleasm script with the ‘configure’ option. It will ask for the user and group that default to owning the ASM driver access point. If the database was running as the ‘oracle’ user and the ‘dba’ group, the output would look like this:

[root@ssk ~]# /etc/init.d/oracleasm configure

Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets (‘[]‘).  Hitting <ENTER> without typing an
answer will keep that current value.  Ctrl-C will abort. 

Default user to own the driver interface [oracle]:
Default group to own the driver interface [dba]:
Start Oracle ASM library driver on boot (y/n) [y]:
Scan for Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:                               [  OK  ]
Scanning the system for Oracle ASMLib disks:               [  OK  ]

[root@ssk ~]#

This should load the oracleasm.o driver module and mount the ASM driver filesystem. By selecting enabled = ‘y’ during the configuration, the system will always load the module and mount the filesystem on boot.

NOTE: Reference: Oracle documentation: http://www.oracle.com/technology/tech/linux/asmlib/install.html

While configuring Oracle ASM if you are getting the following error:

Initializing the Oracle ASMLib driver:                                  [FAILED]

There could be two reasons:

  1. RPM installed for ASMLIB are not correct: Check and reinstall the correct version.
    1. a.      Use the following links:
      http://www.oracle.com/technology/tech/linux/asmlib/install.html
      http://www.oracle.com/technology/tech/linux/asmlib/index.html
  2. Other reason could be: — SELinux is turned on

SELinux would bring trouble for Oracle ASMLib, not only this, it played OCFS, OEM grid control, Oracle cluster service as well. Turn it off by disabling it. Oracle will not complain.

Solution:
Turn off SELinux or put it in permssive mode.

How-to:
1) Go to modify /etc/selinux/config in redhat or /boot/grub/grub.conf in other linux with GRUB boot loader. It looks like this:

# SELINUX= can take one of these three values:
#       enforcing – SELinux security policy is enforced.
#       permissive – SELinux prints warnings instead of enforcing.
#       disabled – SELinux is fully disabled.
SELINUX=enforcing —> change it to SELINUX=disabled

2) Reboot server to take it effect

You can set up it into permissive mode right away without reboot.

 Usage: setenforce [ Enforcing | Permissive | 1 | 0 ]

 The automatic start can be enabled or disabled with the ‘enable’ and ‘disable’ options to /etc/init.d/oracleasm:

[root@ssk ~]# /etc/init.d/oracleasm disable

[root@ssk ~]# /etc/init.d/oracleasm enable

 

[root@ssk ~]# /etc/init.d/oracleasm disable
Writing Oracle ASM library driver configuration: done
Dropping Oracle ASMLib disks:                                                   [  OK  ]
Shutting down the Oracle ASMLib driver:                              [  OK  ]

 [root@ssk ~]# /etc/init.d/oracleasm enable
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:                                       [  OK  ]
Scanning the system for Oracle ASMLib disks:                       [  OK  ]

[root@ssk ~]#

 Next step is of making Disks Available to ASMLib

To create a Disk Group

[root@ssk ~]# /etc/init.d/oracleasm  createdisk VOL1 /dev/hdc11
Marking disk “/dev/hdc11″ as an ASM disk: [ OK ]
[root@ssk ~]# /etc/init.d/oracleasm  createdisk VOL1 /dev/hdc12
Marking disk “/dev/hdc12″ as an ASM disk: [ OK ]
[root@ssk ~]# /etc/init.d/oracleasm  createdisk VOL1 /dev/hdc13
Marking disk “/dev/hdc13″ as an ASM disk: [ OK ]

Note: If above commands fails then please make sure the disk that you are specifying is not already being used or not already mounted:

To Delete a Disk Group

[root@ssk ~]# /etc/init.d/oracleasm  deletedisk VOL1
Deleting Oracle ASM disk “VOL1″ [ OK ]

To query the disks

[root@ssk ~]# /etc/init.d/oracleasm querydisk /dev/hdc11
Device “/dev/hdc11″ is marked an ASM disk with the label “VOL1″

[root@ssk ~]# /etc/init.d/oracleasm querydisk /dev/hdc12
Device “/dev/hdc12″ is marked an ASM disk with the label “VOL2″

[root@ssk ~]# /etc/init.d/oracleasm querydisk /dev/hdc13
Device “/dev/hdc13″ is marked an ASM disk with the label “VOL3″

[root@ssk ~]# /etc/init.d/oracleasm querydisk /dev/hdc10
Device “/dev/hdc10″ is not marked as an ASM disk

 [root@ssk ~]# /etc/init.d/oracleasm querydisk VOL1
Disk “VOL1″ is a valid ASM disk

[root@ssk ~]# /etc/init.d/oracleasm querydisk VOL4
Disk “VOL4″ does not exist or is not instantiated

[root@ssk ~]#

To list and query the existing disks

[root@ssk ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3

# /etc/init.d/oracleasm querydisk VOL1
Disk “VOL1″ is a valid ASM disk on device [8, 2]

 When a disk is added to a RAC setup, the other nodes need to be notified about it. Run the ‘createdisk’ command on one node, and then run ’scandisks’ on every other node:

  [root@ca-test1 /]# /etc/init.d/oracleasm scandisks
  Scanning system for ASM disks                              [  OK  ]
We are now done with installation and configuration of ASMLib on Linux platform.

 Creating New Oracle ASM Instance:

 Create the password file:

[oracle@ssk ~]$ orapwd file=$ORACLE_HOME/dbs/orapw+ASM password=changeIt entries=5

Create required directories:

[oracle@ssk ~]$ mkdir -p $ORACLE_BASE/admin/+ASM
[oracle@ssk ~]$ cd $ORACLE_BASE/admin/+ASM
[oracle@ssk +ASM]$ mkdir bdump
[oracle@ssk +ASM]$ mkdir udump
[oracle@ssk +ASM]$ mkdir cdump
[oracle@ssk +ASM]$ mkdir pfile
 

Create the init+ASM.ora file:

Using vi editor or any other editor you like, create the init+ASM.ora file under the $ORACLE_HOME/dbs
directory and add the below lines into this file.

asm_diskgroups=’DATA_GRP’
asm_diskstring=’ORCL:*’
background_dump_dest=’/u01/app/admin/+ASM/bdump’
core_dump_dest=’/u01/app/admin/+ASM/cdump’
instance_type=’asm’
large_pool_size=12M
remote_login_passwordfile=’SHARED’
user_dump_dest=’/u01/app/admin/+ASM/udump’

[oracle@ssk ~]$ cat $ORACLE_HOME/dbs/init+ASM.ora
asm_diskgroups=’PROD_DB_GRP’
asm_diskstring=’ORCL:*’
background_dump_dest=’/u01/app/admin/+ASM/bdump’
core_dump_dest=’/u01/app/admin/+ASM/cdump’
instance_type=’asm’
large_pool_size=12M
remote_login_passwordfile=’SHARED’
user_dump_dest=’/u01/app/admin/+ASM/udump’
[oracle@ssk ~]$

 

Create spfile+ASM.ora and start the instance using that file:

[oracle@ssk ~]$ export ORACLE_SID=+ASM
[oracle@ssk ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 – Production on Sun Dec 4 21:17:35 2005

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> create spfile from pfile;

File created.

SQL> startup mount

ASM instance started
Total System Global Area 83886080 bytes
Fixed Size 1217836 bytes
Variable Size 57502420 bytes
ASM Cache 25165824 bytes
ORA-15032: not all alterations performed
ORA-15063: ASM discovered an insufficient number of disks for diskgroup
“DATA_GRP”

 

SQL> show parameter disk
 NAME                                 TYPE        VALUE
———————————— ———– ——————————
asm_diskgroups                     string      DATA_GRP
asm_diskstring                       string      ORCL:*
disk_asynch_io                       boolean     TRUE

                         

SQL> create diskgroup data_grp
failgroup f1 disk ‘ORCL:DSK1′
failgroup f2 disk ‘ORCL:DSK2′;

 Diskgroup created.   

 

SQL> set linesize 100
SQL> col name format a15
SQL> col path format a15
SQL> select name, path from v$asm_disk where name is not null;

NAME            PATH
————— —————
DSK1            ORCL:DSK1
DSK2            ORCL:DSK2

 

SQL> select name, type, total_mb, free_mb from v$asm_diskgroup;

    NAME            TYPE     TOTAL_MB   FREE_MB
    ————— —— ———- ———-
    DATA_GRP        NORMAL      59999      59897