ONTAP Discussions

Sample script - Scripted NetApp LUN Creation + Oracle ASM addition

storagejarett
6,400 Views

I created a script to assist customers with creating luns and presenting it up to Oracle ASM, since I was finding that there is a large disconnect in how people think about device IDs and multipath IDs.  Also, there was alot of confusion in the communication between the groups of a company when a DBA requested a new LUN.

 

Blog post about the script and where I will keep up to date copies, and some more information on it.

http://www.jk-47.com/2012/07/scripted-netapp-lun-creation-oracle-asm-addition/

 

Typically, if a customer wanted to add a new LUN to an Oracle database server, the steps would look like this:

  1. DBA asks SAN admin for a LUN
  2. SAN admin creates LUN, presents it to server
  3. SAN admin tells Linux/System Admin it’s presented
  4. Linux/System Admin rescans the SCSI bus to discover the lun
  5. Linux/System Admin does all the multipath mumbojumbo to create the /dev/mapper crap
  6. Linux/System Admin fdisks partition (aligned to SAN I hope)
  7. DBA uses /etc/init.d/oracleasm to tag the new lun to ASM

 

Thats just too many steps... there really only needs to be 1 person in the mix.  After all, thats what SnapDrive is made for...

 

This is a starting point script only.  No guarantees are given.  If you give it the name of a lun which already exists, it WILL fdisk it anyway.  I have modified this for some environments to create everything, all luns, all vols, all tablespaces, etc etc.  Think of it as a starting point.  Again, see my blog for more information and some disclaimers.

 

Example usage and output:

Script Name: makemount.sh
Input 1: Tablespace Name
Input 2: Volume Identified Number
Input 3: Lun Size
Input 4: Lun Identified Number
Input 5: Controller Name

 

 

[root@oraclebox bin]#  ./makemount.sh OCR1 1 5 D netappc1

        LUN netappc1:/vol/OraOCR1Vol1/OraOCR11_D.lun ... created

 

        mapping new lun(s) ... done

        discovering new lun(s) ... done

 

        LUN to device file mappings:

        - netappc1:/vol/OraOCR1Vol1/OraOCR11_D.lun => /dev/sdal, /dev/sdam

 

 

Getting lun info

Getting Multipath information

Partitioning Disk

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. 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)

 

Command (m for help): Command action

   e   extended

   p   primary partition (1-4)

Partition number (1-4): First cylinder (1-652, default 1): Last cylinder or +size or +sizeM or +sizeK (1-652, default 652): Using default value 652

 

Command (m for help):

Expert command (m for help): Partition number (1-4): New beginning of data (63-10474379, default 63):

Expert command (m for help): The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

WARNING: Re-reading the partition table failed with error 22: Invalid argument.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

 

Disk /dev/mapper/360a980006473444b48346b796e6c5749: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

                                         Device Boot      Start         End      Blocks   Id  System

/dev/mapper/360a980006473444b48346b796e6c5749p1               1         652     5237158   83  Linux

Partition 1 has different physical/logical beginnings (non-Linux?):

     phys=(0, 1, 1) logical=(0, 1, 2)

kpartx on disk

add map 360a980006473444b48346b796e6c5749p1 (253:40): 0 10474316 linear /dev/mapper/360a980006473444b48346b796e6c5749 64

CREATEDISK in /etc/init.d

/etc/init.d/oracleasm createdisk OCR1_D /dev/mapper/360a980006473444b48346b796e6c5749p1

Marking disk "OCR1D" as an ASM disk:                       [  OK  ]

Cleaning up

 

------

 

 

That's it.  You have your lun.. and the DBA can see it in ASM to add to a diskgroup and mount up.

 

 

R. Jarett Kulm

VCP5, NetApp NCIE-SAN, F5 CSP,

EMC Velocity SE, NBU7 STS, etc etc etc...

Professional Services Engineer

H.A. Storage Systems, Inc.

1 REPLY 1

VIJAYNUKALA
6,400 Views

Hi..

Few of our jobs are getting failed while accessing the files on the NAS drive...

  System error is [22] [Invalid argument]. ...

The files are already present and there is no clue what exactly  happening... may i know, it which scenario we will get this error...

Coul you please help me?

Public