Table of Contents

Oracle ASM

Using loopback devices in place of real disks

Refs:
Jeff Hunter, How to use Files in place of Real Disk Devices for ASM
Fabien Faye, Howto create Loop Device on REDHAT, CENTOS or FEDORA

For testing only

Create disk files

$ cd /exports/oracle
$ mkdir asmdisks
$ chown oracle:dba asmdisks
$ dd if=/dev/zero of=asmdisks/_file_disk10 bs=1k count=1000000 # 1000MB
$ dd if=/dev/zero of=asmdisks/_file_disk11 bs=1k count=1000000 # 1000MB
$ dd if=/dev/zero of=asmdisks/_file_disk12 bs=1k count=1000000 # 1000MB
$ dd if=/dev/zero of=asmdisks/_file_disk13 bs=1k count=1000000 # 1000MB
$ ls -l asmdisks
total 4003936
-rw-r--r-- 1 oracle oinstall 1024000000 Dec  9 07:00 _file_disk10
-rw-r--r-- 1 oracle oinstall 1024000000 Dec  9 07:00 _file_disk11
-rw-r--r-- 1 oracle oinstall 1024000000 Dec  9 07:01 _file_disk12
-rw-r--r-- 1 oracle oinstall 1024000000 Dec  9 07:01 _file_disk13

Map loopback devices to disk files

# Find first unused device
# losetup -f
/dev/loop0
# losetup /dev/loop0 /exports/oracle/asmdisks/_file_disk10
# losetup /dev/loop1 /exports/oracle/asmdisks/_file_disk11
# losetup /dev/loop2 /exports/oracle/asmdisks/_file_disk12
# losetup /dev/loop3 /exports/oracle/asmdisks/_file_disk13

Create raw devices

# raw /dev/raw/raw10 /dev/loop0
/dev/raw/raw10: bound to major 7, minor 0
# raw /dev/raw/raw11 /dev/loop1
/dev/raw/raw11: bound to major 7, minor 1
# raw /dev/raw/raw12 /dev/loop2
/dev/raw/raw12: bound to major 7, minor 2
# raw /dev/raw/raw13 /dev/loop3
/dev/raw/raw13: bound to major 7, minor 3
# ls /dev/raw
raw1  raw10  raw11  raw12  raw13  raw2  raw3  raw4
# chown oracle:dba /dev/raw/raw10
# chown oracle:dba /dev/raw/raw11
# chown oracle:dba /dev/raw/raw12
# chown oracle:dba /dev/raw/raw13
# chmod 660 /dev/raw/raw10
# chmod 660 /dev/raw/raw11
# chmod 660 /dev/raw/raw12
# chmod 660 /dev/raw/raw13

Check visibility of raw devices in ASM

SQL> l
  1* select group_number, disk_number, mount_status, header_status, state, path from v$asm_disk
SQL> /

GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE    PATH
------------ ----------- ------- ------------ -------- ---------------
           0           0 CLOSED  CANDIDATE    NORMAL   /dev/raw/raw13
           0           1 CLOSED  CANDIDATE    NORMAL   /dev/raw/raw12
           0           2 CLOSED  CANDIDATE    NORMAL   /dev/raw/raw11
           0           3 CLOSED  CANDIDATE    NORMAL   /dev/raw/raw10
           2           2 CACHED  MEMBER       NORMAL   /dev/raw/raw4
           2           1 CACHED  MEMBER       NORMAL   /dev/raw/raw3
           2           0 CACHED  MEMBER       NORMAL   /dev/raw/raw2
           1           0 CACHED  MEMBER       NORMAL   /dev/raw/raw1

Create a diskgroup

SQL> create diskgroup LOOPDG normal redundancy
failgroup fg1 disk '/dev/raw/raw10', '/dev/raw/raw12'
failgroup fg2 disk '/dev/raw/raw11', '/dev/raw/raw13';

Diskgroup created.

Check diskgroup

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

GROUP_NUMBER NAME                             TOTAL_MB    FREE_MB STATE       TYPE
------------ ------------------------------ ---------- ---------- ----------- ------
           1 DG1                                  8189       7183 MOUNTED     EXTERN
           2 DG2                                786414     322583 MOUNTED     EXTERN
           3 LOOPDG                               3904       3798 MOUNTED     NORMAL

SQL> select group_number, disk_number, mount_status, header_status, state, path, failgroup from v$asm_disk;

GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE    PATH            FAILGROUP
------------ ----------- ------- ------------ -------- --------------- ------------------------------
           2           2 CACHED  MEMBER       NORMAL   /dev/raw/raw4   DG2_0002
           2           1 CACHED  MEMBER       NORMAL   /dev/raw/raw3   DG2_0001
           2           0 CACHED  MEMBER       NORMAL   /dev/raw/raw2   DG2_0000
           1           0 CACHED  MEMBER       NORMAL   /dev/raw/raw1   DG1_0000
           3           3 CACHED  MEMBER       NORMAL   /dev/raw/raw13  FG2
           3           1 CACHED  MEMBER       NORMAL   /dev/raw/raw12  FG1
           3           2 CACHED  MEMBER       NORMAL   /dev/raw/raw11  FG2
           3           0 CACHED  MEMBER       NORMAL   /dev/raw/raw10  FG1

Create database objects using new diskgroup

SQL> alter session set db_create_file_dest='+LOOPDG';

Session altered.

SQL> create tablespace LOOPTS datafile size 500M autoextend on next 100M maxsize 2000M;

Tablespace created.

SQL> select file_name from dba_data_files where tablespace_name='LOOPTS';

FILE_NAME
--------------------------------------------------------------------------------
+LOOPDG/nasa/datafile/loopts.256.705137387

SQL> create table LOOPTAB tablespace LOOPTS as select * from dba_source;

Table created.

SQL> select count(*) from looptab;

  COUNT(*)
----------
    295139

Use asmcmd to view datafile in ASM

ASMCMD [+] > ls -l
State    Type    Rebal  Unbal  Name
MOUNTED  EXTERN  N      N      DG1/
MOUNTED  EXTERN  N      N      DG2/
MOUNTED  NORMAL  N      N      LOOPDG/
ASMCMD [+] > cd loopdg/nasa/datafile
ASMCMD [+loopdg/nasa/datafile] > ls -l
Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   DEC 09 07:00:00  Y    LOOPTS.256.705137387

Remote connection to ASM instance

If you attempt a remote connection to ASM and you see an error similar to:

Enter user-name: sys/pwd@asm as sysdba
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

then define a connect string in tnsnames.ora similar to:

ASM =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hostname_or_IP_address)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = +ASM)
      (INSTANCE_NAME = +ASM)
      # Allow connect to blocked ASM instance
      (UR = A)
    )
  )

If you see an error similar to:

Enter user-name: sys/pwd@asm as sysdba
ERROR:
ORA-12528: TNS:listener: all appropriate instances are blocking new connections

then you need to add UR = A to your connect string in tnsnames.ora (see example above).
This will allow connection to the normally blocked ASM instance.

If you see an error similar to:

Enter user-name: sys/pwd@asm as sysdba
ERROR:
ORA-01017: invalid username/password; logon denied

then either:

a) you really did get the password wrong,

b) remote_login_passwordfile not set to EXCLUSIVE, this can be fixed by running:

SQL> alter system set remote_login_passwordfile=EXCLUSIVE scope=spfile;

System altered.

and restartig ASM and all dependent instances.

or c) the password file doesn't allow the connection, recreate the password file:

$ orapwd file=orapw+ASM password=pwd entries=5 force=y