Home > Command Line > SnapMirror failover

SnapMirror failover

January 22nd, 2009

So I helped a customer a few months ago (before SRM) to script a complete site failover. It will bring the DR site online within about 30 minutes, the scripts are a bit clunky and need a massive re-design, so I thought I’d post the originals here.

This, I think, is a great example of how flexible the NetApp systems are in that you can quickly and easily setup SSH access from a management host and script your heart away! Soon as I get the hang of the API, I’m sure there’ll be plenty more info coming along too.

This script will bring all volumes online on the DR filer, what’s more, an volume that is labelled as “_vm” at the end (which is a nice naming convention to use for all VMware volumes anyway), will get re-mapped to a new igroup you choose and already have setup for the DR ESX servers.

I’ve modified this script slightly since writing it to remove filer names, so I don’t expect it to work out of the box, as with my other scripts, it’s just meant to as an example of how this can be achieved.

[root@esx101 root]# cat failover.sh
#!/bin/bash

dr_vmware_igroup=”VMWare_DR”
dr_filer_name=”filer_dr”
dr_filer_command=”ssh -c 3des $dr_filer_name”

for netapp_volume in `$dr_filer_command snapmirror status | grep $dr_filer_name | grep -v “_vm” | cut -d”:” -f3 | cut -d ” ” -f1`; do
 echo $dr_filer_command snapmirror quiesce $netapp_volume
 echo $dr_filer_command snapmirror break $netapp_volume
 echo $dr_filer_command vol online $netapp_volume
done

for netapp_volume in `$dr_filer_command snapmirror status | grep $dr_filer_name | grep “_vm” | cut -d”:” -f3 | cut -d ” ” -f1`; do
 echo $dr_filer_command snapmirror quiesce $netapp_volume
 echo $dr_filer_command snapmirror break $netapp_volume
 echo $dr_filer_command vol online $netapp_volume
 for netapp_lun in `$dr_filer_command lun show | grep /vol/$netapp_volume | awk ‘{print $1}’`; do
  echo $dr_filer_command lun online $netapp_lun
  echo $dr_filer_command lun map $netapp_lun $dr_vmware_igroup
 done
done

Command Line , , , ,

  1. Ty
    | #1

    How are you Mr Kranz?

    Have you made any enhancements to the script since posting?

    Cheers, Ty

  2. | #2

    Hi Ty!

    Unfortuantely I’ve not been able to make any progress on any of the scripts here. I’ll be sure to update them as soon as I have though. I’m hoping to start converting them all to PowerShell first to make them more Windows friendly.

  3. TomK
    | #3

    We are using similiar custom scripts to bring the Snapmirrored volumes/LUN’s online, and it’s working well. Much cheaper than SRM. We’re now working on ways to reduce the SM size out to the DR site. It’s amazing how much change rate there is in a Vmware environment. We’ve implemented all the Netapp best practices, but are still looking for more.

  4. | #4

    There can be significant change, yes, but it depends mostly on the applications and the layout. You can minimise the change by moving out things like swap files and pagefiles, but these can cause more headaches. Make sure SQL and Exchange maintenance jobs aren’t running too regularly (although they do still need to run), and any other maintenance or re-index type jobs. Try narrow down which VM’s or files are causing the rate of change by moving the storage around.

  5. WillR
    | #5

    @TomK
    Hi TomK
    I was wondering if you could help me out. I need to find a way to script the failing over of SnapMirrored volumes for a customer and came across this post, could you by any chance share your scripts? with the sensitive info taken out of course :-)
    cheers
    Will

  6. | #6

    Hi Will, the script is in the text above. This was done with a Linux host and so you’ll need to setup preshared SSH keys and modify script to remove the VMware elements. You could easily re-write this for PowerShell as the steps are pretty straight forward, just a basic loop. In Linux shell, it would look something like…

    dr_filer_name=”filer_dr”
    dr_filer_command=”ssh -c 3des $dr_filer_name”

    for netapp_volume in `$dr_filer_command snapmirror status | grep $dr_filer_name | cut -d”:” -f3 | cut -d ” ” -f1`; do
    echo $dr_filer_command snapmirror quiesce $netapp_volume
    echo $dr_filer_command snapmirror break $netapp_volume
    done

  7. WS
    | #7

    Hello,

    I have to do something similar. Were you able to convert this to powershell? Otherwise do you have any updates to this commandlet?

    Best regards,
    WS

  8. | #8

    Hi WS, unfortunately I haven’t had the chance to update for PowerShell yet (need more hours in the day, or longer weekends!). The script should still work, although you’ll need a Linux box to initiate it from.

  1. No trackbacks yet.



This site is not affiliated or sponsored in anyway by NetApp or any other company mentioned within.
%d bloggers like this: