Installing Oracle ASM using UNIX files as disk devices

De Notas pessoais

Edição feita às 19h01min de 21 de maio de 2011 por Einstein (disc | contribs)
(dif) ← Versão anterior | ver versão atual (dif) | Versão posterior → (dif)
Hands8.gif
 · ATENÇÃO: Este artigo ainda não está completo e necessita ser revisado  ·

From: http://www.idevelopment.info/data/Oracle/DBA_tips/Automatic_Storage_Management/ASM_20.shtml#Creating%20Files%20for%20use%20by%20ASM

How to use Files in place of Real Disk Devices for ASM - (Linux) by Jeff Hunter, Sr. Database Administrator

Tabela de conteúdo

Overview

This article provides the steps to create and configure blank files (instead of real disk devices) for use in testing Oracle's Automatic Storage Manager (ASM) on the Linux platform. This is a handy trick that can be used when the DBA needs to test ASM on a machine that has no free disk partitions or no free disk devices available. Please note that this is intended for testing purposes only!

Creating Files for use by ASM

The first step is to identify an already partitioned and formatted hard disk that contains enough space to contain the blank files to be used as ASM disk devices.

For the purpose of this example, I have enough room on my local hard disk (/dev/sda1) to create four files at 100MB each. I want to create one disk group that contains four disks. The disk group will contain two failure groups and each failure group will be created using two disks.

From within the Linux O/S platform, perform the following actions:

1. Create Files using "dd"

  # mkdir /asmdisks
  # chown oracle:dba /asmdisks
  # su - oracle
  
  $ dd if=/dev/zero of=/asmdisks/_file_disk1 bs=1k count=100000
  $ dd if=/dev/zero of=/asmdisks/_file_disk2 bs=1k count=100000
  $ dd if=/dev/zero of=/asmdisks/_file_disk3 bs=1k count=100000
  $ dd if=/dev/zero of=/asmdisks/_file_disk4 bs=1k count=100000
  

We now have four files to be used as virtual disks of 100MB each:

  $ ls -l /asmdisks
  total 400432
  -rw-r--r--  1 oracle dba 102400000 Jun  8 15:30 _file_disk1
  -rw-r--r--  1 oracle dba 102400000 Jun  8 15:31 _file_disk2
  -rw-r--r--  1 oracle dba 102400000 Jun  8 15:31 _file_disk3
  -rw-r--r--  1 oracle dba 102400000 Jun  8 15:31 _file_disk4

2. Associate Loop Device with the New Files - The next step is to use the losetup command to associate a loop device with a file. This needs to be performed as the root user account:

  # losetup /dev/loop1 /asmdisks/_file_disk1
  # losetup /dev/loop2 /asmdisks/_file_disk2
  # losetup /dev/loop3 /asmdisks/_file_disk3
  # losetup /dev/loop4 /asmdisks/_file_disk4

3. Bind RAW Devices to Existing Block Devices - The next critical step is to use the raw utility to bind a RAW device to each of the block devices we already created. Again, this needs to be performed as the root user account:

  # raw /dev/raw/raw1 /dev/loop1
  /dev/raw/raw1:  bound to major 7, minor 1
 
  # raw /dev/raw/raw2 /dev/loop2
  /dev/raw/raw2:  bound to major 7, minor 2

  # raw /dev/raw/raw3 /dev/loop3
  /dev/raw/raw3:  bound to major 7, minor 3

  # raw /dev/raw/raw4 /dev/loop4
  /dev/raw/raw4:  bound to major 7, minor 4

4. Change Ownership of RAW Devices - Finally, let's change the ownership of all four RAW devices:

  # 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 660 /dev/raw/raw1
  # chmod 660 /dev/raw/raw2
  # chmod 660 /dev/raw/raw3
  # chmod 660 /dev/raw/raw4

After completeting the above steps, the O/S will see four free 'devices' now available for ASM!

Create ASM Disk Groups

Ok, so now that we have devices that can be seen by the O/S, we can now discover these disks within ASM and then create our ASM disk group.

For the purpose of this example, I already have an ASM instance running on the same node named "+ASM".

For a detailed article on configuring ASM, see my article: "Manually Creating an ASM Instance".

Let's start by determining if Oracle can find these four new disks:

   # ls -l /dev/raw/raw[1234]
   crw-rw----  1 oracle dba 162, 1 Jun  2 22:04 /dev/raw/raw1
   crw-rw----  1 oracle dba 162, 2 Jun  2 22:04 /dev/raw/raw2
   crw-rw----  1 oracle dba 162, 3 Jun  2 22:04 /dev/raw/raw3
   crw-rw----  1 oracle dba 162, 4 Jun  2 22:04 /dev/raw/raw4

The view V$ASM_DISK can be queried from the ASM instance to determine which disks are being used or may potentially be used as ASM disks. Note that you must log into the ASM instance with SYSDBA privileges. Here is the query that I ran from the ASM instance as the oracle user account:

   $ ORACLE_SID=+ASM; export ORACLE_SID
   $ sqlplus "/ as sysdba"

   SQL> SELECT group_number, disk_number, mount_status, header_status, state, path
     2  FROM   v$asm_disk

   GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE    PATH
   ------------ ----------- ------- ------------ -------- ---------------
              0           0 CLOSED  CANDIDATE    NORMAL   /dev/raw/raw1
              0           1 CLOSED  CANDIDATE    NORMAL   /dev/raw/raw2
              0           2 CLOSED  CANDIDATE    NORMAL   /dev/raw/raw3
              0           3 CLOSED  CANDIDATE    NORMAL   /dev/raw/raw4

Note the value of zero in the GROUP_NUMBER column for all four disks. This indicates that a disk is available but hasn't yet been assigned to a disk group. The next section details the steps for creating a disk group.

Using SQL*Plus, the following will create a disk group with normal redundancy and two failure groups:

   $ ORACLE_SID=+ASM; export ORACLE_SID

   $ sqlplus "/ as sysdba"

   SQL> CREATE DISKGROUP testdb_data1 NORMAL REDUNDANCY
     2  FAILGROUP controller1 DISK '/dev/raw/raw1', '/dev/raw/raw2'
     3  FAILGROUP controller2 DISK '/dev/raw/raw3', '/dev/raw/raw4';

   Diskgroup created.

Now, let's take a look at the new disk group and disk details:

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

   GROUP_NUMBER NAME             TOTAL_MB    FREE_MB STATE       TYPE
   ------------ -------------- ---------- ---------- ----------- ------
              1 TESTDB_DATA1          388        282 MOUNTED     NORMAL

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

   GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE    PATH            FAILGROUP
   ------------ ----------- ------- ------------ -------- --------------- ------------
              1           0 CACHED  MEMBER       NORMAL   /dev/raw/raw1   CONTROLLER1
              1           1 CACHED  MEMBER       NORMAL   /dev/raw/raw2   CONTROLLER1
              1           2 CACHED  MEMBER       NORMAL   /dev/raw/raw3   CONTROLLER2
              1           3 CACHED  MEMBER       NORMAL   /dev/raw/raw4   CONTROLLER2


Execução do teste

Vamos agora aplicar as informações acima em um servidor Linux para verificarmos se realmente dá certo;

 [root@vm-fd73-65eb oradata]# df -k
 Filesystem           1K-blocks      Used Available Use% Mounted on
 /dev/sda2            101580148  23780128  72579840  25% /
 /dev/sda1               101054     11887     83950  13% /boot
 tmpfs                  4087668         0   4087668   0% /dev/shm
 
 [root@vm-fd73-65eb oradata]# sh create_disks.sh
 + dd if=/dev/zero of=./asm_disk_001.dbf bs=1k count=4096000
 4096000+0 records in
 4096000+0 records out
 4194304000 bytes (4.2 GB) copied, 94.9123 seconds, 44.2 MB/s
 + dd if=/dev/zero of=./asm_disk_002.dbf bs=1k count=4096000
 4096000+0 records in
 4096000+0 records out
 4194304000 bytes (4.2 GB) copied, 87.516 seconds, 47.9 MB/s
 + dd if=/dev/zero of=./asm_disk_003.dbf bs=1k count=4096000
 4096000+0 records in
 4096000+0 records out
 4194304000 bytes (4.2 GB) copied, 91.6356 seconds, 45.8 MB/s
 + dd if=/dev/zero of=./asm_disk_004.dbf bs=1k count=4096000
 4096000+0 records in
 4096000+0 records out
 4194304000 bytes (4.2 GB) copied, 74.9392 seconds, 56.0 MB/s
 + dd if=/dev/zero of=./asm_disk_005.dbf bs=1k count=4096000
 4096000+0 records in
 4096000+0 records out
 4194304000 bytes (4.2 GB) copied, 165.354 seconds, 25.4 MB/s
 + dd if=/dev/zero of=./asm_disk_006.dbf bs=1k count=4096000
 4096000+0 records in
 4096000+0 records out
 4194304000 bytes (4.2 GB) copied, 96.0339 seconds, 43.7 MB/s
 + dd if=/dev/zero of=./asm_disk_007.dbf bs=1k count=4096000
 4096000+0 records in
 4096000+0 records out
 4194304000 bytes (4.2 GB) copied, 87.1412 seconds, 48.1 MB/s
 + dd if=/dev/zero of=./asm_disk_008.dbf bs=1k count=4096000
 4096000+0 records in
 4096000+0 records out
 4194304000 bytes (4.2 GB) copied, 120.422 seconds, 34.8 MB/s


[root@vm-fd73-65eb oradata]# ls -la
total 36900048
drwxr-xr-x 2 root   root       4096 Apr 27 19:07 .
drwxr-xr-x 6 oracle dba        4096 Apr 27 18:50 ..
-rw-r--r-- 1 root   root 4194304000 Apr 27 18:57 asm_disk_001.dbf
-rw-r--r-- 1 root   root 4194304000 Apr 27 18:53 asm_disk_001.dbf1
-rw-r--r-- 1 root   root 4194304000 Apr 27 18:58 asm_disk_002.dbf
-rw-r--r-- 1 root   root 4194304000 Apr 27 19:00 asm_disk_003.dbf
-rw-r--r-- 1 root   root 4194304000 Apr 27 19:01 asm_disk_004.dbf
-rw-r--r-- 1 root   root 4194304000 Apr 27 19:04 asm_disk_005.dbf
-rw-r--r-- 1 root   root 4194304000 Apr 27 19:06 asm_disk_006.dbf
-rw-r--r-- 1 root   root 4194304000 Apr 27 19:07 asm_disk_007.dbf
-rw-r--r-- 1 root   root 4194304000 Apr 27 19:09 asm_disk_008.dbf


[root@vm-fd73-65eb oradata]# ls -la /dev/loop*
brw-r----- 1 root disk 7, 0 Apr 13 17:34 /dev/loop0
brw-r----- 1 root disk 7, 1 Apr 13 17:34 /dev/loop1
brw-r----- 1 root disk 7, 2 Apr 13 17:34 /dev/loop2
brw-r----- 1 root disk 7, 3 Apr 13 17:34 /dev/loop3
brw-r----- 1 root disk 7, 4 Apr 13 17:34 /dev/loop4
brw-r----- 1 root disk 7, 5 Apr 13 17:34 /dev/loop5
brw-r----- 1 root disk 7, 6 Apr 13 17:34 /dev/loop6
brw-r----- 1 root disk 7, 7 Apr 13 17:34 /dev/loop7


[root@vm-fd73-65eb oradata]# sh create_disks.sh
+ losetup /dev/loop0 /optware/oracle/oradata/asm_disk_001.dbf
+ losetup /dev/loop1 /optware/oracle/oradata/asm_disk_002.dbf
+ losetup /dev/loop2 /optware/oracle/oradata/asm_disk_003.dbf
+ losetup /dev/loop3 /optware/oracle/oradata/asm_disk_004.dbf
+ losetup /dev/loop4 /optware/oracle/oradata/asm_disk_005.dbf
+ losetup /dev/loop5 /optware/oracle/oradata/asm_disk_006.dbf
+ losetup /dev/loop6 /optware/oracle/oradata/asm_disk_007.dbf
+ losetup /dev/loop7 /optware/oracle/oradata/asm_disk_008.dbf


[root@vm-fd73-65eb oradata]# sh create_disks.sh
+ raw /dev/raw/raw1 /dev/loop0
/dev/raw/raw1:  bound to major 7, minor 0
+ raw /dev/raw/raw2 /dev/loop1
/dev/raw/raw2:  bound to major 7, minor 1
+ raw /dev/raw/raw3 /dev/loop2
/dev/raw/raw3:  bound to major 7, minor 2
+ raw /dev/raw/raw4 /dev/loop3
/dev/raw/raw4:  bound to major 7, minor 3
+ raw /dev/raw/raw5 /dev/loop4
/dev/raw/raw5:  bound to major 7, minor 4
+ raw /dev/raw/raw6 /dev/loop5
/dev/raw/raw6:  bound to major 7, minor 5
+ raw /dev/raw/raw7 /dev/loop6
/dev/raw/raw7:  bound to major 7, minor 6
+ raw /dev/raw/raw8 /dev/loop7
/dev/raw/raw8:  bound to major 7, minor 7


+ chown oracle:dba /dev/raw/raw1
+ chown oracle:dba /dev/raw/raw2
+ chown oracle:dba /dev/raw/raw3
+ chown oracle:dba /dev/raw/raw4
+ chown oracle:dba /dev/raw/raw5
+ chown oracle:dba /dev/raw/raw6
+ chown oracle:dba /dev/raw/raw7
+ chown oracle:dba /dev/raw/raw8


+ chmod 660 /dev/raw/raw1
+ chmod 660 /dev/raw/raw2
+ chmod 660 /dev/raw/raw3
+ chmod 660 /dev/raw/raw4
+ chmod 660 /dev/raw/raw5
+ chmod 660 /dev/raw/raw6
+ chmod 660 /dev/raw/raw7
+ chmod 660 /dev/raw/raw8


[root@vm-fd73-65eb oradata]# ls -la /dev/raw
total 0
drwxr-xr-x  2 root   root    200 Apr 27 19:20 .
drwxr-xr-x 11 root   root   3680 Apr 27 19:20 ..
crw-rw----  1 oracle dba  162, 1 Apr 27 19:20 raw1
crw-rw----  1 oracle dba  162, 2 Apr 27 19:20 raw2
crw-rw----  1 oracle dba  162, 3 Apr 27 19:20 raw3
crw-rw----  1 oracle dba  162, 4 Apr 27 19:20 raw4
crw-rw----  1 oracle dba  162, 5 Apr 27 19:20 raw5
crw-rw----  1 oracle dba  162, 6 Apr 27 19:20 raw6
crw-rw----  1 oracle dba  162, 7 Apr 27 19:20 raw7
crw-rw----  1 oracle dba  162, 8 Apr 27 19:20 raw8
[root@vm-fd73-65eb oradata]#
Ferramentas pessoais

contador de visitas