Create disk & add asm disk




!! How to CREATE DISK and add asm disk on Diskgroup !!



1 . Check The disk (LUNS)

[root@oravb ~]# hostname
oravb.vbtech.com
[root@oravb ~]# fdisk -l

Disk /dev/sdc: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@oravb ~]#


2. create partitions On " /dev/sdc "

        [root@oravb ~]# fdisk /dev/sdc
        Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
        Building a new DOS disklabel with disk identifier 0x60993f20.
        Changes will remain in memory only, until you decide to write them.
        After that, of course, the previous content won't be recoverable.
       
        Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
       
        WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
                switch off the mode (command 'c') and change display units to
                sectors (command 'u').
       
        Command (m for help): n
        Command action
        e   extended
        p   primary partition (1-4)
        p
        Partition number (1-4): 1
        First cylinder (1-5221, default 1):
        Using default value 1
        Last cylinder, +cylinders or +size{K,M,G} (1-5221, default 5221): 1000
       
        Command (m for help): n
        Command action
        e   extended
        p   primary partition (1-4)
        p
        Partition number (1-4): 2
        First cylinder (1001-5221, default 1001):
        Using default value 1001
        Last cylinder, +cylinders or +size{K,M,G} (1001-5221, default 5221): 2000
       
        Command (m for help): n
        Command action
        e   extended
        p   primary partition (1-4)
        p
        Partition number (1-4): 3
        First cylinder (2001-5221, default 2001):
        Using default value 2001
        Last cylinder, +cylinders or +size{K,M,G} (2001-5221, default 5221): 3000
       
        Command (m for help): n
        Command action
        e   extended
        p   primary partition (1-4)
        p
        Selected partition 4
       
        First cylinder (3001-5221, default 3001):
        Using default value 3001
        Last cylinder, +cylinders or +size{K,M,G} (3001-5221, default 5221):
        Using default value 5221
       
        Command (m for help): p
       
        Disk /dev/sdc: 42.9 GB, 42949672960 bytes
        255 heads, 63 sectors/track, 5221 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0x60993f20
       
        Device Boot      Start         End      Blocks   Id  System
        /dev/sdc1               1        1000     8032468+  83  Linux
        /dev/sdc2            1001        2000     8032500   83  Linux
        /dev/sdc3            2001        3000     8032500   83  Linux
        /dev/sdc4            3001        5221    17840182+  83  Linux
       
        Command (m for help): w
        The partition table has been altered!
       
        Calling ioctl() to re-read partition table.
        Syncing disks.
        [root@oravb ~]# partprobe
        Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
        Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
        [root@oravb ~]#

       
       
3. CREATE ASM DISK FROM os DISKS :

            [root@oravb ~]# oracleasm createdisk  test1 /dev/sdc1
            Writing disk header: done
            Instantiating disk: done
            [root@oravb ~]# oracleasm createdisk  test2 /dev/sdc2
            Writing disk header: done
            Instantiating disk: done
            [root@oravb ~]# oracleasm createdisk  test3 /dev/sdc3
            Writing disk header: done
            Instantiating disk: done
            [root@oravb ~]# oracleasm createdisk  test4 /dev/sdc4
            Writing disk header: done
            Instantiating disk: done
           
            Check disks :
           
            [root@oravb ~]# oracleasm listdisks
            ACFS1
            ACFS2
            DATA
            OCR
            TEST1
            TEST2
            TEST3
            TEST4
           
            Check disks on Os level
           
            [root@oravb ~]# ls -altr /dev/oracleasm/disks
            total 0
            drwxr-xr-x. 4 root   root     0 Jul  5 22:52 ..
            drwxr-xr-x. 1 root   root     0 Jul  5 22:52 .
            brw-rw----. 1 oracle dba  8, 33 Jul  5 23:01 TEST1
            brw-rw----. 1 oracle dba  8, 34 Jul  5 23:01 TEST2
            brw-rw----. 1 oracle dba  8, 35 Jul  5 23:01 TEST3
            brw-rw----. 1 oracle dba  8, 36 Jul  5 23:01 TEST4
            brw-rw----. 1 oracle dba  8, 17 Jul  5 23:01 OCR
            brw-rw----. 1 oracle dba  8, 19 Jul  5 23:01 ACFS2
            brw-rw----. 1 oracle dba  8, 18 Jul  5 23:01 ACFS1
            brw-rw----. 1 oracle dba  8, 20 Jul  5 23:01 DATA
            [root@oravb ~]#
           
           
            CHECK FROM DB LEVEL :
           
            SQL> select disk_number, header_status, mode_status, path, voting_file
                    from v$asm_disk;  2

            DISK_NUMBER HEADER_STATU MODE_ST PATH                                     V
            ----------- ------------ ------- ---------------------------------------- -
                    0 PROVISIONED  ONLINE  /dev/oracleasm/disks/TEST3               N
                    1 PROVISIONED  ONLINE  /dev/oracleasm/disks/TEST2               N
                    2 PROVISIONED  ONLINE  /dev/oracleasm/disks/TEST4               N
                    3 PROVISIONED  ONLINE  /dev/oracleasm/disks/TEST1               N
           
                       

4. CREATE ASM DISKGREOUP :

       
        CREATE DISKGROUP TEST EXTERNAL REDUNDANCY DISK '/dev/oracleasm/disks/TEST1';


        Check if disk added or not :
       
        SQL>col PATH for a40
        set lines 150
        set pages 100
        col NAME for a20
        col ASM_GROUP for a10

        select adg.name ASM_GROUP, ad.disk_number, ad.name,ad.header_status, ad.mode_status,ad.REDUNDANCY, ad.path, ad.voting_file
        from v$asm_diskgroup adg, v$asm_disk ad where   adg.group_number = ad.group_number and adg.name='TEST' order by adg.name,ad.disk_number;
        SQL> SQL> SQL> SQL> SQL> SQL>   2
        ASM_GROUP  DISK_NUMBER NAME                 HEADER_STATU MODE_ST REDUNDA PATH                                     V
        ---------- ----------- -------------------- ------------ ------- ------- ---------------------------------------- -
        TEST                 0 TEST_0000            MEMBER       ONLINE  UNKNOWN /dev/oracleasm/disks/TEST1               N



       
       
5. Add disk on diskgroup :

        Check the os disks state if it "PROVISIONED" then procced .
       
        --where header_status = 'FORMER' order by disk_number; ---- which was the part of diskgroup
        --where header_status = 'MEMBER' order by disk_number; -----wchich is the part of diskgroup currently uning
        --where header_status = 'CANDIDATE' order by disk_number;---fresh disk
        --where header_status = 'PROVISIONED' order by disk_number;----Disk is not part of a disk group and may be added to a disk group with the ALTER
   
   
       
        SQL> ALTER DISKGROUP TEST ADD DISK '/dev/oracleasm/disks/TEST2';

                Diskgroup altered.

        SQL>

        ASM_GROUP  DISK_NUMBER NAME                 HEADER_STATU MODE_ST REDUNDA PATH                                     V
        ---------- ----------- -------------------- ------------ ------- ------- ---------------------------------------- -
        TEST                 0 TEST_0000            MEMBER       ONLINE  UNKNOWN /dev/oracleasm/disks/TEST1               N
        TEST                 1 TEST_0001            MEMBER       ONLINE  UNKNOWN /dev/oracleasm/disks/TEST2               N
       
        SQL>

       
6 . CHECK THE RBALCING STATE :


    SQL> select operation, state,power, actual, sofar, est_work, est_minutes from v$asm_operation;

            no rows selected
    SQL>

   
    CHANGE POWER LIMIT OF DISK :
   
        SQL> ALTER DISKGROUP TEST REBALANCE POWER 4;

            Diskgroup altered.
           
            SQL> select operation, state,power, actual, sofar, est_work, est_minutes from v$asm_operation;
           
            OPERA STAT      POWER     ACTUAL      SOFAR   EST_WORK EST_MINUTES
            ----- ---- ---------- ---------- ---------- ---------- -----------
            REBAL REAP          4          4          0          0           0
            REBAL DONE          4          4          0          0           0
            REBAL DONE          4          4          0          0           0
           
            SQL>
           

7 . DROP DISK FROM DISKGREOUP :

        we can not drop disk on

    SQL> ALTER DISKGROUP TEST  DROP  DISK 'TEST_0001' ;
           
       
    SQL> ALTER DISKGROUP TEST  DROP  DISK 'TEST_0001' ;

    Diskgroup altered.

    SQL>
   
    SQL> ^Ccol PATH for a40
        set lines 150
        set pages 100
        col NAME for a20
        col ASM_GROUP for a10

        select adg.name ASM_GROUP, ad.disk_number, ad.name,ad.header_status, ad.mode_status,ad.REDUNDANCY, ad.path, ad.voting_file
        from v$asm_diskgroup adg, v$asm_disk ad where   adg.group_number = ad.group_number and adg.name='TEST' order by adg.name,ad.disk_number;

SQL> SQL> SQL> SQL> SQL> SQL>   2
ASM_GROUP  DISK_NUMBER NAME                 HEADER_STATU MODE_ST REDUNDA PATH                                     V
---------- ----------- -------------------- ------------ ------- ------- ---------------------------------------- -
TEST                 0 TEST_0000            MEMBER       ONLINE  UNKNOWN /dev/oracleasm/disks/TEST1               N
TEST                 2 TEST_0002            MEMBER       ONLINE  UNKNOWN /dev/oracleasm/disks/TEST3               N
TEST                 3 TEST_0003            MEMBER       ONLINE  UNKNOWN /dev/oracleasm/disks/TEST4               N

SQL>

   
    SQL> ALTER DISKGROUP TEST REBALANCE POWER 4;

        Diskgroup altered.

        SQL>  select operation, state,power, actual, sofar, est_work, est_minutes from v$asm_operation;
       
        OPERA STAT      POWER     ACTUAL      SOFAR   EST_WORK EST_MINUTES
        ----- ---- ---------- ---------- ---------- ---------- -----------
        REBAL REAP          4          4          0          0           0
        REBAL DONE          4          4          0          0           0
        REBAL DONE          4          4          0          0           0
       
        SQL>
       
       
       

   

Table 4-2 Mirroring options for Oracle ASM disk group types
Disk Group TypeSupported Mirroring LevelsDefault Mirroring Level
External redundancy
Unprotected (none)
Unprotected
Normal redundancy
Two-way, three-way, unprotected (none)
Two-way
High redundancy
Three-way
Three-way
Flex redundancy
Two-way, three-way, unprotected (none)
Two-way (newly-created)
Extended redundancy
Two-way, three-way, unprotected (none)
Two-way
For normal and high disk group types, the redundancy level controls how many disk failures are tolerated without dismounting the disk group or losing data. Each file is allocated based on its own redundancy, but the default comes from the disk group.
For the flex group type, the number of failures tolerated before dismount demands on the number of failure groups. For five or more failure groups, two disk failures are tolerated. For three or four failure groups, one disk failure is tolerated.
For the extended disk group type, each site is similar to a flex disk group. If the site has five failure groups or more, two disk failures with in a site can be tolerated before the site becomes compromised. If the site has three or four failure groups, the site can tolerate one disk failure before the site is compromised. When two sites are compromised, the disk group dismounts. An extended disk group requires a minimum of three failure groups for each data site.
For flex and extended disk groups, mirroring describes the availability of the files within a disk group, not the disk group itself. For example: If a file is unprotected in a flex disk group that has five failure groups, then after one failure the disk group is still mounted, but the file becomes unavailable.
The redundancy levels are:
  • External redundancy
    Oracle ASM does not provide mirroring redundancy and relies on the storage system to provide RAID functionality. Any write error causes a forced dismount of the disk group. All disks must be located to successfully mount the disk group.
  • Normal redundancy
    Oracle ASM provides two-way mirroring by default, which means that all files are mirrored so that there are two copies of every extent. A loss of one Oracle ASM disk is tolerated. You can optionally choose three-way or unprotected mirroring.
    A file specified with HIGH redundancy (three-way mirroring) in a NORMAL redundancy disk group provides additional protection from a bad disk sector in one disk, plus the failure of another disk. However, this scenario does not protect against the failure of two disks.
  • High redundancy
    Oracle ASM provides three-way (triple) mirroring by default. A loss of two Oracle ASM disks in different failure groups is tolerated.
  • Flex redundancy
    Oracle ASM provides two-way mirroring by default for newly-created flex disk groups. For migrated flex disk groups, the default values are obtained from the template values in the normal or high redundancy disk groups before migration. For migration from normal redundancy, if the template defaults were not changed, then the flex defaults are two-way mirroring. For migration from high redundancy, if the template defaults were not changed, then the flex defaults are three-way mirroring.
  • Extended redundancy
    Oracle ASM provides two-way mirroring by default. The redundancy setting describes redundancy within a data site. For example: If there is a two-way mirrored file in a two-data-site extended disk group, then there are four copies of the file, two in each data site.
Oracle ASM file groups in a flex or extended disk group can have different redundancy levels.
If there are not enough online failure groups to satisfy the file mirroring (redundancy attribute value) specified in the disk group file type template, Oracle ASM allocates as many mirrors copies as possible and subsequently allocates the remaining mirrors when sufficient online failure groups are available.
Failure groups enable the mirroring of metadata and user data. System reliability can diminish if your environment has an insufficient number of failure groups.