Scripted NetApp LUN Creation + Oracle ASM addition

I am constantly in new customer environments, setting up NetApp, Oracle RAC & ASM, NetApp SnapDrive, SnapManager for Oracle, etc on Linux…

Opinionated Rant: When ever possible, PLEASE use Oracle with Direct NFS or normal NFS on 10gb ethernet. Stop using Fiberchannel or iscsi. It is such a giant pain in the ass to use ASM. Really. Do yourself a favor and go NFS instead of ASM. You’ll thank me

While I know what I am doing in regards to storage and Oracle, most customers do not have a single point man (or woman) who knows all of these technologies and is the administrator to do day to day operations of them all. Also, when I have tried to teach the teams to do this, or if the DBA is in charge of all of these steps in a small environment, they typically get very confused when thinking about the relationship of the /dev/sd* and the multipath /dev/mapper/360* entries.

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
  8. Done… ugh. wtf thats too many handoffs

NetApp created snapdrive as a way that a sysadmin or DBA can interface with the SAN, without having direct access to SSH or SystemManager or Web console into the SAN. Role based access control can be used to limit what the admin can do.

With some clever scripting, you can do ALL the steps above with just one script.

When I do new SMO installs, I typically break the database into the following groups: UNDO REDO CTRL1 CTRL2 ARCH DATA TEMP FRA. This is the most logical way if you want to later clone or replicate you data in the most efficient way.

I like to have a logical naming method to luns and volumes

Right now, this script requires the volumes to be precreated, but it would be pretty easy to add a command to create the volume.

It is up to the person running this to provide good tablespace naming and a unique identified for the lun or else itll crap out. This was a very very quick script I coded on a customer site while I had 3 people staring over my shoulder.

Note: This script should be used for partitions OVER 8gb. Anything under can have an issue with fdisk depending on your linux distribution at the point it tries to automatically align the partition to the 1M block boundary. With how a SAN tries to mount small luns to a box, it “sort of” changes the presentation style to an older LBA like the box would see on smaller bootable disks. You can, however, just change the fdisk code or put it in an if statement to not align the filesystem on ( ${3} -lt 8 ). I had to do this for a customer, and it’s not that complex.

This is an Example usage and output. You see the command.

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

And the official script:


Be Sociable, Share!

, , ,