How to create an ASM Disk (or Diskgroup) when using UDEV.

Hi there!

When Google-ing for using UDev instead of ASMLIB, you either end up downloading the same PDF file over and over again (which does contain nice info) or end up at the support site of Red-hat. Which also covers the information on replacing ASMLIB with UDev and the corresponding rules. I’ll not reiterate this information again here, when there are excellent resources out there.  Unless  there is a request made for this, then I might revise this blog post.

Although the documentation is abundant regarding the replacement of ASMLIB and the kernel driver etc, there is one thing the documentation skips on. Or I’m just not seeing it..

Since it’s great to replace the ASMLib with UDev, the documents are all assuming you have either already created the disks with ASMLib and so it already is available in ASM itself, or the documentation stops just at the point when the disks are available to be used as ASM disks..Ergo: the disks are supposedly be ASM available disks, but how to create a new LUN and have this added to the ASM Instance without using the “oracleasm createdisk” command, that is not mentioned. Replacing the ASMLib means you are not really able to fully utilize the oracleasm-support tools. You can still use:

$ oracleasm listdisks

and have the disks listed, but instantiating the oracle disks with “oracleasm scandisks” is out of the question. It needs the kernel module for this. And since the most users will use UDev in favor of ASMLib since they are using an non-oracle supported OS, this will prove to be a challenge to get to work.

So, the question is: how can we create a (new) ASM disk without using oracleasm?

It took me some time to figure this out, but the answer is deceptively easy: we create the disk within the instance of ASM! By utilizing some SQL commands as sysasm user, we can create disk-groups,  add disks to disk-groups etc! These will then be available to manipulate in ASMCA also, which can be in some cases a real nice boon!

Follow this example, and the possibilities/solution will become clear. I assume the UDev rules are in place, no oracleasm-support rpm is installed (so no oracleasm command is available) and and ASM instance (in my case +ASM1) is up and running. Also the usual rules as having the disk partitioned etc also apply.

Be aware: it is possible to just install the oracleasm-support package, but will provide limited functionality..rendering it next to useless.

The disk I need to create a new disk-group on is available in /dev/mapper/udevDisk01. This is a symbolic link, since I also use multi-path.

For sake of argument and example: these are the relevant entries in my multi-path configuration file, and udev rules:

/etc/multipath.conf:
<snip>
multipaths {
multipath {
wwid                    360a98000647549414731232344567724
alias                   dbf_disk_01
}
multipath {
wwid                    360a98000647549414731232344567725
alias                   fra_disk_01
}
</snip>

and my udev rules(/etc/udev/rules.d/20-asm-disk.rules):

KERNEL=="dm*", PROGRAM="scsi_id --page=0x83 --whitelisted --device=/dev/%k",RESULT=="360a98000647549414731232344567724", NAME+="oracleasm/disks/dbf_disk_01", OWNER:="oracle", GROUP:="dba", MODE="0660"
KERNEL=="dm*", PROGRAM="scsi_id --page=0x83 --whitelisted --device=/dev/%k",RESULT=="360a98000647549414731232344567725", NAME+="oracleasm/disks/fra_disk_01", OWNER:="oracle", GROUP:="dba", MODE="0660

Be aware: the user oracle runs my database, so needs to have access to this disk!

If this is not the case,  a lot of errors will notify you on this, but it will not be all to clear the permissions are wrong!

An example of such an error is:

ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15031: disk specification ‘/dev/mapper/fra_disk_01p1’ matches no disks
ORA-15025: could not open disk “/dev/mapper/fra_disk_01p1”
ORA-15056: additional error message
Linux-x86_64 Error: 13: Permission denied
Additional information: 42
Additional information: -1480381840

Log into the ASM instance:

$ export ORACLE_SID=+ASM1
$ rlwrap sqlplus / as sysasm

Alter the disk string, so ASM will know where to look for the disks:

SQL > alter system set asm_diskstring ='ORCL:*','/dev/mapper/*') scope=memory;
System altered.
SQL >

Check if it is correct:

SQL> show parameter asm

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string      
asm_diskstring                       string      /dev/mapper/*
asm_power_limit                      integer     1
asm_preferred_read_failure_groups    string

Create the diskgroup using the block devices created with UDev:

SQL> create diskgroup udevDataDG external redundancy disk '/dev/mapper/dbf_disk_01p1';
Diskgroup created.
SQL >

Again, let’s check:

SQL> select name,state from v$asm_diskgroup ;

NAME                           STATE
------------------------------ -----------
udevDataDG                        MOUNTED

SQL>

or:

SQL> show parameter asm

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string      udevDataDG
asm_diskstring                       string      /dev/mapper/*
asm_power_limit                      integer     1
asm_preferred_read_failure_groups    string

Check the disk and the path:

SQL> select path,library from v$asm_disk;

PATH
--------------------------------------------------------------------------------
LIBRARY
----------------------------------------------------------------
/dev/mapper/dbf_disk_01p1
System

From the SQL prompt all the things (and even more) oracleasm command can/could do, is possible. For instance: adding a disk to the existing disk-group, and re-balance at high power!

I hope you have found here what you where looking for, and it saved you some time.

Hopefully goodbye until the next post!

Advertisements

About GemsOfProgramming

Beeing a previously enthusiastic Java programmer, I rolled into the Oracle Database Administration world. It turned out I got a knack for this, and since approx. 2000 I'm a full time DBA. My experiences touches lot of Oracle products like Forms and Reports 9/10, JDAPI, Application Server, Weblogic Fusion and of course: Oracle Enterprise Databases, JavaFX, Swing and other Java components.
This entry was posted in Databases, Technical Stuff and tagged , , , , . Bookmark the permalink.

2 Responses to How to create an ASM Disk (or Diskgroup) when using UDEV.

  1. salma says:

    Thank youuuuu !!

  2. Pingback: Moving ASMLib disk to block devices (Non-ASMLib : UDEV) in 11g RAC Environment | hiteshgondalia(OCE,OCP)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s