Sunday, August 18, 2013

Solved: asm_version() failed with code 2

Sometimes when executing oracleasm-discover command, after rebooting Linux system we are getting the following error message: 

[root@home ~]# oracleasm-discover
Using ASMLib from /opt/oracle/extapi/64/asm/orcl/1/libasm.so
asm_version() failed with code 2

Steps to solve the problem (root user)

Check if oracleasm is started
root@home ~]# oracleasm status
Checking if ASM is loaded: no
Checking if /dev/oracleasm is mounted: no

Start oracleasm
[root@home ~]# oracleasm init
Creating /dev/oracleasm mount point: /dev/oracleasm
Loading module "oracleasm": oracleasm
Mounting ASMlib driver filesystem: /dev/oracleasm

Try again to execute oracleasm-discover (error doesn't appear again)
[root@home ~]# oracleasm-discover
Using ASMLib from /opt/oracle/extapi/64/asm/orcl/1/libasm.so
[ASM Library - Generic Linux, version 2.0.4 (KABI_V2)]

Execute oracleasm scandisks
[root@home ~]# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
Instantiating disk "DSK03"
Instantiating disk "DSK01"
Instantiating disk "DSK02"

Execute oracleasm listdisks
[root@home ~]# oracleasm listdisks
DSK01
DSK02
DSK03

Try again to execute oracleasm-discover
[root@home ~]# oracleasm-discover
Using ASMLib from /opt/oracle/extapi/64/asm/orcl/1/libasm.so
[ASM Library - Generic Linux, version 2.0.4 (KABI_V2)]
Discovered disk: ORCL:DSK01 [10414078 blocks (5332007936 bytes), maxio 512]
Discovered disk: ORCL:DSK02 [10414078 blocks (5332007936 bytes), maxio 512]
Discovered disk: ORCL:DSK03 [10414078 blocks (5332007936 bytes), maxio 512]

If oracle or grid user is logged in the error message appears again.

Steps to solve the problem (oracle or grid user)

[oracle@home ~]$ /usr/sbin/oracleasm-discover
Using ASMLib from /opt/oracle/extapi/64/asm/orcl/1/libasm.so
asm_version() failed with code 2

Oracle or grid user must have appropriate privilege in order to discover ASM disks. Back as root user point to /dev/oracleasm  and execute below commands:
[root@home /]# cd /dev/oracleasm/
[root@home oracleasm]# ls -lart
total 0
drwxr-xr-x  4 root root    0 Aug 13 14:32 .
drwxrwx---  1 root root    0 Aug 13 14:32 iid
drwxr-xr-x  1 root root    0 Aug 13 14:32 disks
-rwxrwx---  1 root root    0 Aug 13 14:32 .query_version
-rwxrwx---  1 root root    0 Aug 13 14:32 .get_iid
-rwxrwx---  1 root root    0 Aug 13 14:32 .check_iid
-rwxrwx---  1 root root    0 Aug 13 14:32 .query_disk
drwxr-xr-x 13 root root 4440 Aug 13 14:35 ..
[root@home oracleasm]# chown -R oracle:oinstall iid disks .query_version .get_iid .check_iid .query_disk

Log in as oracle or grid and execute below commands:
[root@home oracleasm]# su oracle
[oracle@home oracleasm]$ /usr/sbin/oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
Unable to fix permissions on ASM disk "DSK01"
[oracle@home oracleasm]$ /usr/sbin/oracleasm listdisks
DSK01
DSK02
DSK03
[oracle@home oracleasm]$ /usr/sbin/oracleasm-discover
Using ASMLib from /opt/oracle/extapi/64/asm/orcl/1/libasm.so
[ASM Library - Generic Linux, version 2.0.4 (KABI_V2)]
Discovered disk: ORCL:DSK01 [10414078 blocks (5332007936 bytes), maxio 512]
Discovered disk: ORCL:DSK02 [10414078 blocks (5332007936 bytes), maxio 512]
Discovered disk: ORCL:DSK03 [10414078 blocks (5332007936 bytes), maxio 512]
[oracle@home oracleasm]$

Oracle or grid user can now discover ASM disks.

2 comments:

  1. Thanks very much, this was bugging me for quite a while; I'd overlooked the hidden directories in /dev/oracleasm when changing ownership.

    ReplyDelete
  2. I had the same issue. I realize I had a problem with my grid user, when I got a permission error the first time I set up asm. I fixed my user and re-ran all the asm commands but it wasn't fixing this and was no longer giving an error on asm config. I finally realize my grid install was failing because oracleasm-discover was failing. Thanks a milllion for pointing out where the issue was.

    ReplyDelete